diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/server/tests/browser/browser_animation_updatedState.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/tests/browser/browser_animation_updatedState.js')
-rw-r--r-- | devtools/server/tests/browser/browser_animation_updatedState.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/devtools/server/tests/browser/browser_animation_updatedState.js b/devtools/server/tests/browser/browser_animation_updatedState.js new file mode 100644 index 0000000000..bc681021f6 --- /dev/null +++ b/devtools/server/tests/browser/browser_animation_updatedState.js @@ -0,0 +1,65 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable mozilla/no-arbitrary-setTimeout */ + +"use strict"; + +// Check the animation player's updated state + +add_task(async function() { + const { target, walker, animations } = await initAnimationsFrontForUrl( + MAIN_DOMAIN + "animation.html" + ); + + await playStateIsUpdatedDynamically(walker, animations); + + await target.destroy(); + gBrowser.removeCurrentTab(); +}); + +async function playStateIsUpdatedDynamically(walker, animations) { + info("Getting the test node (which runs a very long animation)"); + // The animation lasts for 100s, to avoid intermittents. + const node = await walker.querySelector(walker.rootNode, ".long-animation"); + + info("Getting the animation player front for this node"); + const [player] = await animations.getAnimationPlayersForNode(node); + + let state = await player.getCurrentState(); + is( + state.playState, + "running", + "The playState is running while the animation is running" + ); + + info( + "Change the animation's currentTime to be near the end and wait for " + + "it to finish" + ); + const onFinished = waitForAnimationPlayState(player, "finished"); + // Set the currentTime to 98s, knowing that the animation lasts for 100s. + await animations.setCurrentTimes([player], 98 * 1000, false); + state = await onFinished; + is( + state.playState, + "finished", + "The animation has ended and the state has been updated" + ); + ok( + state.currentTime > player.initialState.currentTime, + "The currentTime has been updated" + ); +} + +async function waitForAnimationPlayState(player, playState) { + let state = {}; + while (state.playState !== playState) { + state = await player.getCurrentState(); + await wait(500); + } + return state; +} + +function wait(ms) { + return new Promise(r => setTimeout(r, ms)); +} |