Bug 1241815 - Show a message when filtering yields no matches; r=jsantell

This commit is contained in:
Nick Fitzgerald 2016-03-23 13:08:29 -07:00
Родитель 97fdb27ffd
Коммит aded56b1da
5 изменённых файлов: 151 добавлений и 1 удалений

Просмотреть файл

@ -296,6 +296,18 @@ snapshot.state.saving-census=Saving census…
# state ERROR, used in the snapshot list view.
snapshot.state.error=Error
# LOCALIZATION NOTE (heapview.no-difference): Message displayed when there is no
# difference between two snapshots.
heapview.no-difference=No difference between the baseline and comparison.
# LOCALIZATION NOTE (heapview.none-match): Message displayed when there are no
# matches when filtering.
heapview.none-match=No matches.
# LOCALIZATION NOTE (heapview.none-match): Message displayed when there report
# is empty.
heapview.empty=Empty.
# LOCALIZATION NOTE (heapview.noAllocationStacks): The message displayed to
# users when selecting a display by "allocation stack" but no allocation stacks
# were recorded in the heap snapshot.

Просмотреть файл

@ -256,10 +256,18 @@ const Heap = module.exports = createClass({
},
_renderCensus(state, census, diffing, onViewSourceInDebugger) {
assert(census.report, "Should not render census that does not have a report");
if (!census.report.children) {
const msg = diffing ? L10N.getStr("heapview.no-difference")
: census.filter ? L10N.getStr("heapview.none-match")
: /* else */ L10N.getStr("heapview.empty");
return this._renderHeapView(state, dom.div({ className: "empty" }, msg));
}
const contents = [];
if (census.display.breakdown.by === "allocationStack"
&& census.report
&& census.report.children
&& census.report.children.length === 1
&& census.report.children[0].name === "noStack") {

Просмотреть файл

@ -11,6 +11,7 @@ support-files =
[test_Heap_02.html]
[test_Heap_03.html]
[test_Heap_04.html]
[test_Heap_05.html]
[test_ShortestPaths_01.html]
[test_ShortestPaths_02.html]
[test_Toolbar_01.html]

Просмотреть файл

@ -0,0 +1,128 @@
<!DOCTYPE HTML>
<html>
<!--
Test that we show a message when the census results are empty.
-->
<head>
<meta charset="utf-8">
<title>Tree component test</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<div id="container"></div>
<pre id="test">
<script src="head.js" type="application/javascript;version=1.8"></script>
<script type="application/javascript;version=1.8">
window.onload = Task.async(function* () {
try {
const container = document.getElementById("container");
yield renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, {
snapshot: immutableUpdate(TEST_HEAP_PROPS.snapshot, {
census: immutableUpdate(TEST_HEAP_PROPS.snapshot.census, {
report: {
bytes: 1,
totalBytes: 1,
count: 1,
totalCount: 1,
id: 1,
parent: undefined,
children: [
{
name: Cu.getJSTestingFunctions().saveStack(),
bytes: 1,
totalBytes: 1,
count: 1,
totalCount: 1,
children: undefined,
id: 2,
parent: 1,
},
{
name: "noStack",
bytes: 1,
totalBytes: 1,
count: 1,
totalCount: 1,
children: undefined,
id: 3,
parent: 1,
}
]
},
display: censusDisplays.allocationStack,
}),
}),
})), container);
ok(!container.querySelector(".empty"),
"When the report is not empty, we should not show the empty message");
// Empty Census Report
const emptyCensus = {
report: {
bytes: 0,
totalBytes: 0,
count: 0,
totalCount: 0,
id: 1,
parent: undefined,
children: undefined,
},
expanded: new Set(),
display: censusDisplays.allocationStack,
};
yield renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, {
snapshot: immutableUpdate(TEST_HEAP_PROPS.snapshot, {
census: immutableUpdate(TEST_HEAP_PROPS.snapshot.census, emptyCensus),
}),
})), container);
ok(container.querySelector(".empty"),
"When the report is empty in census view, we show the empty message");
ok(container.textContent.indexOf(L10N.getStr("heapview.empty")) >= 0);
// Empty Diffing Report
yield renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, {
view: viewState.DIFFING,
diffing: {
firstSnapshotId: 1,
secondSnapshotId: 2,
census: emptyCensus,
state: diffingState.TOOK_DIFF,
},
snapshot: null,
})), container);
ok(container.querySelector(".empty"),
"When the report is empty in diffing view, the empty message is shown");
ok(container.textContent.indexOf(L10N.getStr("heapview.no-difference")) >= 0);
// Empty Filtered Census
yield renderComponent(Heap(immutableUpdate(TEST_HEAP_PROPS, {
snapshot: immutableUpdate(TEST_HEAP_PROPS.snapshot, {
census: immutableUpdate(TEST_HEAP_PROPS.snapshot.census, immutableUpdate(emptyCensus, {
filter: "zzzz"
})),
}),
})), container);
ok(container.querySelector(".empty"),
"When the report is empty in census view w/ filter, we show the empty message");
ok(container.textContent.indexOf(L10N.getStr("heapview.none-match")) >= 0);
} catch(e) {
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
} finally {
SimpleTest.finish();
}
});
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -298,6 +298,7 @@ html, body, #app, #memory-tool {
#heap-view > .heap-view-panel > .snapshot-status,
#heap-view > .heap-view-panel > .take-snapshot,
#heap-view .empty,
#shortest-paths-select-node-msg {
margin: auto;
margin-top: 65px;