From aded56b1daa07f4f09ec82a6b0ff9953110afa34 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Wed, 23 Mar 2016 13:08:29 -0700 Subject: [PATCH] Bug 1241815 - Show a message when filtering yields no matches; r=jsantell --- .../client/locales/en-US/memory.properties | 12 ++ devtools/client/memory/components/heap.js | 10 +- devtools/client/memory/test/chrome/chrome.ini | 1 + .../memory/test/chrome/test_Heap_05.html | 128 ++++++++++++++++++ devtools/client/themes/memory.css | 1 + 5 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 devtools/client/memory/test/chrome/test_Heap_05.html diff --git a/devtools/client/locales/en-US/memory.properties b/devtools/client/locales/en-US/memory.properties index 6d5f4f19348d..88a678a7d7c3 100644 --- a/devtools/client/locales/en-US/memory.properties +++ b/devtools/client/locales/en-US/memory.properties @@ -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. diff --git a/devtools/client/memory/components/heap.js b/devtools/client/memory/components/heap.js index 4d722472a8e4..4965a295f736 100644 --- a/devtools/client/memory/components/heap.js +++ b/devtools/client/memory/components/heap.js @@ -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") { diff --git a/devtools/client/memory/test/chrome/chrome.ini b/devtools/client/memory/test/chrome/chrome.ini index 42fc2fa36bb5..774f4310ef52 100644 --- a/devtools/client/memory/test/chrome/chrome.ini +++ b/devtools/client/memory/test/chrome/chrome.ini @@ -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] diff --git a/devtools/client/memory/test/chrome/test_Heap_05.html b/devtools/client/memory/test/chrome/test_Heap_05.html new file mode 100644 index 000000000000..48bbb7125f1d --- /dev/null +++ b/devtools/client/memory/test/chrome/test_Heap_05.html @@ -0,0 +1,128 @@ + + + + + + Tree component test + + + + +
+
+        
+        
+    
+ + diff --git a/devtools/client/themes/memory.css b/devtools/client/themes/memory.css index 257d3a0693b2..4387599fac08 100644 --- a/devtools/client/themes/memory.css +++ b/devtools/client/themes/memory.css @@ -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;