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 timeoutID; | |
Ken Russell (switch to Gerrit)
2013/07/18 19:05:13
Should this be named intervalID for clarity?
Yuta Kitamura
2013/07/19 05:14:08
Done.
| |
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(timeoutID); | |
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 timeoutID = window.setInterval(action, 5); | |
33 }); | |
34 </script> | |
35 </body> | |
36 </html> | |
OLD | NEW |