Commit 9fb16ab2 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[blink] Add top-level-await tests

This CL adds test required for landing top-level-await

- Add more tests for module evaluation order
- Add onunhandledrejection since top-level-await introduces more
  promises


Bug: 1022182
Bug: 1096455c
Bug: 1127215
Bug: v8:9344
Change-Id: Ib5502a47e6c0de6143a00f1ae35cde228e13200f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2411927Reviewed-by: default avatarHiroshige Hayashizaki <hiroshige@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806942}
parent 717e63a8
......@@ -1625,10 +1625,12 @@ crbug.com/441840 external/wpt/css/css-shapes/shape-outside/values/shape-outside-
crbug.com/441840 external/wpt/css/css-shapes/shape-outside/values/shape-outside-polygon-004.html [ Failure ]
crbug.com/441840 [ Win ] external/wpt/css/css-shapes/shape-outside/values/shape-outside-shape-arguments-000.html [ Failure ]
crbug.com/1022182 external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.html [ Failure ]
crbug.com/1022182 external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed.html [ Timeout ]
crbug.com/1022182 external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise.html [ Timeout ]
crbug.com/1022182 external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise.html [ Timeout ]
# Fix once top-level-await is enabled
crbug.com/1022182 external/wpt/html/semantics/scripting-1/the-script-element/module/evaluation-order-4-tla.html [ Skip ]
crbug.com/1022182 external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-delayed.html [ Skip ]
crbug.com/1022182 external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise.html [ Skip ]
crbug.com/1022182 external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.html [ Skip ]
crbug.com/1022182 external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise.html [ Skip ]
crbug.com/676270 [ Mac ] external/wpt/css/css-text/hyphens/hyphens-auto-001.html [ Failure ]
crbug.com/1022415 [ Mac ] external/wpt/css/css-text/hyphens/hyphens-auto-010.html [ Failure ]
......
......@@ -9,6 +9,7 @@
window.log = [];
window.addEventListener("error", ev => log.push(ev.error));
window.addEventListener("onunhandledrejection", unreachable);
const test_load = async_test(
"Parse errors in different files should be reported " +
......
......@@ -9,6 +9,7 @@
window.log = [];
window.addEventListener("error", ev => log.push(ev.error));
window.addEventListener("onunhandledrejection", unreachable);
const test_load = async_test(
"Instantiation errors in different files should be reported " +
......
......@@ -9,6 +9,7 @@
window.log = [];
window.addEventListener("error", ev => log.push(ev.error));
window.addEventListener("onunhandledrejection", unreachable);
const test_load = async_test(
"Evaluation errors are cached in intermediate module scripts");
......
......@@ -9,6 +9,7 @@
window.log = [];
window.addEventListener("error", ev => log.push(ev.error));
window.addEventListener("onunhandledrejection", unreachable);
const test_load = async_test(
"network error has higher priority than parse error");
......
......@@ -9,6 +9,7 @@
window.log = [];
window.addEventListener("error", ev => log.push(ev.error));
window.addEventListener("onunhandledrejection", unreachable);
const test_load = async_test(
"parse error has higher priority than instantiation error");
......
......@@ -9,6 +9,7 @@
window.log = [];
window.addEventListener("error", ev => log.push(ev.error));
window.addEventListener("onunhandledrejection", unreachable);
const test_load = async_test(
"instantiation error has higher priority than evaluation error");
......
<!DOCTYPE html>
<title>Testing evaluation order</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({allow_uncaught_exception: true});
window.log = [];
window.addEventListener("error", ev => testDone());
window.addEventListener("onunhandledrejection", unreachable);
const test_load = async_test("Test evaluation order of modules");
window.addEventListener("load", ev => log.push("window-load"));
function unreachable() { log.push("unexpected"); }
function testDone() {
test_load.step(() => {
assert_array_equals(log, [
"step-4.1-1", "step-4.1-2", "microtask-4.1",
"script-load", "window-load",
"step-4.2-1", "step-4.2-2", "microtask-4.2",
]);
});
test_load.done();
}
</script>
<script type="module" src="evaluation-order-4.1.mjs"
onerror="unreachable()" onload="log.push('script-load')">
</script>
log.push("step-4.1-1");
queueMicrotask(() => log.push("microtask-4.1"));
log.push("step-4.1-2");
await import("./evaluation-order-4.2.mjs");
// Not happening as we throw in the above module.
log.push("step-4.1-3");
log.push("step-4.2-1");
queueMicrotask(() => log.push("microtask-4.2"));
log.push("step-4.2-2");
throw new Error("error");
......@@ -10,7 +10,9 @@ async_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(() => {
assert_equals(iframe.contentDocument.body.textContent, "Initial body contents\n");
......
......@@ -6,17 +6,20 @@
<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');
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);
......
<!doctype html>
<script type=module>
await new Promise(resolve => {
window.parent.document.test.step_timeout(resolve, 0));
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
......@@ -9,18 +9,14 @@ async_test(t => {
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);
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment