mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
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
20 lines
436 B
HTML
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>
|