blob: 247d6174ffd3278deaf15f5d962b75cb78fc0473 [file] [log] [blame]
<p>
This page verifies that timers with equivalent fire times fire in the order they
were registered. If the test passes, you'll see a series of PASS messages below.
</p>
<pre id="pre"></pre>
<script>
function log(s)
{
document.getElementById("pre").appendChild(document.createTextNode(s + "\r\n"));
}
function shouldBe(a, aDescription, b)
{
if (a === b) {
log("PASS: " + aDescription + " should be " + b + " and is.");
} else {
log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
}
}
var count = 100;
var firedTimers = [];
function fired(id)
{
firedTimers.push(id);
if (id == count - 1)
done();
}
function done()
{
for (var i = 0; i < count; ++i)
shouldBe(firedTimers[i], "firedTimers[" + i + "]", i);
if (window.layoutTestController)
layoutTestController.notifyDone();
}
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
for (var i = 0; i < count; ++i)
setTimeout((function() { var j = i; return function() { fired(j); }})(), 0);
</script>