handle propagation in client.frame

This commit is contained in:
velzie 2024-10-10 21:13:47 -04:00
parent 44f5fc0c05
commit 35bca53824

View file

@ -108,7 +108,7 @@ export class ScramjetClient {
resolve(data.port); resolve(data.port);
} }
}); });
}) }),
); );
} }
@ -145,7 +145,17 @@ export class ScramjetClient {
if (!frame) return null; // we're top level if (!frame) return null; // we're top level
const sframe = frame[SCRAMJETFRAME]; const sframe = frame[SCRAMJETFRAME];
if (!sframe) return null; // we're a subframe. TODO handle propagation but not now if (!sframe) {
// we're in a subframe, recurse upward until we find one
let currentwin = this.global.window;
while (currentwin.parent != currentwin) {
if (!currentwin.frameElement) return null; // ??
if (currentwin.frameElement && currentwin.frameElement[SCRAMJETFRAME]) {
return currentwin.frameElement[SCRAMJETFRAME];
}
currentwin = currentwin.parent.window;
}
}
return sframe; return sframe;
} }
@ -239,7 +249,7 @@ export class ScramjetClient {
h.construct = function ( h.construct = function (
constructor: any, constructor: any,
argArray: any[], argArray: any[],
newTarget: AnyFunction newTarget: AnyFunction,
) { ) {
let returnValue: any = undefined; let returnValue: any = undefined;
let earlyreturn = false; let earlyreturn = false;
@ -354,7 +364,7 @@ export class ScramjetClient {
RawTrap<T>( RawTrap<T>(
target: any, target: any,
prop: string, prop: string,
descriptor: Trap<T> descriptor: Trap<T>,
): PropertyDescriptor { ): PropertyDescriptor {
if (!target) return; if (!target) return;
if (!prop) return; if (!prop) return;