Bug 1219584 - Test that we show the allocations recording hint at the correct times. r=jsantell
authorNick Fitzgerald <fitzgen@gmail.com>
Thu, 21 Jan 2016 22:15:39 -0500
changeset 281350 ecfe99ae6aae9107a7e0e200b3037bda18ad8060
parent 281349 7bc3b5df86f24abf78c6f389841293bb91490a39
child 281351 a80761b3a130a7b0d4cd881e5cc6c1641b524103
push id29935
push userphilringnalda@gmail.com
push dateSun, 24 Jan 2016 02:12:02 +0000
treeherdermozilla-central@a2e81822194a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsantell
bugs1219584
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1219584 - Test that we show the allocations recording hint at the correct times. r=jsantell
devtools/client/memory/components/heap.js
devtools/client/memory/test/chrome/chrome.ini
devtools/client/memory/test/chrome/head.js
devtools/client/memory/test/chrome/test_Heap_04.html
--- a/devtools/client/memory/components/heap.js
+++ b/devtools/client/memory/components/heap.js
@@ -253,17 +253,17 @@ const Heap = module.exports = createClas
 
   _renderCensus(state, census, diffing, onViewSourceInDebugger) {
     const contents = [];
 
     if (census.breakdown.by === "allocationStack"
         && census.report.children.length === 1
         && census.report.children[0].name === "noStack") {
       contents.push(dom.div({ className: "error no-allocation-stacks" },
-                           L10N.getStr("heapview.noAllocationStacks")));
+                            L10N.getStr("heapview.noAllocationStacks")));
     }
 
     contents.push(CensusHeader());
     contents.push(Census({
       onViewSourceInDebugger,
       diffing,
       census,
       onExpand: node => this.props.onCensusExpand(census, node),
--- a/devtools/client/memory/test/chrome/chrome.ini
+++ b/devtools/client/memory/test/chrome/chrome.ini
@@ -3,10 +3,11 @@ support-files =
   head.js
 
 [test_DominatorTree_01.html]
 [test_DominatorTree_02.html]
 [test_DominatorTreeItem_01.html]
 [test_Heap_01.html]
 [test_Heap_02.html]
 [test_Heap_03.html]
+[test_Heap_04.html]
 [test_Toolbar_01.html]
 [test_Toolbar_02.html]
--- a/devtools/client/memory/test/chrome/head.js
+++ b/devtools/client/memory/test/chrome/head.js
@@ -12,16 +12,17 @@ Cu.import("resource://devtools/client/sh
 var { require } = BrowserLoader("resource://devtools/client/memory/", this);
 
 var DevToolsUtils = require("devtools/shared/DevToolsUtils");
 DevToolsUtils.testing = true;
 var { immutableUpdate } = DevToolsUtils;
 
 var constants = require("devtools/client/memory/constants");
 var {
+  breakdowns,
   diffingState,
   dominatorTreeBreakdowns,
   dominatorTreeState,
   snapshotState,
   viewState
 } = constants;
 
 const {
new file mode 100644
--- /dev/null
+++ b/devtools/client/memory/test/chrome/test_Heap_04.html
@@ -0,0 +1,101 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+Test that we show the "hey you're not recording allocation stacks" message at the appropriate times.
+-->
+<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: "noStack",
+                         bytes: 1,
+                         totalBytes: 1,
+                         count: 1,
+                         totalCount: 1,
+                         children: undefined,
+                         id: 3,
+                         parent: 1,
+                       }
+                     ]
+                   },
+                   breakdown: breakdowns.allocationStack.breakdown,
+                 }),
+               }),
+             })), container);
+
+             ok(container.querySelector(".no-allocation-stacks"),
+                "When there are no allocation stacks, we should show the message");
+
+             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,
+                       }
+                     ]
+                   },
+                   breakdown: breakdowns.allocationStack.breakdown,
+                 }),
+               }),
+             })), container);
+
+             ok(!container.querySelector(".no-allocation-stacks"),
+                "When there are allocation stacks, we should not show the message");
+           } catch(e) {
+             ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
+           } finally {
+             SimpleTest.finish();
+           }
+         });
+        </script>
+    </pre>
+</body>
+</html>