| <!DOCTYPE html> |
| <title>window.requestIdleCallback callback behavior during long idle periods.</title> |
| <link rel="author" title="Ross McIlroy" href="mailto:rmcilroy@chromium.org" /> |
| <link rel="help" href="http://www.w3.org/TR/requestidlecallback/"/> |
| <script src="../../../../resources/testharness.js"></script> |
| <script src="../../../../resources/testharnessreport.js"></script> |
| <link rel="stylesheet" href="../../../..//resources/testharness.css" /> |
| <script> |
| |
| async_test(function() { |
| // Check that a new idle callback runs after the deadline of a previous one. |
| // This test is similar to one in idle_periods.html, but uses completely |
| // idle renderer and doesn't run requestAnimationFrame. This test lives |
| // in a separate file for isolation (if rAF is requested, renderer will |
| // become non-idle for all tests. |
| var previous_deadline; |
| var idle_callbacks_remaining = 5; |
| var self = this; |
| requestIdleCallback(this.step_func(function rIC(deadline) { |
| var remaining = deadline.timeRemaining(); |
| var now = performance.now(); |
| if (previous_deadline != undefined) { |
| assert_true(now >= previous_deadline, "A requestIdleCallback called during an idle period should not be run until the next idle period."); |
| } |
| |
| // Schedule a new requestIdleCallback. |
| if (--idle_callbacks_remaining > 0) { |
| previous_deadline = now + remaining; |
| requestIdleCallback(rIC); |
| } else { |
| self.done(); |
| } |
| })); |
| |
| }, 'Check that if a new idle callback runs after a deadline for a previous one during long idle period.'); |
| |
| </script> |
| <h1>Description</h1> |
| <p>This test validates that window.requestIdleCallback deals with callbacks during long idle periods correctly.</p> |
| <div id="log"></div> |