tor-browser

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

browser_animation_summary-graph_compositor.js (4096B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that when animations displayed in the timeline are running on the
      7 // compositor, they get a special icon and information in the tooltip.
      8 
      9 requestLongerTimeout(2);
     10 
     11 add_task(async function () {
     12  await addTab(URL_ROOT + "doc_simple_animation.html");
     13  await removeAnimatedElementsExcept([
     14    ".compositor-all",
     15    ".compositor-notall",
     16    ".no-compositor",
     17  ]);
     18  const { animationInspector, inspector, panel } =
     19    await openAnimationInspector();
     20 
     21  info("Check animation whose all properties are running on compositor");
     22  const summaryGraphAllEl = await findSummaryGraph(".compositor-all", panel);
     23  ok(
     24    summaryGraphAllEl.classList.contains("compositor"),
     25    "The element has the compositor css class"
     26  );
     27  ok(
     28    hasTooltip(
     29      summaryGraphAllEl,
     30      ANIMATION_L10N.getStr("player.allPropertiesOnCompositorTooltip")
     31    ),
     32    "The element has the right tooltip content"
     33  );
     34 
     35  info("Check animation is not running on compositor");
     36  const summaryGraphNoEl = await findSummaryGraph(".no-compositor", panel);
     37  ok(
     38    !summaryGraphNoEl.classList.contains("compositor"),
     39    "The element does not have the compositor css class"
     40  );
     41  ok(
     42    !hasTooltip(
     43      summaryGraphNoEl,
     44      ANIMATION_L10N.getStr("player.allPropertiesOnCompositorTooltip")
     45    ),
     46    "The element does not have oncompositor tooltip content"
     47  );
     48  ok(
     49    !hasTooltip(
     50      summaryGraphNoEl,
     51      ANIMATION_L10N.getStr("player.somePropertiesOnCompositorTooltip")
     52    ),
     53    "The element does not have oncompositor tooltip content"
     54  );
     55 
     56  info(
     57    "Select a node has animation whose some properties are running on compositor"
     58  );
     59  await selectNode(".compositor-notall", inspector);
     60  const summaryGraphEl = await findSummaryGraph(".compositor-notall", panel);
     61  ok(
     62    summaryGraphEl.classList.contains("compositor"),
     63    "The element has the compositor css class"
     64  );
     65  ok(
     66    hasTooltip(
     67      summaryGraphEl,
     68      ANIMATION_L10N.getStr("player.somePropertiesOnCompositorTooltip")
     69    ),
     70    "The element has the right tooltip content"
     71  );
     72 
     73  info("Check compositor sign after pausing");
     74  clickOnPauseResumeButton(animationInspector, panel);
     75  await waitUntil(() => !summaryGraphEl.classList.contains("compositor"));
     76  ok(
     77    true,
     78    "The element should not have the compositor css class after pausing"
     79  );
     80 
     81  info("Check compositor sign after resuming");
     82  clickOnPauseResumeButton(animationInspector, panel);
     83  await waitUntil(() => summaryGraphEl.classList.contains("compositor"));
     84  ok(true, "The element should have the compositor css class after resuming");
     85 
     86  info("Check compositor sign after rewind");
     87  clickOnRewindButton(animationInspector, panel);
     88  await waitUntil(() => !summaryGraphEl.classList.contains("compositor"));
     89  ok(
     90    true,
     91    "The element should not have the compositor css class after rewinding"
     92  );
     93  clickOnPauseResumeButton(animationInspector, panel);
     94  await waitUntil(() => summaryGraphEl.classList.contains("compositor"));
     95  ok(true, "The element should have the compositor css class after resuming");
     96 
     97  info("Check compositor sign after setting the current time");
     98  clickOnCurrentTimeScrubberController(animationInspector, panel, 0.5);
     99  await waitUntil(() => !summaryGraphEl.classList.contains("compositor"));
    100  ok(
    101    true,
    102    "The element should not have the compositor css class " +
    103      "after setting the current time"
    104  );
    105  clickOnPauseResumeButton(animationInspector, panel);
    106  await waitUntil(() => summaryGraphEl.classList.contains("compositor"));
    107  ok(true, "The element should have the compositor css class after resuming");
    108 });
    109 
    110 async function findSummaryGraph(selector, panel) {
    111  const animationItemEl = await findAnimationItemByTargetSelector(
    112    panel,
    113    selector
    114  );
    115  return animationItemEl.querySelector(".animation-summary-graph");
    116 }
    117 
    118 function hasTooltip(summaryGraphEl, expected) {
    119  const tooltip = summaryGraphEl.getAttribute("title");
    120  return tooltip.includes(expected);
    121 }