OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>clearInterval test</title> |
| 5 <script src="../../../resources/testharness.js"></script> |
| 6 <script src="../../../resources/testharnessreport.js"></script> |
| 7 <link rel="stylesheet" href="../../../resources/testharness.css"> |
| 8 </head> |
| 9 <body> |
| 10 <script> |
| 11 var clearIntervalTest = async_test('Actions registered with setInterval should b
e cleared by clearInterval.'); |
| 12 |
| 13 clearIntervalTest.step(function () |
| 14 { |
| 15 var count = 0; |
| 16 var intervalID; |
| 17 |
| 18 // Fire |action| every 5ms for three times, and then clear the action. |
| 19 function action() |
| 20 { |
| 21 ++count; |
| 22 if (count == 3) { |
| 23 window.clearInterval(intervalID); |
| 24 // Wait for a reasonably long time (50ms here) to make sure |action|
is not fired anymore. |
| 25 window.setTimeout(clearIntervalTest.step_func(function () |
| 26 { |
| 27 assert_equals(count, 3); |
| 28 clearIntervalTest.done(); |
| 29 }, 50)); |
| 30 } |
| 31 } |
| 32 intervalID = window.setInterval(action, 5); |
| 33 }); |
| 34 </script> |
| 35 </body> |
| 36 </html> |
OLD | NEW |