browser_animation_getStateAfterFinished.js (2181B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 /* eslint-disable mozilla/no-arbitrary-setTimeout */ 4 5 "use strict"; 6 7 // Check that the right duration/iterationCount/delay are retrieved even when 8 // the node has multiple animations and one of them already ended before getting 9 // the player objects. 10 // See devtools/server/actors/animation.js |getPlayerIndex| for more 11 // information. 12 13 add_task(async function () { 14 const { target, walker, animations } = await initAnimationsFrontForUrl( 15 MAIN_DOMAIN + "animation.html" 16 ); 17 18 info("Retrieve a non animated node"); 19 const node = await walker.querySelector(walker.rootNode, ".not-animated"); 20 21 info("Apply the multiple-animations-2 class to start the animations"); 22 await node.modifyAttributes([ 23 { attributeName: "class", newValue: "multiple-animations-2" }, 24 ]); 25 26 info( 27 "Get the list of players, by the time this executes, the first, " + 28 "short, animation should have ended." 29 ); 30 let players = await animations.getAnimationPlayersForNode(node); 31 if (players.length === 3) { 32 info("The short animation hasn't ended yet, wait for a bit."); 33 // The animation lasts for 500ms, so 1000ms should do it. 34 await new Promise(resolve => setTimeout(resolve, 1000)); 35 36 info("And get the list again"); 37 players = await animations.getAnimationPlayersForNode(node); 38 } 39 40 is(players.length, 2, "2 animations remain on the node"); 41 42 is( 43 players[0].state.duration, 44 100000, 45 "The duration of the first animation is correct" 46 ); 47 is( 48 players[0].state.delay, 49 2000, 50 "The delay of the first animation is correct" 51 ); 52 is( 53 players[0].state.iterationCount, 54 null, 55 "The iterationCount of the first animation is correct" 56 ); 57 58 is( 59 players[1].state.duration, 60 300000, 61 "The duration of the second animation is correct" 62 ); 63 is( 64 players[1].state.delay, 65 1000, 66 "The delay of the second animation is correct" 67 ); 68 is( 69 players[1].state.iterationCount, 70 100, 71 "The iterationCount of the second animation is correct" 72 ); 73 74 await target.destroy(); 75 gBrowser.removeCurrentTab(); 76 });