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

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

Issue 1119683003: Implement requestIdleCallback API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address Elliott's review comments Created 5 years, 4 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
(Empty)
1 <title>window.requestIdleCallback exists</title>
esprehn 2015/08/21 08:22:20 You need <!DOCTYPE html>
rmcilroy 2015/08/21 11:21:51 Done.
2 <link rel="author" title="Ross McIlroy" href="mailto:rmcilroy@chromium.org" />
3 <link rel="help" href="http://www.w3.org/TR/requestidlecallback/"/>
4 <script src="../../../../resources/testharness.js"></script>
5 <script src="../../../../resources/testharnessreport.js"></script>
6 <link rel="stylesheet" href="../../resources/testharness.css" />
7 <script>
8 test(function() {
9 assert_equals(typeof window.requestIdleCallback, "function");
10 }, "window.requestIdleCallback is defined", {assert: "The window.requestIdleCall back function is used to request callbacks during browser-defined idle time."});
11
12 test(function() {
13 assert_equals(typeof window.cancelIdleCallback, "function");
14 }, "window.cancelIdleCallback is defined", {assert: "The window.cancelIdleCallba ck function is used to cancel callbacks scheduled via requestIdleCallback."});
15
16 test(function() {
17 assert_equals(typeof window.requestIdleCallback(function() {}), "number");
18 }, "window.requestIdleCallback() returns a number", {assert: "The requestIdleCal lback method MUST return a long"});
19
20 test(function() {
21 assert_equals(typeof window.cancelIdleCallback(1), "undefined");
22 }, "window.cancelIdleCallback() returns undefined", {assert: "The cancelIdleCall back method MUST return void"});
23
24 async_test(function() {
25 // Check whether requestIdleCallback schedules a callback which gets executed
26 // and the deadline argument is passed correctly.
27 requestIdleCallback(this.step_func(function(deadline) {
28 assert_equals(typeof deadline, "object", "IdleDeadline MUST be passed to cal lback.");
29 assert_equals(typeof deadline.timeRemaining, "function", "IdleDeadline.timeR emaining MUST be a function");
30 var timeRemaining = deadline.timeRemaining();
31 assert_equals(typeof timeRemaining, "number", "IdleDeadline.timeRemaining() MUST return a double time remaining in milliseconds");
32 assert_true(timeRemaining <= 50, "IdleDeadline.timeRemaining() MUST be less than or equal to 50ms in the future.");
33 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");
35 this.done();
36 }));
37 }, 'requestIdleCallback schedules callbacks');
38
39 async_test(function() {
40 // Check whether requestIdleCallback schedules a callback which gets executed
41 // and the deadline argument is passed correctly.
42 var handle = requestIdleCallback(this.step_func(function(deadline) {
43 assert_unreached("callback should not be called if canceled with cancelIdleC allback");
44 }));
45 cancelIdleCallback(handle);
46 setTimeout(this.step_func(function() {
47 this.done();
48 }), 200);
49 }, 'cancelIdleCallback cancels callbacks');
50
51 </script>
52 <h1>Description</h1>
53 <p>This test validates that window.requestIdleCallback and window.cancelIdleCall back exist and are a functions.</p>
54 <div id="log"></div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698