Skip to content

Commit

Permalink
Add a WPT test for setTimeout vs setInterval clamping.
Browse files Browse the repository at this point in the history
Bug: 41380458

Change-Id: I5c8758b9df2b3d9f6e9e3009524218ea3bb4533c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6240888
Reviewed-by: Scott Haseley <[email protected]>
Commit-Queue: Chris Harrelson <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1417698}
  • Loading branch information
chrishtr authored and chromium-wpt-export-bot committed Feb 8, 2025
1 parent 1959d93 commit 6b8323b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions html/webappapis/timers/setinterval-settimeout-clamping.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!doctype html>
<meta charset=utf-8>
<meta name="assert" content ="setTimeout and setInterval sequencing is correct even with 0 timeout">
<link rel="help" href="https://html.spec.whatwg.org/#run-steps-after-a-timeout" />
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>

<script>
async_test(t => {
let done = false;
const id = setInterval(() => {
done = true;
}, 0);
t.add_cleanup(() => clearInterval(id));

setTimeout(t.step_func(() => {
assert_true(done);
t.done();
}), 0);
}, "setInterval(0) before setTimeout(0)");

async_test(t => {
let done = false;
setTimeout(() => {
done = true;
}, 0);

const id = setInterval(t.step_func(() => {
assert_true(done);
t.done();
}), 0);
t.add_cleanup(() => clearInterval(id));
}, "setTimeout(0) before setInterval(0)");
</script>

0 comments on commit 6b8323b

Please sign in to comment.