tor-browser

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

browser_animation_reconstructState.js (1293B)


      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, even though the AnimationPlayerActor only sends the bits of its
      7 // state that change, the front reconstructs the whole state everytime.
      8 
      9 add_task(async function () {
     10  const { target, walker, animations } = await initAnimationsFrontForUrl(
     11    MAIN_DOMAIN + "animation.html"
     12  );
     13 
     14  await playerHasCompleteStateAtAllTimes(walker, animations);
     15 
     16  await target.destroy();
     17  gBrowser.removeCurrentTab();
     18 });
     19 
     20 async function playerHasCompleteStateAtAllTimes(walker, animations) {
     21  const node = await walker.querySelector(walker.rootNode, ".simple-animation");
     22  const [player] = await animations.getAnimationPlayersForNode(node);
     23 
     24  // Get the list of state key names from the initialstate.
     25  const keys = Object.keys(player.initialState);
     26 
     27  // Get the state over and over again and check that the object returned
     28  // contains all keys.
     29  // Normally, only the currentTime will have changed in between 2 calls.
     30  for (let i = 0; i < 10; i++) {
     31    await player.refreshState();
     32    keys.forEach(key => {
     33      Assert.notStrictEqual(
     34        typeof player.state[key],
     35        "undefined",
     36        "The state retrieved has key " + key
     37      );
     38    });
     39  }
     40 }