summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/webappapis/microtask-queuing/queue-microtask.any.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/html/webappapis/microtask-queuing/queue-microtask.any.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/webappapis/microtask-queuing/queue-microtask.any.js')
-rw-r--r--testing/web-platform/tests/html/webappapis/microtask-queuing/queue-microtask.any.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/webappapis/microtask-queuing/queue-microtask.any.js b/testing/web-platform/tests/html/webappapis/microtask-queuing/queue-microtask.any.js
new file mode 100644
index 0000000000..e67765fade
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/microtask-queuing/queue-microtask.any.js
@@ -0,0 +1,39 @@
+// META: global=window,worker
+"use strict";
+
+test(() => {
+ assert_equals(typeof queueMicrotask, "function");
+}, "It exists and is a function");
+
+test(() => {
+ assert_throws_js(TypeError, () => queueMicrotask(), "no argument");
+ assert_throws_js(TypeError, () => queueMicrotask(undefined), "undefined");
+ assert_throws_js(TypeError, () => queueMicrotask(null), "null");
+ assert_throws_js(TypeError, () => queueMicrotask(0), "0");
+ assert_throws_js(TypeError, () => queueMicrotask({ handleEvent() { } }), "an event handler object");
+ assert_throws_js(TypeError, () => queueMicrotask("window.x = 5;"), "a string");
+}, "It throws when given non-functions");
+
+async_test(t => {
+ let called = false;
+ queueMicrotask(t.step_func_done(() => {
+ called = true;
+ }));
+ assert_false(called);
+}, "It calls the callback asynchronously");
+
+async_test(t => {
+ queueMicrotask(t.step_func_done(function () { // note: intentionally not an arrow function
+ assert_array_equals(arguments, []);
+ }), "x", "y");
+}, "It does not pass any arguments");
+
+async_test(t => {
+ const happenings = [];
+ Promise.resolve().then(() => happenings.push("a"));
+ queueMicrotask(() => happenings.push("b"));
+ Promise.reject().catch(() => happenings.push("c"));
+ queueMicrotask(t.step_func_done(() => {
+ assert_array_equals(happenings, ["a", "b", "c"]);
+ }));
+}, "It interleaves with promises as expected");