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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests taking snapshots and default states.
*/
const TEST_URL =
"http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html";
const { viewState } = require("resource://devtools/client/memory/constants.js");
const {
changeView,
} = require("resource://devtools/client/memory/actions/view.js");
this.test = makeMemoryTest(TEST_URL, async function ({ panel }) {
const { gStore, document } = panel.panelWin;
const { getState, dispatch } = gStore;
dispatch(changeView(viewState.CENSUS));
let snapshotEls = document.querySelectorAll(
"#memory-tool-container .list li"
);
is(getState().snapshots.length, 0, "Starts with no snapshots in store");
is(snapshotEls.length, 0, "No snapshots rendered");
await takeSnapshot(panel.panelWin);
snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(getState().snapshots.length, 1, "One snapshot was created in store");
is(snapshotEls.length, 1, "One snapshot was rendered");
ok(
snapshotEls[0].classList.contains("selected"),
"Only snapshot has `selected` class"
);
await takeSnapshot(panel.panelWin);
snapshotEls = document.querySelectorAll("#memory-tool-container .list li");
is(getState().snapshots.length, 2, "Two snapshots created in store");
is(snapshotEls.length, 2, "Two snapshots rendered");
ok(
!snapshotEls[0].classList.contains("selected"),
"First snapshot no longer has `selected` class"
);
ok(
snapshotEls[1].classList.contains("selected"),
"Second snapshot has `selected` class"
);
await waitUntilCensusState(gStore, s => s.census, [
censusState.SAVED,
censusState.SAVED,
]);
ok(
document.querySelector(".heap-tree-item-name"),
"Should have rendered some tree items"
);
});
|