summaryrefslogtreecommitdiff
path: root/js/globals_test.ts
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2019-04-19 17:39:54 -0700
committerRyan Dahl <ry@tinyclouds.org>2019-04-19 20:39:54 -0400
commitc8db224efed08d7722c9951cde048d731db050d3 (patch)
treeb492275744af8dfae9977ef8309925e725daba09 /js/globals_test.ts
parent0796a8f2f75005df95ef6115a4bdf6dd66e58dc3 (diff)
Make Deno/Deno.core not deletable/writable (#2153)
Diffstat (limited to 'js/globals_test.ts')
-rw-r--r--js/globals_test.ts44
1 files changed, 44 insertions, 0 deletions
diff --git a/js/globals_test.ts b/js/globals_test.ts
index 60b560134..4937e6c9a 100644
--- a/js/globals_test.ts
+++ b/js/globals_test.ts
@@ -33,3 +33,47 @@ test(function DenoNamespaceIsFrozen() {
test(function webAssemblyExists() {
assert(typeof WebAssembly.compile === "function");
});
+
+test(function DenoNamespaceImmutable() {
+ 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);
+});