Skip to content

Commit dc776bb

Browse files
committed
HTML: document.write() and reloading
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.
1 parent 7a7d2e1 commit dc776bb

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
async_test(t => {
2+
const frame = document.body.appendChild(document.createElement("iframe"));
3+
let reloaded = false;
4+
frame.src = "/common/blank.html";
5+
frame.onload = t.step_func(() => {
6+
if (reloaded) {
7+
assert_equals(frame.contentDocument.body.textContent, "");
8+
t.done();
9+
return;
10+
}
11+
assert_false(reloaded);
12+
assert_equals(frame.contentDocument.body.textContent, "");
13+
frame.contentDocument.write("Hey");
14+
assert_equals(frame.contentDocument.body.textContent, "Hey");
15+
reloaded = true;
16+
frame.contentWindow.location.reload();
17+
});
18+
}, "document.write() and reloading");
19+
20+
async_test(t => {
21+
const frame = document.body.appendChild(document.createElement("iframe"));
22+
let reloaded = false;
23+
frame.onload = t.step_func(() => {
24+
if (reloaded) {
25+
assert_equals(frame.contentDocument.body.textContent, "");
26+
t.done();
27+
return;
28+
}
29+
});
30+
assert_equals(frame.contentDocument.body.textContent, "");
31+
frame.contentDocument.write("Hey");
32+
assert_equals(frame.contentDocument.body.textContent, "Hey");
33+
reloaded = true;
34+
frame.contentWindow.location.reload();
35+
}, "document.write() and reloading, part 2");

0 commit comments

Comments
 (0)