window.frameElement trap

This commit is contained in:
velzie 2024-10-14 10:48:25 -04:00
parent 85da42120c
commit e9800f38bf
No known key found for this signature in database
GPG key ID: AA51AEFB0A1F3820

View file

@ -39,4 +39,20 @@ export default function (client: ScramjetClient) {
} }
}, },
}); });
client.Trap("window.frameElement", {
get(ctx) {
const f = ctx.get() as HTMLIFrameElement | null;
if (!f) return f;
const win = f.ownerDocument.defaultView;
if (win[SCRAMJETCLIENT]) {
// then this is a subframe in a scramjet context, and it's safe to pass back the real iframe
return f;
} else {
// no, the top frame is outside the sandbox
return null;
}
},
});
} }