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_setPlaybackRate.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_setPlaybackRate.js')
-rw-r--r-- | devtools/server/tests/browser/browser_animation_setPlaybackRate.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/devtools/server/tests/browser/browser_animation_setPlaybackRate.js b/devtools/server/tests/browser/browser_animation_setPlaybackRate.js new file mode 100644 index 0000000000..b14751b114 --- /dev/null +++ b/devtools/server/tests/browser/browser_animation_setPlaybackRate.js @@ -0,0 +1,49 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Check that a player's playbackRate can be changed, and that multiple players +// can have their rates changed at the same time. + +add_task(async function () { + const { target, walker, animations } = await initAnimationsFrontForUrl( + MAIN_DOMAIN + "animation.html" + ); + + info("Retrieve an animated node"); + let node = await walker.querySelector(walker.rootNode, ".simple-animation"); + + info("Retrieve the animation player for the node"); + const [player] = await animations.getAnimationPlayersForNode(node); + + info("Change the rate to 10"); + await animations.setPlaybackRates([player], 10); + + info("Query the state again"); + let state = await player.getCurrentState(); + is(state.playbackRate, 10, "The playbackRate was updated"); + + info("Change the rate back to 1"); + await animations.setPlaybackRates([player], 1); + + info("Query the state again"); + state = await player.getCurrentState(); + is(state.playbackRate, 1, "The playbackRate was changed back"); + + info("Retrieve several animation players and set their rates"); + node = await walker.querySelector(walker.rootNode, "body"); + const players = await animations.getAnimationPlayersForNode(node); + + info("Change all animations in <body> to .5 rate"); + await animations.setPlaybackRates(players, 0.5); + + info("Query their states and check they are correct"); + for (const animPlayer of players) { + const animPlayerState = await animPlayer.getCurrentState(); + is(animPlayerState.playbackRate, 0.5, "The playbackRate was updated"); + } + + await target.destroy(); + gBrowser.removeCurrentTab(); +}); |