tor-browser

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

browser_animation_getSubTreeAnimations.js (1807B)


      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 the AnimationsActor can retrieve all animations inside a node's
      7 // subtree (but not going into iframes).
      8 
      9 const URL = MAIN_DOMAIN + "animation.html";
     10 
     11 // Import inspector's shared head.
     12 Services.scriptloader.loadSubScript(
     13  "chrome://mochitests/content/browser/devtools/client/inspector/test/shared-head.js",
     14  this
     15 );
     16 
     17 add_task(async function () {
     18  info("Creating a test document with 2 iframes containing animated nodes");
     19 
     20  const { inspector, target, walker, animations } =
     21    await initAnimationsFrontForUrl(
     22      "data:text/html;charset=utf-8," +
     23        "<iframe id='iframe' src='" +
     24        URL +
     25        "'></iframe>"
     26    );
     27 
     28  info("Try retrieving all animations from the root doc's <body> node");
     29  const rootBody = await walker.querySelector(walker.rootNode, "body");
     30  let players = await animations.getAnimationPlayersForNode(rootBody);
     31  is(players.length, 0, "The node has no animation players");
     32 
     33  info("Retrieve all animations from the iframe's <body> node");
     34  const frameBody = await getNodeFrontInFrames(["#iframe", "body"], inspector);
     35  const animationsForFrame = await frameBody.targetFront.getFront("animations");
     36  players = await animationsForFrame.getAnimationPlayersForNode(frameBody);
     37 
     38  // Testing for a hard-coded number of animations here would intermittently
     39  // fail depending on how fast or slow the test is (indeed, the test page
     40  // contains short transitions, and delayed animations). So just make sure we
     41  // at least have the infinitely running animations.
     42  Assert.greaterOrEqual(
     43    players.length,
     44    4,
     45    "All subtree animations were retrieved"
     46  );
     47 
     48  await target.destroy();
     49  gBrowser.removeCurrentTab();
     50 });