browser_animation_setPlaybackRate.js (1702B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Check that a player's playbackRate can be changed, and that multiple players 7 // can have their rates changed at the same time. 8 9 add_task(async function () { 10 const { target, walker, animations } = await initAnimationsFrontForUrl( 11 MAIN_DOMAIN + "animation.html" 12 ); 13 14 info("Retrieve an animated node"); 15 let node = await walker.querySelector(walker.rootNode, ".simple-animation"); 16 17 info("Retrieve the animation player for the node"); 18 const [player] = await animations.getAnimationPlayersForNode(node); 19 20 info("Change the rate to 10"); 21 await animations.setPlaybackRates([player], 10); 22 23 info("Query the state again"); 24 let state = await player.getCurrentState(); 25 is(state.playbackRate, 10, "The playbackRate was updated"); 26 27 info("Change the rate back to 1"); 28 await animations.setPlaybackRates([player], 1); 29 30 info("Query the state again"); 31 state = await player.getCurrentState(); 32 is(state.playbackRate, 1, "The playbackRate was changed back"); 33 34 info("Retrieve several animation players and set their rates"); 35 node = await walker.querySelector(walker.rootNode, "body"); 36 const players = await animations.getAnimationPlayersForNode(node); 37 38 info("Change all animations in <body> to .5 rate"); 39 await animations.setPlaybackRates(players, 0.5); 40 41 info("Query their states and check they are correct"); 42 for (const animPlayer of players) { 43 const animPlayerState = await animPlayer.getCurrentState(); 44 is(animPlayerState.playbackRate, 0.5, "The playbackRate was updated"); 45 } 46 47 await target.destroy(); 48 gBrowser.removeCurrentTab(); 49 });