commit 7d421f26348783ce2d3b912180d6140950d3aba2
parent 57aa550bf65ff74298690b63e8ea8659914f9b51
Author: Ryan Reno <106123293+rreno@users.noreply.github.com>
Date: Mon, 27 Oct 2025 10:02:05 +0000
Bug 1995868 [wpt PR 55601] - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=301008, a=testonly
Automatic update from web-platform-tests
WebKit export of https://bugs.webkit.org/show_bug.cgi?id=301008 (#55601)
--
wpt-commits: 5b4458b877e5dfa2b2401961f6ab2004358f6b6f
wpt-pr: 55601
Diffstat:
1 file changed, 38 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/html/webappapis/timers/timer-nesting-not-inherited-in-microtask.html b/testing/web-platform/tests/html/webappapis/timers/timer-nesting-not-inherited-in-microtask.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#perform-a-microtask-checkpoint">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timer-initialisation-steps">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+// queue a microtask after the timer has reached the spec-defined maximum nesting level. Then we ensure
+// the new timer did not inherit the nesting level from the outer timer task by checking that the sub-4ms
+// timeout was not clamped to 4ms.
+
+test(() => {
+ assert_equals(typeof performance.now, "function");
+}, "Test requires performance.now() to measure approximate timing of callbacks.");
+
+
+let t = async_test("Test that a timer scheduled during a microtask checkpoint does not inherit the timer nesting level of the task that just ran.");
+
+var rescheduleTimeoutCalledCount = 0;
+function rescheduleTimeout()
+{
+ if (++rescheduleTimeoutCalledCount > 15)
+ return t.done();
+ else if (rescheduleTimeoutCalledCount > 5) {
+ queueMicrotask(() => {
+ const checkNotNestedScheduledAt = performance.now();
+ setTimeout(() => {
+ const approximateDelay = performance.now() - checkNotNestedScheduledAt;
+ t.step(() => assert_less_than(approximateDelay, 4, "Timer should not be clamped to 4ms"));
+ }, 1);
+ });
+ }
+ setTimeout(rescheduleTimeout, 8);
+}
+
+window.addEventListener("load", () => setTimeout(rescheduleTimeout, 8));
+</script>
+</html>