2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / fast / dom / simultaneouslyRegsiteredTimerFireOrder.html
blob247d6174ffd3278deaf15f5d962b75cb78fc0473
1 <p>
2 This page verifies that timers with equivalent fire times fire in the order they
3 were registered. If the test passes, you'll see a series of PASS messages below.
4 </p>
6 <pre id="pre"></pre>
8 <script>
9 function log(s)
11 document.getElementById("pre").appendChild(document.createTextNode(s + "\r\n"));
14 function shouldBe(a, aDescription, b)
16 if (a === b) {
17 log("PASS: " + aDescription + " should be " + b + " and is.");
18 } else {
19 log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
23 var count = 100;
24 var firedTimers = [];
26 function fired(id)
28 firedTimers.push(id);
29 if (id == count - 1)
30 done();
33 function done()
35 for (var i = 0; i < count; ++i)
36 shouldBe(firedTimers[i], "firedTimers[" + i + "]", i);
38 if (window.layoutTestController)
39 layoutTestController.notifyDone();
42 if (window.layoutTestController) {
43 layoutTestController.dumpAsText();
44 layoutTestController.waitUntilDone();
47 for (var i = 0; i < count; ++i)
48 setTimeout((function() { var j = i; return function() { fired(j); }})(), 0);
49 </script>