🐛 delete defineProperty to recover doc.currentScript (#2372)
This commit is contained in:
parent
2fc395e51f
commit
68d0e12bdb
|
|
@ -283,6 +283,7 @@ function getOverwrittenAppendChildOrInsertBefore(opts: {
|
||||||
const scopedGlobalVariables = speedySandbox ? trustedGlobals : [];
|
const scopedGlobalVariables = speedySandbox ? trustedGlobals : [];
|
||||||
|
|
||||||
if (src) {
|
if (src) {
|
||||||
|
let isRedfinedCurrentScript = false;
|
||||||
execScripts(null, [src], proxy, {
|
execScripts(null, [src], proxy, {
|
||||||
fetch,
|
fetch,
|
||||||
strictGlobal,
|
strictGlobal,
|
||||||
|
|
@ -299,14 +300,23 @@ function getOverwrittenAppendChildOrInsertBefore(opts: {
|
||||||
},
|
},
|
||||||
configurable: true,
|
configurable: true,
|
||||||
});
|
});
|
||||||
|
isRedfinedCurrentScript = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
success: () => {
|
success: () => {
|
||||||
manualInvokeElementOnLoad(element);
|
manualInvokeElementOnLoad(element);
|
||||||
|
if (isRedfinedCurrentScript) {
|
||||||
|
// @ts-ignore
|
||||||
|
delete document.currentScript;
|
||||||
|
}
|
||||||
element = null;
|
element = null;
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
manualInvokeElementOnError(element);
|
manualInvokeElementOnError(element);
|
||||||
|
if (isRedfinedCurrentScript) {
|
||||||
|
// @ts-ignore
|
||||||
|
delete document.currentScript;
|
||||||
|
}
|
||||||
element = null;
|
element = null;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,8 @@ export default class ProxySandbox implements SandBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the descriptor of global variables in whitelist before it been modified
|
// the descriptor of global variables in whitelist before it been modified
|
||||||
globalWhitelistPrevDescriptor: { [p in typeof globalVariableWhiteList[number]]: PropertyDescriptor | undefined } = {};
|
globalWhitelistPrevDescriptor: { [p in (typeof globalVariableWhiteList)[number]]: PropertyDescriptor | undefined } =
|
||||||
|
{};
|
||||||
globalContext: typeof window;
|
globalContext: typeof window;
|
||||||
|
|
||||||
constructor(name: string, globalContext = window) {
|
constructor(name: string, globalContext = window) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user