Files
ladybird/Tests/LibWeb/Text/input/setTimeout-equal-delay-registration-order.html
Aliaksandr Kalenik de3f32a5c9 LibCore: Make timer firing order stable for equal deadlines
Timers scheduled with identical `fire_time` could fire out of order
because the heap is not stable. This change assigns a monotonically
increasing `sequence_id` when a timer is scheduled and extend the heap
comparator to order by (`fire_time`, `sequence_id`). This guarantees
FIFO among timers with the same deadline.

This matches the HTML "run steps after a timeout" ordering requirement:
older invocations with <= delay complete before newer ones.
https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#run-steps-after-a-timeout
2025-09-22 12:34:32 +01:00

20 lines
436 B
HTML

<!DOCTYPE html>
<script src="include.js"></script>
<script>
asyncTest(done => {
let invocation = 0;
function makeTimeout() {
const count = ++invocation;
setTimeout(() => {
println(count);
if (count === 100)
done();
}, 1);
}
for (let i = 0; i < 100; i++) {
makeTimeout();
}
});
</script>