2019-01-21 14:03:30 -05:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-01-16 17:57:15 -05:00
|
|
|
import { test, assert } from "./test_util.ts";
|
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
test(function globalThisExists(): void {
|
2019-01-16 17:57:15 -05:00
|
|
|
assert(globalThis != null);
|
|
|
|
});
|
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
test(function windowExists(): void {
|
2019-01-16 17:57:15 -05:00
|
|
|
assert(window != null);
|
|
|
|
});
|
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
test(function windowWindowExists(): void {
|
2019-01-16 17:57:15 -05:00
|
|
|
assert(window.window === window);
|
|
|
|
});
|
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
test(function globalThisEqualsWindow(): void {
|
2019-04-01 12:47:25 -04:00
|
|
|
// @ts-ignore (TypeScript thinks globalThis and window don't match)
|
2019-01-16 17:57:15 -05:00
|
|
|
assert(globalThis === window);
|
|
|
|
});
|
2019-02-05 08:12:58 -05:00
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
test(function DenoNamespaceExists(): void {
|
2019-02-12 10:08:56 -05:00
|
|
|
assert(Deno != null);
|
|
|
|
});
|
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
test(function DenoNamespaceEqualsWindowDeno(): void {
|
2019-02-12 10:08:56 -05:00
|
|
|
assert(Deno === window.Deno);
|
|
|
|
});
|
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
test(function DenoNamespaceIsFrozen(): void {
|
2019-02-12 10:08:56 -05:00
|
|
|
assert(Object.isFrozen(Deno));
|
|
|
|
});
|
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
test(function webAssemblyExists(): void {
|
2019-02-05 08:12:58 -05:00
|
|
|
assert(typeof WebAssembly.compile === "function");
|
|
|
|
});
|
2019-04-19 20:39:54 -04:00
|
|
|
|
2019-04-21 16:40:10 -04:00
|
|
|
test(function DenoNamespaceImmutable(): void {
|
2019-04-19 20:39:54 -04:00
|
|
|
const denoCopy = window.Deno;
|
|
|
|
try {
|
|
|
|
// @ts-ignore
|
|
|
|
Deno = 1;
|
|
|
|
} catch {}
|
|
|
|
assert(denoCopy === Deno);
|
|
|
|
try {
|
|
|
|
// @ts-ignore
|
|
|
|
window.Deno = 1;
|
|
|
|
} catch {}
|
|
|
|
assert(denoCopy === Deno);
|
|
|
|
try {
|
|
|
|
delete window.Deno;
|
|
|
|
} catch {}
|
|
|
|
assert(denoCopy === Deno);
|
|
|
|
|
|
|
|
const { readFile } = Deno;
|
|
|
|
try {
|
|
|
|
// @ts-ignore
|
|
|
|
Deno.readFile = 1;
|
|
|
|
} catch {}
|
|
|
|
assert(readFile === Deno.readFile);
|
|
|
|
try {
|
|
|
|
delete window.Deno.readFile;
|
|
|
|
} catch {}
|
|
|
|
assert(readFile === Deno.readFile);
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
const { print } = Deno.core;
|
|
|
|
try {
|
|
|
|
// @ts-ignore
|
|
|
|
Deno.core.print = 1;
|
|
|
|
} catch {}
|
|
|
|
// @ts-ignore
|
|
|
|
assert(print === Deno.core.print);
|
|
|
|
try {
|
|
|
|
// @ts-ignore
|
|
|
|
delete Deno.core.print;
|
|
|
|
} catch {}
|
|
|
|
// @ts-ignore
|
|
|
|
assert(print === Deno.core.print);
|
|
|
|
});
|