gecko-dev/dom/base/test/file_timer_flood.html
Ehsan Akhgari 87a8f718ea Bug 1312514 - Part 4: Add a test to ensure that splitting timeouts into two buckets doesn't affect the order in which we fire them; r=bkelly
We're adding this test to test_timer_flood.html since it already
examines dispatching thousands of timeouts.  Putting the timeouts in the
two buckets randomly ensures that the test isn't biased towards, for
example, alternating ordering of the timeouts.
2016-12-20 12:40:33 -05:00

30 lines
908 B
HTML

<!DOCTYPE HTML>
<html>
<body>
<script>
let count = 0;
let last_timer_set = 0;
let last_timer_observed = 0;
function cb(timer_observed) {
if (timer_observed > last_timer_observed) {
// In order to make the test more efficient, we don't use the SimpleTest
// ok() function to avoid generating one test assertion per one of these
// checks. We only send a message to the parent which fails the test if
// we detect out of order firing of timeouts.
window.parent.postMessage('OUT_OF_ORDER', '*');
}
last_timer_observed = timer_observed;
count += 1;
// Notify our parent that we are ready once the timer flood has
// warmed up.
if (count === 10000) {
window.parent.postMessage('STARTED', '*');
}
last_timer_set = setTimeout(cb.bind(last_timer_set), 0);
last_timer_set = setTimeout(cb.bind(last_timer_set), 0);
}
addEventListener('load', cb);
</script>
</body>
</html>