Skip to content

Commit 7660118

Browse files
camillobrunimoz-wptsync-bot
authored andcommitted
Bug 1663596 [wpt PR 25430] - [blink][web_tests] document-write tests cleanup, a=testonly
Automatic update from web-platform-tests [blink][web_tests] document-write tests cleanup - Add better assertion failure messages - Use better content for document.write The tests assume that the ignore-destructive-writes counter is only incremented during the synchronous part of module evaluation (see whatwg/html#4352 (comment)). This also fixes document-write/module-delayed.html which accidentally had wrong test expectations checked in that made it pass. Bug: 1127215 Bug: 1022182 Bug: v8:9344 Change-Id: I01a75534f7efd0bd8e376dfd049432e52661604d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2397696 Reviewed-by: Hiroshige Hayashizaki <[email protected]> Commit-Queue: Camillo Bruni <[email protected]> Cr-Commit-Position: refs/heads/master@{#807384} -- wpt-commits: 05285a54f6369d56c51df2dc12e05730dd297d81 wpt-pr: 25430
1 parent 65e9d62 commit 7660118

File tree

7 files changed

+23
-17
lines changed

7 files changed

+23
-17
lines changed

testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-delayed.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010
const iframe = document.createElement("iframe");
1111

1212
iframe.onerror = t.unreached_func("Error loading iframe");
13+
1314
let onLoadWasCalled = false;
1415
iframe.onload = t.step_func(() => {
16+
onLoadWasCalled = true;
1517
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
1618
// Don't call the event handler another time after document.write.
1719
iframe.onload = null;
18-
onLoadWasCalled = true;
1920
});
2021
document.addEventListener("documentWriteDone", t.step_func_done(() => {
21-
assert_equals(iframe.onload, null);
22-
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
22+
assert_true(onLoadWasCalled, "onload must be called");
23+
assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
2324
}));
2425

2526
iframe.src = "module-delayed-iframe.html";

testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
const iframe = document.createElement("iframe");
99

1010
iframe.onerror = t.unreached_func("Error loading iframe");
11+
1112
let onLoadWasCalled = false;
1213
iframe.onload = t.step_func(() => {
14+
onLoadWasCalled = true;
1315
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
16+
// Don't call the event handler another time after document.write.
1417
iframe.onload = null;
15-
onLoadWasCalled = true;
1618
});
1719
document.addEventListener("documentWriteDone", t.step_func_done(() => {
18-
assert_true(onLoadWasCalled);
20+
assert_true(onLoadWasCalled, "onload must be called");
1921
assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
2022
}));
2123

testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
// Expose {test} in the iframe for using the step_timeout helper.
99
document.test = t;
1010
const iframe = document.createElement("iframe");
11-
1211
iframe.onerror = t.unreached_func("Error loading iframe");
12+
1313
let onLoadWasCalled = false;
1414
iframe.onload = t.step_func(() => {
15+
onLoadWasCalled = true;
1516
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
17+
// Don't call the event handler another time after document.write.
1618
iframe.onload = null;
17-
onLoadWasCalled = true;
1819
});
1920
document.addEventListener("documentWriteDone", t.step_func_done(() => {
20-
assert_true(onLoadWasCalled);
21+
assert_true(onLoadWasCalled, "onload must be called");
2122
assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
2223
}));
2324

testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-static-import.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
<script>
77
async_test(t => {
88
const iframe = document.createElement("iframe");
9+
910
iframe.onerror = t.unreached_func("Error loading iframe");
1011

1112
let testEndWasCalled = false;
1213
document.addEventListener("documentWriteDone", t.step_func(() => {
13-
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
1414
testEndWasCalled = true;
15+
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
1516
}));
1617
iframe.onload = t.step_func_done(() => {
17-
assert_true(testEndWasCalled);
18+
assert_true(testEndWasCalled, "onload must be called");
1819
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
1920
});
2021

testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed-iframe.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
resolve => window.parent.document.test.step_timeout(resolve, 0));
55

66
delay.then(() => {
7-
document.write("FAIL");
7+
document.write("document.write body contents\n");
88
document.close();
99
window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
1010
});

testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
let onLoadWasCalled = false;
1717
iframe.onload = t.step_func(() => {
18+
onLoadWasCalled = true;
1819
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
1920
iframe.onload = null;
20-
onLoadWasCalled = true;
2121
});
2222
document.addEventListener("documentWriteDone", t.step_func_done(() => {
23-
assert_true(onLoadWasCalled);
24-
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
23+
assert_true(onLoadWasCalled, "onload must be called");
24+
assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
2525
}));
2626

2727
iframe.src = "module-tla-delayed-iframe.html";

testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99
document.test = t;
1010

1111
const iframe = document.createElement("iframe");
12-
1312
iframe.onerror = t.unreached_func("Error loading iframe");
13+
1414
let onLoadWasCalled = false;
1515
iframe.onload = t.step_func(() => {
16+
onLoadWasCalled = true;
1617
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
18+
// Don't call the event handler another time after document.write.
1719
iframe.onload = null;
18-
onLoadWasCalled = true;
1920
});
2021
document.addEventListener("documentWriteDone", t.step_func_done(() => {
21-
assert_true(onLoadWasCalled);
22+
assert_false(onLoadWasCalled, "onload must not be called yet");
2223
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
2324
}));
2425

0 commit comments

Comments
 (0)