mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-16 23:50:02 -04:00
fix: function proxy and frame elements
This commit is contained in:
parent
e5dff7f6fc
commit
06583fb0b2
3 changed files with 60 additions and 19 deletions
|
@ -263,6 +263,57 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
},
|
||||
});
|
||||
|
||||
client.Trap("HTMLFrameElement.prototype.contentWindow", {
|
||||
get(ctx) {
|
||||
const realwin = ctx.get() as Window;
|
||||
if (!realwin) return realwin;
|
||||
|
||||
if (SCRAMJETCLIENT in realwin) {
|
||||
return realwin[SCRAMJETCLIENT].globalProxy;
|
||||
} else {
|
||||
// hook the iframe
|
||||
const newclient = new ScramjetClient(realwin);
|
||||
newclient.hook();
|
||||
|
||||
return newclient.globalProxy;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
client.Trap("HTMLFrameElement.prototype.contentDocument", {
|
||||
get(ctx) {
|
||||
const contentwindow =
|
||||
client.descriptors["HTMLFrameElement.prototype.contentWindow"].get;
|
||||
const realwin = contentwindow.apply(ctx.this);
|
||||
if (!realwin) return realwin;
|
||||
|
||||
if (SCRAMJETCLIENT in realwin) {
|
||||
return realwin[SCRAMJETCLIENT].documentProxy;
|
||||
} else {
|
||||
const newclient = new ScramjetClient(realwin);
|
||||
newclient.hook();
|
||||
|
||||
return newclient.documentProxy;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
client.Proxy(
|
||||
[
|
||||
"HTMLIFrameElement.prototype.getSVGDocument",
|
||||
"HTMLObjectElement.prototype.getSVGDocument",
|
||||
"HTMLEmbedElement.prototype.getSVGDocument",
|
||||
],
|
||||
{
|
||||
apply(ctx) {
|
||||
const doc = ctx.call();
|
||||
if (doc) {
|
||||
ctx.return(ctx.this.contentDocument);
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
client.Trap("TreeWalker.prototype.currentNode", {
|
||||
get(ctx) {
|
||||
return ctx.get();
|
||||
|
@ -312,22 +363,6 @@ export default function (client: ScramjetClient, self: typeof window) {
|
|||
}
|
||||
);
|
||||
|
||||
client.Proxy(
|
||||
[
|
||||
"HTMLIFrameElement.prototype.getSVGDocument",
|
||||
"HTMLObjectElement.prototype.getSVGDocument",
|
||||
"HTMLEmbedElement.prototype.getSVGDocument",
|
||||
],
|
||||
{
|
||||
apply(ctx) {
|
||||
const doc = ctx.call();
|
||||
if (doc) {
|
||||
ctx.return(ctx.this.contentDocument);
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
client.Proxy("Node.prototype.getRootNode", {
|
||||
apply(ctx) {
|
||||
const n = ctx.call() as Node;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue