Chromium Code Reviews| Index: LayoutTests/fast/dom/Window/clear-interval.html |
| diff --git a/LayoutTests/fast/dom/Window/clear-interval.html b/LayoutTests/fast/dom/Window/clear-interval.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..db89c8c13404c7eeede7cabe6af6371dac867970 |
| --- /dev/null |
| +++ b/LayoutTests/fast/dom/Window/clear-interval.html |
| @@ -0,0 +1,36 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<title>clearInterval test</title> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<link rel="stylesheet" href="../../../resources/testharness.css"> |
| +</head> |
| +<body> |
| +<script> |
| +var clearIntervalTest = async_test('Actions registered with setInterval should be cleared by clearInterval.'); |
| + |
| +clearIntervalTest.step(function () |
| +{ |
| + var count = 0; |
| + 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.
|
| + |
| + // Fire |action| every 5ms for three times, and then clear the action. |
| + function action() |
| + { |
| + ++count; |
| + if (count == 3) { |
| + window.clearInterval(timeoutID); |
| + // Wait for a reasonably long time (50ms here) to make sure |action| is not fired anymore. |
| + window.setTimeout(clearIntervalTest.step_func(function () |
| + { |
| + assert_equals(count, 3); |
| + clearIntervalTest.done(); |
| + }, 50)); |
| + } |
| + } |
| + timeoutID = window.setInterval(action, 5); |
| +}); |
| +</script> |
| +</body> |
| +</html> |