summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write')
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/001.html12
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/002.html13
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/003.html14
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/004.html14
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/005.html14
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/005.js1
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/006.html14
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/006.js1
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/007.html15
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/007.js4
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008-1.js3
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008.html15
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008.js4
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/009.html15
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010-1.js4
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010.html15
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010.js4
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011-1.js5
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011.html15
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011.js5
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/012.html15
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/012.js5
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/013.html15
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/013.js1
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/014.html15
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/015.html16
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/016.html16
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/017.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/018.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/019.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/020.html18
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/021.html18
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/022.html18
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/023.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/024.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/025.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/026.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/027.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/028.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/029.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/030.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/031.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/032.html22
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/033.html20
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/034.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/035.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/036.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/037.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/038.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/039.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/040.html10
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/041.html13
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/042.html16
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/043.html16
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/044.html17
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/045.html20
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/046.html20
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/047-1.html7
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/047.html11
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/049.html18
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/050.html25
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/051.html22
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/contentType.window.js28
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/document.write-01.xhtml19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/document.write-02.html27
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/during-readystatechange.window.js24
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/empty.html1
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_001.html14
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_002.html22
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_003.html23
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_004.html22
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_005.html25
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_005.js3
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_006.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_007.html17
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_008.html18
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_009.html21
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_010.html23
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-delayed-iframe.html9
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-delayed.html29
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import-iframe.html7
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.html27
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.mjs4
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-iframe.html7
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed-iframe.html5
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.html28
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.mjs5
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-iframe.html5
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import.html26
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import.mjs4
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed-iframe.html14
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed.html30
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise-iframe.html10
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise.html29
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import-iframe.html5
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.html27
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.mjs4
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise-iframe.html11
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise.html24
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module.html22
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-1.html2
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-2.html7
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-external.js1
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/original-id.json1
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_001.html10
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_002.html20
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_003.html10
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_004.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_005.html20
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_006.html20
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_007.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_008.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_009.html19
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_010.html22
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_011.html22
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_012.html22
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_013.html24
-rw-r--r--testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/write-active-document.html35
118 files changed, 1853 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/001.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/001.html
new file mode 100644
index 0000000000..3ac6423f4a
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/001.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("PASS");
+ assert_equals(document.body.textContent, "PASS");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/002.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/002.html
new file mode 100644
index 0000000000..08975bca7b
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/002.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/003.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/003.html
new file mode 100644
index 0000000000..915e1f6d61
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/003.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<");
+ document.write("i>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/004.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/004.html
new file mode 100644
index 0000000000..dd01725860
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/004.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i");
+ document.write(">Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/005.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/005.html
new file mode 100644
index 0000000000..4c161c4d47
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/005.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i>");
+ document.write("Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/005.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/005.js
new file mode 100644
index 0000000000..ebfd7e2585
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/005.js
@@ -0,0 +1 @@
+order.push(3); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/006.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/006.html
new file mode 100644
index 0000000000..92bfb44c3a
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/006.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i id='test'>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute("id"), "test");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/006.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/006.js
new file mode 100644
index 0000000000..ebfd7e2585
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/006.js
@@ -0,0 +1 @@
+order.push(3); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/007.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/007.html
new file mode 100644
index 0000000000..753316b89c
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/007.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i ");
+ document.write("id='test'>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute("id"), "test");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/007.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/007.js
new file mode 100644
index 0000000000..31fcf18d49
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/007.js
@@ -0,0 +1,4 @@
+t.step(function() {
+ order.push(2);
+ document.write("<script>t.step(function() {order.push(3)})</script>");
+ }); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008-1.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008-1.js
new file mode 100644
index 0000000000..ef90c722b7
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008-1.js
@@ -0,0 +1,3 @@
+t.step(function() {
+ order.push(3);
+ }); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008.html
new file mode 100644
index 0000000000..4818bc388f
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i i");
+ document.write("d='test'>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute("id"), "test");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008.js
new file mode 100644
index 0000000000..367597515d
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/008.js
@@ -0,0 +1,4 @@
+t.step(function() {
+ order.push(2);
+ document.write("<script src=\"008-1.js\"></script>");
+ }); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/009.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/009.html
new file mode 100644
index 0000000000..d7b78333b8
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/009.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i id");
+ document.write("='test'>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute("id"), "test");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010-1.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010-1.js
new file mode 100644
index 0000000000..fd815bab77
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010-1.js
@@ -0,0 +1,4 @@
+t.step(function() {
+ order.push(4);
+ assert_equals(document.getElementsByTagName("meta").length, 1);
+ }); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010.html
new file mode 100644
index 0000000000..c8b9958258
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i id=");
+ document.write("'test'>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute("id"), "test");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010.js
new file mode 100644
index 0000000000..bb328ad55a
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/010.js
@@ -0,0 +1,4 @@
+t.step(function() {
+ order.push(3);
+ assert_equals(document.getElementsByTagName("meta").length, 0);
+ });
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011-1.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011-1.js
new file mode 100644
index 0000000000..944b70d2d0
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011-1.js
@@ -0,0 +1,5 @@
+t.step(function() {
+ order.push(4);
+ document.write("<meta>");
+ assert_equals(document.getElementsByTagName("meta").length, 1);
+ }); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011.html
new file mode 100644
index 0000000000..33464429e6
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i id='");
+ document.write("test'>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute("id"), "test");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011.js
new file mode 100644
index 0000000000..ce47bcd283
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/011.js
@@ -0,0 +1,5 @@
+t.step(function() {
+ order.push(3);
+ document.write("<script src='011-1.js'></script" + "><meta>");
+ assert_equals(document.getElementsByTagName("meta").length, 0);
+ }); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/012.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/012.html
new file mode 100644
index 0000000000..c9902a4875
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/012.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i id='te");
+ document.write("st'>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute("id"), "test");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/012.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/012.js
new file mode 100644
index 0000000000..7ab4c6b386
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/012.js
@@ -0,0 +1,5 @@
+t.step(
+function() {
+ order.push(5);
+ assert_equals(document.getElementsByTagName("meta").length, 0);
+}); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/013.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/013.html
new file mode 100644
index 0000000000..7b87d28976
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/013.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i id='test");
+ document.write("'>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute("id"), "test");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/013.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/013.js
new file mode 100644
index 0000000000..b5ce5f27da
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/013.js
@@ -0,0 +1 @@
+document.write('<svg><![CDATA['); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/014.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/014.html
new file mode 100644
index 0000000000..75518a8981
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/014.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i id='test'");
+ document.write(">Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute("id"), "test");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/015.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/015.html
new file mode 100644
index 0000000000..3dd79a63ef
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/015.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i id='test'");
+ document.write("class='a'>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute("id"), "test");
+ assert_equals(document.body.firstChild.getAttribute("class"), "a");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/016.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/016.html
new file mode 100644
index 0000000000..4c2f58912a
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/016.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<i>Filler Text");
+ document.write("</i><b>Filler Text");
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+ assert_equals(document.body.childNodes[1].localName, "b");
+ assert_equals(document.body.childNodes[1].textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/017.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/017.html
new file mode 100644
index 0000000000..8d1b24b06e
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/017.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ var s = "<i id=test>Filler Text</i><b>Filler Text"
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+ assert_equals(document.body.firstChild.localName, "i");
+ assert_equals(document.body.firstChild.getAttribute('id'), "test");
+ assert_equals(document.body.firstChild.textContent, "Filler Text");
+ assert_equals(document.body.childNodes[1].localName, "b");
+ assert_equals(document.body.childNodes[1].textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/018.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/018.html
new file mode 100644
index 0000000000..cf8dddbc54
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/018.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+function() {
+ document.write("<body>");
+ var s = "<!--comment--><i>Filler Text</i>"
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+ assert_equals(document.body.firstChild.nodeType, document.COMMENT_NODE);
+ assert_equals(document.body.firstChild.data, "comment");
+ assert_equals(document.body.childNodes[1].localName, "i");
+ assert_equals(document.body.childNodes[1].textContent, "Filler Text");
+}
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/019.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/019.html
new file mode 100644
index 0000000000..5e988f79ef
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/019.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<i");
+});
+</script>
+>Filler Text</i>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "i");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/020.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/020.html
new file mode 100644
index 0000000000..1d31bbf35d
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/020.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><");
+});
+</script>!--comment-->
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].nodeType, document.COMMENT_NODE);
+ assert_equals(document.body.childNodes[0].data, "comment");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/021.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/021.html
new file mode 100644
index 0000000000..500bb19398
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/021.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><sp");
+});
+</script>an>Filler Text</span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/022.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/022.html
new file mode 100644
index 0000000000..53ba299012
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/022.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span>");
+});
+</script>Filler Text</span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/023.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/023.html
new file mode 100644
index 0000000000..ca89e0e0bc
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/023.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span ");
+});
+</script>id=a>Filler Text</span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].getAttribute("id"), "a");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/024.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/024.html
new file mode 100644
index 0000000000..2a47d76cb3
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/024.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span i");
+});
+</script>d=a>Filler Text</span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].getAttribute("id"), "a");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/025.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/025.html
new file mode 100644
index 0000000000..31c68cf7df
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/025.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span id");
+});
+</script>=a>Filler Text</span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].getAttribute("id"), "a");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/026.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/026.html
new file mode 100644
index 0000000000..a9bce7743e
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/026.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span id=");
+});
+</script>a>Filler Text</span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].getAttribute("id"), "a");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/027.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/027.html
new file mode 100644
index 0000000000..dcfd67c0f7
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/027.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span id=a");
+});
+</script>>Filler Text</span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].getAttribute("id"), "a");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/028.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/028.html
new file mode 100644
index 0000000000..f5b7e9ef2b
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/028.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span id=a>Filler Text<");
+});
+</script>/span><b>Filler Text</b></span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].getAttribute("id"), "a");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+ assert_equals(document.body.childNodes[1].localName, "b");
+ assert_equals(document.body.childNodes[1].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/029.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/029.html
new file mode 100644
index 0000000000..f005a72227
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/029.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span id=a>Filler Text</");
+});
+</script>span><b>Filler Text</b></span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].getAttribute("id"), "a");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+ assert_equals(document.body.childNodes[1].localName, "b");
+ assert_equals(document.body.childNodes[1].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/030.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/030.html
new file mode 100644
index 0000000000..cc361d3aaf
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/030.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span id=a>Filler Text</sp");
+});
+</script>an><b>Filler Text</b></span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].getAttribute("id"), "a");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+ assert_equals(document.body.childNodes[1].localName, "b");
+ assert_equals(document.body.childNodes[1].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/031.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/031.html
new file mode 100644
index 0000000000..32c97c5056
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/031.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span id=a>Filler Text</span");
+});
+</script>><b>Filler Text</b></span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "span");
+ assert_equals(document.body.childNodes[0].getAttribute("id"), "a");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+ assert_equals(document.body.childNodes[1].localName, "b");
+ assert_equals(document.body.childNodes[1].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/032.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/032.html
new file mode 100644
index 0000000000..1a33408f1b
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/032.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ var tag_name_length = 100000;
+ var tag_name = "";
+ for (var i=0; i<tag_name_length; i++) {
+ tag_name += "a";
+ }
+ document.write("<body><" + tag_name + ">Filler Text</" + tag_name + ">");
+});
+</script>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/033.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/033.html
new file mode 100644
index 0000000000..1b8e1c2706
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/033.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+test(
+ function() {
+ document.writeln("<i");
+ var s = " b='a'>Filler"
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]+"\n");
+ }
+ document.writeln("</i");
+ document.writeln(">");
+ assert_equals(document.body.childNodes[0].localName, "i");
+ assert_equals(document.body.childNodes[0].getAttribute("b"), "\na\n");
+ assert_equals(document.body.childNodes[0].textContent, "\nF\ni\nl\nl\ne\nr\n");
+ }
+);
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/034.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/034.html
new file mode 100644
index 0000000000..abd481a64d
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/034.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ var s = "<svg><![CDATA[Filler Text]]></svg>";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+});
+</script>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "svg");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/035.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/035.html
new file mode 100644
index 0000000000..a1e7f9ee67
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/035.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ var s = "<svg><!";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+});
+</script>[CDATA[Filler Text]]></svg>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "svg");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/036.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/036.html
new file mode 100644
index 0000000000..8719e0598d
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/036.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ var s = "<svg><![CDATA[Filler Text]";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+});
+</script>]></svg>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "svg");
+ assert_equals(document.body.childNodes[0].textContent, "Filler Text");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/037.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/037.html
new file mode 100644
index 0000000000..cf0787ce76
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/037.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ var s = "<body><!DOCTYPE html>";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+});
+</script><script>
+t.step(function() {
+ //Nothing should be inserted into the DOM for the doctype node so
+ //just checking nothing odd happens
+ assert_equals(document.body.childNodes[0].localName, "script");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/038.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/038.html
new file mode 100644
index 0000000000..4ae9d32b23
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/038.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ var s = "<body><";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+});
+</script>!DOCTYPE html><script>
+t.step(function() {
+ //Nothing should be inserted into the DOM for the doctype node so
+ //just checking nothing odd happens
+ assert_equals(document.body.childNodes[0].localName, "script");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/039.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/039.html
new file mode 100644
index 0000000000..611a01390c
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/039.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ var s = "<body><!";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+});
+</script>DOCTYPE html><script>
+t.step(function() {
+ //Nothing should be inserted into the DOM for the doctype node so
+ //just checking nothing odd happens
+ assert_equals(document.body.childNodes[0].localName, "script");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/040.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/040.html
new file mode 100644
index 0000000000..d76deffa40
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/040.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<title>document.write entity</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = test(function() {
+ document.write("<body><span>&notin;abc");
+ assert_equals(document.body.childNodes[0].textContent, "\u2209abc");
+});
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/041.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/041.html
new file mode 100644
index 0000000000..592711c94f
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/041.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<title>document.write entity</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = test(function() {
+ var s = "<body><span>&notin;abc";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+ assert_equals(document.body.childNodes[0].textContent, "\u2209abc");
+});
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/042.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/042.html
new file mode 100644
index 0000000000..e15f1d0c0f
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/042.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<title>document.write entity</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span>&not");
+});
+</script>in;abc</span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].textContent, "\u2209abc");
+})
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/043.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/043.html
new file mode 100644
index 0000000000..4058e7a823
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/043.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<title>document.write entity</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><span>&");
+});
+</script>notabc</span>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].textContent, "\u00ACabc");
+})
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/044.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/044.html
new file mode 100644
index 0000000000..4c9f50273c
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/044.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<body><textarea><span>Filler</span></textarea>");
+});
+</script>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "textarea");
+ assert_equals(document.body.childNodes[0].textContent, "<span>Filler</span>");
+})
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/045.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/045.html
new file mode 100644
index 0000000000..987eabf0f4
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/045.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ var s = "<body><textarea><span>Filler</span></textarea>";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+});
+</script>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "textarea");
+ assert_equals(document.body.childNodes[0].textContent, "<span>Filler</span>");
+})
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/046.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/046.html
new file mode 100644
index 0000000000..e87e9cc825
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/046.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ var s = "<body><textarea>";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+});
+</script><span>Filler</span></textarea>
+<script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].localName, "textarea");
+ assert_equals(document.body.childNodes[0].textContent, "<span>Filler</span>");
+})
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/047-1.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/047-1.html
new file mode 100644
index 0000000000..6a43faec51
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/047-1.html
@@ -0,0 +1,7 @@
+<script>
+onload = opener.t.step_func_done(function() {
+ document.write("<body>Filler Text<div id='log'></div>");
+ opener.assert_equals(document.body.textContent, "Filler Text");
+});
+</script>
+<body>FAIL
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/047.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/047.html
new file mode 100644
index 0000000000..677d3e1786
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/047.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+var win;
+var t = async_test(() => {
+ win = window.open("047-1.html");
+});
+t.add_cleanup(() => win.close());
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/049.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/049.html
new file mode 100644
index 0000000000..0ec282f2bc
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/049.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>document.write plaintext</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<div id="log"></div><script>
+test(function() {
+ var s = "<table><tr><td>Text</tr><plaintext><tr><td>Filler ";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+ document.close();
+ assert_equals(document.body.childNodes[2].nodeType, document.ELEMENT_NODE);
+ assert_equals(document.body.childNodes[2].localName, "plaintext");
+ assert_equals(document.body.childNodes[2].textContent, "<tr><td>Filler ");
+ assert_equals(document.body.childNodes[3].nodeType, document.ELEMENT_NODE);
+ assert_equals(document.body.childNodes[3].localName, "table");
+ assert_equals(document.body.childNodes[3].textContent, "Text");
+});
+</script> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/050.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/050.html
new file mode 100644
index 0000000000..0a37fa4c5f
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/050.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>document.write plaintext</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<div id="log"></div><script>
+var t = async_test();
+
+t.step(function() {
+ document.write("<plaintext>");
+ assert_equals(document.body.childNodes[2].nodeType, document.ELEMENT_NODE);
+ assert_equals(document.body.childNodes[2].localName, "plaintext");
+ var s = "Filler ";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ assert_equals(document.body.childNodes[2].textContent, s.slice(0,i+1));
+ }
+ document.close();
+});
+
+onload = function() {
+ t.step(function() {
+ assert_equals(document.body.childNodes[2].textContent, "Filler Text\n");
+ });
+ t.done();
+}
+</script>Text
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/051.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/051.html
new file mode 100644
index 0000000000..80ea279dad
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/051.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>document.write \r\n</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<div id="log"></div>
+
+<script>
+var t = async_test();
+
+t.step(function() {
+ document.write("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nA");
+})
+
+onload = function() {
+ t.step(function() {
+ const lastNode = document.getElementById('after');
+ assert_equals(lastNode.previousSibling.data, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nAB");
+ });
+ t.done();
+};
+</script>B<div id=after></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/contentType.window.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/contentType.window.js
new file mode 100644
index 0000000000..5a91203874
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/contentType.window.js
@@ -0,0 +1,28 @@
+// META: script=/common/media.js
+
+const videoURL = getVideoURI("/images/pattern"),
+ videoMIMEType = getMediaContentType(videoURL);
+
+[
+ [videoURL, videoMIMEType, "video"],
+ ["/images/red.png", "image/png", "image"],
+ ["/common/text-plain.txt", "text/plain", "text"],
+ ["/common/blank.html", "text/html", "HTML"]
+].forEach(val => {
+ async_test(t => {
+ const frame = document.body.appendChild(document.createElement("iframe"));
+ t.add_cleanup(() => frame.remove());
+ frame.src = val[0];
+ frame.onload = t.step_func_done(() => {
+ assert_equals(frame.contentDocument.contentType, val[1]);
+ frame.contentDocument.write("<b>Heya</b>");
+ assert_equals(frame.contentDocument.body.firstChild.localName, "b");
+ assert_equals(frame.contentDocument.body.firstChild.textContent, "Heya");
+ assert_equals(frame.contentDocument.contentType, val[1]);
+
+ // Make sure a load event is fired across browsers
+ // https://github.com/web-platform-tests/wpt/pull/10239
+ frame.contentDocument.close();
+ });
+ }, "document.write(): " + val[2] + " document");
+});
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/document.write-01.xhtml b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/document.write-01.xhtml
new file mode 100644
index 0000000000..fc21d4e2bf
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/document.write-01.xhtml
@@ -0,0 +1,19 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>document.write in XHTML</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#document.write%28%29"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<div id="log"></div>
+<script>
+test(function() {
+ assert_throws_dom("INVALID_STATE_ERR", function() {
+ document.write("Failure: document.write actually worked");
+ }, "document.write in XHTML should throw an INVALID_STATE_ERR ");
+}, "document.write in XHTML");
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/document.write-02.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/document.write-02.html
new file mode 100644
index 0000000000..4c25da8b68
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/document.write-02.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<title>document.write and null/undefined</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-write%28%29">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#documents-in-the-dom">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ var iframe = document.createElement("iframe");
+ document.body.appendChild(iframe);
+ doc = iframe.contentDocument;
+ test(function() {
+ doc.open();
+ doc.write(null);
+ doc.close();
+ assert_equals(doc.documentElement.textContent, "null");
+ }, "document.write(null)");
+ test(function() {
+ doc.open();
+ doc.write(undefined);
+ doc.close();
+ assert_equals(doc.documentElement.textContent, "undefined");
+ }, "document.write(undefined)");
+}, "Calling document.write with null and undefined");
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/during-readystatechange.window.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/during-readystatechange.window.js
new file mode 100644
index 0000000000..49d5051c25
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/during-readystatechange.window.js
@@ -0,0 +1,24 @@
+// This tests whether the insertion point gets reset before or after the readystatechange event.
+// See https://github.com/whatwg/html/pull/6613#discussion_r620171070.
+// Recall that resetting the insertion point means that document.write() performs the document open
+// steps and blows away previous content in the document.
+
+async_test(t => {
+ const frame = document.body.appendChild(document.createElement("iframe"));
+ t.add_cleanup(() => { frame.remove(); });
+ frame.src = "../opening-the-input-stream/resources/dummy.html";
+ frame.onload = t.step_func_done(() => {
+ const states = [];
+ frame.contentDocument.onreadystatechange = t.step_func(() => {
+ if (frame.contentDocument.readyState === "interactive") {
+ assert_not_equals(frame.contentDocument.textContent, "", "Precondition check: dummy document is not empty");
+
+ frame.contentDocument.write("Some text");
+
+ // If the insertion point is reset before the readystatechange handler, then the
+ // document.write() call above will blow away the text originally in dummy.html, leaving only what we wrote.
+ assert_equals(frame.contentDocument.textContent, "Some text");
+ }
+ });
+ });
+}, "document.write() during readystatechange to interactive");
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/empty.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/empty.html
new file mode 100644
index 0000000000..0dc101b533
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/empty.html
@@ -0,0 +1 @@
+<html><body></body></html>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_001.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_001.html
new file mode 100644
index 0000000000..8b54560c6c
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_001.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<title>document.write into iframe</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<iframe id="test"></iframe>
+<script>
+test(
+function() {
+ var iframe = document.getElementById("test");
+ iframe.contentDocument.write("Filler Text");
+ iframe.contentDocument.close();
+ assert_equals(iframe.contentDocument.body.textContent, "Filler Text");
+});
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_002.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_002.html
new file mode 100644
index 0000000000..f77819adb6
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_002.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>document.write into iframe</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<iframe id="test"></iframe>
+<script>
+test(
+function() {
+ var iframe = document.getElementById("test");
+ var s = "<i id='a'>Filler Text</i><b id=b>Filler Text</b>"
+ for (var i=0; i<s.length; i++) {
+ iframe.contentDocument.write(s[i]);
+ }
+ iframe.contentDocument.close();
+ assert_equals(iframe.contentDocument.body.childNodes[0].textContent, "Filler Text");
+ assert_equals(iframe.contentDocument.body.childNodes[0].localName, "i");
+ assert_equals(iframe.contentDocument.body.childNodes[0].getAttribute('id'), "a");
+ assert_equals(iframe.contentDocument.body.childNodes[1].textContent, "Filler Text");
+ assert_equals(iframe.contentDocument.body.childNodes[1].localName, "b");
+ assert_equals(iframe.contentDocument.body.childNodes[1].getAttribute('id'), "b");
+});
+</script>
+<div id="log"></div> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_003.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_003.html
new file mode 100644
index 0000000000..9865874da4
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_003.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<title>document.write script into iframe</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<iframe id="test"></iframe>
+<script>
+test(
+function() {
+ var iframe = document.getElementById("test");
+ var s = "<script>document.write(\"<i id='a'>Filler Text</i>\")</script" + "><b id=b>Filler Text</b>"
+ for (var i=0; i<s.length; i++) {
+ iframe.contentDocument.write(s[i]);
+ }
+ iframe.contentDocument.close();
+ //Note: <script> ends up in <head>
+ assert_equals(iframe.contentDocument.body.childNodes[0].textContent, "Filler Text");
+ assert_equals(iframe.contentDocument.body.childNodes[0].localName, "i");
+ assert_equals(iframe.contentDocument.body.childNodes[0].getAttribute('id'), "a");
+ assert_equals(iframe.contentDocument.body.childNodes[1].textContent, "Filler Text");
+ assert_equals(iframe.contentDocument.body.childNodes[1].localName, "b");
+ assert_equals(iframe.contentDocument.body.childNodes[1].getAttribute('id'), "b");
+});
+</script>
+<div id="log"></div> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_004.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_004.html
new file mode 100644
index 0000000000..a4d7b1ddad
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_004.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>document.write script into iframe write back into parent</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<iframe id="test"></iframe>
+<script>
+var t = async_test();
+var iframe = document.getElementById("test");
+var order = [];
+t.step(function() {
+ order.push(1);
+ var s = "<script>parent.order.push(2); parent.document.write('<script>order.push(3);</script'+'>'); parent.order.push(4)</script" + ">";
+ for (var i=0; i<s.length; i++) {
+ iframe.contentDocument.write(s[i]);
+ }
+ iframe.contentDocument.close();
+ order.push(5);
+ assert_array_equals(order, [1,2,3,4,5])
+}
+);
+t.done();
+</script>
+<div id="log"></div> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_005.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_005.html
new file mode 100644
index 0000000000..7bc3ed6c29
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_005.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>document.write external script into iframe write back into parent</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<iframe id="test"></iframe>
+<script>
+var t = async_test();
+var iframe = document.getElementById("test");
+var order = [];
+t.step(function() {
+ order.push(1);
+ var s = "<script src='iframe_005.js'></script" + ">";
+ iframe.contentDocument.write(s);
+ iframe.contentDocument.close();
+ order.push(2);
+ assert_array_equals(order, [1,2])
+}
+);
+addEventListener("load", function() {
+ t.step(function() {
+ assert_array_equals(order, [1,2,3,4,5])
+ });
+ t.done();
+}, false);
+</script>
+<div id="log"></div> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_005.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_005.js
new file mode 100644
index 0000000000..bf038f7004
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_005.js
@@ -0,0 +1,3 @@
+parent.order.push(3);
+document.write("<script>parent.order.push(4)</script>");
+parent.order.push(5); \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_006.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_006.html
new file mode 100644
index 0000000000..d080ee3673
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_006.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write external script into iframe write back into parent</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<iframe id="test"></iframe>
+<script>
+var t = async_test();
+var iframe = document.getElementById("test");
+var order = [];
+t.step(function() {
+ order.push(1);
+ var s = "<script>parent.order.push(2); parent.document.write('<script>order.push(3); iframe.contentDocument.write(\"<script>parent.order.push(4)</script\"+\">\");order.push(5);</script' + '>'); parent.order.push(6)</script"+">";
+ iframe.contentDocument.write(s);
+ iframe.contentDocument.close();
+ order.push(7);
+ assert_array_equals(order, [1,2,3,4,5,6,7]);
+});
+t.done();
+</script>
+<div id="log"></div> \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_007.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_007.html
new file mode 100644
index 0000000000..c00aa7062d
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_007.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<title>document.write comment into iframe</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<iframe id="test"></iframe>
+<script>
+test(function() {
+ var iframe = document.getElementById("test");
+ var s = "<!--Filler-->";
+ for (var i=0; i<s.length; i++) {
+ iframe.contentDocument.write(s);
+ }
+ iframe.contentDocument.close();
+ assert_equals(iframe.contentDocument.childNodes[0].nodeType, document.COMMENT_NODE);
+ assert_equals(iframe.contentDocument.childNodes[0].data, "Filler");
+});
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_008.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_008.html
new file mode 100644
index 0000000000..c814958d19
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_008.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<title>document.write plaintext into iframe</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<iframe id="test"></iframe>
+<script>
+test(function() {
+ var iframe = document.getElementById("test");
+ var s = "<plaintext><span>Filler Text";
+ for (var i=0; i<s.length; i++) {
+ iframe.contentDocument.write(s[i]);
+ }
+ iframe.contentDocument.close();
+ assert_equals(iframe.contentDocument.body.childNodes[0].nodeType, document.ELEMENT_NODE);
+ assert_equals(iframe.contentDocument.body.childNodes[0].localName, "plaintext");
+ assert_equals(iframe.contentDocument.body.childNodes[0].textContent, "<span>Filler Text");
+});
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_009.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_009.html
new file mode 100644
index 0000000000..8b271c7a03
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_009.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>document.write plaintext into iframe</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<iframe id="test"></iframe>
+<script>
+test(function() {
+ var iframe = document.getElementById("test");
+ var s = "<table><tr><td>Text</tr><plaintext><tr><td>Filler ";
+ for (var i=0; i<s.length; i++) {
+ iframe.contentDocument.write(s[i]);
+ }
+ iframe.contentDocument.close();
+ assert_equals(iframe.contentDocument.body.childNodes[0].nodeType, document.ELEMENT_NODE);
+ assert_equals(iframe.contentDocument.body.childNodes[0].localName, "plaintext");
+ assert_equals(iframe.contentDocument.body.childNodes[0].textContent, "<tr><td>Filler ");
+ assert_equals(iframe.contentDocument.body.childNodes[1].nodeType, document.ELEMENT_NODE);
+ assert_equals(iframe.contentDocument.body.childNodes[1].localName, "table");
+ assert_equals(iframe.contentDocument.body.childNodes[1].textContent, "Text");
+});
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_010.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_010.html
new file mode 100644
index 0000000000..8dc21a013a
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/iframe_010.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<title>document.write plaintext</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<iframe id="test"></iframe>
+<script>
+var t = async_test();
+var iframe = document.getElementById("test");
+
+function check_dom() {
+ assert_equals(iframe.contentDocument.body.childNodes[0].localName, "plaintext")
+ assert_equals(iframe.contentDocument.body.childNodes[0].textContent, "Filler ")
+ assert_equals(iframe.contentDocument.body.childNodes[1].localName, "table")
+}
+
+t.step(function() {
+ var s = "<script>document.write('<table><plaintext>Filler '); document.close(); top.t.step(function() {top.check_dom()})</script" + ">";
+ for (var i=0; i<s.length; i++) {
+ iframe.contentDocument.write(s[i]);
+ }
+ t.done();
+});
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-delayed-iframe.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-delayed-iframe.html
new file mode 100644
index 0000000000..f97f597238
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-delayed-iframe.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<script type=module>
+window.parent.document.test.step_timeout(() => {
+ document.write("document.write body contents\n")
+ document.close();
+ window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
+}, 0);
+</script>
+Initial body contents
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-delayed.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-delayed.html
new file mode 100644
index 0000000000..acdeab59ff
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-delayed.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<title>async document.write in a module</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ // Expose {test} in the iframe for using the step_timeout helper.
+ document.test = t;
+ const iframe = document.createElement("iframe");
+
+ iframe.onerror = t.unreached_func("Error loading iframe");
+
+ let onLoadWasCalled = false;
+ iframe.onload = t.step_func(() => {
+ onLoadWasCalled = true;
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ // Don't call the event handler another time after document.write.
+ iframe.onload = null;
+ });
+ document.addEventListener("documentWriteDone", t.step_func_done(() => {
+ assert_true(onLoadWasCalled, "onload must be called");
+ assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
+ }));
+
+ iframe.src = "module-delayed-iframe.html";
+ document.body.appendChild(iframe);
+});
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import-iframe.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import-iframe.html
new file mode 100644
index 0000000000..672bb953d6
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import-iframe.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<script type=module>
+(async () => {
+ let module = await import("./module-dynamic-import.mjs");
+})();
+</script>
+Initial body contents
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.html
new file mode 100644
index 0000000000..5939968f05
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<title>document.write in an imported module</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ const iframe = document.createElement("iframe");
+
+ iframe.onerror = t.unreached_func("Error loading iframe");
+
+ let onLoadWasCalled = false;
+ iframe.onload = t.step_func(() => {
+ onLoadWasCalled = true;
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ // Don't call the event handler another time after document.write.
+ iframe.onload = null;
+ });
+ document.addEventListener("documentWriteDone", t.step_func_done(() => {
+ assert_true(onLoadWasCalled, "onload must be called");
+ assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
+ }));
+
+ iframe.src = "module-dynamic-import-iframe.html";
+ document.body.appendChild(iframe);
+});
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.mjs b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.mjs
new file mode 100644
index 0000000000..74d2427537
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.mjs
@@ -0,0 +1,4 @@
+document.write("document.write body contents\n");
+document.close();
+
+window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-iframe.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-iframe.html
new file mode 100644
index 0000000000..f8646df56b
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-iframe.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<script type=module>
+document.write("document.write body contents\n");
+document.close();
+window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
+</script>
+Initial body contents
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed-iframe.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed-iframe.html
new file mode 100644
index 0000000000..3ae1464653
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed-iframe.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<script type=module>
+import "./module-static-import-delayed.mjs"
+</script>
+Initial body contents
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.html
new file mode 100644
index 0000000000..a6e003907f
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<title>document.write in an imported module</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ // Expose {test} in the iframe for using the step_timeout helper.
+ document.test = t;
+ const iframe = document.createElement("iframe");
+ iframe.onerror = t.unreached_func("Error loading iframe");
+
+ let onLoadWasCalled = false;
+ iframe.onload = t.step_func(() => {
+ onLoadWasCalled = true;
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ // Don't call the event handler another time after document.write.
+ iframe.onload = null;
+ });
+ document.addEventListener("documentWriteDone", t.step_func_done(() => {
+ assert_true(onLoadWasCalled, "onload must be called");
+ assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
+ }));
+
+ iframe.src = "module-static-import-delayed-iframe.html";
+ document.body.appendChild(iframe);
+});
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.mjs b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.mjs
new file mode 100644
index 0000000000..45478d6f63
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.mjs
@@ -0,0 +1,5 @@
+window.parent.document.test.step_timeout(() => {
+ document.write("document.write body contents\n")
+ document.close();
+ window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
+}, 0);
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-iframe.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-iframe.html
new file mode 100644
index 0000000000..ed4f6d1c6c
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-iframe.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<script type=module>
+import "./module-static-import.mjs"
+</script>
+Initial body contents
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import.html
new file mode 100644
index 0000000000..3cae88047e
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>document.write in an imported module</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ const iframe = document.createElement("iframe");
+
+ iframe.onerror = t.unreached_func("Error loading iframe");
+
+ let testEndWasCalled = false;
+ document.addEventListener("documentWriteDone", t.step_func(() => {
+ testEndWasCalled = true;
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ }));
+ iframe.onload = t.step_func_done(() => {
+ assert_true(testEndWasCalled, "onload must be called");
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ });
+
+ iframe.src = "module-static-import-iframe.html";
+ document.body.appendChild(iframe);
+});
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import.mjs b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import.mjs
new file mode 100644
index 0000000000..74d2427537
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import.mjs
@@ -0,0 +1,4 @@
+document.write("document.write body contents\n");
+document.close();
+
+window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed-iframe.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed-iframe.html
new file mode 100644
index 0000000000..5629c47be7
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed-iframe.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<script type=module>
+let delay = new Promise(
+ resolve => window.parent.document.test.step_timeout(resolve, 0));
+
+delay.then(() => {
+ document.write("document.write body contents\n");
+ document.close();
+ window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
+});
+
+await delay;
+</script>
+Initial body contents
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed.html
new file mode 100644
index 0000000000..5fa8216600
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<title>document.write in an imported module</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ // Expose {test} in the iframe for using the step_timeout helper.
+ document.test = t;
+
+ const iframe = document.createElement("iframe");
+
+ iframe.onunhandledrejection = t.unreached_func("Unhandled promise rejection detected");
+ iframe.onerror = t.unreached_func("Error loading iframe");
+
+ let onLoadWasCalled = false;
+ iframe.onload = t.step_func(() => {
+ onLoadWasCalled = true;
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ iframe.onload = null;
+ });
+ document.addEventListener("documentWriteDone", t.step_func_done(() => {
+ assert_true(onLoadWasCalled, "onload must be called");
+ assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
+ }));
+
+ iframe.src = "module-tla-delayed-iframe.html";
+ document.body.appendChild(iframe);
+});
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise-iframe.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise-iframe.html
new file mode 100644
index 0000000000..3e90fb2ea7
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise-iframe.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<script type=module>
+await new Promise(resolve => {
+ document.write("document.write body contents\n");
+ document.close();
+ window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
+ resolve();
+});
+</script>
+Initial body contents
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise.html
new file mode 100644
index 0000000000..f60aa38e00
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<title>document.write in an imported module</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ // Expose {test} in the iframe for using the step_timeout helper.
+ document.test = t;
+
+ const iframe = document.createElement("iframe");
+ iframe.onerror = t.unreached_func("Error loading iframe");
+
+ let onLoadWasCalled = false;
+ iframe.onload = t.step_func(() => {
+ onLoadWasCalled = true;
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ // Don't call the event handler another time after document.write.
+ iframe.onload = null;
+ });
+ document.addEventListener("documentWriteDone", t.step_func_done(() => {
+ assert_false(onLoadWasCalled, "onload must not be called yet");
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ }));
+
+ iframe.src = "module-tla-immediate-promise-iframe.html";
+ document.body.appendChild(iframe);
+});
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import-iframe.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import-iframe.html
new file mode 100644
index 0000000000..ec4a6ed6aa
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import-iframe.html
@@ -0,0 +1,5 @@
+<!doctype html>
+<script type=module>
+await import("./module-tla-import.mjs");
+</script>
+Initial body contents
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.html
new file mode 100644
index 0000000000..20645f4d78
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<title>document.write in an imported module</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ const iframe = document.createElement("iframe");
+ iframe.onerror = t.unreached_func("Error loading iframe");
+
+ let onLoadWasCalled = false;
+
+ iframe.onload = t.step_func(() => {
+ onLoadWasCalled = true;
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ // Don't call the event handler another time after document.write.
+ iframe.onload = null;
+ });
+ document.addEventListener("documentWriteDone", t.step_func_done(() => {
+ assert_true(onLoadWasCalled, "onload must be called");
+ assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
+ }));
+
+ iframe.src = "module-tla-import-iframe.html";
+ document.body.appendChild(iframe);
+});
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.mjs b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.mjs
new file mode 100644
index 0000000000..74d2427537
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.mjs
@@ -0,0 +1,4 @@
+document.write("document.write body contents\n");
+document.close();
+
+window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise-iframe.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise-iframe.html
new file mode 100644
index 0000000000..edc9e80cb3
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise-iframe.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<script type=module>
+await new Promise(resolve => {
+ window.parent.document.test.step_timeout(resolve, 0);
+ document.write("document.write body contents\n");
+ document.close();
+ window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
+});
+</script>
+
+Initial body contents
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise.html
new file mode 100644
index 0000000000..4f1281bcce
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<title>document.write in an imported module</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ // Expose {test} in the iframe for using the step_timeout helper.
+ document.test = t;
+
+ const iframe = document.createElement("iframe");
+ iframe.onerror = t.unreached_func("Error loading iframe");
+
+ document.addEventListener("documentWriteDone", t.step_func(() => {
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ }));
+ iframe.onload = t.step_func_done(() => {
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ });
+
+ iframe.src = "module-tla-promise-iframe.html";
+ document.body.appendChild(iframe);
+});
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module.html
new file mode 100644
index 0000000000..7e970d3fd9
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>document.write in a module</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+async_test(t => {
+ const iframe = document.createElement("iframe");
+
+ iframe.onerror = t.unreached_func("Error loading iframe");
+ document.addEventListener("documentWriteDone", t.step_func(() => {
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ }));
+ iframe.onload = t.step_func_done(() => {
+ assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
+ });
+
+ iframe.src = "module-iframe.html";
+ document.body.appendChild(iframe);
+});
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-1.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-1.html
new file mode 100644
index 0000000000..c7a7a1db4e
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-1.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<body>You should see the word "worked" below<br><script>document.write("\u003cscript>document.write(\"\\u003cscript src='nested-document-write-external.js'>\\u003c/script>r\"); document.write(\"k\");\u003c/script>e"); document.write("d");</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-2.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-2.html
new file mode 100644
index 0000000000..60b8eae1ef
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-2.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<body>
+You should see the word "worked" in the frame below.<br>
+<iframe></iframe>
+<script>
+var doc = document.getElementsByTagName("iframe")[0].contentDocument;
+doc.open(); doc.write("\u003cscript>document.write(\"\\u003cscript src='nested-document-write-external.js'>\\u003c/script>r\"); document.write(\"k\");\u003c/script>e"); doc.write("d"); doc.close();</script>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-external.js b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-external.js
new file mode 100644
index 0000000000..bf91daf986
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/nested-document-write-external.js
@@ -0,0 +1 @@
+document.write("w"); document.write("o");
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/original-id.json b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/original-id.json
new file mode 100644
index 0000000000..08bd4d0d4e
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/original-id.json
@@ -0,0 +1 @@
+{"original_id":"document.write()"} \ No newline at end of file
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_001.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_001.html
new file mode 100644
index 0000000000..43c7adb4d4
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_001.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<title>document.write script</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<script>t.done();<"+"/script>");
+});
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_002.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_002.html
new file mode 100644
index 0000000000..3879d8489f
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_002.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>document.write script executed synchronously</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+var order = [];
+t.step(function() {
+ document.write("<script>t.step(function() {order.push(1);});<"+"/script>");
+ order.push(2);
+});
+</script>
+<script>
+t.step(function() {
+ order.push(3);
+ assert_array_equals(order, [1,2,3]);
+})
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_003.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_003.html
new file mode 100644
index 0000000000..e669252f75
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_003.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<title>document.write script writing a further script</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ document.write("<script>document.write('<script>t.done()</script'+'>')<"+"/script>");
+});
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_004.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_004.html
new file mode 100644
index 0000000000..15fda325b1
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_004.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write script writing script; order of execution</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+var order = [];
+t.step(function() {
+ order.push(1);
+ document.write("<script>order.push(2); document.write('<script>order.push(3);</script'+'>'); order.push(4);<"+"/script>");
+ order.push(5);
+});
+</script>
+<script>
+t.step(function() {
+ assert_array_equals(order, [1,2,3,4,5]);
+});
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_005.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_005.html
new file mode 100644
index 0000000000..b99196c7d0
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_005.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>document.write external script</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+var order = [];
+t.step(function() {
+ order.push(1);
+ document.write("<script src='005.js'><"+"/script>");
+ order.push(2);
+});
+</script>
+<script>
+order.push(4);
+t.step(function() {
+ assert_array_equals(order, [1,2,3,4]);
+});
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_006.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_006.html
new file mode 100644
index 0000000000..c8dd9a5f9a
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_006.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<title>document.write external script followed by internal script</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+var order = [];
+t.step(function() {
+ order.push(1);
+ document.write("<script src='006.js'><"+"/script><script>t.step(function(){order.push(4)})</script"+">");
+ order.push(2);
+});
+</script>
+<script>
+t.step(function() {
+ order.push(5);
+ assert_array_equals(order, [1,2,3,4,5]);
+});
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_007.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_007.html
new file mode 100644
index 0000000000..fbbe5b2f86
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_007.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write external script that document.writes inline script</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+var order = [];
+t.step(function() {
+ order.push(1);
+});
+</script>
+<script src="007.js"></script>
+<script>
+t.step(function() {
+ order.push(4);
+ assert_array_equals(order, [1,2,3,4]);
+});
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_008.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_008.html
new file mode 100644
index 0000000000..c5a44dc700
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_008.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write external script that document.writes external script</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+var order = [];
+t.step(function() {
+ order.push(1);
+});
+</script>
+<script src="008.js"></script>
+<script>
+t.step(function() {
+ order.push(4);
+ assert_array_equals(order, [1,2,3,4]);
+});
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_009.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_009.html
new file mode 100644
index 0000000000..d12d934ea0
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_009.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<title>document.write script that document.writes script</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+var order = [];
+t.step(function() {
+ order.push(1);
+ document.write("<script>order.push(2); document.write('<script>order.push(3); document.write(\"<script>order.push(4);</script\"+\">\"); order.push(5);</script' + '>'); order.push(6);</script" + ">");
+ order.push(7);
+});
+</script>
+<script>
+t.step(function() {
+ assert_array_equals(order, [1,2,3,4,5,6,7]);
+});
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_010.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_010.html
new file mode 100644
index 0000000000..93728d6f27
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_010.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>document.write external script tokenizer order</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+var order = [];
+t.step(function() {
+ order.push(1);
+ document.write("<script src='010.js'></script" + "><meta><script src='010-1.js'></script" + ">");
+ order.push(2);
+ assert_equals(document.getElementsByTagName("meta").length, 0);
+});
+</script>
+<script>
+t.step(function() {
+ order.push(5);
+ assert_equals(document.getElementsByTagName("meta").length, 1);
+ assert_array_equals(order, [1,2,3,4,5]);
+});
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_011.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_011.html
new file mode 100644
index 0000000000..2bbcaf976e
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_011.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>document.write external script that document.writes external script</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+var order = [];
+t.step(function() {
+ order.push(1);
+ document.write("<script src='011.js'></script" + "><meta>");
+ order.push(2);
+ assert_equals(document.getElementsByTagName("meta").length, 0);
+});
+</script>
+<script>
+t.step(function() {
+ order.push(5);
+ assert_equals(document.getElementsByTagName("meta").length, 3, "Number of meta elements at end");
+ assert_array_equals(order, [1,2,3,4,5]);
+});
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_012.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_012.html
new file mode 100644
index 0000000000..57755f4c94
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_012.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>document.write external script tokenizer order</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+var order = [];
+t.step(function() {
+ order.push(1);
+ document.write("<script>order.push(2); document.write('<script src=\"012.js\"></script' + '><meta>'); order.push(3); t.step(function() {assert_equals(document.getElementsByTagName('meta').length, 0)});</script" + "><meta>");
+ order.push(4);
+ assert_equals(document.getElementsByTagName("meta").length, 0);
+});
+</script>
+<script>
+t.step(function() {
+ order.push(6);
+ assert_equals(document.getElementsByTagName("meta").length, 2);
+ assert_array_equals(order, [1,2,3,4,5,6]);
+});
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_013.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_013.html
new file mode 100644
index 0000000000..0e71e5eb0c
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/script_013.html
@@ -0,0 +1,24 @@
+<!doctype html>
+<title>document.write</title>
+<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>
+<script>
+var t = async_test();
+t.step(function() {
+ var s = "<script src='013.js'><" + "/script></svg>]]><path></svg>";
+ for (var i=0; i<s.length; i++) {
+ document.write(s[i]);
+ }
+});
+</script><script>
+t.step(function() {
+ assert_equals(document.body.childNodes[0].nodeType, document.ELEMENT_NODE);
+ assert_equals(document.body.childNodes[0].localName, "svg");
+ assert_equals(document.body.childNodes[0].childNodes[0].nodeType, document.TEXT_NODE);
+ assert_equals(document.body.childNodes[0].childNodes[0].data, "</svg>");
+ assert_equals(document.body.childNodes[0].childNodes[1].nodeType, document.ELEMENT_NODE);
+ assert_equals(document.body.childNodes[0].childNodes[1].localName, "path");
+}
+);
+t.done();
+</script>
+<div id="log"></div>
diff --git a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/write-active-document.html b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/write-active-document.html
new file mode 100644
index 0000000000..6faffd81de
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/write-active-document.html
@@ -0,0 +1,35 @@
+<!doctype html>
+<title>document.write only writes to active documents</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body><div id="log"></div></body>
+<script>
+ async_test(function(t) {
+ var child = document.createElement("iframe");
+ child.src = "empty.html?1";
+ child.onload = t.step_func(function() {
+ var child1 = child.contentDocument;
+ var link = child1.createElement("a");
+ link.href = "data:text/html,Clicked.";
+ link.innerText = "Link.";
+ child1.body.appendChild(link);
+ var grandchild = child1.createElement("iframe");
+ grandchild.src = "empty.html?2";
+ grandchild.onload = t.step_func(function() {
+ var grandchild1 = grandchild.contentDocument;
+ child.onload = t.step_func(function() {
+ // This is a write to an inactive document
+ child1.write('WRITE HAPPENED');
+ assert_equals(child1.body.lastChild.tagName, "IFRAME");
+ // This is a write to an active but not fully active document
+ grandchild1.write('WRITE HAPPENED');
+ assert_equals(grandchild1.body.innerHTML, "WRITE HAPPENED");
+ t.done();
+ });
+ link.click();
+ });
+ child1.body.appendChild(grandchild);
+ });
+ document.body.appendChild(child);
+ });
+</script>