blob: a7c3fa617238340588560edd9e13b97261ffbd09 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
export class AllowJavascriptChild extends JSWindowActorChild {
async receiveMessage(msg) {
switch (msg.name) {
case "CheckScriptsAllowed":
return this.checkScriptsAllowed();
case "CheckFiredLoadEvent":
return this.contentWindow.wrappedJSObject.gFiredOnload;
case "CreateIframe":
return this.createIframe(msg.data.url);
}
return null;
}
handleEvent(event) {
if (event.type === "load") {
this.sendAsyncMessage("LoadFired");
}
}
checkScriptsAllowed() {
let win = this.contentWindow;
win.wrappedJSObject.gFiredOnclick = false;
win.document.body.click();
return win.wrappedJSObject.gFiredOnclick;
}
async createIframe(url) {
let doc = this.contentWindow.document;
let iframe = doc.createElement("iframe");
iframe.src = url;
doc.body.appendChild(iframe);
await new Promise(resolve => {
iframe.addEventListener("load", resolve, { once: true });
});
return iframe.browsingContext;
}
}
|