зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1627693 [wpt PR 22723] - [blink] Add tests for destructive writes with JavaScript modules, a=testonly
Automatic update from web-platform-tests [blink] Add tests for destructive writes with JavaScript modules (#22723) * [blink] Add tests for destructive writes with JavaScript modules This adds test for document.write in different situations with modules that were previously not tested or documented to the same extent. This also adds a test for future top-level await implementation. - JavaScript proposal: https://github.com/tc39/proposal-top-level-await - HTML proposal: https://github.com/whatwg/html/pull/4352 Bug: 1022182, v8:9344 Change-Id: I873df1e6aab2aa1ac6f7bf1b842059053f4a7cc4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134132 Reviewed-by: Domenic Denicola <domenic@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Commit-Queue: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/master@{#760411} Co-authored-by: Camillo Bruni <cbruni@chromium.org> Co-authored-by: Stephen McGruer <smcgruer@chromium.org> -- wpt-commits: 3a31f9c2822c84b2cbad5287a41c42c8ecbd7708 wpt-pr: 22723
This commit is contained in:
Родитель
767c8ae3f7
Коммит
a3e7351d63
|
@ -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
|
|
@ -0,0 +1,28 @@
|
|||
<!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(() => {
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
// Don't call the event handler another time after document.write.
|
||||
iframe.onload = null;
|
||||
onLoadWasCalled = true;
|
||||
});
|
||||
document.addEventListener("documentWriteDone", t.step_func_done(() => {
|
||||
assert_equals(iframe.onload, null);
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
}));
|
||||
|
||||
iframe.src = "module-delayed-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,7 @@
|
|||
<!doctype html>
|
||||
<script type=module>
|
||||
(async () => {
|
||||
let module = await import("./module-dynamic-import.mjs");
|
||||
})();
|
||||
</script>
|
||||
Initial body contents
|
|
@ -0,0 +1,25 @@
|
|||
<!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(() => {
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
iframe.onload = null;
|
||||
onLoadWasCalled = true;
|
||||
});
|
||||
document.addEventListener("documentWriteDone", t.step_func_done(() => {
|
||||
assert_true(onLoadWasCalled);
|
||||
assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
|
||||
}));
|
||||
|
||||
iframe.src = "module-dynamic-import-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,4 @@
|
|||
document.write("document.write body contents\n");
|
||||
document.close();
|
||||
|
||||
window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
|
|
@ -1,7 +1,7 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<script type=module>
|
||||
document.write("FAIL");
|
||||
document.write("document.write body contents\n");
|
||||
document.close();
|
||||
window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
|
||||
</script>
|
||||
PASS
|
||||
Initial body contents
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<!doctype html>
|
||||
<script type=module>
|
||||
import "./module-static-import-delayed.mjs"
|
||||
</script>
|
||||
Initial body contents
|
|
@ -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 => {
|
||||
// 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(() => {
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
iframe.onload = null;
|
||||
onLoadWasCalled = true;
|
||||
});
|
||||
document.addEventListener("documentWriteDone", t.step_func_done(() => {
|
||||
assert_true(onLoadWasCalled);
|
||||
assert_equals(iframe.contentDocument.body.textContent, "document.write body contents\n");
|
||||
}));
|
||||
|
||||
iframe.src = "module-static-import-delayed-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
|
@ -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);
|
|
@ -0,0 +1,5 @@
|
|||
<!doctype html>
|
||||
<script type=module>
|
||||
import "./module-static-import.mjs"
|
||||
</script>
|
||||
Initial body contents
|
|
@ -0,0 +1,25 @@
|
|||
<!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(() => {
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
testEndWasCalled = true;
|
||||
}));
|
||||
iframe.onload = t.step_func_done(() => {
|
||||
assert_true(testEndWasCalled);
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
});
|
||||
|
||||
iframe.src = "module-static-import-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
||||
ß
|
|
@ -0,0 +1,4 @@
|
|||
document.write("document.write body contents\n");
|
||||
document.close();
|
||||
|
||||
window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
|
|
@ -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("FAIL");
|
||||
document.close();
|
||||
window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
|
||||
});
|
||||
|
||||
await delay;
|
||||
</script>
|
||||
Initial body contents
|
|
@ -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(() => {
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
iframe.onload = null;
|
||||
onLoadWasCalled = true;
|
||||
});
|
||||
document.addEventListener("documentWriteDone", t.step_func_done(() => {
|
||||
assert_true(onLoadWasCalled);
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
}));
|
||||
|
||||
iframe.src = "module-tla-delayed-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
|
@ -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
|
|
@ -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(() => {
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
iframe.onload = null;
|
||||
onLoadWasCalled = true;
|
||||
});
|
||||
document.addEventListener("documentWriteDone", t.step_func_done(() => {
|
||||
assert_true(onLoadWasCalled);
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
}));
|
||||
|
||||
iframe.src = "module-tla-immediate-promise-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,5 @@
|
|||
<!doctype html>
|
||||
<script type=module>
|
||||
await import("./module-tla-import.mjs");
|
||||
</script>
|
||||
Initial body contents
|
|
@ -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 => {
|
||||
const iframe = document.createElement("iframe");
|
||||
|
||||
iframe.onerror = t.unreached_func("Error loading iframe");
|
||||
let testEndWasCalled = false;
|
||||
document.addEventListener("documentWriteDone", t.step_func(() => {
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
testEndWasCalled = true;
|
||||
}));
|
||||
iframe.onload = t.step_func_done(() => {
|
||||
assert_true(testEndWasCalled, 'documentWriteDone event was not sent');
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
});
|
||||
|
||||
iframe.src = "module-tla-import-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,4 @@
|
|||
document.write("document.write body contents\n");
|
||||
document.close();
|
||||
|
||||
window.parent.document.dispatchEvent(new CustomEvent("documentWriteDone"));
|
|
@ -0,0 +1,10 @@
|
|||
<!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
|
|
@ -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(() => {
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
iframe.onload = null;
|
||||
onLoadWasCalled = true;
|
||||
});
|
||||
document.addEventListener("documentWriteDone", t.step_func_done(() => {
|
||||
assert_true(onLoadWasCalled);
|
||||
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
|
||||
}));
|
||||
|
||||
iframe.src = "module-tla-promise-iframe.html";
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
</script>
|
|
@ -7,11 +7,16 @@
|
|||
<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);
|
||||
iframe.onerror = t.unreached_func("Error loading iframe");
|
||||
iframe.onload = t.step_func_done(() => {
|
||||
assert_equals(iframe.contentDocument.body.textContent, "PASS\n");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче