summaryrefslogtreecommitdiffstats
path: root/devtools/client/memory/test/browser/browser_memory_individuals_01.js
blob: eae8248c3602c36fbda51c04f88f4d23048dade9 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

// Sanity test that we can show census group individuals, and then go back to
// the previous view.

"use strict";

const {
  individualsState,
  viewState,
  censusState,
} = require("devtools/client/memory/constants");
const { changeViewAndRefresh, changeView } = require("devtools/client/memory/actions/view");

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

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

  dispatch(changeView(viewState.CENSUS));

  // Take a snapshot and wait for the census to finish.

  const takeSnapshotButton = doc.getElementById("take-snapshot");
  EventUtils.synthesizeMouseAtCenter(takeSnapshotButton, {}, panel.panelWin);

  yield waitUntilState(store, state => {
    return state.snapshots.length === 1 &&
           state.snapshots[0].census &&
           state.snapshots[0].census.state === censusState.SAVED;
  });

  // Click on the first individuals button found, and wait for the individuals
  // to be fetched.

  const individualsButton = doc.querySelector(".individuals-button");
  EventUtils.synthesizeMouseAtCenter(individualsButton, {}, panel.panelWin);

  yield waitUntilState(store, state => {
    return state.view.state === viewState.INDIVIDUALS &&
           state.individuals &&
           state.individuals.state === individualsState.FETCHED;
  });

  ok(doc.getElementById("shortest-paths"),
     "Should be showing the shortest paths component");
  ok(doc.querySelector(".heap-tree-item"),
     "Should be showing the individuals");

  // Go back to the previous view.

  const popViewButton = doc.getElementById("pop-view-button");
  ok(popViewButton, "Should be showing the #pop-view-button");
  EventUtils.synthesizeMouseAtCenter(popViewButton, {}, panel.panelWin);

  yield waitUntilState(store, state => {
    return state.view.state === viewState.CENSUS;
  });

  ok(!doc.getElementById("shortest-paths"),
     "Should not be showing the shortest paths component anymore");
});