tor-browser

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

browser_animation_keepFinished.js (1787B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 /* eslint-disable mozilla/no-arbitrary-setTimeout */
      4 
      5 "use strict";
      6 
      7 // Test that the AnimationsActor doesn't report finished animations as removed.
      8 // Indeed, animations that only have the "finished" playState can be modified
      9 // still, so we want the AnimationsActor to preserve the corresponding
     10 // AnimationPlayerActor.
     11 
     12 add_task(async function () {
     13  const { target, walker, animations } = await initAnimationsFrontForUrl(
     14    MAIN_DOMAIN + "animation.html"
     15  );
     16 
     17  info("Retrieve a non-animated node");
     18  const node = await walker.querySelector(walker.rootNode, ".not-animated");
     19 
     20  info("Retrieve the animation player for the node");
     21  let players = await animations.getAnimationPlayersForNode(node);
     22  is(players.length, 0, "The node has no animation players");
     23 
     24  info("Listen for new animations");
     25  let reportedMutations = [];
     26  function onMutations(mutations) {
     27    reportedMutations = [...reportedMutations, ...mutations];
     28  }
     29  animations.on("mutations", onMutations);
     30 
     31  info("Add a short animation on the node");
     32  await node.modifyAttributes([
     33    { attributeName: "class", newValue: "short-animation" },
     34  ]);
     35 
     36  info("Wait for longer than the animation's duration");
     37  await wait(2000);
     38 
     39  players = await animations.getAnimationPlayersForNode(node);
     40  is(players.length, 0, "The added animation is surely finished");
     41 
     42  is(reportedMutations.length, 1, "Only one mutation was reported");
     43  is(reportedMutations[0].type, "added", "The mutation was an addition");
     44 
     45  animations.off("mutations", onMutations);
     46 
     47  await target.destroy();
     48  gBrowser.removeCurrentTab();
     49 });
     50 
     51 function wait(ms) {
     52  return new Promise(resolve => {
     53    setTimeout(resolve, ms);
     54  });
     55 }