Lightpanda: the headless browser designed for AI and automation
test: add max-timers test
Karl Seguin3a4e6febad04
diff --git a/src/browser/tests/window/timer_limits.html b/src/browser/tests/window/timer_limits.htmlnew file mode 100644index 000000000..bc3a2e2e4--- /dev/null+++ b/src/browser/tests/window/timer_limits.html@@ -0,0 +1,40 @@+<!DOCTYPE html>+<script src="../testing.js"></script>++<script id=one-shot-limit>+ // One-shot timers pile up legitimately: a fan-out of async tasks that each+ // yield through `new Promise((r) => setTimeout(r))` queues one per task, and+ // none of them can run until the microtask queue drains.+ const timeouts = [];+ for (let i = 0; i < 1000; i++) {+ timeouts.push(window.setTimeout(() => {}, 100000));+ }+ testing.expectEqual(1000, timeouts.length);++ for (const id of timeouts) {+ window.clearTimeout(id);+ }+</script>++<script id=interval-limit>+ const intervals = [];+ let threw = false;+ try {+ for (let i = 0; i < 600; i++) {+ intervals.push(window.setInterval(() => {}, 100000));+ }+ } catch (e) {+ threw = true;+ }+ testing.expectEqual(true, threw);+ testing.expectEqual(512, intervals.length);++ window.clearInterval(intervals.pop());+ intervals.push(window.setInterval(() => {}, 100000));+ testing.expectEqual(512, intervals.length);++ for (const id of intervals) {+ window.clearInterval(id);+ }+</script>+: