🐛 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 : [];
|
||||
|
||||
if (src) {
|
||||
let isRedfinedCurrentScript = false;
|
||||
execScripts(null, [src], proxy, {
|
||||
fetch,
|
||||
strictGlobal,
|
||||
|
|
@ -299,14 +300,23 @@ function getOverwrittenAppendChildOrInsertBefore(opts: {
|
|||
},
|
||||
configurable: true,
|
||||
});
|
||||
isRedfinedCurrentScript = true;
|
||||
}
|
||||
},
|
||||
success: () => {
|
||||
manualInvokeElementOnLoad(element);
|
||||
if (isRedfinedCurrentScript) {
|
||||
// @ts-ignore
|
||||
delete document.currentScript;
|
||||
}
|
||||
element = null;
|
||||
},
|
||||
error: () => {
|
||||
manualInvokeElementOnError(element);
|
||||
if (isRedfinedCurrentScript) {
|
||||
// @ts-ignore
|
||||
delete document.currentScript;
|
||||
}
|
||||
element = null;
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -161,7 +161,8 @@ export default class ProxySandbox implements SandBox {
|
|||
}
|
||||
|
||||
// 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;
|
||||
|
||||
constructor(name: string, globalContext = window) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user