From c8db224efed08d7722c9951cde048d731db050d3 Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Fri, 19 Apr 2019 17:39:54 -0700 Subject: Make Deno/Deno.core not deletable/writable (#2153) --- js/globals_test.ts | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'js/globals_test.ts') 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); +}); -- cgit v1.2.3