Skip to content

Commit

Permalink
HTML: document.write() and reloading
Browse files Browse the repository at this point in the history
For whatwg/html#3651 or possibly a standalone patch.

It seems that Firefox only supports the reload override flag for about:blank resources. Edge always supports it. Safari overrides the URL and therefore ends up in a loop. Chrome doesn't support it, which seems most desirable as it's a rather hairy feature.
  • Loading branch information
annevk committed May 3, 2018
1 parent 7a7d2e1 commit dc776bb
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions html/dom/dynamic-markup-insertion/document-write/reload.window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
async_test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
let reloaded = false;
frame.src = "/common/blank.html";
frame.onload = t.step_func(() => {
if (reloaded) {
assert_equals(frame.contentDocument.body.textContent, "");
t.done();
return;
}
assert_false(reloaded);
assert_equals(frame.contentDocument.body.textContent, "");
frame.contentDocument.write("Hey");
assert_equals(frame.contentDocument.body.textContent, "Hey");
reloaded = true;
frame.contentWindow.location.reload();
});
}, "document.write() and reloading");

async_test(t => {
const frame = document.body.appendChild(document.createElement("iframe"));
let reloaded = false;
frame.onload = t.step_func(() => {
if (reloaded) {
assert_equals(frame.contentDocument.body.textContent, "");
t.done();
return;
}
});
assert_equals(frame.contentDocument.body.textContent, "");
frame.contentDocument.write("Hey");
assert_equals(frame.contentDocument.body.textContent, "Hey");
reloaded = true;
frame.contentWindow.location.reload();
}, "document.write() and reloading, part 2");

0 comments on commit dc776bb

Please sign in to comment.