tor-browser

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

browser_animation_unhandledActorPlayers.js (2458B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Check that calling AnimationsActor method taking AnimationPlayerActor arrays (pauseSome,
      7 // playSome, setCurrentTimes, setPlaybackRates) with instances that are not handled by
      8 // the AnimationsActor anymore doesn't throw nor trigger unexpected animations (see Bug 2001590).
      9 
     10 add_task(async function () {
     11  const { target, walker, animations } = await initAnimationsFrontForUrl(
     12    `data:text/html,<meta charset=utf8>${encodeURIComponent(`
     13    <style>
     14      #target {
     15        animation: my-anim 1s infinite alternate;
     16 
     17        &.still {
     18          animation: none;
     19        }
     20      }
     21      @keyframes my-anim {
     22        to {
     23          background-color: tomato;
     24        }
     25      }
     26    </style>
     27    <div id=target>Hello</div>`)}`
     28  );
     29 
     30  info("Retrieve an animated node");
     31  const node = await walker.querySelector(walker.rootNode, "#target");
     32 
     33  const getAnimationPlayersForTargetNode = () =>
     34    animations.getAnimationPlayersForNode(node);
     35 
     36  info("Retrieve the animation player for the node");
     37  const players = await getAnimationPlayersForTargetNode();
     38  is(players.length, 1, "Got one animation player");
     39  const animationPlayer = players[0];
     40 
     41  info("Stop the animation on the node");
     42  await node.modifyAttributes([
     43    {
     44      attributeName: "class",
     45      newValue: "still",
     46    },
     47  ]);
     48 
     49  // Wait until we're not getting the animation anymore
     50  await waitFor(async () => {
     51    return (await getAnimationPlayersForTargetNode()).length === 0;
     52  });
     53 
     54  info("Call methodes with outdated animationplayer front");
     55  const onPause = animations.pauseSome([animationPlayer]);
     56  const onPlay = animations.playSome([animationPlayer]);
     57  const onCurrentTimeSet = animations.setCurrentTimes(
     58    [animationPlayer],
     59    1,
     60    true
     61  );
     62  const onPlaybackRateSet = animations.setPlaybackRates([animationPlayer], 10);
     63 
     64  await onPause;
     65  ok(true, "pauseSome succeeded");
     66 
     67  await onPlay;
     68  ok(true, "playSome succedded");
     69 
     70  await onCurrentTimeSet;
     71  ok(true, "setCurrentTimes succedded");
     72 
     73  await onPlaybackRateSet;
     74  ok(true, "setPlaybackRates succedded");
     75 
     76  // wait for a bit so we would get notified about new animations
     77  await wait(500);
     78  is(
     79    (await getAnimationPlayersForTargetNode()).length,
     80    0,
     81    "No players were created after calling those methods"
     82  );
     83 
     84  await target.destroy();
     85  gBrowser.removeCurrentTab();
     86 });