blob: 9c98ac4350a159efc865a080af8baa307ecd2947 [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 + "\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.testRunner)
testRunner.notifyDone();
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
for (var i = 0; i < count; ++i)
setTimeout((function() { var j = i; return function() { fired(j); }})(), 0);
</script>