aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks
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/microtasks
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/microtasks')
-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.mjs8
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2.2.mjs7
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3-setup.js7
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3.1.mjs11
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3.2.mjs5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-4.1.mjs8
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-4.2.mjs5
-rw-r--r--tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js30
23 files changed, 233 insertions, 0 deletions
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/microtasks/resources/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
new file mode 100644
index 00000000000..d6c2afa2f72
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2.1.mjs
@@ -0,0 +1,8 @@
+globalThis.log.push("step-2.1-1");
+queueMicrotask(() => globalThis.log.push("microtask-2.1"));
+globalThis.log.push("step-2.1-2");
+
+// import is evaluated first.
+import "./evaluation-order-2.2.mjs";
+
+globalThis.log.push("step-2.1-3");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/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
new file mode 100644
index 00000000000..5c67c4f9a25
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-2.2.mjs
@@ -0,0 +1,7 @@
+globalThis.log.push("step-2.2-1");
+queueMicrotask(() => globalThis.log.push("microtask-2.2"));
+globalThis.log.push("step-2.2-2");
+
+globalThis.test_load.step_timeout(() => globalThis.testDone(), 0);
+
+throw new Error("error");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3-setup.js b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3-setup.js
new file mode 100644
index 00000000000..edc046910e4
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3-setup.js
@@ -0,0 +1,7 @@
+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",
+]);
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/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
new file mode 100644
index 00000000000..ef320632af7
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3.1.mjs
@@ -0,0 +1,11 @@
+globalThis.log.push("step-3.1-1");
+queueMicrotask(() => globalThis.log.push("microtask-3.1"));
+globalThis.log.push("step-3.1-2");
+
+import("./evaluation-order-3.2.mjs").catch(
+ exception => {
+ globalThis.log.push("import-catch", exception.message);
+ globalThis.testDone();
+ });
+
+globalThis.log.push("step-3.1-3");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/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
new file mode 100644
index 00000000000..8ccb5812066
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-3.2.mjs
@@ -0,0 +1,5 @@
+globalThis.log.push("step-3.2-1");
+queueMicrotask(() => globalThis.log.push("microtask-3.2"));
+globalThis.log.push("step-3.2-2");
+
+throw new Error("error");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/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
new file mode 100644
index 00000000000..f3347c1d28e
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-4.1.mjs
@@ -0,0 +1,8 @@
+log.push("step-4.1-1");
+queueMicrotask(() => log.push("microtask-4.1"));
+log.push("step-4.1-2");
+
+await import("./evaluation-order-4.2.mjs");
+
+// Not happening as we throw in the above module.
+log.push("step-4.1-3");
diff --git a/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/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
new file mode 100644
index 00000000000..96a5cca3a63
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-4.2.mjs
@@ -0,0 +1,5 @@
+log.push("step-4.2-1");
+queueMicrotask(() => log.push("microtask-4.2"));
+log.push("step-4.2-2");
+
+throw new Error("error");
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();
+ }
+};