tor-browser

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

test_dominator_trees_09.js (2626B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test that we can change the display with which we describe a dominator tree
      7 // while the dominator tree is in the middle of being fetched.
      8 
      9 const {
     10  dominatorTreeState,
     11  viewState,
     12  labelDisplays,
     13  treeMapState,
     14 } = require("resource://devtools/client/memory/constants.js");
     15 const {
     16  setLabelDisplayAndRefresh,
     17 } = require("resource://devtools/client/memory/actions/label-display.js");
     18 const {
     19  changeView,
     20 } = require("resource://devtools/client/memory/actions/view.js");
     21 const {
     22  takeSnapshotAndCensus,
     23 } = require("resource://devtools/client/memory/actions/snapshot.js");
     24 
     25 add_task(async function () {
     26  const front = new StubbedMemoryFront();
     27  const heapWorker = new HeapAnalysesClient();
     28  await front.attach();
     29  const store = Store();
     30  const { getState, dispatch } = store;
     31 
     32  dispatch(changeView(viewState.DOMINATOR_TREE));
     33 
     34  dispatch(takeSnapshotAndCensus(front, heapWorker));
     35  await waitUntilCensusState(store, s => s.treeMap, [treeMapState.SAVED]);
     36  ok(
     37    !getState().snapshots[0].dominatorTree,
     38    "There shouldn't be a dominator tree model yet since it is not computed " +
     39      "until we switch to the dominators view."
     40  );
     41 
     42  // Wait for the dominator tree to start fetching.
     43  await waitUntilState(
     44    store,
     45    state =>
     46      state.snapshots[0] &&
     47      state.snapshots[0].dominatorTree &&
     48      state.snapshots[0].dominatorTree.state === dominatorTreeState.FETCHING
     49  );
     50 
     51  ok(
     52    getState().labelDisplay,
     53    "We have a default display for describing nodes in a dominator tree"
     54  );
     55  equal(
     56    getState().labelDisplay,
     57    labelDisplays.coarseType,
     58    "and the default is coarse type"
     59  );
     60  equal(
     61    getState().labelDisplay,
     62    getState().snapshots[0].dominatorTree.display,
     63    "and the newly computed dominator tree has that display"
     64  );
     65 
     66  // Switch to the allocationStack display while we are still fetching the
     67  // dominator tree.
     68  dispatch(
     69    setLabelDisplayAndRefresh(heapWorker, labelDisplays.allocationStack)
     70  );
     71 
     72  // Wait for the dominator tree to finish being fetched.
     73  await waitUntilState(
     74    store,
     75    state =>
     76      state.snapshots[0].dominatorTree.state === dominatorTreeState.LOADED
     77  );
     78 
     79  equal(
     80    getState().snapshots[0].dominatorTree.display,
     81    labelDisplays.allocationStack,
     82    "The new dominator tree's display is allocationStack"
     83  );
     84  equal(
     85    getState().labelDisplay,
     86    labelDisplays.allocationStack,
     87    "as is our requested dominator tree display"
     88  );
     89 
     90  heapWorker.destroy();
     91  await front.detach();
     92 });