browser_animation_setCurrentTime.js (1528B)
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 AnimationsActor allows changing many players' currentTimes at once. 7 8 add_task(async function () { 9 const { target, walker, animations } = await initAnimationsFrontForUrl( 10 MAIN_DOMAIN + "animation.html" 11 ); 12 13 await testSetCurrentTimes(walker, animations); 14 15 await target.destroy(); 16 gBrowser.removeCurrentTab(); 17 }); 18 19 async function testSetCurrentTimes(walker, animations) { 20 ok(animations.setCurrentTimes, "The AnimationsActor has the right method"); 21 22 info("Retrieve multiple animated node and its animation players"); 23 24 const nodeMulti = await walker.querySelector( 25 walker.rootNode, 26 ".multiple-animations" 27 ); 28 const players = await animations.getAnimationPlayersForNode(nodeMulti); 29 30 Assert.greater(players.length, 1, "Node has more than 1 animation player"); 31 32 info("Try to set multiple current times at once"); 33 // Assume that all animations were created at same time. 34 const createdTime = players[1].state.createdTime; 35 await animations.setCurrentTimes(players, createdTime + 500, true); 36 37 info("Get the states of players and verify their correctness"); 38 for (let i = 0; i < players.length; i++) { 39 const state = await players[i].getCurrentState(); 40 is(state.playState, "paused", `Player ${i + 1} is paused`); 41 is( 42 parseInt(state.currentTime.toPrecision(4), 10), 43 500, 44 `Player ${i + 1} has the right currentTime` 45 ); 46 } 47 }