tor-browser

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

browser_memory_individuals_01.js (2251B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Sanity test that we can show census group individuals, and then go back to
      5 // the previous view.
      6 
      7 "use strict";
      8 
      9 const {
     10  individualsState,
     11  viewState,
     12 } = require("resource://devtools/client/memory/constants.js");
     13 const {
     14  changeView,
     15 } = require("resource://devtools/client/memory/actions/view.js");
     16 
     17 const TEST_URL =
     18  "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html";
     19 
     20 this.test = makeMemoryTest(TEST_URL, async function ({ panel }) {
     21  const store = panel.panelWin.gStore;
     22  const { dispatch } = store;
     23  const doc = panel.panelWin.document;
     24 
     25  dispatch(changeView(viewState.CENSUS));
     26 
     27  // Take a snapshot and wait for the census to finish.
     28 
     29  const takeSnapshotButton = doc.getElementById("take-snapshot");
     30  EventUtils.synthesizeMouseAtCenter(takeSnapshotButton, {}, panel.panelWin);
     31 
     32  await waitUntilState(store, state => {
     33    return (
     34      state.snapshots.length === 1 &&
     35      state.snapshots[0].census &&
     36      state.snapshots[0].census.state === censusState.SAVED
     37    );
     38  });
     39 
     40  // Click on the first individuals button found, and wait for the individuals
     41  // to be fetched.
     42 
     43  const individualsButton = doc.querySelector(".individuals-button");
     44  EventUtils.synthesizeMouseAtCenter(individualsButton, {}, panel.panelWin);
     45 
     46  await waitUntilState(store, state => {
     47    return (
     48      state.view.state === viewState.INDIVIDUALS &&
     49      state.individuals &&
     50      state.individuals.state === individualsState.FETCHED
     51    );
     52  });
     53 
     54  ok(
     55    doc.getElementById("shortest-paths"),
     56    "Should be showing the shortest paths component"
     57  );
     58  ok(doc.querySelector(".heap-tree-item"), "Should be showing the individuals");
     59 
     60  // Go back to the previous view.
     61 
     62  const popViewButton = doc.getElementById("pop-view-button");
     63  ok(popViewButton, "Should be showing the #pop-view-button");
     64  EventUtils.synthesizeMouseAtCenter(popViewButton, {}, panel.panelWin);
     65 
     66  await waitUntilState(store, state => {
     67    return state.view.state === viewState.CENSUS;
     68  });
     69 
     70  ok(
     71    !doc.getElementById("shortest-paths"),
     72    "Should not be showing the shortest paths component anymore"
     73  );
     74 });