diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/tests/js/timer.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/js/timer.js')
-rw-r--r-- | dom/tests/js/timer.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dom/tests/js/timer.js b/dom/tests/js/timer.js new file mode 100644 index 000000000..ac1ed1ef3 --- /dev/null +++ b/dom/tests/js/timer.js @@ -0,0 +1,71 @@ + +function oneShot(testNum, str) +{ + dump("Test #" + testNum + " successful:" + str + "\n"); +} + +setTimeout(oneShot, 1000, 1, "one shot timer with function argument"); +setTimeout("oneShot(2, 'one shot timer with string argument');", 2000); + +function reschedule(testNum, numTimes) +{ + if (numTimes == 4) { + dump("Test #" + testNum + " successful: Creating a timeout in a timeout\n"); + kickoff4(); + } + else { + dump("Test #" + testNum + " in progress: " + numTimes + "\n"); + setTimeout(reschedule, 500, 3, numTimes+1); + } +} + +setTimeout(reschedule, 3000, 3, 0); + +var count = 0; +var repeat_timer = null; +function repeat(testNum, numTimes, str, func, delay) +{ + dump("Test #" + testNum + " in progress: interval delayed by " + delay + " milliseconds\n"); + if (count++ > numTimes) { + clearInterval(repeat_timer); + dump("Test #" + testNum + " successful: " + str + "\n"); + if (func != null) { + func(); + } + } +} + +function kickoff4() +{ + repeat_timer = setInterval(repeat, 500, 4, 5, "interval test", kickoff5); +} + +//setTimeout(kickoff4, 5000); + +function oneShot2(testNum) +{ + dump("Test #" + testNum + " in progress: one shot timer\n"); + if (count++ == 4) { + dump("Test #" + testNum + " in progress: end of one shots\n"); + } + else { + setTimeout(oneShot2, 500, 5); + } +} + +function kickoff5() +{ + count = 0; + setTimeout(oneShot2, 500, 5); + repeat_timer = setInterval("repeat(5, 8, 'multiple timer test', kickoff6)", 600); +} + +//setTimeout(kickoff5, 12000); + +function kickoff6() +{ + dump("Test #6: Interval timeout should end when you go to a new page\n"); + setInterval(repeat, 1000, 6, 1000, "endless timer test", null); +} + +//setTimeout(kickoff6, 18000);
\ No newline at end of file |