summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-06-22 07:17:35 +1000
committerGitHub <noreply@github.com>2021-06-22 07:17:35 +1000
commitcda15f2a98b10330422d1c8352d163d703ee6a49 (patch)
treea221c21283d1d19675cf77a66929f5c2b2936861 /cli/tests
parent2d2b5625e04a466362c9a4afb05e2f559c4fb4b0 (diff)
feat: Deno namespace configurable and unfrozen (#11062)
Closes #11033
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit/globals_test.ts50
1 files changed, 9 insertions, 41 deletions
diff --git a/cli/tests/unit/globals_test.ts b/cli/tests/unit/globals_test.ts
index 7603457b9..08ae23765 100644
--- a/cli/tests/unit/globals_test.ts
+++ b/cli/tests/unit/globals_test.ts
@@ -62,8 +62,8 @@ unitTest(function DenoNamespaceEqualsWindowDeno(): void {
assert(Deno === window.Deno);
});
-unitTest(function DenoNamespaceIsFrozen(): void {
- assert(Object.isFrozen(Deno));
+unitTest(function DenoNamespaceIsNotFrozen(): void {
+ assert(!Object.isFrozen(Deno));
});
unitTest(function webAssemblyExists(): void {
@@ -77,46 +77,14 @@ declare global {
}
}
-unitTest(function DenoNamespaceImmutable(): void {
- const denoCopy = window.Deno;
- try {
- // deno-lint-ignore no-explicit-any
- (Deno as any) = 1;
- } catch {
- // pass
- }
- assert(denoCopy === Deno);
- try {
- // deno-lint-ignore no-explicit-any
- (window as any).Deno = 1;
- } catch {
- // pass
- }
- assert(denoCopy === Deno);
- try {
- // deno-lint-ignore no-explicit-any
- delete (window as any).Deno;
- } catch {
- // pass
- }
- assert(denoCopy === Deno);
-
- const { readFile } = Deno;
- try {
- // deno-lint-ignore no-explicit-any
- (Deno as any).readFile = 1;
- } catch {
- // pass
- }
- assert(readFile === Deno.readFile);
- try {
- // deno-lint-ignore no-explicit-any
- delete (window as any).Deno.readFile;
- } catch {
- // pass
- }
- assert(readFile === Deno.readFile);
+unitTest(function DenoNamespaceConfigurable() {
+ const desc = Object.getOwnPropertyDescriptor(globalThis, "Deno");
+ assert(desc);
+ assert(desc.configurable);
+ assert(!desc.writable);
+});
+unitTest(function DenoCoreNamespaceIsImmutable(): void {
const { print } = Deno.core;
try {
Deno.core.print = 1;