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

Side by Side Diff: third_party/WebKit/LayoutTests/virtual/threaded/fast/idle-callback/basic.html

Issue 1989363005: Graceful idle callback cancellation with invalid IDs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ScriptedIdleTaskController.h » ('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 test(function() {
26 assert_equals(typeof window.cancelIdleCallback(-1), "undefined");
27 assert_equals(typeof window.cancelIdleCallback(0), "undefined");
28 }, "window.cancelIdleCallback() returns undefined for unmapped IDs", {assert: "T he cancelIdleCallback method MUST return void"});
29
25 async_test(function() { 30 async_test(function() {
26 // Check whether requestIdleCallback schedules a callback which gets executed 31 // Check whether requestIdleCallback schedules a callback which gets executed
27 // and the deadline argument is passed correctly. 32 // and the deadline argument is passed correctly.
28 requestIdleCallback(this.step_func(function(deadline) { 33 requestIdleCallback(this.step_func(function(deadline) {
29 assert_equals(typeof deadline, "object", "IdleDeadline MUST be passed to cal lback."); 34 assert_equals(typeof deadline, "object", "IdleDeadline MUST be passed to cal lback.");
30 assert_equals(typeof deadline.timeRemaining, "function", "IdleDeadline.timeR emaining MUST be a function which returns the time remaining in milliseconds"); 35 assert_equals(typeof deadline.timeRemaining, "function", "IdleDeadline.timeR emaining MUST be a function which returns the time remaining in milliseconds");
31 assert_equals(typeof deadline.timeRemaining(), "number", "IdleDeadline.timeR emaining MUST return a double of the time remaining in milliseconds"); 36 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."); 37 assert_true(deadline.timeRemaining() <= 50, "IdleDeadline.timeRemaining() MU ST be less than or equal to 50ms in the future.");
33 assert_equals(typeof deadline.didTimeout, "boolean", "IdleDeadline.didTimeou t MUST be a boolean"); 38 assert_equals(typeof deadline.didTimeout, "boolean", "IdleDeadline.didTimeou t MUST be a boolean");
34 assert_false(deadline.didTimeout, "IdleDeadline.didTimeout MUST be false if requestIdleCallback wasn't scheduled due to a timeout"); 39 assert_false(deadline.didTimeout, "IdleDeadline.didTimeout MUST be false if requestIdleCallback wasn't scheduled due to a timeout");
(...skipping 10 matching lines...) Expand all
45 cancelIdleCallback(handle); 50 cancelIdleCallback(handle);
46 setTimeout(this.step_func(function() { 51 setTimeout(this.step_func(function() {
47 this.done(); 52 this.done();
48 }), 200); 53 }), 200);
49 }, 'cancelIdleCallback cancels callbacks'); 54 }, 'cancelIdleCallback cancels callbacks');
50 55
51 </script> 56 </script>
52 <h1>Description</h1> 57 <h1>Description</h1>
53 <p>This test validates that window.requestIdleCallback and window.cancelIdleCall back exist and are a functions.</p> 58 <p>This test validates that window.requestIdleCallback and window.cancelIdleCall back exist and are a functions.</p>
54 <div id="log"></div> 59 <div id="log"></div>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ScriptedIdleTaskController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698