fix: only check for scramjetclient if win exists

This commit is contained in:
Percs 2024-10-27 15:08:56 -05:00
parent 1b509b2c8a
commit 4ea3e74fb6

View file

@ -36,6 +36,7 @@ export function createGlobalProxy(
const win: Self = value.self; const win: Self = value.self;
// indexing into window gives you the contentWindow of the subframes for some reason // indexing into window gives you the contentWindow of the subframes for some reason
// you can't *set* it so this should always be the right value // you can't *set* it so this should always be the right value
if (win) {
if (SCRAMJETCLIENT in win) { if (SCRAMJETCLIENT in win) {
// then we've already hooked this frame and we can just send over its proxy // then we've already hooked this frame and we can just send over its proxy
return win[SCRAMJETCLIENT].globalProxy; return win[SCRAMJETCLIENT].globalProxy;
@ -48,8 +49,9 @@ export function createGlobalProxy(
return newclient.globalProxy; return newclient.globalProxy;
} }
} }
}
if (prop === "$scramjet") return null; if (prop === "$scramjet") return undefined;
if (typeof prop === "string" && UNSAFE_GLOBALS.includes(prop)) if (typeof prop === "string" && UNSAFE_GLOBALS.includes(prop))
return client.wrapfn(value); return client.wrapfn(value);