fune/toolkit/components/antitracking/test/browser/3rdPartyWO.html

51 lines
1.2 KiB
HTML

<html>
<head>
<title>Interact with me!</title>
</head>
<body>
<h1>Interact with me!</h1>
<script>
function info(msg) {
parent.postMessage({ type: "info", msg }, "*");
}
function ok(what, msg) {
parent.postMessage({ type: "ok", what: !!what, msg }, "*");
}
function is(a, b, msg) {
ok(a === b, msg);
}
onmessage = function(e) {
let runnableStr = `(() => {return (${e.data.blockingCallback});})();`;
let runnable = eval(runnableStr); // eslint-disable-line no-eval
runnable.call(this, /* Phase */ 2).then(_ => {
info("Let's do a window.open()");
return new Promise(resolve => {
if (location.search == "?noopener") {
let features = "noopener";
window.open("3rdPartyOpen.html", undefined, features);
setTimeout(resolve, 1000);
} else {
onmessage = resolve;
window.open("3rdPartyOpen.html");
}
});
}).then(_ => {
info("The popup has been dismissed!");
let runnableStr = `(() => {return (${e.data.nonBlockingCallback});})();`;
let runnable = eval(runnableStr); // eslint-disable-line no-eval
return runnable.call(this, /* Phase */ 2);
}).then(_ => {
parent.postMessage({ type: "finish" }, "*");
});
};
</script>
</body>
</html>