summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/browser/browser_animation_getMultipleStates.js
blob: 77e6a7722bd97c5394cd23d5d30a941696fd9449 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Check that the duration, iterationCount and delay are retrieved correctly for
// multiple animations.

add_task(async function () {
  const { target, walker, animations } = await initAnimationsFrontForUrl(
    MAIN_DOMAIN + "animation.html"
  );

  await playerHasAnInitialState(walker, animations);

  await target.destroy();
  gBrowser.removeCurrentTab();
});

async function playerHasAnInitialState(walker, animations) {
  let state = await getAnimationStateForNode(
    walker,
    animations,
    ".delayed-multiple-animations",
    0
  );

  is(state.duration, 500, "The duration of the first animation is correct");
  is(
    state.iterationCount,
    10,
    "The iterationCount of the first animation is correct"
  );
  is(state.delay, 1000, "The delay of the first animation is correct");

  state = await getAnimationStateForNode(
    walker,
    animations,
    ".delayed-multiple-animations",
    1
  );

  is(state.duration, 1000, "The duration of the second animation is correct");
  is(
    state.iterationCount,
    30,
    "The iterationCount of the second animation is correct"
  );
  is(state.delay, 750, "The delay of the second animation is correct");
}

async function getAnimationStateForNode(
  walker,
  animations,
  selector,
  playerIndex
) {
  const node = await walker.querySelector(walker.rootNode, selector);
  const players = await animations.getAnimationPlayersForNode(node);
  const player = players[playerIndex];
  const state = await player.getCurrentState();
  return state;
}