mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 21:50:00 -05:00
parent
2d2b5625e0
commit
cda15f2a98
3 changed files with 16 additions and 45 deletions
|
@ -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;
|
||||
|
|
|
@ -117,6 +117,7 @@
|
|||
return {
|
||||
value,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
};
|
||||
}
|
||||
|
@ -125,6 +126,8 @@
|
|||
return {
|
||||
value,
|
||||
enumerable: true,
|
||||
writable: false,
|
||||
configurable: true,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -132,6 +135,7 @@
|
|||
return {
|
||||
get: getter,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -492,10 +492,9 @@ delete Object.prototype.__proto__;
|
|||
Object.assign(finalDenoNs, denoNsUnstable);
|
||||
}
|
||||
|
||||
// Setup `Deno` global - we're actually overriding already
|
||||
// existing global `Deno` with `Deno` namespace from "./deno.ts".
|
||||
util.immutableDefine(globalThis, "Deno", finalDenoNs);
|
||||
Object.freeze(globalThis.Deno);
|
||||
// Setup `Deno` global - we're actually overriding already existing global
|
||||
// `Deno` with `Deno` namespace from "./deno.ts".
|
||||
Object.defineProperty(globalThis, "Deno", util.readOnly(finalDenoNs));
|
||||
Object.freeze(globalThis.Deno.core);
|
||||
Object.freeze(globalThis.Deno.core.sharedQueue);
|
||||
signals.setSignals();
|
||||
|
|
Loading…
Add table
Reference in a new issue