summaryrefslogtreecommitdiffstats
path: root/devtools/client/memory/test/browser/browser_memory_no_allocation_stacks.js
blob: b8b09b35d001a494dd4f9a49b601d0bc54202244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

// Sanity test that we can show allocation stack displays in the tree.

"use strict";

const {
  takeSnapshotAndCensus,
} = require("resource://devtools/client/memory/actions/snapshot.js");
const censusDisplayActions = require("resource://devtools/client/memory/actions/census-display.js");
const { viewState } = require("resource://devtools/client/memory/constants.js");
const {
  changeView,
} = require("resource://devtools/client/memory/actions/view.js");

const TEST_URL =
  "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html";

this.test = makeMemoryTest(TEST_URL, async function ({ tab, panel }) {
  const heapWorker = panel.panelWin.gHeapAnalysesClient;
  const { getState, dispatch } = panel.panelWin.gStore;
  const front = getState().front;
  const doc = panel.panelWin.document;

  dispatch(changeView(viewState.CENSUS));

  ok(!getState().allocations.recording, "Should not be recording allocagtions");

  await dispatch(takeSnapshotAndCensus(front, heapWorker));
  await dispatch(
    censusDisplayActions.setCensusDisplayAndRefresh(
      heapWorker,
      censusDisplays.allocationStack
    )
  );

  is(
    getState().censusDisplay.breakdown.by,
    "allocationStack",
    "Should be using allocation stack breakdown"
  );

  ok(
    !getState().allocations.recording,
    "Should still not be recording allocagtions"
  );

  ok(
    doc.querySelector(".no-allocation-stacks"),
    "Because we did not record allocations, " +
      "the no-allocation-stack warning should be visible"
  );
});