summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-animations/CSSAnimation-pausing.tentative.html
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/css/css-animations/CSSAnimation-pausing.tentative.html
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/css/css-animations/CSSAnimation-pausing.tentative.html')
-rw-r--r--testing/web-platform/tests/css/css-animations/CSSAnimation-pausing.tentative.html259
1 files changed, 259 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-animations/CSSAnimation-pausing.tentative.html b/testing/web-platform/tests/css/css-animations/CSSAnimation-pausing.tentative.html
new file mode 100644
index 0000000000..156a1afa96
--- /dev/null
+++ b/testing/web-platform/tests/css/css-animations/CSSAnimation-pausing.tentative.html
@@ -0,0 +1,259 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Pausing a CSSAnimation</title>
+<link rel="help"
+ href="https://drafts.csswg.org/css-animations-2/#animation-play-state">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support/testcommon.js"></script>
+<style>
+@keyframes anim {
+ 0% { margin-left: 0px }
+ 100% { margin-left: 10000px }
+}
+</style>
+<div id="log"></div>
+<script>
+'use strict';
+
+promise_test(async t => {
+ const div = addDiv(t);
+ div.style.animation = 'anim 1000s paused';
+
+ const animation = div.getAnimations()[0];
+ animation.play();
+
+ await animation.ready;
+ await waitForNextFrame();
+
+ assert_equals(
+ animation.playState,
+ 'running',
+ 'Play state is running after calling play()'
+ );
+
+ // Flip the animation-play-state back and forth to check it has no effect
+
+ div.style.animationPlayState = 'running';
+ getComputedStyle(div).animationPlayState;
+ div.style.animationPlayState = 'paused';
+ getComputedStyle(div).animationPlayState;
+
+ assert_equals(
+ animation.playState,
+ 'running',
+ 'Should still be running even after flipping the animation-play-state'
+ );
+}, 'play() overrides animation-play-state');
+
+promise_test(async t => {
+ const div = addDiv(t);
+ div.style.animation = 'anim 100s infinite paused';
+
+ const animation = div.getAnimations()[0];
+ animation.playbackRate = -1;
+ animation.currentTime = -1;
+
+ assert_throws_dom('InvalidStateError', () => {
+ animation.play();
+ }, 'Trying to play a reversed infinite animation should throw');
+
+ assert_equals(
+ animation.playState,
+ 'paused',
+ 'Animation should still be paused'
+ );
+
+ animation.playbackRate = 1;
+ div.style.animationPlayState = 'running';
+
+ assert_equals(
+ animation.playState,
+ 'running',
+ 'Changing the animation-play-state should play the animation'
+ );
+}, 'play() does NOT override the animation-play-state if there was an error');
+
+promise_test(async t => {
+ const div = addDiv(t);
+ div.style.animation = 'anim 1000s paused';
+
+ const animation = div.getAnimations()[0];
+ animation.pause();
+
+ div.style.animationPlayState = 'running';
+ getComputedStyle(div).animationPlayState;
+
+ await animation.ready;
+ await waitForNextFrame();
+
+ assert_equals(animation.playState, 'paused', 'playState is paused ');
+
+ // Flip the animation-play-state back and forth to check it has no effect
+
+ div.style.animationPlayState = 'paused';
+ getComputedStyle(div).animationPlayState;
+ div.style.animationPlayState = 'running';
+ getComputedStyle(div).animationPlayState;
+
+ assert_equals(
+ animation.playState,
+ 'paused',
+ 'Should still be paused even after flipping the animation-play-state'
+ );
+}, 'pause() overrides animation-play-state');
+
+promise_test(async t => {
+ const div = addDiv(t);
+ div.style.animation = 'anim 100s paused';
+
+ const animation = div.getAnimations()[0];
+ animation.reverse();
+
+ assert_equals(
+ animation.playState,
+ 'running',
+ 'Play state is running after calling reverse()'
+ );
+
+ // Flip the animation-play-state back and forth to check it has no effect
+
+ div.style.animationPlayState = 'running';
+ getComputedStyle(div).animationPlayState;
+ div.style.animationPlayState = 'paused';
+ getComputedStyle(div).animationPlayState;
+
+ assert_equals(
+ animation.playState,
+ 'running',
+ 'Should still be running even after flipping the animation-play-state'
+ );
+}, 'reverse() overrides animation-play-state when it starts playing the'
+ + ' animation');
+
+promise_test(async t => {
+ const div = addDiv(t);
+ div.style.animation = 'anim 100s';
+
+ const animation = div.getAnimations()[0];
+ animation.reverse();
+
+ assert_equals(
+ animation.playState,
+ 'running',
+ 'Play state is running after calling reverse()'
+ );
+
+ div.style.animationPlayState = 'paused';
+ getComputedStyle(div).animationPlayState;
+
+ assert_equals(
+ animation.playState,
+ 'paused',
+ 'Should be paused after changing the animation-play-state'
+ );
+}, 'reverse() does NOT override animation-play-state if the animation is'
+ + ' already running');
+
+promise_test(async t => {
+ const div = addDiv(t);
+ div.style.animation = 'anim 100s';
+
+ const animation = div.getAnimations()[0];
+ animation.startTime = null;
+
+ assert_equals(
+ animation.playState,
+ 'paused',
+ 'Play state is paused after setting the start time to null'
+ );
+
+ // Flip the animation-play-state back and forth to check it has no effect
+
+ div.style.animationPlayState = 'paused';
+ getComputedStyle(div).animationPlayState;
+ div.style.animationPlayState = 'running';
+ getComputedStyle(div).animationPlayState;
+
+ assert_equals(
+ animation.playState,
+ 'paused',
+ 'Should still be paused even after flipping the animation-play-state'
+ );
+}, 'Setting the startTime to null overrides animation-play-state if the'
+ + ' animation is already running');
+
+promise_test(async t => {
+ const div = addDiv(t);
+ div.style.animation = 'anim 100s paused';
+
+ const animation = div.getAnimations()[0];
+ animation.startTime = document.timeline.currentTime;
+
+ assert_equals(
+ animation.playState,
+ 'running',
+ 'Play state is running after setting the start time to non-null'
+ );
+
+ // Flip the animation-play-state back and forth to check it has no effect
+
+ div.style.animationPlayState = 'running';
+ getComputedStyle(div).animationPlayState;
+ div.style.animationPlayState = 'paused';
+ getComputedStyle(div).animationPlayState;
+
+ assert_equals(
+ animation.playState,
+ 'running',
+ 'Should still be running even after flipping the animation-play-state'
+ );
+}, 'Setting the startTime to non-null overrides animation-play-state if the'
+ + ' animation is paused');
+
+promise_test(async t => {
+ const div = addDiv(t);
+ div.style.animation = 'anim 100s';
+
+ const animation = div.getAnimations()[0];
+ animation.startTime = document.timeline.currentTime;
+
+ div.style.animationPlayState = 'paused';
+ getComputedStyle(div).animationPlayState;
+
+ assert_equals(
+ animation.playState,
+ 'paused',
+ 'Should be paused after changing the animation-play-state'
+ );
+}, 'Setting the startTime to non-null does NOT override the'
+ + ' animation-play-state if the animation is already running');
+
+promise_test(async t => {
+ const div = addDiv(t, { style: 'animation: anim 1000s' });
+ const animation = div.getAnimations()[0];
+ let readyPromiseRun = false;
+
+ await animation.ready;
+
+ div.style.animationPlayState = 'paused';
+ assert_true(animation.pending && animation.playState === 'paused',
+ 'Animation is pause-pending');
+
+ // Set current time
+ animation.currentTime = 5 * MS_PER_SEC;
+ assert_equals(animation.playState, 'paused',
+ 'Animation is paused immediately after setting currentTime');
+ assert_equals(animation.startTime, null,
+ 'Animation startTime is unresolved immediately after ' +
+ 'setting currentTime');
+ assert_equals(animation.currentTime, 5 * MS_PER_SEC,
+ 'Animation currentTime does not change when forcing a ' +
+ 'pause operation to complete');
+
+ // The ready promise should now be resolved. If it's not then test will
+ // probably time out before anything else happens that causes it to resolve.
+ await animation.ready;
+}, 'Setting the current time completes a pending pause');
+
+</script>