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

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: Rebased 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 <!DOCTYPE html>
2 <html>
3 <head>
esprehn 2015/08/20 20:45:55 leave out hmtl, head, meta charset
rmcilroy 2015/08/21 00:03:44 Done.
4 <meta charset="utf-8" />
5 <title>window.requestIdleCallback exists</title>
6 <link rel="author" title="Ross McIlroy" href="mailto:rmcilroy@chromium.org" />
7 <link rel="help" href="http://www.w3.org/TR/requestidlecallback/"/>
8 <script src="../../../../resources/testharness.js"></script>
9 <script src="../../../../resources/testharnessreport.js"></script>
10 <link rel="stylesheet" href="../../resources/testharness.css" />
11 <script>
12 test(function() {
13 assert_equals(typeof window.requestIdleCallback, "function");
14 }, "window.requestIdleCallback is defined", {assert: "The window.requestIdleCall back function is used to request callbacks during browser-defined idle time."});
15
16 test(function() {
17 assert_equals(typeof window.cancelIdleCallback, "function");
18 }, "window.cancelIdleCallback is defined", {assert: "The window.cancelIdleCallba ck function is used to cancel callbacks scheduled via requestIdleCallback."});
19
20 test(function() {
21 assert_equals(typeof window.requestIdleCallback(function() {}), "number");
22 }, "window.requestIdleCallback() returns a number", {assert: "The requestIdleCal lback method MUST return a long"});
23
24 test(function() {
25 assert_equals(typeof window.cancelIdleCallback(1), "undefined");
26 }, "window.cancelIdleCallback() returns undefined", {assert: "The cancelIdleCall back method MUST return void"});
27
28 async_test(function() {
29 // Check whether requestIdleCallback schedules a callback which gets executed
30 // and the deadline argument is passed correctly.
31 requestIdleCallback(this.step_func(function(deadline) {
32 assert_equals(typeof deadline, "object", "IdleDeadline MUST be passed to cal lback.");
33 assert_equals(typeof deadline.timeRemaining, "function", "IdleDeadline.timeR emaining MUST be a function");
34 var timeRemaining = deadline.timeRemaining();
35 assert_equals(typeof timeRemaining, "number", "IdleDeadline.timeRemaining() MUST return a double time remaining in milliseconds");
36 assert_true(timeRemaining <= 50, "IdleDeadline.timeRemaining() MUST be less than or equal to 50ms in the future.");
37 assert_equals(typeof deadline.didTimeout, "boolean", "IdleDeadline.didTimeou t MUST be a boolean");
38 assert_false(deadline.didTimeout, "IdleDeadline.didTimeout MUST be false if requestIdleCallback wasn't scheduled due to a timeout");
39 this.done();
40 }));
41 }, 'requestIdleCallback schedules callbacks');
42
43 async_test(function() {
44 // Check whether requestIdleCallback schedules a callback which gets executed
45 // and the deadline argument is passed correctly.
46 var handle = requestIdleCallback(this.step_func(function(deadline) {
47 assert_unreached("callback should not be called if canceled with cancelIdleC allback");
48 }));
49 cancelIdleCallback(handle);
50 setTimeout(this.step_func(function() {
51 this.done();
52 }), 200);
53 }, 'cancelIdleCallback cancels callbacks');
54
55 </script>
56 <h1>Description</h1>
57 <p>This test validates that window.requestIdleCallback and window.cancelIdleCall back exist and are a functions.</p>
58 </head>
59 <body>
60 <div id="log"></div>
61
62 </body>
esprehn 2015/08/20 20:45:55 leave out body and html
rmcilroy 2015/08/21 00:03:44 Done.
63 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698