aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element
diff options
context:
space:
mode:
authorWPT Sync Bot <josh+wptsync@joshmatthews.net>2022-11-10 01:22:36 +0000
committerWPT Sync Bot <josh+wptsync@joshmatthews.net>2022-11-10 01:27:28 +0000
commitdf68c4e5d155bdca6f787268bb266fd7979347f0 (patch)
treed1a2e89454b0ba282bca143acd7616fdcc86c4e3 /tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element
parentace9b32b1c18fb5a2fa3118f47aea98e9965ed67 (diff)
downloadservo-df68c4e5d155bdca6f787268bb266fd7979347f0.tar.gz
servo-df68c4e5d155bdca6f787268bb266fd7979347f0.zip
Update web-platform-tests to revision b'b728032f59a396243864b0f8584e7211e3632005'
Diffstat (limited to 'tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element')
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/README.md7
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/async-script-2.html40
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/async-script.html22
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/defer-script-xml.xhtml40
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/defer-script.html37
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/document-write.html67
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/async-script-1.js1
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/defer-script-1.js1
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/defer-script-2.js1
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-open-write-close.js3
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-open-write.js2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write-close.js2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write-iframe.sub.html14
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write.js1
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/helper.js17
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/sync-script-1.js1
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/sync-script-2.js1
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/support/async-script.html44
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-sharedworker.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-worker-setup.js4
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-worker.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow.html19
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-sharedworker.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker-setup.js4
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker.js9
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1.html19
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/029.html53
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/080.html30
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-nothrow-importScripts.any.js11
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-nothrow-static-import.any.js5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-importScripts.any.js22
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-static-import.any.js5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1.html34
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-2.any.js5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-2.html8
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-3.any.js5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-3.html8
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-4.html18
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-nothrow-setup.js5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-nothrow.js2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-throw-setup.js10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-throw.js4
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2-setup.js10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2.1.mjs (renamed from tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2.1.mjs)0
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2.2.mjs (renamed from tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2.2.mjs)0
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3-setup.js (renamed from tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker.mjs)5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3.1.mjs (renamed from tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3.1.mjs)0
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3.2.mjs (renamed from tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3.2.mjs)0
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-4.1.mjs (renamed from tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-4.1.mjs)0
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-4.2.mjs (renamed from tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-4.2.mjs)0
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js30
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/delay-load-event.html25
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/basic.any.js32
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/css-import-in-worker.any.js14
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/empty-module.css4
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/empty-module.js4
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/serviceworker.any.js14
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/ticker.js13
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/with-import-assertions.any.js15
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/worklet-ref.https.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/worklet.https.html43
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-sharedworker.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker-setup.mjs6
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker.mjs7
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow.html19
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow.mjs3
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-sharedworker.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker-setup.mjs6
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker.mjs9
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1.html20
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1.mjs5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-sharedworker.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker-setup.mjs6
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker.mjs7
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import.html20
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-sharedworker.html11
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker-setup.mjs6
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker.html11
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic.html19
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-4-tla.html33
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-setup.mjs19
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-object.any.js20
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-importmap.html57
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-multiple-scripts.html39
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve.any.js77
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-url.any.js20
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-1.mjs1
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-2.mjs1
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-import-meta.mjs2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/store-import-meta.html5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/README.md2
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/README.md6
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-1.html10
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-2.html14
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-iframe.html5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/helper.js31
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/in-order.html35
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/parser-blocking.html41
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/resources/script-type-and-language-js.js141
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-defer-xhtml.xhtml31
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-referrerpolicy-idl.html26
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-modifications-csp.html52
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-modifications.html9
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js-svg.svg37
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js-xhtml.xhtml42
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js.html120
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-2-helper.html4
111 files changed, 1366 insertions, 569 deletions
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/README.md b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/README.md
new file mode 100644
index 00000000000..ac5c91c9a2e
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/README.md
@@ -0,0 +1,7 @@
+The tests in this directory is intended for Chromium's DeferAllScript
+experiment https://crbug.com/1339112, containing scenarios that would be
+affected by DeferAllScript, to monitor the behavior on Chromium and other
+browsers.
+
+The same set of expectations (when async/defer scripts are evaluated) should
+already be covered somewhere in WPT.
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/async-script-2.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/async-script-2.html
new file mode 100644
index 00000000000..f7377d847ad
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/async-script-2.html
@@ -0,0 +1,40 @@
+<!doctype html>
+<title>Async Script Execution Order</title>
+<html>
+<head>
+ <meta charset="utf-8">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="resources/helper.js"></script>
+</head>
+<body>
+ <script>
+ setup({single_test: true});
+ function finish() {
+ assert_array_equals(
+ window.result,
+ ["Inline1", "Sync1", "Async1", "Sync2", "EndOfBody",
+ "DOMContentLoaded"],
+ "Execution order");
+ // Chromium's force-defer order would be:
+ // ["EndOfBody", "Inline1", "Sync1", "Sync2",
+ // "DOMContentLoaded", "Async1"]
+ //
+ // If we delay async script e.g. after DOMContentLoaded,
+ // the order would be:
+ // ["Inline1", "Sync1", "Sync2", "EndOfBody",
+ // "DOMContentLoaded", "Async1"]
+ done();
+ }
+ logScript("Inline1");
+ window.addEventListener("load", finish);
+ </script>
+ <script src="resources/sync-script-1.js"></script>
+ <!-- To test the async script loaded before force-deferred scripts
+ should be evaluated after the force-deferred scripts
+ in Chromium's force-defer order. -->
+ <script src="resources/async-script-1.js?pipe=trickle(d1)" async></script>
+ <script src="resources/sync-script-2.js?pipe=trickle(d2)"></script>
+ <pre id="bodyend">End</pre>
+</body>
+</html>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/async-script.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/async-script.html
new file mode 100644
index 00000000000..dea7f987bfa
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/async-script.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<title>Async Script Execution Order</title>
+<html>
+<head>
+ <meta charset="utf-8">
+ <meta name=variant content="">
+ <meta name=variant content="?reload">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="resources/helper.js"></script>
+</head>
+<body>
+ <script>
+ let child_path = 'support/async-script.html';
+ if (location.search == '?reload') {
+ child_path += '?reload';
+ }
+ const child_window = window.open(child_path);
+ fetch_tests_from_window(child_window);
+ </script>
+</body>
+</html>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/defer-script-xml.xhtml b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/defer-script-xml.xhtml
new file mode 100644
index 00000000000..9d02ff39f51
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/defer-script-xml.xhtml
@@ -0,0 +1,40 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Defer Script Execution Order</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="resources/helper.js"></script>
+</head>
+<body>
+ <div id="scriptlog"/>
+ <input id="testElement"/>
+ <script>
+ setup({single_test: true});
+ function finish() {
+ assert_array_equals(
+ window.result,
+ ["Inline1", "Sync1", "Inline2", "Sync2", "EndOfBody",
+ "Defer1", "Defer2", "DOMContentLoaded"],
+ "Execution order");
+ // Chromium order is (due to https://crbug.com/874749):
+ // ["Inline1", "Sync1", "Defer1", "Inline2", "Defer2", "Sync2",
+ // "EndOfBody", "DOMContentLoaded"]
+ done();
+ }
+ logScript("Inline1");
+ window.addEventListener("load", finish);
+ </script>
+
+ <script src="resources/sync-script-1.js"></script>
+ <script src="resources/defer-script-1.js" defer="defer"></script>
+ <script>
+ logScript("Inline2");
+ </script>
+ <script src="resources/defer-script-2.js" defer="defer"></script>
+ <script src="resources/sync-script-2.js"></script>
+ <pre id="bodyend">End</pre>
+</body>
+</html>
+
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/defer-script.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/defer-script.html
new file mode 100644
index 00000000000..62c3a74014f
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/defer-script.html
@@ -0,0 +1,37 @@
+<!doctype html>
+<title>Defer Script Execution Order</title>
+<html>
+<head>
+ <meta charset="utf-8">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="resources/helper.js"></script>
+</head>
+<body>
+ <script>
+ setup({single_test: true});
+ function finish() {
+ assert_array_equals(
+ window.result,
+ ["Inline1", "Sync1", "Inline2", "Sync2", "EndOfBody",
+ "Defer1", "Defer2", "DOMContentLoaded"],
+ "Execution order");
+ // Chromium's force defer order would be:
+ // ["EndOfBody", "Inline1", "Sync1", "Inline2", "Sync2",
+ // "Defer1", "Defer2", "DOMContentLoaded"]
+ done();
+ }
+ logScript("Inline1");
+ window.addEventListener("load", finish);
+ </script>
+
+ <script src="resources/sync-script-1.js"></script>
+ <script src="resources/defer-script-1.js" defer></script>
+ <script>
+ logScript("Inline2");
+ </script>
+ <script src="resources/defer-script-2.js" defer></script>
+ <script src="resources/sync-script-2.js"></script>
+ <pre id="bodyend">End</pre>
+</body>
+</html>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/document-write.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/document-write.html
new file mode 100644
index 00000000000..63e251bae5c
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/document-write.html
@@ -0,0 +1,67 @@
+<!doctype html>
+<title>DeferAllScript: document.write()</title>
+<html>
+<head>
+ <meta charset="utf-8">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script>
+ const t1 = async_test("document.write()");
+ const t2 = async_test("document.write(),close()");
+ const t3 = async_test("document.open(),write()");
+ const t4 = async_test("document.open(),write(),close()");
+ function finish() {
+ const expected = ["Inline1", "Sync2", "Async1", "Sync1",
+ "EndOfBody", "DOMContentLoaded", "WindowLoad"];
+ t1.step_func_done(() => {
+ assert_array_equals(
+ document.getElementById("document-write").contentWindow.result,
+ expected,
+ "Execution order");
+ })();
+
+ t2.step_func_done(() => {
+ assert_array_equals(
+ document.getElementById("document-write-close").contentWindow.result,
+ expected,
+ "Execution order");
+ })();
+
+ t3.step_func_done(() => {
+ assert_array_equals(
+ document.getElementById("document-open-write").contentWindow.result,
+ expected,
+ "Execution order");
+ })();
+
+ t4.step_func_done(() => {
+ assert_array_equals(
+ document.getElementById(
+ "document-open-write-close").contentWindow.result,
+ expected,
+ "Execution order");
+ })();
+ // For cases where documents are kept open, call `document.close()` here
+ // to finish the test harness.
+ for (const iframe of document.querySelectorAll("iframe")) {
+ iframe.contentDocument.close();
+ }
+ }
+
+ // For cases where documents are kept open (that should never occur in
+ // non-intervention cases), schedule `finish()` because Window load events
+ // might be not fired.
+ setTimeout(finish, 5000);
+ </script>
+</head>
+<body onload="finish()">
+<iframe id="document-write"
+ src="resources/document-write-iframe.sub.html?script=document-write.js"></iframe>
+<iframe id="document-write-close"
+ src="resources/document-write-iframe.sub.html?script=document-write-close.js"></iframe>
+<iframe id="document-open-write"
+ src="resources/document-write-iframe.sub.html?script=document-open-write.js"></iframe>
+<iframe id="document-open-write-close"
+ src="resources/document-write-iframe.sub.html?script=document-open-write-close.js"></iframe>
+</body>
+</html>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/async-script-1.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/async-script-1.js
new file mode 100644
index 00000000000..267f324aa65
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/async-script-1.js
@@ -0,0 +1 @@
+logScript("Async1");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/defer-script-1.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/defer-script-1.js
new file mode 100644
index 00000000000..1a0524f4fbd
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/defer-script-1.js
@@ -0,0 +1 @@
+logScript("Defer1");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/defer-script-2.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/defer-script-2.js
new file mode 100644
index 00000000000..d644e37f182
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/defer-script-2.js
@@ -0,0 +1 @@
+logScript("Defer2");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-open-write-close.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-open-write-close.js
new file mode 100644
index 00000000000..80703d5c0ef
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-open-write-close.js
@@ -0,0 +1,3 @@
+document.open();
+document.write(`<script src="sync-script-2.js"></script>`);
+document.close();
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-open-write.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-open-write.js
new file mode 100644
index 00000000000..178c374df69
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-open-write.js
@@ -0,0 +1,2 @@
+document.open();
+document.write(`<script src="sync-script-2.js"></script>`);
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write-close.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write-close.js
new file mode 100644
index 00000000000..7cdde0d78ff
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write-close.js
@@ -0,0 +1,2 @@
+document.write(`<script src="sync-script-2.js"></script>`);
+document.close();
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write-iframe.sub.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write-iframe.sub.html
new file mode 100644
index 00000000000..e3022e3bf1f
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write-iframe.sub.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<html>
+<body>
+<script src="helper.js"></script>
+<script>
+logScript("Inline1");
+window.addEventListener("load", () => logScript("WindowLoad"));
+</script>
+<script src="{{GET[script]}}?pipe=trickle(d1)"></script>
+<script src="async-script-1.js" async></script>
+<script src="sync-script-1.js?pipe=trickle(d2)"></script>
+<pre id="bodyend">End</pre>
+</body>
+</html>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write.js
new file mode 100644
index 00000000000..413a9bc6210
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/document-write.js
@@ -0,0 +1 @@
+document.write(`<script src="sync-script-2.js"></script>`);
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/helper.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/helper.js
new file mode 100644
index 00000000000..89c6d1e8282
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/helper.js
@@ -0,0 +1,17 @@
+window.result = [];
+function log(msg) {
+ window.result.push(msg);
+}
+function checkIfReachedBodyEnd() {
+ const endelement = document.getElementById("bodyend");
+ // `<pre id="bodyend">End</pre>` is needed at the end of HTML.
+ if (endelement && endelement.textContent === "End") {
+ log("EndOfBody");
+ endelement.textContent = "Detected";
+ }
+}
+function logScript(msg) {
+ checkIfReachedBodyEnd();
+ log(msg);
+}
+document.addEventListener("DOMContentLoaded", function() { logScript("DOMContentLoaded"); });
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/sync-script-1.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/sync-script-1.js
new file mode 100644
index 00000000000..726b56346e8
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/sync-script-1.js
@@ -0,0 +1 @@
+logScript("Sync1");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/sync-script-2.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/sync-script-2.js
new file mode 100644
index 00000000000..ba2edfbf270
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/resources/sync-script-2.js
@@ -0,0 +1 @@
+logScript("Sync2");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/support/async-script.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/support/async-script.html
new file mode 100644
index 00000000000..d513bafe4f6
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/defer-script/support/async-script.html
@@ -0,0 +1,44 @@
+<!doctype html>
+<title>Child Async Script Execution Order</title>
+<html>
+
+<head>
+ <meta charset="utf-8">
+ <script src="/resources/testharness.js"></script>
+ <script src="../resources/helper.js"></script>
+</head>
+
+<body>
+ <script>
+ const reload_key = 'run-after-reload';
+ if (location.search == '?reload' && !window.localStorage.getItem(reload_key)) {
+ window.localStorage.setItem(reload_key, true);
+ location.reload();
+ } else {
+ window.localStorage.clear();
+ test();
+ }
+
+ function test() {
+ setup({ single_test: true });
+ function finish() {
+ assert_array_equals(
+ window.result,
+ ["Inline1", "Sync1", "EndOfBody", "DOMContentLoaded", "Async1"],
+ "Execution order");
+ // Chromium's force-defer order would be:
+ // ["EndOfBody", "Inline1", "Sync1", "DOMContentLoaded", "Async1"]
+ done();
+ }
+ logScript("Inline1");
+ window.addEventListener("load", finish);
+ }
+ </script>
+ <script src="../resources/sync-script-1.js"></script>
+ <!-- Delays are added to make DOMContentLoaded be fired before
+ async script load completion -->
+ <script src="../resources/async-script-1.js?pipe=trickle(d1)" async></script>
+ <pre id="bodyend">End</pre>
+</body>
+
+</html>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-sharedworker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-sharedworker.html
deleted file mode 100644
index 9bfe5a1f312..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-sharedworker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new SharedWorker(
- "evaluation-order-1-nothrow-worker-setup.js");
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-worker-setup.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-worker-setup.js
deleted file mode 100644
index 88fc22ba7f7..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-worker-setup.js
+++ /dev/null
@@ -1,4 +0,0 @@
-importScripts("/resources/testharness.js");
-importScripts("module/evaluation-order-setup.mjs");
-importScripts("module/evaluation-order-1-nothrow-worker.mjs");
-importScripts("module/evaluation-order-1-nothrow.mjs");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-worker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-worker.html
deleted file mode 100644
index 4ddfb61d507..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow-worker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new Worker(
- "evaluation-order-1-nothrow-worker-setup.js");
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow.html
deleted file mode 100644
index b08372efd71..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-nothrow.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script src="module/evaluation-order-setup.mjs"></script>
-<script>
- window.addEventListener("load", ev => globalThis.testDone());
- globalThis.expectedLog = [
- "step-1-1", "step-1-2",
- "microtask",
- "script-load",
- "global-load",
- ];
-</script>
-
-<script src="module/evaluation-order-1-nothrow.mjs"
- onerror="globalThis.unreachable()"
- onload="globalThis.log.push('script-load')"></script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-sharedworker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-sharedworker.html
deleted file mode 100644
index 0ad18a8fba8..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-sharedworker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new SharedWorker(
- "evaluation-order-1-worker-setup.js");
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker-setup.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker-setup.js
deleted file mode 100644
index 5ac90a2388a..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker-setup.js
+++ /dev/null
@@ -1,4 +0,0 @@
-importScripts("/resources/testharness.js");
-importScripts("module/evaluation-order-setup.mjs");
-importScripts("evaluation-order-1-worker.js");
-importScripts("module/evaluation-order-1.mjs");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker.html
deleted file mode 100644
index 7760e087c2d..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new Worker(
- "evaluation-order-1-worker-setup.js");
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker.js
deleted file mode 100644
index b583bf1ca62..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1-worker.js
+++ /dev/null
@@ -1,9 +0,0 @@
-globalThis.expectedLog = [
- "step-1-1", "step-1-2",
- "global-error", "error",
- "microtask",
-];
-
-globalThis.test_load.step_timeout(() => globalThis.testDone(), 0);
-
-done();
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1.html
deleted file mode 100644
index 7bf7132081e..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/evaluation-order-1.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script src="module/evaluation-order-setup.mjs"></script>
-<script>
- window.addEventListener("load", event => globalThis.testDone());
- globalThis.expectedLog = [
- "step-1-1", "step-1-2",
- "global-error", "error",
- "microtask",
- "script-load",
- "global-load"
- ];
-</script>
-
-<script src="module/evaluation-order-1.mjs"
- onerror="unreachable()" onload="log.push('script-load')"></script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/029.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/029.html
deleted file mode 100644
index 33548e566ac..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/029.html
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE html>
-<html><head>
- <title> scheduler: javascript: URL in HREF</title>
- <script src="/resources/testharness.js"></script>
- <script src="/resources/testharnessreport.js"></script>
- <script src="testlib/testlib.js"></script>
-</head>
-<body>
-
- <div id="log">FAILED (This TC requires JavaScript enabled)</div>
- <p><a href="javascript:log('JS URL')"></a></p>
- <script>log('inline script #1');
- window.addEventListener("beforeunload", function( event ) {
- log('beforeunload event');
- });
- if(document.links[0].click){
- document.links[0].click();
- }else{
- var evt = document.createEvent("MouseEvents");
- evt.initMouseEvent("click", true, true, window,
- 0, 0, 0, 0, 0, false, false, false, false, 0, null);
- document.links[0].dispatchEvent(evt);
- }
- log('end script #1');
- </script>
-
- <script type="text/javascript">
- log( 'inline script #2' );
- var t = async_test()
-
- function final_test() {
- // The JS URL part is required to run in an additional task,
- // altough that is not fully consistently implemented,
- // see https://github.com/whatwg/html/issues/3730#issuecomment-492071447
- assert_any(assert_array_equals, eventOrder, [
- ['inline script #1', 'end script #1', 'beforeunload event', 'inline script #2', 'JS URL'],
- ['inline script #1', 'end script #1', 'inline script #2', 'beforeunload event', 'JS URL']]);
- t.done();
- }
-
- function test_on_load() {
- // When the page loads, a task to run the navigate steps
- // previously enqueued as part of following-hyperlinks,
- // should have run, and have enqueued another task to execute the JS URL.
- assert_any(assert_array_equals, eventOrder, [
- ['inline script #1', 'end script #1', 'beforeunload event', 'inline script #2'],
- ['inline script #1', 'end script #1', 'inline script #2', 'beforeunload event']]);
- t.step_timeout(final_test, 1000)
- }
- onload = t.step_func(test_on_load);
- </script>
-
-</body></html>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/080.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/080.html
deleted file mode 100644
index bd983355a1f..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/080.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE html>
-<html><head>
- <title>scheduler: IFRAMEs added with DOM (appendChild), javascript: URL</title>
- <script src="/resources/testharness.js"></script>
- <script src="/resources/testharnessreport.js"></script>
- <script src="testlib/testlib.js"></script>
-</head>
-<body>
-
- <div id="log">FAILED (This TC requires JavaScript enabled)</div>
- <div></div>
- <script>log('inline script #1');
- var iframe=document.createElement('iframe');
- iframe.src='javascript:parent.log(\'JS URL\');\'<html><script>parent.log(\\\'frame script\\\')<\/script></html>\'';
- document.getElementsByTagName('div')[1].appendChild(iframe);
- log('end script #1');
- </script>
-
- <script type="text/javascript">
- log( 'inline script #2' );
- var t = async_test()
-
- function test() {
- assert_array_equals(eventOrder, ['inline script #1', 'end script #1', 'inline script #2', 'JS URL', 'frame script']);
- t.done();
- }
- onload = t.step_func(function(){setTimeout(t.step_func(test), 400);})
- </script>
-
-</body></html>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-nothrow-importScripts.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-nothrow-importScripts.any.js
new file mode 100644
index 00000000000..bacfc9fd04b
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-nothrow-importScripts.any.js
@@ -0,0 +1,11 @@
+// META: global=dedicatedworker,sharedworker
+// META: script=./resources/evaluation-order-setup.js
+
+// Spec: https://html.spec.whatwg.org/C/#run-a-classic-script
+// called from https://html.spec.whatwg.org/C/#import-scripts-into-worker-global-scope
+setupTest("importScripts() queueing a microtask then throwing an exception", [
+ "body",
+ "microtask",
+]);
+
+importScripts('./resources/evaluation-order-1-nothrow.js');
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-nothrow-static-import.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-nothrow-static-import.any.js
new file mode 100644
index 00000000000..006eab7a7e0
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-nothrow-static-import.any.js
@@ -0,0 +1,5 @@
+// META: global=dedicatedworker-module,sharedworker-module
+// META: script=./resources/evaluation-order-setup.js
+
+import './resources/evaluation-order-1-nothrow-setup.js';
+import './resources/evaluation-order-1-nothrow.js';
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-importScripts.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-importScripts.any.js
new file mode 100644
index 00000000000..0b42ea1e501
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-importScripts.any.js
@@ -0,0 +1,22 @@
+// META: global=dedicatedworker,sharedworker
+// META: script=./resources/evaluation-order-setup.js
+
+// Spec: https://html.spec.whatwg.org/C/#run-a-classic-script
+// called from https://html.spec.whatwg.org/C/#import-scripts-into-worker-global-scope
+setupTest("importScripts() queueing a microtask then throwing an exception", [
+ // Step 6 of #run-a-classic-script.
+ "body",
+
+ // Step 7.1.1 ("Clean up after running script") is no-op because JavaScript
+ // execution context stack is still non-empty immediately after
+ // importScripts() as the outer script is still executing.
+
+ // Step 7.1.2 (Rethrowing an exception) causes worker onerror.
+ "global-error",
+
+ // Microtask checkpoint is performed later, perhaps
+ // "Clean up after running script" after the outer script is finished.
+ "microtask",
+]);
+
+importScripts('./resources/evaluation-order-1-throw.js');
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-static-import.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-static-import.any.js
new file mode 100644
index 00000000000..f6cc427c719
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1-throw-static-import.any.js
@@ -0,0 +1,5 @@
+// META: global=dedicatedworker-module,sharedworker-module
+// META: script=./resources/evaluation-order-setup.js
+
+import './resources/evaluation-order-1-throw-setup.js';
+import './resources/evaluation-order-1-throw.js';
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1.html
new file mode 100644
index 00000000000..4800ef81bc0
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-1.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/evaluation-order-setup.js"></script>
+
+<script>
+// Spec: https://html.spec.whatwg.org/C/#run-a-classic-script
+setupTest("Classic script queueing a microtask then throwing an exception", [
+ "body", // Step 6.
+ "global-error", // "Report the exception" at Step 7.3.
+ "microtask", // "Clean up after running script" at Step 7.2.
+ ]);
+</script>
+<script src="resources/evaluation-order-1-throw.js"
+ onerror="unreachable()" onload="testDone()"></script>
+
+<script>
+// Spec: https://html.spec.whatwg.org/C/#run-a-classic-script
+setupTest("Classic script queueing a microtask", [
+ "body", // Step 6.
+ "microtask", // "Clean up after running script" at Step 7.2.
+ ]);
+</script>
+<script src="resources/evaluation-order-1-nothrow.js"
+ onerror="unreachable()" onload="testDone()"></script>
+
+
+<script type="module" src="resources/evaluation-order-1-throw-setup.js"></script>
+<script type="module" src="resources/evaluation-order-1-throw.js"
+ onerror="unreachable()" onload="testDone()"></script>
+
+<script type="module" src="resources/evaluation-order-1-nothrow-setup.js"></script>
+<script type="module" src="resources/evaluation-order-1-nothrow.js"
+ onerror="unreachable()" onload="testDone()"></script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-2.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-2.any.js
new file mode 100644
index 00000000000..bbc64748235
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-2.any.js
@@ -0,0 +1,5 @@
+// META: global=dedicatedworker-module,sharedworker-module
+// META: script=./resources/evaluation-order-setup.js
+
+import './resources/evaluation-order-2-setup.js';
+import './resources/evaluation-order-2.1.mjs';
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-2.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-2.html
new file mode 100644
index 00000000000..e55c2ecbed4
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-2.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/evaluation-order-setup.js"></script>
+
+<script type="module" src="resources/evaluation-order-2-setup.js"></script>
+<script type="module" src="resources/evaluation-order-2.1.mjs"
+ onerror="unreachable()" onload="testDone()"></script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-3.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-3.any.js
new file mode 100644
index 00000000000..19e94714e5d
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-3.any.js
@@ -0,0 +1,5 @@
+// META: global=dedicatedworker-module,sharedworker-module
+// META: script=./resources/evaluation-order-setup.js
+
+import './resources/evaluation-order-3-setup.js';
+import './resources/evaluation-order-3.1.mjs';
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-3.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-3.html
new file mode 100644
index 00000000000..ef351acd288
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-3.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/evaluation-order-setup.js"></script>
+
+<script type="module" src="resources/evaluation-order-3-setup.js"></script>
+<script type="module" src="resources/evaluation-order-3.1.mjs"
+ onerror="unreachable()"></script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-4.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-4.html
new file mode 100644
index 00000000000..f27678439df
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/evaluation-order-4.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/evaluation-order-setup.js"></script>
+
+<script>
+// Spec: https://html.spec.whatwg.org/C/#run-a-module-script
+setupTest("Module script queueing a microtask then top-level await", [
+ "step-4.1-1", "step-4.1-2",
+ "microtask-4.1",
+ "script-load",
+ "step-4.2-1", "step-4.2-2",
+ "microtask-4.2",
+]);
+window.onerror = testDone;
+</script>
+<script type="module" src="resources/evaluation-order-4.1.mjs"
+ onerror="unreachable()" onload="log.push('script-load')"></script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-nothrow-setup.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-nothrow-setup.js
new file mode 100644
index 00000000000..1b42e995937
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-nothrow-setup.js
@@ -0,0 +1,5 @@
+// Spec: https://html.spec.whatwg.org/C/#run-a-module-script
+setupTest("Module script queueing a microtask", [
+ "body", // Step 6.
+ "microtask", // "Clean up after running script" at Step 8.
+]);
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-nothrow.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-nothrow.js
new file mode 100644
index 00000000000..e19d9b1b137
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-nothrow.js
@@ -0,0 +1,2 @@
+queueMicrotask(() => globalThis.log.push("microtask"));
+globalThis.log.push("body");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-throw-setup.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-throw-setup.js
new file mode 100644
index 00000000000..651a494e530
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-throw-setup.js
@@ -0,0 +1,10 @@
+// Spec: https://html.spec.whatwg.org/C/#run-a-module-script
+setupTest("Module script queueing a microtask then throwing an exception", [
+ "body", // Step 6.
+ "microtask", // "Clean up after running script" at Step 8.
+ "global-error", // "Clean up after running script" at Step 8, because
+ // `evaluationPromise` is synchronously rejected and the rejection is
+ // processed in the microtask checkpoint here (See also Step 7).
+ // As `evaluationPromise` is rejected after the microtask queued during
+ // evaluation, "global-error" occurs after "microtask".
+]);
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-throw.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-throw.js
new file mode 100644
index 00000000000..2451df1c155
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-1-throw.js
@@ -0,0 +1,4 @@
+queueMicrotask(() => globalThis.log.push("microtask"));
+globalThis.log.push("body");
+
+throw new Error("error");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2-setup.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2-setup.js
new file mode 100644
index 00000000000..46f7354538a
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2-setup.js
@@ -0,0 +1,10 @@
+// Spec: https://html.spec.whatwg.org/C/#run-a-module-script
+setupTest("Module script queueing a microtask then throwing an exception", [
+ "step-2.2-1", "step-2.2-2", // Step 6.
+ "microtask-2.2", // "Clean up after running script" at Step 8.
+ "global-error", // "Clean up after running script" at Step 8,
+ // because `evaluationPromise` is synchronously rejected and the rejection
+ // is processed in the microtask checkpoint here (See also Step 7).
+ // As `evaluationPromise` is rejected after the microtask queued during
+ // evaluation, "global-error" occurs after "microtask".
+]);
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2.1.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2.1.mjs
index d6c2afa2f72..d6c2afa2f72 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2.1.mjs
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2.1.mjs
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2.2.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2.2.mjs
index 5c67c4f9a25..5c67c4f9a25 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2.2.mjs
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2.2.mjs
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3-setup.js
index 79dabab10b3..edc046910e4 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker.mjs
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3-setup.js
@@ -1,8 +1,7 @@
-globalThis.expectedLog = [
+setupTest("Module script queueing a microtask then throwing an exception", [
"step-3.1-1", "step-3.1-2", "step-3.1-3",
"microtask-3.1",
"step-3.2-1", "step-3.2-2",
"microtask-3.2",
"import-catch", "error",
-];
-done(); \ No newline at end of file
+]);
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3.1.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3.1.mjs
index ef320632af7..ef320632af7 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3.1.mjs
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3.1.mjs
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3.2.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3.2.mjs
index 8ccb5812066..8ccb5812066 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3.2.mjs
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3.2.mjs
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-4.1.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-4.1.mjs
index f3347c1d28e..f3347c1d28e 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-4.1.mjs
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-4.1.mjs
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-4.2.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-4.2.mjs
index 96a5cca3a63..96a5cca3a63 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-4.2.mjs
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-4.2.mjs
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js
new file mode 100644
index 00000000000..d2e28935c43
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js
@@ -0,0 +1,30 @@
+globalThis.setup({allow_uncaught_exception: true});
+
+// Must be called after previous tests are completed.
+globalThis.setupTest = (description, expectedLog) => {
+ globalThis.log = [];
+ globalThis.onerror = message => {
+ globalThis.log.push("global-error");
+ return true;
+ };
+ globalThis.onunhandledrejection =
+ () => globalThis.log.push('unhandled-promise-rejection');
+
+ globalThis.unreachable = () => globalThis.log.push("unreachable");
+
+ globalThis.test_load = async_test(description);
+ globalThis.testDone = globalThis.test_load.step_func_done(() => {
+ assert_array_equals(globalThis.log, expectedLog);
+ });
+
+ if (!('Window' in globalThis && globalThis instanceof Window)) {
+ // In workers, there are no <script> load event, so scheduling `testDone()`
+ // here, assuming the target script is loaded and evaluated soon.
+ globalThis.test_load.step_timeout(() => globalThis.testDone(), 1000);
+
+ // In workers, call `done()` here because the auto-generated `done()` calls
+ // by `any.js` etc. are at the end of main script and thus are not
+ // evaluated when the target script throws an exception.
+ done();
+ }
+};
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/delay-load-event.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/delay-load-event.html
new file mode 100644
index 00000000000..5ec6433e65b
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/delay-load-event.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<title>Dynamic imports don't delay the load event</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+// Dynamic imports don't #delay-the-load-event.
+// Therefore, Window load event would be fired
+// just after the dynamic import() below starts.
+window.loaded = [];
+window.addEventListener('load', () => loaded.push('Window load event'));
+promise_test(t => {
+ loaded.push('import start');
+ // This 'loading' log is added to detect the previous Chromium behavior
+ // where the Window load event is delayed until just before script
+ // element's load event.
+ t.step_timeout(() => loaded.push('loading'), 1000);
+ return import("../resources/slow-module.js?pipe=trickle(d2)")
+ .then(() => {
+ assert_array_equals(
+ loaded,
+ ['import start', 'Window load event', 'loading', 'slow'],
+ "Window load event shouldn't be delayed by dynamic imports");
+ });
+}, "Dynamic imports don't delay the load event.");
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/basic.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/basic.any.js
new file mode 100644
index 00000000000..82cb3b215db
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/basic.any.js
@@ -0,0 +1,32 @@
+// META: global=window,dedicatedworker,sharedworker
+// META: script=ticker.js
+
+promise_test(async t => {
+ const getCount = ticker(1000);
+
+ const importP = import("<invalid>");
+ await promise_rejects_js(t, TypeError, importP, 'import() should reject');
+
+ assert_less_than(getCount(), 1000);
+}, "import() should not drain the microtask queue if it fails during specifier resolution");
+
+promise_test(async t => {
+ // Use Date.now() to ensure that the module is not in the module map
+ const specifier = "./empty-module.js?" + Date.now();
+
+ await import(specifier);
+
+ const getCount = ticker(1000);
+ await import(specifier);
+ assert_less_than(getCount(), 1000);
+}, "import() should not drain the microtask queue when loading an already loaded module");
+
+promise_test(async t => {
+ // Use Date.now() to ensure that the module is not in the module map
+ const specifier = "./empty-module.js?" + Date.now();
+
+ const getCount = ticker(1e7);
+ await import(specifier);
+ assert_equals(getCount(), 1e7);
+}, "import() should drain the microtask queue when fetching a new module");
+
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/css-import-in-worker.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/css-import-in-worker.any.js
new file mode 100644
index 00000000000..bd6f5d092f3
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/css-import-in-worker.any.js
@@ -0,0 +1,14 @@
+// META: global=dedicatedworker,sharedworker
+// META: script=ticker.js
+
+promise_test(async t => {
+ // Use Date.now() to ensure that the module is not in the module map
+ const specifier = "./empty-module.css?" + Date.now();
+
+ const getCount = ticker(1000);
+
+ const importP = import(specifier, { assert: { type: "css" } });
+ await promise_rejects_js(t, TypeError, importP, 'import() should reject');
+
+ assert_less_than(getCount(), 1000);
+}, "import() should not drain the microtask queue if it fails because of the 'type: css' assertion in a worker");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/empty-module.css b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/empty-module.css
new file mode 100644
index 00000000000..108e7649bdd
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/empty-module.css
@@ -0,0 +1,4 @@
+/*
+This file is empty, because all it matters is if the
+dynamic import that loads it fails or succedes.
+*/
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/empty-module.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/empty-module.js
new file mode 100644
index 00000000000..108e7649bdd
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/empty-module.js
@@ -0,0 +1,4 @@
+/*
+This file is empty, because all it matters is if the
+dynamic import that loads it fails or succedes.
+*/
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/serviceworker.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/serviceworker.any.js
new file mode 100644
index 00000000000..4c75cab1b65
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/serviceworker.any.js
@@ -0,0 +1,14 @@
+// META: global=serviceworker
+// META: script=ticker.js
+
+promise_test(async t => {
+ // Use Date.now() to ensure that the module is not in the module map
+ const specifier = "./empty-module.js?" + Date.now();
+
+ const getCount = ticker(1000);
+
+ const importP = import(specifier);
+ await promise_rejects_js(t, TypeError, importP, 'import() should reject');
+
+ assert_less_than(getCount(), 1000);
+}, "import() should not drain the microtask queue if it fails because it's used in a ServiceWorker");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/ticker.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/ticker.js
new file mode 100644
index 00000000000..42619b6e700
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/ticker.js
@@ -0,0 +1,13 @@
+globalThis.ticker = function ticker(max) {
+ let i = 0;
+ let stop = false;
+ Promise.resolve().then(function loop() {
+ if (stop || i >= max) return;
+ i++;
+ Promise.resolve().then(loop);
+ });
+ return () => {
+ stop = true;
+ return i;
+ };
+};
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/with-import-assertions.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/with-import-assertions.any.js
new file mode 100644
index 00000000000..f67ba9a1ae4
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/with-import-assertions.any.js
@@ -0,0 +1,15 @@
+// META: global=window,dedicatedworker,sharedworker
+// META: script=ticker.js
+
+promise_test(async t => {
+ // Use Date.now() to ensure that the module is not in the module map
+ const specifier = "./empty-module.js?" + Date.now();
+
+ const getCount = ticker(1000);
+
+ const importP = import(specifier, { assert: { type: "<invalid>" } });
+ await promise_rejects_js(t, TypeError, importP, 'import() should reject');
+
+ assert_less_than(getCount(), 1000);
+}, "import() should not drain the microtask queue if it fails while validating the 'type' assertion");
+
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/worklet-ref.https.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/worklet-ref.https.html
new file mode 100644
index 00000000000..6c598aee393
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/worklet-ref.https.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<canvas id ="output" width="100" height="100" style="background: blue;"></canvas>
+<script>
+"use strict";
+const canvas = document.getElementById('output');
+const ctx = canvas.getContext('2d');
+
+ctx.fillStyle = 'green';
+ctx.fillRect(0, 0, 100, 100);
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/worklet.https.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/worklet.https.html
new file mode 100644
index 00000000000..5cd59f86dc7
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/worklet.https.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<link rel="help" href="https://html.spec.whatwg.org/#hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability)">
+<link rel="match" href="worklet-ref.https.html">
+<style>
+#output {
+ width: 100px;
+ height: 100px;
+ background-image: paint(rects);
+ background-color: blue;
+}
+</style>
+<script src="/common/reftest-wait.js"></script>
+<script src="/common/worklet-reftest.js"></script>
+<body>
+<div id="output"></div>
+
+<script id="code" type="text/worklet">
+registerPaint('rects', class {
+ async paint(ctx, geom) {
+ ctx.fillStyle = 'red';
+
+ const getCount = ticker(1000);
+
+ try {
+ // Use Date.now() to ensure that the module is not in the module map
+ await import("./empty-module.js?" + Date.now());
+ } catch (e) {
+ if (getCount() < 1000) {
+ ctx.fillStyle = 'green';
+ }
+ }
+ ctx.fillRect(0, 0, geom.width, geom.height);
+ }
+});
+</script>
+
+<script>
+"use strict";
+CSS.paintWorklet.addModule("./ticker.js").then(() =>
+ importWorkletAndTerminateTestAfterAsyncPaint(CSS.paintWorklet, document.getElementById('code').textContent)
+);
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-sharedworker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-sharedworker.html
deleted file mode 100644
index 77ece9e4922..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-sharedworker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new SharedWorker(
- "evaluation-order-1-nothrow-worker-setup.mjs", {type:"module"});
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker-setup.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker-setup.mjs
deleted file mode 100644
index 24cccd486be..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker-setup.mjs
+++ /dev/null
@@ -1,6 +0,0 @@
-import "/resources/testharness.js";
-import "./evaluation-order-setup.mjs";
-
-import "./evaluation-order-1-nothrow-worker.mjs";
-
-import "./evaluation-order-1-nothrow.mjs";
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker.html
deleted file mode 100644
index 1b7ea09ebdd..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new Worker(
- "evaluation-order-1-nothrow-worker-setup.mjs", {type:"module"});
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker.mjs
deleted file mode 100644
index 4d3cf31a79c..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow-worker.mjs
+++ /dev/null
@@ -1,7 +0,0 @@
-globalThis.expectedLog = [
- "step-1-1", "step-1-2",
- "microtask",
-];
-
-globalThis.test_load.step_timeout(() => globalThis.testDone(), 0);
-done(); \ No newline at end of file
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow.html
deleted file mode 100644
index 080f5ac3bda..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script type="module">
- import "./evaluation-order-setup.mjs";
- window.addEventListener("load", ev => globalThis.testDone());
- globalThis.expectedLog = [
- "step-1-1", "step-1-2",
- "microtask",
- "script-load",
- "global-load",
- ];
-</script>
-
-<script type="module" src="evaluation-order-1-nothrow.mjs"
- onerror="globalThis.unreachable()"
- onload="globalThis.log.push('script-load')"></script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow.mjs
deleted file mode 100644
index c1d35beb3e6..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-nothrow.mjs
+++ /dev/null
@@ -1,3 +0,0 @@
-globalThis.log.push("step-1-1");
-queueMicrotask(() => globalThis.log.push("microtask"));
-globalThis.log.push("step-1-2");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-sharedworker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-sharedworker.html
deleted file mode 100644
index cc7f0302bfc..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-sharedworker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new SharedWorker(
- "evaluation-order-1-worker-setup.mjs", {type:"module"});
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker-setup.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker-setup.mjs
deleted file mode 100644
index 3971461d2ee..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker-setup.mjs
+++ /dev/null
@@ -1,6 +0,0 @@
-import "/resources/testharness.js";
-import "./evaluation-order-setup.mjs";
-
-import "./evaluation-order-1-worker.mjs";
-
-import "./evaluation-order-1.mjs";
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker.html
deleted file mode 100644
index 0325bb2a30d..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new Worker(
- "evaluation-order-1-worker-setup.mjs", {type:"module"});
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker.mjs
deleted file mode 100644
index 9be87c72227..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1-worker.mjs
+++ /dev/null
@@ -1,9 +0,0 @@
-globalThis.expectedLog = [
- "step-1-1", "step-1-2",
- "microtask",
- "global-error", "error",
-];
-
-globalThis.test_load.step_timeout(() => globalThis.testDone(), 0);
-
-done();
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1.html
deleted file mode 100644
index 728aded3301..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-
-<script type="module">
- import "./evaluation-order-setup.mjs";
- window.addEventListener("load", event => globalThis.testDone());
- globalThis.expectedLog = [
- "step-1-1", "step-1-2",
- "microtask",
- "global-error", "error",
- "script-load",
- "global-load"
- ];
-</script>
-
-<script type="module" src="evaluation-order-1.mjs"
- onerror="unreachable()" onload="log.push('script-load')"></script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1.mjs
deleted file mode 100644
index 7a437266351..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-1.mjs
+++ /dev/null
@@ -1,5 +0,0 @@
-globalThis.log.push("step-1-1");
-queueMicrotask(() => log.push("microtask"));
-globalThis.log.push("step-1-2");
-
-throw new Error("error");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-sharedworker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-sharedworker.html
deleted file mode 100644
index 06456390021..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-sharedworker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new SharedWorker(
- "evaluation-order-2-import-worker-setup.mjs", {type:"module"});
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker-setup.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker-setup.mjs
deleted file mode 100644
index 0cfdca65f08..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker-setup.mjs
+++ /dev/null
@@ -1,6 +0,0 @@
-import "/resources/testharness.js";
-import "./evaluation-order-setup.mjs";
-
-import "./evaluation-order-2-import-worker.mjs";
-
-import "./evaluation-order-2.1.mjs";
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker.html
deleted file mode 100644
index 83070191af9..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new Worker(
- "evaluation-order-2-import-worker-setup.mjs", {type:"module"});
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker.mjs
deleted file mode 100644
index 3d9c9bb7497..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import-worker.mjs
+++ /dev/null
@@ -1,7 +0,0 @@
-globalThis.expectedLog = [
- "step-2.2-1", "step-2.2-2",
- "microtask-2.2",
- "global-error", "error",
-];
-
-done();
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import.html
deleted file mode 100644
index 1db333cb1cd..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-2-import.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script type="module">
- import "./evaluation-order-setup.mjs";
- globalThis.expectedLog = [
- "step-2.2-1", "step-2.2-2",
- "microtask-2.2",
- "global-error", "error",
- "script-load",
- "global-load",
- ];
-</script>
-
-<script type="module" src="evaluation-order-2.1.mjs"
- onerror="globalThis.unreachable()"
- onload="globalThis.log.push('script-load')">
- </script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-sharedworker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-sharedworker.html
deleted file mode 100644
index cd1f5edfa22..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-sharedworker.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new SharedWorker(
- "evaluation-order-3-dynamic-worker-setup.mjs", {type:"module"});
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker-setup.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker-setup.mjs
deleted file mode 100644
index f202cff96a7..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker-setup.mjs
+++ /dev/null
@@ -1,6 +0,0 @@
-import "/resources/testharness.js";
-import "./evaluation-order-setup.mjs";
-
-import "./evaluation-order-3-dynamic-worker.mjs";
-
-import "./evaluation-order-3.1.mjs"; \ No newline at end of file
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker.html
deleted file mode 100644
index 49731bd4822..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic-worker.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
- const worker = new Worker(
- "evaluation-order-3-dynamic-worker-setup.mjs", {type:"module"});
- fetch_tests_from_worker(worker);
-</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic.html
deleted file mode 100644
index 6306c0b5cf2..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-3-dynamic.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-<title>Testing evaluation order</title>
-
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script type="module">
- import "./evaluation-order-setup.mjs";
- globalThis.expectedLog = [
- "step-3.1-1", "step-3.1-2", "step-3.1-3", "microtask-3.1",
- "script-load",
- "step-3.2-1", "step-3.2-2", "microtask-3.2",
- "import-catch", "error"
- ];
-</script>
-
-<script type="module" src="evaluation-order-3.1.mjs"
- onerror="globalThis.unreachable()"
- onload="globalThis.log.push('script-load')">
- </script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-4-tla.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-4-tla.html
deleted file mode 100644
index da07faf42d6..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-4-tla.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!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>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-setup.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-setup.mjs
deleted file mode 100644
index d3f22e9ee0f..00000000000
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/evaluation-order-setup.mjs
+++ /dev/null
@@ -1,19 +0,0 @@
-globalThis.setup({allow_uncaught_exception: true});
-
-globalThis.log = [];
-
-globalThis.addEventListener("error",
- event => globalThis.log.push("global-error", event.error.message));
-globalThis.addEventListener("onunhandledrejection",
- event => globalThis.log.push('unhandled-promise-rejection'));
-globalThis.addEventListener("load",
- event => globalThis.log.push("global-load"));
-
-globalThis.unreachable = function() {
- globalThis.log.push("unreachable");
-}
-
-globalThis.test_load = async_test("Test evaluation order of modules");
-globalThis.testDone = globalThis.test_load.step_func_done(() => {
- assert_array_equals(globalThis.log, globalThis.expectedLog);
-});
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-object.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-object.any.js
new file mode 100644
index 00000000000..494e1681023
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-object.any.js
@@ -0,0 +1,20 @@
+// META: global=dedicatedworker-module,sharedworker-module,serviceworker-module
+
+test(() => {
+ assert_equals(typeof import.meta, "object");
+ assert_not_equals(import.meta, null);
+}, "import.meta is an object");
+
+test(() => {
+ import.meta.newProperty = 1;
+ assert_true(Object.isExtensible(import.meta));
+}, "import.meta is extensible");
+
+test(() => {
+ for (const name of Reflect.ownKeys(import.meta)) {
+ const desc = Object.getOwnPropertyDescriptor(import.meta, name);
+ assert_equals(desc.writable, true);
+ assert_equals(desc.enumerable, true);
+ assert_equals(desc.configurable, true);
+ }
+}, "import.meta's properties are writable, configurable, and enumerable");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-importmap.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-importmap.html
new file mode 100644
index 00000000000..214b9bb59c3
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-importmap.html
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<!--
+ More extensive tests of import maps and import.meta.resolve() will be
+ located in the import maps test suite. This contains some basic tests plus
+ tests some tricky parts of the import.meta.resolve() algorithm around string
+ conversion which are only testable with import maps.
+-->
+
+<script type="importmap">
+{
+ "imports": {
+ "bare": "https://example.com/",
+ "https://example.com/rewrite": "https://example.com/rewritten",
+
+ "1": "https://example.com/PASS-1",
+ "null": "https://example.com/PASS-null",
+ "undefined": "https://example.com/PASS-undefined",
+ "[object Object]": "https://example.com/PASS-object",
+
+ "./start": "./resources/export-1.mjs",
+ "./resources/export-1.mjs": "./resources/export-2.mjs"
+ }
+}
+</script>
+
+<script type="module">
+test(() => {
+ assert_equals(import.meta.resolve("bare"), "https://example.com/");
+}, "import.meta.resolve() given an import mapped bare specifier");
+
+test(() => {
+ assert_equals(import.meta.resolve("https://example.com/rewrite"), "https://example.com/rewritten");
+}, "import.meta.resolve() given an import mapped URL-like specifier");
+
+test(() => {
+ assert_equals(import.meta.resolve(), "https://example.com/PASS-undefined", "no-arg case");
+
+ assert_equals(import.meta.resolve(1), "https://example.com/PASS-1");
+ assert_equals(import.meta.resolve(null), "https://example.com/PASS-null");
+ assert_equals(import.meta.resolve(undefined), "https://example.com/PASS-undefined");
+
+ // Only toString() methods are consulted by ToString, not valueOf() ones.
+ // So this becomes "[object Object]".
+ assert_equals(import.meta.resolve({ valueOf() { return "./x"; } }), "https://example.com/PASS-object");
+}, "Testing the ToString() step of import.meta.resolve() via import maps");
+
+promise_test(async () => {
+ const one = (await import("./start")).default;
+ assert_equals(one, 1);
+
+ const two = (await import(import.meta.resolve("./start"))).default;
+ assert_equals(two, 2);
+}, "import(import.meta.resolve(x)) can be different from import(x)");
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-multiple-scripts.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-multiple-scripts.html
new file mode 100644
index 00000000000..d2e0f185e0b
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-multiple-scripts.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe src="resources/store-import-meta.html"></iframe>
+
+<script type="module">
+import * as otherImportMeta from "./resources/export-import-meta.mjs";
+setup({ explicit_done: true });
+
+window.onload = () => {
+ test(() => {
+ assert_not_equals(frames[0].importMetaURL, import.meta.url,
+ "Precondition check: we've set things up so that the other script has a different import.meta.url");
+
+ const expected = (new URL("resources/x", location.href)).href;
+ assert_equals(frames[0].importMetaResolve("./x"), expected);
+ }, "import.meta.resolve resolves URLs relative to the import.meta.url, not relative to the active script when it is called: another global's inline script");
+
+ test(() => {
+ const otherFrameImportMetaResolve = frames[0].importMetaResolve;
+
+ document.querySelector("iframe").remove();
+
+ const expected = (new URL("resources/x", location.href)).href;
+ assert_equals(otherFrameImportMetaResolve("./x"), expected);
+ }, "import.meta.resolve still works if its global has been destroyed (by detaching the iframe)");
+
+ test(() => {
+ assert_not_equals(otherImportMeta.url, import.meta.url,
+ "Precondition check: we've set things up so that the other script has a different import.meta.url");
+
+ const expected = (new URL("resources/x", location.href)).href;
+ assert_equals(otherImportMeta.resolve("./x"), expected);
+ }, "import.meta.resolve resolves URLs relative to the import.meta.url, not relative to the active script when it is called: another module script");
+
+ done();
+};
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve.any.js
new file mode 100644
index 00000000000..5b8a84efaf9
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve.any.js
@@ -0,0 +1,77 @@
+// META: global=dedicatedworker-module,sharedworker-module,serviceworker-module
+
+import { importMetaOnRootModule, importMetaOnDependentModule }
+ from "./import-meta-root.js";
+
+test(() => {
+ assert_equals(typeof import.meta.resolve, "function");
+ assert_equals(import.meta.resolve.name, "resolve");
+ assert_equals(import.meta.resolve.length, 1);
+ assert_equals(Object.getPrototypeOf(import.meta.resolve), Function.prototype);
+}, "import.meta.resolve is a function with the right properties");
+
+test(() => {
+ assert_false(isConstructor(import.meta.resolve));
+
+ assert_throws_js(TypeError, () => new import.meta.resolve("./x"));
+}, "import.meta.resolve is not a constructor");
+
+test(() => {
+ // See also tests in ./import-meta-resolve-importmap.html.
+
+ assert_equals(import.meta.resolve({ toString() { return "./x"; } }), resolveURL("x"));
+ assert_throws_js(TypeError, () => import.meta.resolve(Symbol("./x")),
+ "symbol");
+ assert_throws_js(TypeError, () => import.meta.resolve(),
+ "no argument (which is treated like \"undefined\")");
+}, "import.meta.resolve ToString()s its argument");
+
+test(() => {
+ assert_equals(import.meta.resolve("./x"), resolveURL("x"),
+ "current module import.meta");
+ assert_equals(importMetaOnRootModule.resolve("./x"), resolveURL("x"),
+ "sibling module import.meta");
+ assert_equals(importMetaOnDependentModule.resolve("./x"), resolveURL("x"),
+ "dependency module import.meta");
+}, "Relative URL-like specifier resolution");
+
+test(() => {
+ assert_equals(import.meta.resolve("https://example.com/"), "https://example.com/",
+ "current module import.meta");
+ assert_equals(importMetaOnRootModule.resolve("https://example.com/"), "https://example.com/",
+ "sibling module import.meta");
+ assert_equals(importMetaOnDependentModule.resolve("https://example.com/"), "https://example.com/",
+ "dependency module import.meta");
+}, "Absolute URL-like specifier resolution");
+
+test(() => {
+ const invalidSpecifiers = [
+ "https://eggplant:b/c",
+ "pumpkins.js",
+ ".tomato",
+ "..zuccini.mjs",
+ ".\\yam.es"
+ ];
+
+ for (const specifier of invalidSpecifiers) {
+ assert_throws_js(TypeError, () => import.meta.resolve(specifier), specifier);
+ }
+}, "Invalid module specifiers");
+
+test(() => {
+ const { resolve } = import.meta;
+ assert_equals(resolve("https://example.com/"), "https://example.com/", "current module import.meta");
+}, "Works fine with no this value");
+
+function resolveURL(urlRelativeToThisTest) {
+ return (new URL(urlRelativeToThisTest, location.href)).href;
+}
+
+function isConstructor(o) {
+ try {
+ new (new Proxy(o, { construct: () => ({}) }));
+ return true;
+ } catch {
+ return false;
+ }
+}
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-url.any.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-url.any.js
index 82982b4d93c..61d96f35af3 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-url.any.js
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-url.any.js
@@ -15,26 +15,6 @@ test(() => {
base + "/import-meta-dependent.js");
}, "import.meta.url in a dependent external script");
-test(() => {
- assert_equals(typeof importMetaOnRootModule, "object");
- assert_not_equals(importMetaOnRootModule, null);
-}, "import.meta is an object");
-
-test(() => {
- importMetaOnRootModule.newProperty = 1;
- assert_true(Object.isExtensible(importMetaOnRootModule));
-}, "import.meta is extensible");
-
-test(() => {
- const names = new Set(Reflect.ownKeys(importMetaOnRootModule));
- for (const name of names) {
- var desc = Object.getOwnPropertyDescriptor(importMetaOnRootModule, name);
- assert_equals(desc.writable, true);
- assert_equals(desc.enumerable, true);
- assert_equals(desc.configurable, true);
- }
-}, "import.meta's properties are writable, configurable, and enumerable");
-
import { importMetaOnRootModule as hashedImportMetaOnRootModule1,
importMetaOnDependentModule as hashedImportMetaOnDependentModule1 }
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-1.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-1.mjs
new file mode 100644
index 00000000000..aef22247d75
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-1.mjs
@@ -0,0 +1 @@
+export default 1;
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-2.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-2.mjs
new file mode 100644
index 00000000000..842e368a0a2
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-2.mjs
@@ -0,0 +1 @@
+export default 2;
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-import-meta.mjs b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-import-meta.mjs
new file mode 100644
index 00000000000..488ca74c935
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/export-import-meta.mjs
@@ -0,0 +1,2 @@
+export const url = import.meta.url;
+export const resolve = import.meta.resolve;
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/store-import-meta.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/store-import-meta.html
new file mode 100644
index 00000000000..c9751da408b
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/module/import-meta/resources/store-import-meta.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<script type="module">
+window.importMetaURL = import.meta.url;
+window.importMetaResolve = import.meta.resolve;
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/README.md b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/README.md
index eff0df1844c..f95e0a63a32 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/README.md
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/README.md
@@ -6,7 +6,7 @@ Use
$ tools/generate.py
```
-to generate test HTML files.
+to generate test HTML files (except for tests in subdirectories).
Background:
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/README.md b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/README.md
new file mode 100644
index 00000000000..dcf5597e2da
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/README.md
@@ -0,0 +1,6 @@
+The tests in this directory checks side effects (other than script
+evaluation/event firing, which is covered by the tests in the parent directory)
+caused by scripts moved between Documents.
+
+The tests assume that script loading is not canceled when moved between
+documents (which is not explicitly specified as of Jan 2022).
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-1.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-1.html
new file mode 100644
index 00000000000..5c8acd470eb
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-1.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="helper.js"></script>
+<body>
+<script>
+runDelayEventTest('Script elements (parser-blocking)');
+</script>
+<script id="to-be-moved" src="../../resources/throw.js?pipe=trickle(d3)"></script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-2.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-2.html
new file mode 100644
index 00000000000..3399a8c001f
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-2.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="helper.js"></script>
+<body>
+<script>
+runDelayEventTest('Script elements (async)');
+
+const script = document.createElement('script');
+script.setAttribute('id', 'to-be-moved');
+script.setAttribute('src', '../../resources/throw.js?pipe=trickle(d3)');
+document.body.appendChild(script);
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-iframe.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-iframe.html
new file mode 100644
index 00000000000..38a9a215419
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/delay-load-event-iframe.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<body onload="parent.onloadIframe()">
+<script src="../../resources/throw.js?pipe=trickle(d2)"></script>
+</body>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/helper.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/helper.js
new file mode 100644
index 00000000000..331cf79bf0b
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/helper.js
@@ -0,0 +1,31 @@
+function runDelayEventTest(description) {
+ const t = async_test(description +
+ ' still delay the load event in the original Document after move');
+ const t_new = async_test(description +
+ ' does not delay the load event in the new Document after move');
+ const start_time = performance.now();
+ const iframe = document.createElement('iframe');
+ iframe.setAttribute('src', 'delay-load-event-iframe.html');
+ document.body.appendChild(iframe);
+
+ window.onload = t.step_func_done(() => {
+ // The `#to-be-moved` script should delay the load event until it is loaded
+ // (i.e. 3 seconds), not just until it is moved out to another Document
+ // (i.e. 1 second). Here we expect the delay should be at least 2 seconds,
+ // as the latency can be slightly less than 3 seconds due to preloading.
+ assert_greater_than(performance.now() - start_time, 2000,
+ 'Load event should be delayed until script is loaded');
+ });
+
+ window.onloadIframe = t_new.step_func_done(() => {
+ // The iframe's load event is fired after 2 seconds of its subresource
+ // loading, and shouldn't wait for the `#to-be-moved` script.
+ assert_less_than(performance.now() - start_time, 2500,
+ 'Load event should not be delayed until moved script is loaded');
+ });
+
+ t.step_timeout(() => {
+ const script = document.querySelector('#to-be-moved');
+ iframe.contentDocument.body.appendChild(script);
+ }, 1000);
+}
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/in-order.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/in-order.html
new file mode 100644
index 00000000000..6a3e2b54a77
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/in-order.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<link rel="help" href="https://html.spec.whatwg.org/C/#list-of-scripts-that-will-execute-in-order-as-soon-as-possible">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="helper.js"></script>
+<body>
+<script>
+const t = async_test('Script elements (in-order) still block subsequent in-order scripts in the original Document after moved to another Document');
+const start_time = performance.now();
+const iframe = document.createElement('iframe');
+document.body.appendChild(iframe);
+
+const onScript2Evaluated = t.step_func_done(() => {
+ // `script1` should remain the
+ // #list-of-scripts-that-will-execute-in-order-as-soon-as-possible of the
+ // original Document and thus blocks `script2` evaluation until it is loaded.
+ assert_greater_than(performance.now() - start_time, 2000,
+ 'In-order scripts should block subsequent in-order scripts');
+});
+
+const script1 = document.createElement('script');
+script1.async = false;
+script1.setAttribute('src', '../../resources/throw.js?pipe=trickle(d2)');
+document.body.appendChild(script1);
+
+const script2 = document.createElement('script');
+script2.async = false;
+script2.setAttribute('src', 'data:text/javascript,onScript2Evaluated()');
+document.body.appendChild(script2);
+
+t.step_timeout(() => {
+ iframe.contentDocument.body.appendChild(script1);
+}, 1000);
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/parser-blocking.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/parser-blocking.html
new file mode 100644
index 00000000000..9edde137367
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/parser-blocking.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<link rel="help" href="https://html.spec.whatwg.org/C/#pending-parsing-blocking-script">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="helper.js"></script>
+<body>
+<script>
+const t = async_test('Script elements (parser-blocking) still block the parser in the original Document after moved to another Document');
+const start_time = performance.now();
+const iframe = document.createElement('iframe');
+document.body.appendChild(iframe);
+
+t.step_timeout(() => {
+ const script = document.querySelector('#to-be-moved');
+ iframe.contentDocument.body.appendChild(script);
+}, 1000);
+
+let syncScriptEvaluated = false;
+
+const onSyncScript = t.step_func(() => {
+ syncScriptEvaluated = true;
+
+ // The `#to-be-moved` script should block the parser and thus the sync
+ // script after `#to-be-moved` should be delayed until `#to-be-moved` is
+ // loaded (i.e. 3 seconds).
+ // Here we expect the delay should be at least 2 seconds,
+ // as the latency can be slightly less than 3 seconds due to preloading.
+ assert_greater_than(performance.now() - start_time, 2000,
+ 'Parser should be blocked until script is loaded');
+});
+
+document.addEventListener('DOMContentLoaded', t.step_func_done(() => {
+ assert_true(syncScriptEvaluated,
+ 'sync script should be evaluated before DOMContentLoaded');
+ assert_greater_than(performance.now() - start_time, 2000,
+ 'DOMContentLoaded event should be delayed until script is loaded');
+}));
+</script>
+<script id="to-be-moved" src="../../resources/throw.js?pipe=trickle(d3)"></script>
+<script src="data:text/javascript,onSyncScript()"></script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/resources/script-type-and-language-js.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/resources/script-type-and-language-js.js
new file mode 100644
index 00000000000..d357bc49944
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/resources/script-type-and-language-js.js
@@ -0,0 +1,141 @@
+function testAttribute(attr, val, shouldRun) {
+ test(function() {
+ assert_false(window.ran, "ran variable not reset");
+ let script;
+ if (document.contentType === 'image/svg+xml') {
+ // SVG
+ script = document.createElementNS("http://www.w3.org/2000/svg", "script");
+ } else {
+ // HTML or XHTML
+ script = document.createElement("script");
+ }
+ script.setAttribute(attr, val);
+ script.textContent = "window.ran = true;";
+ document.querySelector('#script-placeholder').appendChild(script);
+ assert_equals(window.ran, shouldRun);
+ }, "Script should" + (shouldRun ? "" : "n't") + " run with " + attr + "=" +
+ format_value(val));
+ window.ran = false;
+}
+function testTypeShouldRun(type) {
+ testAttribute("type", type, true);
+}
+function testLanguageShouldRun(lang) {
+ testAttribute("language", lang, true);
+}
+function testTypeShouldNotRun(type) {
+ testAttribute("type", type, false);
+}
+function testLanguageShouldNotRunUnlessSVG(lang) {
+ // In SVGs, there is no concrete spec but all browsers agree that
+ // language attributes have no effects and thus script elements
+ // without type attributes are always expected to run regardless of
+ // language attributes.
+ const expectedToRun = document.contentType === 'image/svg+xml';
+ testAttribute("language", lang, expectedToRun);
+}
+
+// Unlike `test*()` methods above, there should be a (parser-inserted) script
+// with an invalid type/language that would set `window.ran` to true just
+// before `testParserInsertedDidNotRun()`, and
+// `testParserInsertedDidNotRun()` asserts that the script did not run.
+// `window.ran` should be reset where needed. For example:
+// <script>window.ran = false;</script>
+// <script type="invalid-type">window.ran = true;</script>
+// <script>testParserInsertedDidNotRun('type=invalid-type');</script>
+function testParserInsertedDidNotRun(description) {
+ test(() => assert_false(window.ran),
+ "Script shouldn't run with " + description + " (parser-inserted)");
+ window.ran = false;
+}
+
+// When prefixed by "application/", these match with
+// https://mimesniff.spec.whatwg.org/#javascript-mime-type
+const application = [
+ "ecmascript",
+ "javascript",
+ "x-ecmascript",
+ "x-javascript"
+];
+
+// When prefixed by "text/", these match with
+// https://mimesniff.spec.whatwg.org/#javascript-mime-type
+const text = [
+ "ecmascript",
+ "javascript",
+ "javascript1.0",
+ "javascript1.1",
+ "javascript1.2",
+ "javascript1.3",
+ "javascript1.4",
+ "javascript1.5",
+ "jscript",
+ "livescript",
+ "x-ecmascript",
+ "x-javascript"
+];
+
+const legacyTypes = [
+ "javascript1.6",
+ "javascript1.7",
+ "javascript1.8",
+ "javascript1.9"
+];
+
+const spaces = [" ", "\t", "\n", "\r", "\f"];
+
+window.ran = false;
+
+// Type attribute
+
+testTypeShouldRun("");
+testTypeShouldNotRun(" ");
+
+application.map(t => "application/" + t).forEach(testTypeShouldRun);
+application.map(t => ("application/" + t).toUpperCase()).forEach(
+ testTypeShouldRun);
+
+spaces.forEach(function(s) {
+ application.map(t => "application/" + t + s).forEach(testTypeShouldRun);
+ application.map(t => s + "application/" + t).forEach(testTypeShouldRun);
+});
+
+application.map(t => "application/" + t + "\0").forEach(testTypeShouldNotRun);
+application.map(t => "application/" + t + "\0foo").forEach(
+ testTypeShouldNotRun);
+
+text.map(t => "text/" + t).forEach(testTypeShouldRun);
+text.map(t => ("text/" + t).toUpperCase()).forEach(testTypeShouldRun);
+
+legacyTypes.map(t => "text/" + t).forEach(testTypeShouldNotRun);
+
+spaces.forEach(function(s) {
+ text.map(t => "text/" + t + s).forEach(testTypeShouldRun);
+ text.map(t => s + "text/" + t).forEach(testTypeShouldRun);
+});
+
+text.map(t => "text/" + t + "\0").forEach(testTypeShouldNotRun);
+text.map(t => "text/" + t + "\0foo").forEach(testTypeShouldNotRun);
+
+text.forEach(testTypeShouldNotRun);
+legacyTypes.forEach(testTypeShouldNotRun);
+
+// Language attribute
+
+testLanguageShouldRun("");
+testLanguageShouldNotRunUnlessSVG(" ");
+
+text.forEach(testLanguageShouldRun);
+text.map(t => t.toUpperCase()).forEach(testLanguageShouldRun);
+
+legacyTypes.forEach(testLanguageShouldNotRunUnlessSVG);
+
+spaces.forEach(function(s) {
+ text.map(t => t + s).forEach(testLanguageShouldNotRunUnlessSVG);
+ text.map(t => s + t).forEach(testLanguageShouldNotRunUnlessSVG);
+});
+text.map(t => t + "xyz").forEach(testLanguageShouldNotRunUnlessSVG);
+text.map(t => "xyz" + t).forEach(testLanguageShouldNotRunUnlessSVG);
+
+text.map(t => t + "\0").forEach(testLanguageShouldNotRunUnlessSVG);
+text.map(t => t + "\0foo").forEach(testLanguageShouldNotRunUnlessSVG);
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-defer-xhtml.xhtml b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-defer-xhtml.xhtml
new file mode 100644
index 00000000000..3f4a50f7790
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-defer-xhtml.xhtml
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>XHTML Test: HTMLScriptElement - defer</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<meta charset="utf-8" />
+</head>
+<body>
+<div id="log"></div>
+
+<script>
+
+let script_run_status = "inline";
+let t = async_test("the defer script run later");
+
+</script>
+
+<script type="text/javascript" src="defer.js" defer="defer"></script>
+
+<script>
+
+t.step(() => {
+ assert_equals(script_run_status, "inline", "the script run status");
+ script_run_status = "deferred";
+});
+
+</script>
+</body>
+</html>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-referrerpolicy-idl.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-referrerpolicy-idl.html
new file mode 100644
index 00000000000..bf01cb83b8c
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-referrerpolicy-idl.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>&lt;script> referrerPolicy IDL</title>
+<link rel="author" href="mailto:masonf@chromium.org">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#referrer-policy-attribute">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<body>
+<script>
+ test(() => {
+ const script = document.createElement('script');
+ document.body.appendChild(script);
+ assert_equals(script.referrerPolicy,"",'Missing content attribute should reflect as empty');
+ script.setAttribute('referrerpolicy','no-referrer');
+ assert_equals(script.referrerPolicy,"no-referrer",'Valid value should reflect');
+ script.setAttribute('referrerpolicy','');
+ assert_equals(script.referrerPolicy,"",'Empty string should reflect as empty');
+ script.setAttribute('referrerpolicy','invalid-value-here');
+ assert_equals(script.referrerPolicy,"",'Invalid values should reflect as empty');
+ script.referrerPolicy = 'no-referrer';
+ assert_equals(script.referrerPolicy,"no-referrer",'Valid value via IDL');
+ script.referrerPolicy = null;
+ assert_equals(script.referrerPolicy,"",'Null should reflect as empty');
+ },'Missing/invalid/null referrerPolicy should reflect as the empty string')
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-modifications-csp.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-modifications-csp.html
new file mode 100644
index 00000000000..a9911510661
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-modifications-csp.html
@@ -0,0 +1,52 @@
+<!doctype html>
+<head>
+<meta charset=utf-8>
+<title>Modify HTMLScriptElement's text after #prepare-a-script that violates CSP</title>
+<link rel=help href="https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<meta http-equiv="content-security-policy" content="script-src
+ 'nonce-allow'
+ 'sha256-2+5xh6b9uuIi4GaJtmHWtgR2nwRXJpBtMY4nVaOBpfc='
+">
+<!-- The hash is that of the original content of `script0`. -->
+
+<script nonce="allow">
+window.t = async_test("Modify inline script element's text " +
+ "after prepare-a-script before evaluation (CSP)");
+
+const updatedText =
+ 't.unreached_func("CSP check was done against the original text but the updated text was evaluated")();';
+
+function changeScriptText() {
+ document.querySelector('#script0').textContent = updatedText;
+}
+
+t.step_timeout(changeScriptText, 500);
+</script>
+
+<!-- This is "a style sheet that is blocking scripts" and thus ... -->
+<link rel="stylesheet" href="/common/slow.py?pipe=trickle(d1)"></link>
+
+<!-- This inline script becomes a parser-blocking script, and thus
+the step_timeout is evaluated after script0 is inserted into DOM,
+prepare-a-script'ed, but before its evaluation. -->
+<script id="script0">
+t.step(() => {
+ // When this is evaluated after the stylesheet is loaded,
+ // script0's textContent is modified by the async script above,
+ // but the evaluated script is still the original script here,
+ // not what is overwritten, because "child text content" is taken in
+ // #prepare-a-script and passed to "creating a classic script".
+ var s = document.getElementById('script0');
+ assert_equals(s.textContent, updatedText,
+ "<script>'s textContent should be already modified");
+ t.done();
+ });
+</script>
+<script nonce="allow">
+// If this makes the test fail, it indicates `script0` (the original or updated
+// text) was not evaluated, probably blocked by CSP that was checked against the
+// updated text.
+t.unreached_func("CSP check was done against the updated text")();
+</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-modifications.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-modifications.html
index 0ddec6a851f..cb54da6995b 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-modifications.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-modifications.html
@@ -27,17 +27,14 @@ prepare-a-script'ed, but before its evaluation. -->
<script id="script0">
t.step(() => {
// When this is evaluated after the stylesheet is loaded,
- // script0's innerText is modified by the async script above,
+ // script0's textContent is modified by the async script above,
// but the evaluated script is still the original script here,
// not what is overwritten, because "child text content" is taken in
// #prepare-a-script and passed to "creating a classic script".
var s = document.getElementById('script0');
- assert_equals(s.innerText,
+ assert_equals(s.textContent,
't.unreached_func("This should not be evaluated")();',
- "<script>'s innerText should be already modified");
- assert_equals(s.text,
- 't.unreached_func("This should not be evaluated")();',
- "<script>'s text should be already modified");
+ "<script>'s textContent should be already modified");
t.done();
});
</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js-svg.svg b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js-svg.svg
new file mode 100644
index 00000000000..2f31d4d75c0
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js-svg.svg
@@ -0,0 +1,37 @@
+<?xml version="1.0" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+<metadata>
+ <h:link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages" />
+ <h:link rel="help" href="https://html.spec.whatwg.org/multipage/#prepare-a-script" />
+</metadata>
+<h:script src="/resources/testharness.js"/>
+<h:script src="/resources/testharnessreport.js"/>
+<h:div id="script-placeholder"/>
+<h:script src="resources/script-type-and-language-js.js"/>
+<script>window.ran = false;</script>
+<script type="javascript">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript');</script>
+<script type="javascript1.0">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.0');</script>
+<script type="javascript1.1">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.1');</script>
+<script type="javascript1.2">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.2');</script>
+<script type="javascript1.3">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.3');</script>
+<script type="javascript1.4">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.4');</script>
+<script type="javascript1.5">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.5');</script>
+<script type="javascript1.6">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.6');</script>
+<script type="javascript1.7">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.7');</script>
+<script type="livescript">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=livescript');</script>
+<script type="ecmascript">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=ecmascript');</script>
+<script type="jscript">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=jscript');</script>
+</svg>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js-xhtml.xhtml b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js-xhtml.xhtml
new file mode 100644
index 00000000000..0bfdfce3c4b
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js-xhtml.xhtml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Script @type and @language: JavaScript types</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com" />
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages" />
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#prepare-a-script" />
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<div id="script-placeholder"/>
+<script src="resources/script-type-and-language-js.js"></script>
+
+<script>ran = false;</script>
+<script type="javascript">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript');</script>
+<script type="javascript1.0">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.0');</script>
+<script type="javascript1.1">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.1');</script>
+<script type="javascript1.2">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.2');</script>
+<script type="javascript1.3">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.3');</script>
+<script type="javascript1.4">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.4');</script>
+<script type="javascript1.5">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.5');</script>
+<script type="javascript1.6">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.6');</script>
+<script type="javascript1.7">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.7');</script>
+<script type="livescript">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=livescript');</script>
+<script type="ecmascript">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=ecmascript');</script>
+<script type="jscript">ran = true;</script>
+<script>testParserInsertedDidNotRun('type=jscript');</script>
+
+</body>
+</html>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js.html
index 2f56ade9bee..009123de2b5 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/script-type-and-language-js.html
@@ -5,95 +5,31 @@
<link rel="help" href="https://html.spec.whatwg.org/multipage/#prepare-a-script">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
-<div id="log"></div>
-<script>
-function testAttribute(attr, val, shouldRun) {
- test(function() {
- assert_false(ran, "ran variable not reset");
- var script = document.createElement("script");
- script.setAttribute(attr, val);
- script.textContent = "ran = true;"
- document.body.appendChild(script);
- assert_equals(ran, shouldRun);
- }, "Script should" + (shouldRun ? "" : "n't") + " run with " + attr + "=" + format_value(val));
- ran = false
-}
-function testType(type) {
- testAttribute("type", type, true);
-}
-function testLanguage(lang) {
- testAttribute("language", lang, true);
-}
-function testTypeIgnored(type) {
- testAttribute("type", type, false);
-}
-function testLanguageIgnored(lang) {
- testAttribute("language", lang, false);
-}
-var application = [
- "ecmascript",
- "javascript",
- "x-ecmascript",
- "x-javascript"
-];
-var text = [
- "ecmascript",
- "javascript",
- "javascript1.0",
- "javascript1.1",
- "javascript1.2",
- "javascript1.3",
- "javascript1.4",
- "javascript1.5",
- "jscript",
- "livescript",
- "x-ecmascript",
- "x-javascript"
-];
-var spaces = [" ", "\t", "\n", "\r", "\f"];
-
-var ran = false;
-
-// Type attribute
-
-testType("");
-testTypeIgnored(" ");
-
-application.map(function(t) { return "application/" + t; }).forEach(testType);
-application.map(function(t) { return ("application/" + t).toUpperCase(); }).forEach(testType);
-
-spaces.forEach(function(s) {
- application.map(function(t) { return "application/" + t + s; }).forEach(testType);
- application.map(function(t) { return s + "application/" + t; }).forEach(testType);
-})
-
-application.map(function(t) { return "application/" + t + "\0"; }).forEach(testTypeIgnored);
-application.map(function(t) { return "application/" + t + "\0foo"; }).forEach(testTypeIgnored);
-
-text.map(function(t) { return "text/" + t; }).forEach(testType);
-text.map(function(t) { return ("text/" + t).toUpperCase(); }).forEach(testType);
-
-spaces.forEach(function(s) {
- text.map(function(t) { return "text/" + t + s; }).forEach(testType);
- text.map(function(t) { return s + "text/" + t; }).forEach(testType);
-})
-
-text.map(function(t) { return "text/" + t + "\0"; }).forEach(testTypeIgnored);
-text.map(function(t) { return "text/" + t + "\0foo"; }).forEach(testTypeIgnored);
-
-// Language attribute
-
-testLanguage("");
-testLanguageIgnored(" ");
-
-text.forEach(testLanguage);
-text.map(function(t) { return t.toUpperCase(); }).forEach(testLanguage);
-
-text.map(function(t) { return t + " "; }).forEach(testLanguageIgnored);
-text.map(function(t) { return " " + t; }).forEach(testLanguageIgnored);
-text.map(function(t) { return t + "xyz"; }).forEach(testLanguageIgnored);
-text.map(function(t) { return "xyz" + t; }).forEach(testLanguageIgnored);
-
-text.map(function(t) { return t + "\0"; }).forEach(testLanguageIgnored);
-text.map(function(t) { return t + "\0foo"; }).forEach(testLanguageIgnored);
-</script>
+<div id="script-placeholder"></div>
+<script src="resources/script-type-and-language-js.js"></script>
+
+<script>window.ran = false;</script>
+<script type="javascript">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript');</script>
+<script type="javascript1.0">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.0');</script>
+<script type="javascript1.1">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.1');</script>
+<script type="javascript1.2">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.2');</script>
+<script type="javascript1.3">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.3');</script>
+<script type="javascript1.4">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.4');</script>
+<script type="javascript1.5">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.5');</script>
+<script type="javascript1.6">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.6');</script>
+<script type="javascript1.7">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=javascript1.7');</script>
+<script type="livescript">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=livescript');</script>
+<script type="ecmascript">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=ecmascript');</script>
+<script type="jscript">window.ran = true;</script>
+<script>testParserInsertedDidNotRun('type=jscript');</script>
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-2-helper.html b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-2-helper.html
index 7a173981562..a9ee80026aa 100644
--- a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-2-helper.html
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/support/script-onerror-insertion-point-2-helper.html
@@ -1,2 +1,2 @@
-Some <script src="http://this is not parseable"
- onerror="document.write('text'); parent.writeDone(document.documentElement.textContent)"></script>
+Some <script src="http://this is not parseable:-80/"
+ onerror="document.write('text'); document.close(); parent.writeDone(document.documentElement.textContent)"></script>