blob: eb2f0c2729e90f19f3b77de53d03d30fa4bcce1b [file] [edit]
<!-- webkit-test-runner [ SiteIsolationEnabled=true ] -->
<!DOCTYPE html>
<html>
<body>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
const src = "http://localhost:8000/site-isolation/resources/frame-reports-commit-to-top.html";
let commits = 0;
let done = false;
let log = [];
function finish(reason) {
if (done)
return;
done = true;
if (commits >= 2)
document.body.textContent = "PASS: re-inserted cross-origin iframe committed.";
else
document.body.textContent = "FAIL (" + reason + "): re-inserted iframe did not commit. " + log.join(" ");
if (window.testRunner)
testRunner.notifyDone();
}
setTimeout(() => finish("timeout"), 10000);
window.addEventListener("message", (event) => {
if (typeof event.data !== "string" || !event.data.startsWith("committed:"))
return;
commits++;
log.push("commit#" + commits);
if (commits === 1) {
const frame = document.querySelector("iframe");
frame.remove();
document.body.appendChild(frame);
frame.src = src;
return;
}
finish("complete");
});
function start()
{
try {
const frame = document.createElement("iframe");
frame.src = src;
document.body.appendChild(frame);
log.push("created");
} catch (e) {
log.push("exception:" + e);
finish("exception");
}
}
if (document.readyState === "complete")
start();
else
window.addEventListener("load", start);
</script>
</body>
</html>