mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 22:40:01 -04:00
window.frameElement trap
This commit is contained in:
parent
85da42120c
commit
e9800f38bf
1 changed files with 16 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue