tor-browser

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

test_action_diffing_02.js (1558B)


      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 toggling diffing unselects all snapshots.
      7 
      8 const {
      9  censusState,
     10  viewState,
     11 } = require("resource://devtools/client/memory/constants.js");
     12 const {
     13  toggleDiffing,
     14 } = require("resource://devtools/client/memory/actions/diffing.js");
     15 const {
     16  takeSnapshotAndCensus,
     17 } = require("resource://devtools/client/memory/actions/snapshot.js");
     18 const {
     19  changeView,
     20 } = require("resource://devtools/client/memory/actions/view.js");
     21 
     22 add_task(async function () {
     23  const front = new StubbedMemoryFront();
     24  const heapWorker = new HeapAnalysesClient();
     25  await front.attach();
     26  const store = Store();
     27  const { getState, dispatch } = store;
     28 
     29  dispatch(changeView(viewState.CENSUS));
     30 
     31  equal(getState().diffing, null, "not diffing by default");
     32 
     33  dispatch(takeSnapshotAndCensus(front, heapWorker));
     34  dispatch(takeSnapshotAndCensus(front, heapWorker));
     35  dispatch(takeSnapshotAndCensus(front, heapWorker));
     36  await waitUntilCensusState(store, s => s.census, [
     37    censusState.SAVED,
     38    censusState.SAVED,
     39    censusState.SAVED,
     40  ]);
     41 
     42  ok(
     43    getState().snapshots.some(s => s.selected),
     44    "One of the new snapshots is selected"
     45  );
     46 
     47  dispatch(toggleDiffing());
     48  ok(getState().diffing, "now diffing after toggling");
     49 
     50  for (const s of getState().snapshots) {
     51    ok(
     52      !s.selected,
     53      "No snapshot should be selected after entering diffing mode"
     54    );
     55  }
     56 
     57  heapWorker.destroy();
     58  await front.detach();
     59 });