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( function immutableDefine(
o, o,
p, p,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value, value,
) { ) {
Object.defineProperty(o, p, { Object.defineProperty(o, p, {

View file

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

View file

@ -5,6 +5,13 @@ unitTest(function globalThisExists(): void {
assert(globalThis != null); 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 { unitTest(function windowExists(): void {
assert(window != null); assert(window != null);
}); });

View file

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

View file

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

View file

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