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

Side by Side Diff: LayoutTests/virtual/threaded/fast/idle-callback/basic.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
« no previous file with comments | « no previous file | LayoutTests/virtual/threaded/fast/idle-callback/timeout.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>window.requestIdleCallback exists</title> 2 <title>window.requestIdleCallback exists</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 test(function() { 9 test(function() {
10 assert_equals(typeof window.requestIdleCallback, "function"); 10 assert_equals(typeof window.requestIdleCallback, "function");
11 }, "window.requestIdleCallback is defined", {assert: "The window.requestIdleCall back function is used to request callbacks during browser-defined idle time."}); 11 }, "window.requestIdleCallback is defined", {assert: "The window.requestIdleCall back function is used to request callbacks during browser-defined idle time."});
12 12
13 test(function() { 13 test(function() {
14 assert_equals(typeof window.cancelIdleCallback, "function"); 14 assert_equals(typeof window.cancelIdleCallback, "function");
15 }, "window.cancelIdleCallback is defined", {assert: "The window.cancelIdleCallba ck function is used to cancel callbacks scheduled via requestIdleCallback."}); 15 }, "window.cancelIdleCallback is defined", {assert: "The window.cancelIdleCallba ck function is used to cancel callbacks scheduled via requestIdleCallback."});
16 16
17 test(function() { 17 test(function() {
18 assert_equals(typeof window.requestIdleCallback(function() {}), "number"); 18 assert_equals(typeof window.requestIdleCallback(function() {}), "number");
19 }, "window.requestIdleCallback() returns a number", {assert: "The requestIdleCal lback method MUST return a long"}); 19 }, "window.requestIdleCallback() returns a number", {assert: "The requestIdleCal lback method MUST return a long"});
20 20
21 test(function() { 21 test(function() {
22 assert_equals(typeof window.cancelIdleCallback(1), "undefined"); 22 assert_equals(typeof window.cancelIdleCallback(1), "undefined");
23 }, "window.cancelIdleCallback() returns undefined", {assert: "The cancelIdleCall back method MUST return void"}); 23 }, "window.cancelIdleCallback() returns undefined", {assert: "The cancelIdleCall back method MUST return void"});
24 24
25 async_test(function() { 25 async_test(function() {
26 // Check whether requestIdleCallback schedules a callback which gets executed 26 // Check whether requestIdleCallback schedules a callback which gets executed
27 // and the deadline argument is passed correctly. 27 // and the deadline argument is passed correctly.
28 requestIdleCallback(this.step_func(function(deadline) { 28 requestIdleCallback(this.step_func(function(deadline) {
29 assert_equals(typeof deadline, "object", "IdleDeadline MUST be passed to cal lback."); 29 assert_equals(typeof deadline, "object", "IdleDeadline MUST be passed to cal lback.");
30 assert_equals(typeof deadline.timeRemaining, "number", "IdleDeadline.timeRem aining MUST be a double time remaining in milliseconds"); 30 assert_equals(typeof deadline.timeRemaining, "function", "IdleDeadline.timeR emaining MUST be a function which returns the time remaining in milliseconds");
31 assert_true(deadline.timeRemaining <= 50, "IdleDeadline.timeRemaining() MUST be less than or equal to 50ms in the future."); 31 assert_equals(typeof deadline.timeRemaining(), "number", "IdleDeadline.timeR emaining MUST return a double of the time remaining in milliseconds");
32 assert_true(deadline.timeRemaining() <= 50, "IdleDeadline.timeRemaining() MU ST be less than or equal to 50ms in the future.");
32 assert_equals(typeof deadline.didTimeout, "boolean", "IdleDeadline.didTimeou t MUST be a boolean"); 33 assert_equals(typeof deadline.didTimeout, "boolean", "IdleDeadline.didTimeou t MUST be a boolean");
33 assert_false(deadline.didTimeout, "IdleDeadline.didTimeout MUST be false if requestIdleCallback wasn't scheduled due to a timeout"); 34 assert_false(deadline.didTimeout, "IdleDeadline.didTimeout MUST be false if requestIdleCallback wasn't scheduled due to a timeout");
34 this.done(); 35 this.done();
35 })); 36 }));
36 }, 'requestIdleCallback schedules callbacks'); 37 }, 'requestIdleCallback schedules callbacks');
37 38
38 async_test(function() { 39 async_test(function() {
39 // Check whether requestIdleCallback schedules a callback which gets executed 40 // Check whether requestIdleCallback schedules a callback which gets executed
40 // and the deadline argument is passed correctly. 41 // and the deadline argument is passed correctly.
41 var handle = requestIdleCallback(this.step_func(function(deadline) { 42 var handle = requestIdleCallback(this.step_func(function(deadline) {
42 assert_unreached("callback should not be called if canceled with cancelIdleC allback"); 43 assert_unreached("callback should not be called if canceled with cancelIdleC allback");
43 })); 44 }));
44 cancelIdleCallback(handle); 45 cancelIdleCallback(handle);
45 setTimeout(this.step_func(function() { 46 setTimeout(this.step_func(function() {
46 this.done(); 47 this.done();
47 }), 200); 48 }), 200);
48 }, 'cancelIdleCallback cancels callbacks'); 49 }, 'cancelIdleCallback cancels callbacks');
49 50
50 </script> 51 </script>
51 <h1>Description</h1> 52 <h1>Description</h1>
52 <p>This test validates that window.requestIdleCallback and window.cancelIdleCall back exist and are a functions.</p> 53 <p>This test validates that window.requestIdleCallback and window.cancelIdleCall back exist and are a functions.</p>
53 <div id="log"></div> 54 <div id="log"></div>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/virtual/threaded/fast/idle-callback/timeout.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698