Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(961)

Side by Side Diff: LayoutTests/virtual/threaded/fast/idle-callback/timeout.html

Issue 1309523008: Change IdleCallbackDeadline.timeRemaining to be a function instead of an attribute. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add webexposed change Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>window.requestIdleCallback deals with timeouts correctly</title> 2 <title>window.requestIdleCallback deals with timeouts correctly</title>
3 <link rel="author" title="Ross McIlroy" href="mailto:rmcilroy@chromium.org" /> 3 <link rel="author" title="Ross McIlroy" href="mailto:rmcilroy@chromium.org" />
4 <link rel="help" href="http://www.w3.org/TR/requestidlecallback/"/> 4 <link rel="help" href="http://www.w3.org/TR/requestidlecallback/"/>
5 <script src="../../../../resources/testharness.js"></script> 5 <script src="../../../../resources/testharness.js"></script>
6 <script src="../../../../resources/testharnessreport.js"></script> 6 <script src="../../../../resources/testharnessreport.js"></script>
7 <link rel="stylesheet" href="../../resources/testharness.css" /> 7 <link rel="stylesheet" href="../../resources/testharness.css" />
8 <script> 8 <script>
9 9
10 async_test(function() { 10 async_test(function() {
(...skipping 26 matching lines...) Expand all
37 37
38 async_test(function() { 38 async_test(function() {
39 // Check whether requestIdleCallback with a timeout works when the event loop 39 // Check whether requestIdleCallback with a timeout works when the event loop
40 // is busy. 40 // is busy.
41 var busy_raf_loop_iterations_remaining = 10; // Should take 20 * 40 = 400ms 41 var busy_raf_loop_iterations_remaining = 10; // Should take 20 * 40 = 400ms
42 var timeout = 200; 42 var timeout = 200;
43 var idle_callback_scheduled; 43 var idle_callback_scheduled;
44 var idle_callback = this.step_func(function(deadline) { 44 var idle_callback = this.step_func(function(deadline) {
45 var time_delta = performance.now() - idle_callback_scheduled; 45 var time_delta = performance.now() - idle_callback_scheduled;
46 assert_true(time_delta >= timeout, "Should only have been run after timeout" ); 46 assert_true(time_delta >= timeout, "Should only have been run after timeout" );
47 assert_true(deadline.timeRemaining == 0, "IdleDeadline.timeRemaining MUST be equal to zero if requestIdleCallback was scheduled due to a timeout"); 47 assert_true(deadline.timeRemaining() == 0, "IdleDeadline.timeRemaining MUST be equal to zero if requestIdleCallback was scheduled due to a timeout");
48 assert_true(deadline.didTimeout, "IdleDeadline.didTimeout MUST be true if re questIdleCallback was scheduled due to a timeout"); 48 assert_true(deadline.didTimeout, "IdleDeadline.didTimeout MUST be true if re questIdleCallback was scheduled due to a timeout");
49 assert_true(busy_raf_loop_iterations_remaining > 0, "Busy rAF loop should st ill be going"); 49 assert_true(busy_raf_loop_iterations_remaining > 0, "Busy rAF loop should st ill be going");
50 this.done(); 50 this.done();
51 }); 51 });
52 52
53 requestAnimationFrame(this.step_func(function busyRAFLoop() { 53 requestAnimationFrame(this.step_func(function busyRAFLoop() {
54 var start_time = performance.now(); 54 var start_time = performance.now();
55 if (!idle_callback_scheduled) { 55 if (!idle_callback_scheduled) {
56 idle_callback_scheduled = start_time; 56 idle_callback_scheduled = start_time;
57 requestIdleCallback(idle_callback, timeout); 57 requestIdleCallback(idle_callback, timeout);
58 } 58 }
59 59
60 // Use up the whole frame budget. 60 // Use up the whole frame budget.
61 while (performance.now() - start_time < 40) { } 61 while (performance.now() - start_time < 40) { }
62 if (busy_raf_loop_iterations_remaining > 0) { 62 if (busy_raf_loop_iterations_remaining > 0) {
63 busy_raf_loop_iterations_remaining--; 63 busy_raf_loop_iterations_remaining--;
64 requestAnimationFrame(busyRAFLoop); 64 requestAnimationFrame(busyRAFLoop);
65 } 65 }
66 })); 66 }));
67 }, 'requestIdleCallback scheduled with timeout when event loop is busy.'); 67 }, 'requestIdleCallback scheduled with timeout when event loop is busy.');
68 68
69 </script> 69 </script>
70 <h1>Description</h1> 70 <h1>Description</h1>
71 <p>This test validates that window.requestIdleCallback deals with timeouts corre ctly.</p> 71 <p>This test validates that window.requestIdleCallback deals with timeouts corre ctly.</p>
72 <div id="log"></div> 72 <div id="log"></div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698