| Andreas Farre | da8dc80 | 2016-11-02 15:05:11 | [diff] [blame] | 1 | <!doctype html> |
| 2 | <meta charset=utf-8> |
| 3 | <title>cancelling idle requests</title> |
| 4 | <script src=/resources/testharness.js></script> |
| 5 | <script src=/resources/testharnessreport.js></script> |
| 6 | <div id="log"></div> |
| 7 | <script> |
| 8 | test(function (t) { |
| 9 | window.cancelIdleCallback(42); |
| 10 | assert_true(true); |
| 11 | }, "cancelIdleCallback does nothing if there is no callback with the given handle"); |
| 12 | |
| 13 | async_test(function (t) { |
| 14 | assert_false(document.hidden, "document.hidden must exist and be false to run this test properly"); |
| 15 | var neverCalled = true; |
| 16 | var handle = window.requestIdleCallback(function () { |
| 17 | neverCalled = false; |
| 18 | }); |
| 19 | window.cancelIdleCallback(handle); |
| 20 | |
| 21 | t.step_timeout(function() { |
| 22 | assert_true(neverCalled); |
| 23 | t.done(); |
| 24 | }, 2000); |
| 25 | }, "A cancelled callback is never invoked"); |
| Andreas Farre | 16ee47a | 2017-02-15 19:48:51 | [diff] [blame] | 26 | |
| 27 | async_test(function (t) { |
| 28 | var handle = requestIdleCallback(t.step_func_done(function () { |
| 29 | cancelIdleCallback(handle); |
| 30 | })); |
| 31 | }, "Cancelling the currently executing idle callback should be allowed"); |
| Andreas Farre | da8dc80 | 2016-11-02 15:05:11 | [diff] [blame] | 32 | </script> |