tor-browser

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

test_dominator_trees_08.js (2742B)


      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 // and that the dominator tree is re-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 finish being fetched.
     43  await waitUntilState(
     44    store,
     45    state =>
     46      state.snapshots[0] &&
     47      state.snapshots[0].dominatorTree &&
     48      state.snapshots[0].dominatorTree.state === dominatorTreeState.LOADED
     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.
     67  dispatch(
     68    setLabelDisplayAndRefresh(heapWorker, labelDisplays.allocationStack)
     69  );
     70 
     71  await waitUntilState(
     72    store,
     73    state =>
     74      state.snapshots[0].dominatorTree.state === dominatorTreeState.FETCHING
     75  );
     76  ok(
     77    true,
     78    "switching display types caused the dominator tree to be fetched " +
     79      "again."
     80  );
     81 
     82  await waitUntilState(
     83    store,
     84    state =>
     85      state.snapshots[0].dominatorTree.state === dominatorTreeState.LOADED
     86  );
     87  equal(
     88    getState().snapshots[0].dominatorTree.display,
     89    labelDisplays.allocationStack,
     90    "The new dominator tree's display is allocationStack"
     91  );
     92  equal(
     93    getState().labelDisplay,
     94    labelDisplays.allocationStack,
     95    "as is our requested dominator tree display"
     96  );
     97 
     98  heapWorker.destroy();
     99  await front.detach();
    100 });