forked from kdashg/gecko-cinn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1890925 [wpt PR 45660] - Test inserted async script execution ord…
…er, a=testonly Automatic update from web-platform-tests Test inserted async script execution order whatwg/html#9864 discusses the issue. whatwg/html#10272 matches what is tested here. -- wpt-commits: 5adce6fa88ba7bcb5c119d62736fb30cf1273306 wpt-pr: 45660
- Loading branch information
1 parent
b7bc949
commit fbfbba0
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
...html/semantics/scripting-1/the-script-element/module/inline-async-inserted-execorder.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Inline async="" module scripts execute or throw parse errors asynchronously</title> | ||
<link rel="help" href="https://github.com/whatwg/html/issues/9864"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<body> | ||
<script> | ||
"use strict"; | ||
setup({ allow_uncaught_exception: true }); | ||
|
||
promise_test(async t => { | ||
window.log = ["before any script execution"]; | ||
|
||
window.addEventListener("error", ev => { | ||
window.log.push("error event on Window"); | ||
}); | ||
|
||
const noErrorScript = document.createElement("script"); | ||
noErrorScript.type = "module"; | ||
noErrorScript.async = true; | ||
noErrorScript.textContent = "window.log.push('no error script executed');"; | ||
|
||
// This should queue a task to run the script, but not run it immediately. | ||
document.head.append(noErrorScript); | ||
|
||
log.push("after inserting noErrorScript"); | ||
assert_array_equals(window.log, [ | ||
"before any script execution", | ||
"after inserting noErrorScript" | ||
]); | ||
|
||
const parseErrorScript = document.createElement("script"); | ||
parseErrorScript.type = "module"; | ||
parseErrorScript.async = true; | ||
parseErrorScript.textContent = "+++++"; | ||
|
||
// This should queue a task to fire the error event, but not fire it immediately. | ||
document.head.append(parseErrorScript); | ||
|
||
log.push("after inserting parseErrorScript"); | ||
assert_array_equals(window.log, [ | ||
"before any script execution", | ||
"after inserting noErrorScript", | ||
"after inserting parseErrorScript" | ||
]); | ||
|
||
// After a microtask, the script run / error event must not happen. | ||
queueMicrotask(t.step_func(() => { | ||
assert_array_equals(window.log, [ | ||
"before any script execution", | ||
"after inserting noErrorScript", | ||
"after inserting parseErrorScript" | ||
]); | ||
})); | ||
|
||
// But it must eventually happen, after a full task. | ||
await t.step_wait(() => window.log.length == 5, "5 items must eventually be logged"); | ||
|
||
// And when it does the order must be correct. | ||
assert_array_equals(window.log, [ | ||
"before any script execution", | ||
"after inserting noErrorScript", | ||
"after inserting parseErrorScript", | ||
"no error script executed", | ||
"error event on Window" | ||
]); | ||
}); | ||
</script> |