tor-browser

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

browser_animation_animation-target.js (1887B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test for following AnimationTarget component works.
      7 // * element existance
      8 // * number of elements
      9 // * content of element
     10 // * title of inspect icon
     11 
     12 const TEST_DATA = [
     13  { expectedTextContent: "div.ball.animated" },
     14  { expectedTextContent: "div.ball.long" },
     15 ];
     16 
     17 add_task(async function () {
     18  await addTab(URL_ROOT + "doc_simple_animation.html");
     19  await removeAnimatedElementsExcept([".animated", ".long"]);
     20  const { animationInspector, panel } = await openAnimationInspector();
     21 
     22  info("Checking the animation target elements existance");
     23  const animationItemEls = panel.querySelectorAll(
     24    ".animation-list .animation-item"
     25  );
     26  is(
     27    animationItemEls.length,
     28    animationInspector.state.animations.length,
     29    "Number of animation target element should be same to number of animations " +
     30      "that displays"
     31  );
     32 
     33  for (let i = 0; i < animationItemEls.length; i++) {
     34    const animationItemEl = animationItemEls[i];
     35    animationItemEl.scrollIntoView(false);
     36    await waitUntil(() => animationItemEl.querySelector(".animation-target"));
     37 
     38    const animationTargetEl =
     39      animationItemEl.querySelector(".animation-target");
     40    ok(
     41      animationTargetEl,
     42      "The animation target element should be in each animation item element"
     43    );
     44 
     45    info("Checking the content of animation target");
     46    const testData = TEST_DATA[i];
     47    is(
     48      animationTargetEl.textContent,
     49      testData.expectedTextContent,
     50      "The target element's content is correct"
     51    );
     52    ok(
     53      animationTargetEl.querySelector(".objectBox"),
     54      "objectBox is in the page exists"
     55    );
     56    ok(
     57      animationTargetEl.querySelector(".highlight-node").title,
     58      INSPECTOR_L10N.getStr("inspector.nodePreview.highlightNodeLabel")
     59    );
     60  }
     61 });