diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/base/test/test_suppressed_microtasks.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dom/base/test/test_suppressed_microtasks.html | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/dom/base/test/test_suppressed_microtasks.html b/dom/base/test/test_suppressed_microtasks.html new file mode 100644 index 0000000000..f5d3336386 --- /dev/null +++ b/dom/base/test/test_suppressed_microtasks.html @@ -0,0 +1,62 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <title>Test microtask suppression</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> + <script> + SimpleTest.waitForExplicitFinish(); + + var previousTask = -1; + function test() { + let win = window.open("about:blank"); + win.onload = function() { + win.onmessage = function() { + win.start = win.performance.now(); + win.didRunMicrotask = false; + win.onmessage = function() { + ok(win.didRunMicrotask, "Should have run a microtask."); + let period = win.performance.now() - win.start; + win.opener.ok( + period < 200, + "Running a task should be fast. Took " + period + "ms."); + win.onmessage = null; + } + win.queueMicrotask(function() { win.didRunMicrotask = true; }); + win.postMessage("measurementMessage", "*"); + } + win.postMessage("initialMessage", "*"); + + const last = 500000; + for (let i = 0; i < last + 1; ++i) { + window.queueMicrotask(function() { + // Check that once microtasks are unsuppressed, they are handled in + // the correct order. + if (previousTask != i - 1) { + // Explicitly optimize out cases which pass. + ok(false, "Microtasks should be handled in order."); + } + previousTask = i; + if (i == last) { + win.close(); + SimpleTest.finish(); + } + }); + } + + // Synchronous XMLHttpRequest suppresses microtasks. + var xhr = new XMLHttpRequest(); + xhr.open("GET", "slow.sjs", false); + xhr.send(); + is(previousTask, -1, "Shouldn't have run microtasks during a sync XHR."); + } + } + </script> +</head> +<body onload="test()"> +<p id="display"></p> +<div id="content" style="display: none"></div> +<pre id="test"></pre> +</body> +</html> |