summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/webappapis/idle-callbacks
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/html/webappapis/idle-callbacks
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/html/webappapis/idle-callbacks')
-rw-r--r--testing/web-platform/tests/html/webappapis/idle-callbacks/callback-exception.html22
-rw-r--r--testing/web-platform/tests/html/webappapis/idle-callbacks/callback-iframe.html17
-rw-r--r--testing/web-platform/tests/html/webappapis/idle-callbacks/callback-invoked.html12
-rw-r--r--testing/web-platform/tests/html/webappapis/idle-callbacks/callback-multiple-calls.html41
-rw-r--r--testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout.html28
-rw-r--r--testing/web-platform/tests/html/webappapis/idle-callbacks/cancel-invoked.html26
-rw-r--r--testing/web-platform/tests/html/webappapis/idle-callbacks/idlharness.html34
7 files changed, 180 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-exception.html b/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-exception.html
new file mode 100644
index 000000000..fecda221d
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-exception.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>requestIdleCallback callback exception reported to error handler</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id="log"></div>
+<script>
+ var custom_exception = 'requestIdleCallbackException';
+ setup({allow_uncaught_exception : true});
+ async_test(function (t) {
+ assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
+ addEventListener("error",function(e) {
+ t.step(function() {
+ assert_equals(e.error.message, custom_exception);
+ t.done();
+ })
+ });
+ window.requestIdleCallback(function () {
+ throw new Error(custom_exception);
+ });
+ }, "requestIdleCallback callback exceptions are reported to error handler");
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-iframe.html b/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-iframe.html
new file mode 100644
index 000000000..965941be1
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-iframe.html
@@ -0,0 +1,17 @@
+<!doctype html>
+<meta charset=utf-8>
+<title></title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id="log"></div>
+<iframe style="display:none" id="frame"></iframe>
+<script>
+ async_test(function (t) {
+ let frame = document.getElementById("frame");
+ frame.contentWindow.test = function() {
+ frame.contentWindow.requestIdleCallback(t.step_func_done());
+ }
+
+ frame.contentWindow.test();
+ });
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-invoked.html b/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-invoked.html
new file mode 100644
index 000000000..5e799cf39
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-invoked.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>requestIdleCallback callback must be called eventually</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id="log"></div>
+<script>
+ async_test(function (t) {
+ assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
+ window.requestIdleCallback(t.step_func_done());
+ }, "requestIdleCallback callback is invoked at least once before the timeout");
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-multiple-calls.html b/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-multiple-calls.html
new file mode 100644
index 000000000..8584c71da
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-multiple-calls.html
@@ -0,0 +1,41 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>multiple calls to requestIdleCallback</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id="log"></div>
+<script>
+ async_test(function (t) {
+ assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
+ var counter = 0;
+ function f(c) {
+ assert_equals(counter, c);
+ if (counter === 99) {
+ t.done();
+ }
+
+ ++counter;
+ }
+ for (var i = 0; i < 100; ++i) {
+ let j = i;
+ window.requestIdleCallback(t.step_func(function () { f(j) }));
+ }
+ }, "requestIdleCallback callbacks should be invoked in order (called iteratively)");
+
+ async_test(function (t) {
+ assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
+ var counter = 0;
+
+ function f(c) {
+ assert_equals(counter, c);
+ if (counter === 99) {
+ t.done();
+ }
+
+ ++counter;
+ window.requestIdleCallback(t.step_func(function () { f(c + 1) }));
+ }
+
+ window.requestIdleCallback(t.step_func(function () { f(0) }));
+ }, "requestIdleCallback callbacks should be invoked in order (called recursively)");
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout.html b/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout.html
new file mode 100644
index 000000000..823d5f5db
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>requestIdleCallback timeout callback must be called with didTimeout equal to true</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id="log"></div>
+<script>
+ async_test(function (t) {
+ assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
+ var counter = 0;
+
+ function g(deadline) {
+ assert_true(deadline.didTimeout)
+ t.done();
+ }
+
+ function f(deadline) {
+ assert_false(deadline.didTimeout);
+ window.requestIdleCallback(t.step_func(g), {timeout:300});
+
+ var d = Date.now() + 500;
+ while (Date.now() < d) {
+
+ }
+ }
+ window.requestIdleCallback(t.step_func(f));
+ }, "requestIdleCallback callback should time out");
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/idle-callbacks/cancel-invoked.html b/testing/web-platform/tests/html/webappapis/idle-callbacks/cancel-invoked.html
new file mode 100644
index 000000000..8956b8709
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/idle-callbacks/cancel-invoked.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>cancelling idle requests</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id="log"></div>
+<script>
+ test(function (t) {
+ window.cancelIdleCallback(42);
+ assert_true(true);
+ }, "cancelIdleCallback does nothing if there is no callback with the given handle");
+
+ async_test(function (t) {
+ assert_false(document.hidden, "document.hidden must exist and be false to run this test properly");
+ var neverCalled = true;
+ var handle = window.requestIdleCallback(function () {
+ neverCalled = false;
+ });
+ window.cancelIdleCallback(handle);
+
+ t.step_timeout(function() {
+ assert_true(neverCalled);
+ t.done();
+ }, 2000);
+ }, "A cancelled callback is never invoked");
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/idle-callbacks/idlharness.html b/testing/web-platform/tests/html/webappapis/idle-callbacks/idlharness.html
new file mode 100644
index 000000000..6033535f3
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/idle-callbacks/idlharness.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>idlharness test</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src="/resources/WebIDLParser.js"></script>
+<script src="/resources/idlharness.js"></script>
+
+<pre id='untested_idl' style='display:none'>
+[PrimaryGlobal]
+interface Window {
+};
+</pre>
+
+<pre id='idl'>
+partial interface Window {
+ unsigned long requestIdleCallback(IdleRequestCallback callback,
+ optional IdleRequestOptions options);
+ void cancelIdleCallback(unsigned long handle);
+};
+
+dictionary IdleRequestOptions {
+ unsigned long timeout;
+};
+
+callback IdleRequestCallback = void (IdleDeadline deadline);
+</pre>
+<script>
+ var idl_array = new IdlArray();
+ idl_array.add_untested_idls(document.getElementById("untested_idl").textContent);
+ idl_array.add_idls(document.getElementById("idl").textContent);
+ idl_array.add_objects({Window: ["window"]});
+ idl_array.test();
+</script>