mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
87a8f718ea
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.
30 lines
908 B
HTML
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>
|