Truly independent web browser
<!doctype html>
<script src="../include.js"></script>
<script>
asyncTest(async done => {
const iframe = document.createElement("iframe");
const load = action => new Promise(resolve => {
iframe.addEventListener("load", resolve, { once: true });
action();
});
await load(() => {
iframe.srcdoc = "First document";
document.body.append(iframe);
});
if (document.readyState !== "complete")
await new Promise(resolve => window.addEventListener("load", resolve, { once: true }));
await internals.flushSessionHistoryTraversalQueue();
await load(() => { iframe.contentWindow.location.assign("about:blank"); });
await load(() => { iframe.contentWindow.history.back(); });
// Flush the completion notification before reopening the traversed document.
await internals.flushSessionHistoryTraversalQueue();
await load(() => {
iframe.contentDocument.open();
iframe.contentDocument.write("Reopened document");
iframe.contentDocument.close();
});
await internals.flushSessionHistoryTraversalQueue();
println(iframe.contentDocument.body.textContent);
done();
});
</script>