diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/server/tests/browser/browser_animation_playPauseSeveral.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/tests/browser/browser_animation_playPauseSeveral.js')
-rw-r--r-- | devtools/server/tests/browser/browser_animation_playPauseSeveral.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/devtools/server/tests/browser/browser_animation_playPauseSeveral.js b/devtools/server/tests/browser/browser_animation_playPauseSeveral.js new file mode 100644 index 0000000000..d478a801d0 --- /dev/null +++ b/devtools/server/tests/browser/browser_animation_playPauseSeveral.js @@ -0,0 +1,67 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Check that the AnimationsActor can pause/play a given list of animations at once. + +// List of selectors that match "all" animated nodes in the test page. +// This list misses a bunch of animated nodes on purpose. Only the ones that +// have infinite animations are listed. This is done to avoid intermittents +// caused when finite animations are already done playing by the time the test +// runs. +const ALL_ANIMATED_NODES = [ + ".simple-animation", + ".multiple-animations", + ".delayed-animation", +]; + +add_task(async function () { + const { target, walker, animations } = await initAnimationsFrontForUrl( + MAIN_DOMAIN + "animation.html" + ); + + info("Pause all animations in the test document"); + await toggleAndCheckStates(walker, animations, ALL_ANIMATED_NODES, "paused"); + + info("Play all animations in the test document"); + await toggleAndCheckStates(walker, animations, ALL_ANIMATED_NODES, "running"); + + await target.destroy(); + gBrowser.removeCurrentTab(); +}); + +async function toggleAndCheckStates(walker, animations, selectors, playState) { + info( + "Checking the playState of all the nodes that have infinite running " + + "animations" + ); + + for (const selector of selectors) { + const players = await getPlayersFor(walker, animations, selector); + + if (playState === "paused") { + await animations.pauseSome(players); + } else { + await animations.playSome(players); + } + + info("Getting the AnimationPlayerFront for node " + selector); + const player = players[0]; + await checkPlayState(player, selector, playState); + } +} + +async function getPlayersFor(walker, animations, selector) { + const node = await walker.querySelector(walker.rootNode, selector); + return animations.getAnimationPlayersForNode(node); +} + +async function checkPlayState(player, selector, expectedState) { + const state = await player.getCurrentState(); + is( + state.playState, + expectedState, + "The playState of node " + selector + " is " + expectedState + ); +} |