Skip to content

Commit 90fb8e3

Browse files
author
Alan Jeffrey
committed
Added a test for document.write.
1 parent 20399ca commit 90fb8e3

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

tests/wpt/metadata/MANIFEST.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45867,6 +45867,12 @@
4586745867
"url": "/cssom/overflow-serialization.html"
4586845868
}
4586945869
],
45870+
"html/dom/dynamic-markup-insertion/document-write/write-active-document.html": [
45871+
{
45872+
"path": "html/dom/dynamic-markup-insertion/document-write/write-active-document.html",
45873+
"url": "/html/dom/dynamic-markup-insertion/document-write/write-active-document.html"
45874+
}
45875+
],
4587045876
"html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html": [
4587145877
{
4587245878
"path": "html/semantics/embedded-content/the-iframe-element/iframe-synchronously-discard.html",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[write-active-document.html]
2+
type: testharness
3+
[document.write only writes to active documents]
4+
expected: FAIL
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!doctype html>
2+
<title>document.write only writes to active documents</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<body><div id="log"></div></body>
6+
<script>
7+
async_test(function(t) {
8+
var child = document.createElement("iframe");
9+
child.src = "empty.html?1";
10+
child.onload = t.step_func(function() {
11+
var child1 = child.contentDocument;
12+
child1.write('<a id="link" href="data:text/html,Clicked.">Link.</a>');
13+
var grandchild = child1.createElement("iframe");
14+
grandchild.src = "empty.html?2";
15+
grandchild.onload = t.step_func(function() {
16+
var grandchild1 = grandchild.contentDocument;
17+
grandchild1.write('<a id="link" href="data:text/html,Clicked.">Link.</a>');
18+
child.onload = t.step_func(function() {
19+
// This is a write to an active but not fully active document
20+
grandchild1.write(' WRITE HAPPENED');
21+
assert_equals(grandchild1.body.innerText.trim(), "Link. WRITE HAPPENED");
22+
// This is a write to an inactive document
23+
child1.write(' WRITE HAPPENED');
24+
assert_equals(child1.body.innerText.trim(), "Link.");
25+
t.done();
26+
});
27+
child1.getElementById('link').click();
28+
});
29+
child1.body.appendChild(grandchild);
30+
});
31+
document.body.appendChild(child);
32+
});
33+
</script>

0 commit comments

Comments
 (0)