summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/webappapis/animation-frames
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/webappapis/animation-frames
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/webappapis/animation-frames')
-rw-r--r--testing/web-platform/tests/html/webappapis/animation-frames/callback-cross-realm-report-exception.html29
-rw-r--r--testing/web-platform/tests/html/webappapis/animation-frames/callback-exception.html27
-rw-r--r--testing/web-platform/tests/html/webappapis/animation-frames/callback-handle.html16
-rw-r--r--testing/web-platform/tests/html/webappapis/animation-frames/callback-invoked.html18
-rw-r--r--testing/web-platform/tests/html/webappapis/animation-frames/callback-multicalls.html26
-rw-r--r--testing/web-platform/tests/html/webappapis/animation-frames/callback-timestamp.html17
-rw-r--r--testing/web-platform/tests/html/webappapis/animation-frames/cancel-handle-manual.html51
-rw-r--r--testing/web-platform/tests/html/webappapis/animation-frames/cancel-invoked.html18
-rw-r--r--testing/web-platform/tests/html/webappapis/animation-frames/cancel-pending.html26
-rw-r--r--testing/web-platform/tests/html/webappapis/animation-frames/same-dispatch-time.html31
10 files changed, 259 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/webappapis/animation-frames/callback-cross-realm-report-exception.html b/testing/web-platform/tests/html/webappapis/animation-frames/callback-cross-realm-report-exception.html
new file mode 100644
index 0000000000..1b8aa41a6d
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/animation-frames/callback-cross-realm-report-exception.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>requestAnimationFrame() reports the exception from its callback in the callback's global object</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<iframe></iframe>
+<iframe></iframe>
+<iframe></iframe>
+<script>
+setup({ allow_uncaught_exception: true });
+
+const onerrorCalls = [];
+window.onerror = () => { onerrorCalls.push("top"); };
+frames[0].onerror = () => { onerrorCalls.push("frame0"); };
+frames[1].onerror = () => { onerrorCalls.push("frame1"); };
+frames[2].onerror = () => { onerrorCalls.push("frame2"); };
+
+async_test(t => {
+ window.onload = t.step_func(() => {
+ frames[0].requestAnimationFrame(new frames[1].Function(`throw new parent.frames[2].Error("PASS");`));
+ document.querySelector("iframe").height = 200;
+
+ t.step_timeout(() => {
+ assert_array_equals(onerrorCalls, ["frame1"]);
+ t.done();
+ }, 100);
+ });
+});
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/animation-frames/callback-exception.html b/testing/web-platform/tests/html/webappapis/animation-frames/callback-exception.html
new file mode 100644
index 0000000000..3867f0c41d
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/animation-frames/callback-exception.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<html>
+ <head>
+ <title>requestAnimationFrame callback exception reported to error handler</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="help" href="https://w3c.github.io/web-performance/specs/RequestAnimationFrame/Overview.html#dom-windowanimationtiming-requestanimationframe"/>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ var custom_exception = 'requestAnimationFrameException';
+ setup({allow_uncaught_exception : true});
+ async_test(function (t) {
+ addEventListener("error",function(e) {
+ t.step(function() {
+ assert_equals(e.error.message, custom_exception);
+ t.done();
+ })
+ });
+ window.requestAnimationFrame(function () {
+ throw new Error(custom_exception);
+ });
+ }, "requestAnimationFrame callback exceptions are reported to error handler");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/webappapis/animation-frames/callback-handle.html b/testing/web-platform/tests/html/webappapis/animation-frames/callback-handle.html
new file mode 100644
index 0000000000..f1b8830031
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/animation-frames/callback-handle.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>AnimationTiming Test: FrameRequestCallback - valid callback handle</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#animation-frames">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+
+ test(() => {
+ let requestId = window.requestAnimationFrame(() => {});
+ assert_greater_than(requestId, 0, "callback handle is a integer greater than zero");
+ }, "Check window.requestAnimationFrame can return a valid callback handle");
+
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/animation-frames/callback-invoked.html b/testing/web-platform/tests/html/webappapis/animation-frames/callback-invoked.html
new file mode 100644
index 0000000000..ca34e455a2
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/animation-frames/callback-invoked.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<html>
+ <head>
+ <title>requestAnimationFrame must be triggered once</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="help" href="https://w3c.github.io/web-performance/specs/RequestAnimationFrame/Overview.html#dom-windowanimationtiming-requestanimationframe"/>
+ </head>
+ <body>
+ <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.requestAnimationFrame(t.step_func_done());
+ }, "requestAnimationFrame callback is invoked at least once before the timeout");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/webappapis/animation-frames/callback-multicalls.html b/testing/web-platform/tests/html/webappapis/animation-frames/callback-multicalls.html
new file mode 100644
index 0000000000..38f34171ea
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/animation-frames/callback-multicalls.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>AnimationTiming Test: multiple calls to requestAnimationFrame with the same callback</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window-requestanimationframe">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+
+ async_test(function(t) {
+ var counter = 0;
+ window.requestAnimationFrame(callback);
+
+ function callback() {
+ ++counter;
+ if (counter == 2) {
+ t.done();
+ } else {
+ window.requestAnimationFrame(callback);
+ }
+ };
+
+ }, "Check that multiple calls to requestAnimationFrame with the same callback will result in multiple entries being in the list with that same callback.");
+
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/animation-frames/callback-timestamp.html b/testing/web-platform/tests/html/webappapis/animation-frames/callback-timestamp.html
new file mode 100644
index 0000000000..8e61db61b8
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/animation-frames/callback-timestamp.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>AnimationTiming Test: FrameRequestCallback - timestamp argument</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#animation-frames">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+
+ async_test(t => {
+ requestAnimationFrame(t.step_func_done(time => {
+ assert_equals(typeof time, "number", "callback contains a number argument");
+ }))
+ }, "Check FrameRequestCallback has a DOMHighResTimeStamp argument");
+
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/animation-frames/cancel-handle-manual.html b/testing/web-platform/tests/html/webappapis/animation-frames/cancel-handle-manual.html
new file mode 100644
index 0000000000..0328272522
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/animation-frames/cancel-handle-manual.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>AnimationTiming Test: cancelAnimationFrame used to cancel request callback</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/#animation-frames">
+
+<style>
+ #animated {
+ background: blue;
+ color: white;
+ height: 100px;
+ width: 100px;
+ position: absolute;
+ }
+</style>
+
+<p>
+ Test passes if there is a filled blue square with 'Filler Text',
+ which moves from left to right repeatly, when click the 'stop' button,
+ the square stops.
+</p>
+<button onclick="stop()">stop</button>
+<div id="animated">Filler Text</div>
+
+<script>
+
+let requestId = 0;
+let requestAnimation = window.requestAnimationFrame;
+let cancelAnimation = window.cancelAnimationFrame;
+
+function animate(time) {
+ let div = document.getElementById("animated");
+ div.style.left = (time - animationStartTime) % 2000 / 4 + "px";
+ requestId = requestAnimation(animate);
+}
+
+function start() {
+ animationStartTime = window.performance.now();
+ requestId = requestAnimation(animate);
+}
+
+function stop() {
+ if (requestId) {
+ cancelAnimation(requestId);
+ requestId = 0;
+ }
+}
+
+start();
+
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/animation-frames/cancel-invoked.html b/testing/web-platform/tests/html/webappapis/animation-frames/cancel-invoked.html
new file mode 100644
index 0000000000..d075c0fdac
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/animation-frames/cancel-invoked.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<html>
+ <head>
+ <title>cancelAnimationFrame does nothing</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="help" href="https://w3c.github.io/web-performance/specs/RequestAnimationFrame/Overview.html#dom-windowanimationtiming-cancelanimationframe"/>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ test(function (t) {
+ window.cancelAnimationFrame(42);
+ assert_true(true);
+ }, "cancelAnimationFrame does nothing if there is no callback with the given handle");
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/html/webappapis/animation-frames/cancel-pending.html b/testing/web-platform/tests/html/webappapis/animation-frames/cancel-pending.html
new file mode 100644
index 0000000000..9c9aff511d
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/animation-frames/cancel-pending.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>cancelAnimationFrame cancels a pending animation frame callback</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#run-the-animation-frame-callbacks">
+<div id="log"></div>
+<script>
+async_test(t => {
+ let didCall = false;
+
+ function callbackOne() {
+ cancelAnimationFrame(twoHandle);
+ requestAnimationFrame(t.step_func(() => {
+ assert_false(didCall, 'Should NOT have called the second callback');
+ t.done();
+ }));
+ }
+
+ function callbackTwo() {
+ didCall = true;
+ }
+
+ requestAnimationFrame(callbackOne);
+ const twoHandle = requestAnimationFrame(callbackTwo);
+}, 'cancelAnimationFrame cancels a pending animation frame callback');
+</script>
diff --git a/testing/web-platform/tests/html/webappapis/animation-frames/same-dispatch-time.html b/testing/web-platform/tests/html/webappapis/animation-frames/same-dispatch-time.html
new file mode 100644
index 0000000000..28e94f1e33
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/animation-frames/same-dispatch-time.html
@@ -0,0 +1,31 @@
+<!doctype html>
+<html>
+ <head>
+ <title>requestAnimationFrame in queue get the same timestamp</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="help" href="http://w3c.github.io/animation-timing/#dfn-invoke-callbacks-algorithm"/>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ async_test(function (t) {
+ var a = 0, b = 0;
+
+ /* REASONING:
+ * These two methods that will be called with a timestamp. Because
+ * they execute right after eachother, they're added to the same
+ * queue and SHOULD be timestamped with the same value.
+ */
+ requestAnimationFrame(t.step_func(function() { a = arguments[0]; }));
+ requestAnimationFrame(t.step_func(function() {
+ b = arguments[0];
+ assert_not_equals(a, 0);
+ assert_not_equals(b, 0);
+ assert_equals(a, b);
+ t.done();
+ }));
+ }, "requestAnimationFrame will timestamp events in the same queue with the same time");
+ </script>
+ </body>
+</html>