tor-browser

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

test_action-clear-snapshots_01.js (1280B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test clearSnapshots deletes snapshots with READ censuses
      7 
      8 const {
      9  takeSnapshotAndCensus,
     10  clearSnapshots,
     11 } = require("resource://devtools/client/memory/actions/snapshot.js");
     12 const { actions } = require("resource://devtools/client/memory/constants.js");
     13 const {
     14  treeMapState,
     15 } = require("resource://devtools/client/memory/constants.js");
     16 
     17 add_task(async function () {
     18  const front = new StubbedMemoryFront();
     19  const heapWorker = new HeapAnalysesClient();
     20  await front.attach();
     21  const store = Store();
     22  const { getState, dispatch } = store;
     23 
     24  dispatch(takeSnapshotAndCensus(front, heapWorker));
     25  await waitUntilCensusState(store, s => s.treeMap, [treeMapState.SAVED]);
     26  ok(true, "snapshot created");
     27 
     28  ok(true, "dispatch clearSnapshots action");
     29  const deleteEvents = Promise.all([
     30    waitForDispatch(store, actions.DELETE_SNAPSHOTS_START),
     31    waitForDispatch(store, actions.DELETE_SNAPSHOTS_END),
     32  ]);
     33  dispatch(clearSnapshots(heapWorker));
     34  await deleteEvents;
     35  ok(true, "received delete snapshots events");
     36 
     37  equal(getState().snapshots.length, 0, "no snapshot remaining");
     38 
     39  heapWorker.destroy();
     40  await front.detach();
     41 });