summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/animation/test/summary-graph_computed-timing-path_head.js
blob: 8516e96fa3fa7f0739f75eb6ffc98f3457805edd (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

/* import-globals-from head.js */

/**
 * Test for computed timing path on summary graph using given test data.
 * @param {Array} testData
 */
// eslint-disable-next-line no-unused-vars
async function testComputedTimingPath(testData) {
  await addTab(URL_ROOT + "doc_multi_timings.html");
  await removeAnimatedElementsExcept(testData.map(t => `.${t.targetClass}`));
  const { panel } = await openAnimationInspector();

  for (const {
    expectedDelayPath,
    expectedEndDelayPath,
    expectedForwardsPath,
    expectedIterationPathList,
    isInfinity,
    targetClass,
  } of testData) {
    const animationItemEl = await findAnimationItemByTargetSelector(
      panel,
      `.${targetClass}`
    );

    info(`Checking computed timing path existance for ${targetClass}`);
    const computedTimingPathEl = animationItemEl.querySelector(
      ".animation-computed-timing-path"
    );
    ok(
      computedTimingPathEl,
      "The computed timing path element should be in each animation item element"
    );

    info(`Checking delay path for ${targetClass}`);
    const delayPathEl = computedTimingPathEl.querySelector(
      ".animation-delay-path"
    );

    if (expectedDelayPath) {
      ok(delayPathEl, "delay path should be existance");
      assertPathSegments(delayPathEl, true, expectedDelayPath);
    } else {
      ok(!delayPathEl, "delay path should not be existance");
    }

    info(`Checking iteration path list for ${targetClass}`);
    const iterationPathEls = computedTimingPathEl.querySelectorAll(
      ".animation-iteration-path"
    );
    is(
      iterationPathEls.length,
      expectedIterationPathList.length,
      `Number of iteration path should be ${expectedIterationPathList.length}`
    );

    for (const [j, iterationPathEl] of iterationPathEls.entries()) {
      assertPathSegments(iterationPathEl, true, expectedIterationPathList[j]);

      info(`Checking infinity ${targetClass}`);
      if (isInfinity && j >= 1) {
        ok(
          iterationPathEl.classList.contains("infinity"),
          "iteration path should have 'infinity' class"
        );
      } else {
        ok(
          !iterationPathEl.classList.contains("infinity"),
          "iteration path should not have 'infinity' class"
        );
      }
    }

    info(`Checking endDelay path for ${targetClass}`);
    const endDelayPathEl = computedTimingPathEl.querySelector(
      ".animation-enddelay-path"
    );

    if (expectedEndDelayPath) {
      ok(endDelayPathEl, "endDelay path should be existance");
      assertPathSegments(endDelayPathEl, true, expectedEndDelayPath);
    } else {
      ok(!endDelayPathEl, "endDelay path should not be existance");
    }

    info(`Checking forwards fill path for ${targetClass}`);
    const forwardsPathEl = computedTimingPathEl.querySelector(
      ".animation-fill-forwards-path"
    );

    if (expectedForwardsPath) {
      ok(forwardsPathEl, "forwards path should be existance");
      assertPathSegments(forwardsPathEl, true, expectedForwardsPath);
    } else {
      ok(!forwardsPathEl, "forwards path should not be existance");
    }
  }
}