tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

summary-graph_computed-timing-path_head.js (3240B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /* import-globals-from head.js */
      7 
      8 /**
      9 * Test for computed timing path on summary graph using given test data.
     10 *
     11 * @param {Array} testData
     12 */
     13 // eslint-disable-next-line no-unused-vars
     14 async function testComputedTimingPath(testData) {
     15  await addTab(URL_ROOT + "doc_multi_timings.html");
     16  await removeAnimatedElementsExcept(testData.map(t => `.${t.targetClass}`));
     17  const { panel } = await openAnimationInspector();
     18 
     19  for (const {
     20    expectedDelayPath,
     21    expectedEndDelayPath,
     22    expectedForwardsPath,
     23    expectedIterationPathList,
     24    isInfinity,
     25    targetClass,
     26  } of testData) {
     27    const animationItemEl = await findAnimationItemByTargetSelector(
     28      panel,
     29      `.${targetClass}`
     30    );
     31 
     32    info(`Checking computed timing path existance for ${targetClass}`);
     33    const computedTimingPathEl = animationItemEl.querySelector(
     34      ".animation-computed-timing-path"
     35    );
     36    ok(
     37      computedTimingPathEl,
     38      "The computed timing path element should be in each animation item element"
     39    );
     40 
     41    info(`Checking delay path for ${targetClass}`);
     42    const delayPathEl = computedTimingPathEl.querySelector(
     43      ".animation-delay-path"
     44    );
     45 
     46    if (expectedDelayPath) {
     47      ok(delayPathEl, "delay path should be existance");
     48      assertPathSegments(delayPathEl, true, expectedDelayPath);
     49    } else {
     50      ok(!delayPathEl, "delay path should not be existance");
     51    }
     52 
     53    info(`Checking iteration path list for ${targetClass}`);
     54    const iterationPathEls = computedTimingPathEl.querySelectorAll(
     55      ".animation-iteration-path"
     56    );
     57    is(
     58      iterationPathEls.length,
     59      expectedIterationPathList.length,
     60      `Number of iteration path should be ${expectedIterationPathList.length}`
     61    );
     62 
     63    for (const [j, iterationPathEl] of iterationPathEls.entries()) {
     64      assertPathSegments(iterationPathEl, true, expectedIterationPathList[j]);
     65 
     66      info(`Checking infinity ${targetClass}`);
     67      if (isInfinity && j >= 1) {
     68        ok(
     69          iterationPathEl.classList.contains("infinity"),
     70          "iteration path should have 'infinity' class"
     71        );
     72      } else {
     73        ok(
     74          !iterationPathEl.classList.contains("infinity"),
     75          "iteration path should not have 'infinity' class"
     76        );
     77      }
     78    }
     79 
     80    info(`Checking endDelay path for ${targetClass}`);
     81    const endDelayPathEl = computedTimingPathEl.querySelector(
     82      ".animation-enddelay-path"
     83    );
     84 
     85    if (expectedEndDelayPath) {
     86      ok(endDelayPathEl, "endDelay path should be existance");
     87      assertPathSegments(endDelayPathEl, true, expectedEndDelayPath);
     88    } else {
     89      ok(!endDelayPathEl, "endDelay path should not be existance");
     90    }
     91 
     92    info(`Checking forwards fill path for ${targetClass}`);
     93    const forwardsPathEl = computedTimingPathEl.querySelector(
     94      ".animation-fill-forwards-path"
     95    );
     96 
     97    if (expectedForwardsPath) {
     98      ok(forwardsPathEl, "forwards path should be existance");
     99      assertPathSegments(forwardsPathEl, true, expectedForwardsPath);
    100    } else {
    101      ok(!forwardsPathEl, "forwards path should not be existance");
    102    }
    103  }
    104 }