browser_animation_getMultipleStates.js (1643B)
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 the duration, iterationCount and delay are retrieved correctly for 7 // multiple animations. 8 9 add_task(async function () { 10 const { target, walker, animations } = await initAnimationsFrontForUrl( 11 MAIN_DOMAIN + "animation.html" 12 ); 13 14 await playerHasAnInitialState(walker, animations); 15 16 await target.destroy(); 17 gBrowser.removeCurrentTab(); 18 }); 19 20 async function playerHasAnInitialState(walker, animations) { 21 let state = await getAnimationStateForNode( 22 walker, 23 animations, 24 ".delayed-multiple-animations", 25 0 26 ); 27 28 is(state.duration, 500, "The duration of the first animation is correct"); 29 is( 30 state.iterationCount, 31 10, 32 "The iterationCount of the first animation is correct" 33 ); 34 is(state.delay, 1000, "The delay of the first animation is correct"); 35 36 state = await getAnimationStateForNode( 37 walker, 38 animations, 39 ".delayed-multiple-animations", 40 1 41 ); 42 43 is(state.duration, 1000, "The duration of the second animation is correct"); 44 is( 45 state.iterationCount, 46 30, 47 "The iterationCount of the second animation is correct" 48 ); 49 is(state.delay, 750, "The delay of the second animation is correct"); 50 } 51 52 async function getAnimationStateForNode( 53 walker, 54 animations, 55 selector, 56 playerIndex 57 ) { 58 const node = await walker.querySelector(walker.rootNode, selector); 59 const players = await animations.getAnimationPlayersForNode(node); 60 const player = players[playerIndex]; 61 const state = await player.getCurrentState(); 62 return state; 63 }