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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/* 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 {
dominatorTreeState,
viewState,
} = require("resource://devtools/client/memory/constants.js");
const {
changeViewAndRefresh,
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 ({ panel }) {
const heapWorker = panel.panelWin.gHeapAnalysesClient;
const store = panel.panelWin.gStore;
const { dispatch } = store;
const doc = panel.panelWin.document;
dispatch(changeView(viewState.CENSUS));
const takeSnapshotButton = doc.getElementById("take-snapshot");
EventUtils.synthesizeMouseAtCenter(takeSnapshotButton, {}, panel.panelWin);
await waitUntilState(
store,
state =>
state.snapshots.length === 1 &&
state.snapshots[0].census &&
state.snapshots[0].census.state === censusState.SAVING
);
let filterInput = doc.getElementById("filter");
EventUtils.synthesizeMouseAtCenter(filterInput, {}, panel.panelWin);
EventUtils.sendString("js::Shape", panel.panelWin);
await waitUntilState(
store,
state =>
state.snapshots.length === 1 &&
state.snapshots[0].census &&
state.snapshots[0].census.state === censusState.SAVING
);
ok(true, "adding a filter string should trigger census recompute");
await waitUntilState(
store,
state =>
state.snapshots.length === 1 &&
state.snapshots[0].census &&
state.snapshots[0].census.state === censusState.SAVED
);
let nameElem = doc.querySelector(".heap-tree-item-field.heap-tree-item-name");
ok(nameElem, "Should get a tree item row with a name");
is(
nameElem.textContent.trim(),
"js::Shape",
"the tree item should be the one we filtered for"
);
is(
filterInput.value,
"js::Shape",
"and filter input contains the user value"
);
// Now switch the dominator view, then switch back to census view
// and check that the filter word is still correctly applied
dispatch(changeViewAndRefresh(viewState.DOMINATOR_TREE, heapWorker));
ok(true, "change view to dominator tree");
// Wait for the dominator tree to be computed and fetched.
await waitUntilDominatorTreeState(store, [dominatorTreeState.LOADED]);
ok(true, "computed and fetched the dominator tree.");
dispatch(changeViewAndRefresh(viewState.CENSUS, heapWorker));
ok(true, "change view back to census");
await waitUntilState(
store,
state =>
state.snapshots.length === 1 &&
state.snapshots[0].census &&
state.snapshots[0].census.state === censusState.SAVED
);
nameElem = doc.querySelector(".heap-tree-item-field.heap-tree-item-name");
filterInput = doc.getElementById("filter");
ok(nameElem, "Should still get a tree item row with a name");
is(
nameElem.textContent.trim(),
"js::Shape",
"the tree item should still be the one we filtered for"
);
is(
filterInput.value,
"js::Shape",
"and filter input still contains the user value"
);
});
|