Chromium Code Reviews| Index: LayoutTests/virtual/threaded/fast/idle-callback/basic.html |
| diff --git a/LayoutTests/virtual/threaded/fast/idle-callback/basic.html b/LayoutTests/virtual/threaded/fast/idle-callback/basic.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8026e92a2a52fdad9c061e8b0031fa8b95075a77 |
| --- /dev/null |
| +++ b/LayoutTests/virtual/threaded/fast/idle-callback/basic.html |
| @@ -0,0 +1,54 @@ |
| +<title>window.requestIdleCallback exists</title> |
|
esprehn
2015/08/21 08:22:20
You need <!DOCTYPE html>
rmcilroy
2015/08/21 11:21:51
Done.
|
| +<link rel="author" title="Ross McIlroy" href="mailto:rmcilroy@chromium.org" /> |
| +<link rel="help" href="http://www.w3.org/TR/requestidlecallback/"/> |
| +<script src="../../../../resources/testharness.js"></script> |
| +<script src="../../../../resources/testharnessreport.js"></script> |
| +<link rel="stylesheet" href="../../resources/testharness.css" /> |
| +<script> |
| +test(function() { |
| + assert_equals(typeof window.requestIdleCallback, "function"); |
| +}, "window.requestIdleCallback is defined", {assert: "The window.requestIdleCallback function is used to request callbacks during browser-defined idle time."}); |
| + |
| +test(function() { |
| + assert_equals(typeof window.cancelIdleCallback, "function"); |
| +}, "window.cancelIdleCallback is defined", {assert: "The window.cancelIdleCallback function is used to cancel callbacks scheduled via requestIdleCallback."}); |
| + |
| +test(function() { |
| + assert_equals(typeof window.requestIdleCallback(function() {}), "number"); |
| +}, "window.requestIdleCallback() returns a number", {assert: "The requestIdleCallback method MUST return a long"}); |
| + |
| +test(function() { |
| + assert_equals(typeof window.cancelIdleCallback(1), "undefined"); |
| +}, "window.cancelIdleCallback() returns undefined", {assert: "The cancelIdleCallback method MUST return void"}); |
| + |
| +async_test(function() { |
| + // Check whether requestIdleCallback schedules a callback which gets executed |
| + // and the deadline argument is passed correctly. |
| + requestIdleCallback(this.step_func(function(deadline) { |
| + assert_equals(typeof deadline, "object", "IdleDeadline MUST be passed to callback."); |
| + assert_equals(typeof deadline.timeRemaining, "function", "IdleDeadline.timeRemaining MUST be a function"); |
| + var timeRemaining = deadline.timeRemaining(); |
| + assert_equals(typeof timeRemaining, "number", "IdleDeadline.timeRemaining() MUST return a double time remaining in milliseconds"); |
| + assert_true(timeRemaining <= 50, "IdleDeadline.timeRemaining() MUST be less than or equal to 50ms in the future."); |
| + assert_equals(typeof deadline.didTimeout, "boolean", "IdleDeadline.didTimeout MUST be a boolean"); |
| + assert_false(deadline.didTimeout, "IdleDeadline.didTimeout MUST be false if requestIdleCallback wasn't scheduled due to a timeout"); |
| + this.done(); |
| + })); |
| +}, 'requestIdleCallback schedules callbacks'); |
| + |
| +async_test(function() { |
| + // Check whether requestIdleCallback schedules a callback which gets executed |
| + // and the deadline argument is passed correctly. |
| + var handle = requestIdleCallback(this.step_func(function(deadline) { |
| + assert_unreached("callback should not be called if canceled with cancelIdleCallback"); |
| + })); |
| + cancelIdleCallback(handle); |
| + setTimeout(this.step_func(function() { |
| + this.done(); |
| + }), 200); |
| +}, 'cancelIdleCallback cancels callbacks'); |
| + |
| +</script> |
| +<h1>Description</h1> |
| +<p>This test validates that window.requestIdleCallback and window.cancelIdleCallback exist and are a functions.</p> |
| +<div id="log"></div> |