1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

fix: don't expose globalThis.__bootstrap (#7344)

This commit is contained in:
Kitson Kelly 2020-09-04 21:52:19 +10:00 committed by GitHub
parent 15649b61bd
commit 9e50b3ee61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 13 deletions

View file

@ -53,7 +53,6 @@
function immutableDefine(
o,
p,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value,
) {
Object.defineProperty(o, p, {

View file

@ -1,7 +1,6 @@
// Removes the `__proto__` for security reasons. This intentionally makes
// Deno non compliant with ECMA-262 Annex B.2.2.1
//
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete Object.prototype.__proto__;
((window) => {
@ -292,9 +291,9 @@ delete Object.prototype.__proto__;
if (hasBootstrapped) {
throw new Error("Worker runtime already bootstrapped");
}
// Remove bootstrapping methods from global scope
globalThis.__bootstrap = undefined;
globalThis.bootstrap = undefined;
// Remove bootstrapping data from the global scope
delete globalThis.__bootstrap;
delete globalThis.bootstrap;
util.log("bootstrapMainRuntime");
hasBootstrapped = true;
Object.defineProperties(globalThis, windowOrWorkerGlobalScopeMethods);
@ -360,9 +359,9 @@ delete Object.prototype.__proto__;
if (hasBootstrapped) {
throw new Error("Worker runtime already bootstrapped");
}
// Remove bootstrapping methods from global scope
globalThis.__bootstrap = undefined;
globalThis.bootstrap = undefined;
// Remove bootstrapping data from the global scope
delete globalThis.__bootstrap;
delete globalThis.bootstrap;
util.log("bootstrapWorkerRuntime");
hasBootstrapped = true;
Object.defineProperties(globalThis, windowOrWorkerGlobalScopeMethods);
@ -412,7 +411,6 @@ delete Object.prototype.__proto__;
workerRuntime: bootstrapWorkerRuntime,
},
configurable: true,
writable: true,
},
});
})(this);

View file

@ -5,6 +5,13 @@ unitTest(function globalThisExists(): void {
assert(globalThis != null);
});
unitTest(function noInternalGlobals(): void {
// globalThis.__bootstrap should not be there.
for (const key of Object.keys(globalThis)) {
assert(!key.startsWith("_"));
}
});
unitTest(function windowExists(): void {
assert(window != null);
});

View file

@ -14,7 +14,6 @@
// Removes the `__proto__` for security reasons. This intentionally makes
// Deno non compliant with ECMA-262 Annex B.2.2.1
//
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete Object.prototype.__proto__;
((window) => {
@ -1528,7 +1527,7 @@ delete Object.prototype.__proto__;
core.registerErrorClass("TypeError", TypeError);
core.registerErrorClass("Other", Error);
core.registerErrorClass("Busy", errors.Busy);
globalThis.__bootstrap = undefined;
delete globalThis.__bootstrap;
runtimeStart("TS");
}

View file

@ -393,7 +393,6 @@
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function isEitherArrayBuffer(x) {
return x instanceof SharedArrayBuffer || x instanceof ArrayBuffer ||
typeof x === "undefined";

View file

@ -72,7 +72,6 @@ function eventPreventDefaultSuccess() {
}
function eventInitializedWithNonStringType() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const type = undefined;
const event = new Event(type);