Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / virtual / threaded / fast / idle-callback / basic.html
blob0b0e410235c52063664c9c88564554cc404a41bd
1 <!DOCTYPE html>
2 <title>window.requestIdleCallback exists</title>
3 <link rel="author" title="Ross McIlroy" href="mailto:rmcilroy@chromium.org" />
4 <link rel="help" href="http://www.w3.org/TR/requestidlecallback/"/>
5 <script src="../../../../resources/testharness.js"></script>
6 <script src="../../../../resources/testharnessreport.js"></script>
7 <link rel="stylesheet" href="../../resources/testharness.css" />
8 <script>
9 test(function() {
10 assert_equals(typeof window.requestIdleCallback, "function");
11 }, "window.requestIdleCallback is defined", {assert: "The window.requestIdleCallback function is used to request callbacks during browser-defined idle time."});
13 test(function() {
14 assert_equals(typeof window.cancelIdleCallback, "function");
15 }, "window.cancelIdleCallback is defined", {assert: "The window.cancelIdleCallback function is used to cancel callbacks scheduled via requestIdleCallback."});
17 test(function() {
18 assert_equals(typeof window.requestIdleCallback(function() {}), "number");
19 }, "window.requestIdleCallback() returns a number", {assert: "The requestIdleCallback method MUST return a long"});
21 test(function() {
22 assert_equals(typeof window.cancelIdleCallback(1), "undefined");
23 }, "window.cancelIdleCallback() returns undefined", {assert: "The cancelIdleCallback method MUST return void"});
25 async_test(function() {
26 // Check whether requestIdleCallback schedules a callback which gets executed
27 // and the deadline argument is passed correctly.
28 requestIdleCallback(this.step_func(function(deadline) {
29 assert_equals(typeof deadline, "object", "IdleDeadline MUST be passed to callback.");
30 assert_equals(typeof deadline.timeRemaining, "function", "IdleDeadline.timeRemaining MUST be a function which returns the time remaining in milliseconds");
31 assert_equals(typeof deadline.timeRemaining(), "number", "IdleDeadline.timeRemaining MUST return a double of the time remaining in milliseconds");
32 assert_true(deadline.timeRemaining() <= 50, "IdleDeadline.timeRemaining() MUST be less than or equal to 50ms in the future.");
33 assert_equals(typeof deadline.didTimeout, "boolean", "IdleDeadline.didTimeout 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');
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 cancelIdleCallback");
44 }));
45 cancelIdleCallback(handle);
46 setTimeout(this.step_func(function() {
47 this.done();
48 }), 200);
49 }, 'cancelIdleCallback cancels callbacks');
51 </script>
52 <h1>Description</h1>
53 <p>This test validates that window.requestIdleCallback and window.cancelIdleCallback exist and are a functions.</p>
54 <div id="log"></div>