Bug 1171821 - Children markers should not be hidden when filtering out their parent markers. r=vp
authorJordan Santell <jsantell@mozilla.com>
Tue, 09 Jun 2015 15:36:52 -0700
changeset 279675 99f99d774fa3cea30621c7337b55624448498b94
parent 279674 f408cb6966411651e096021f5828a058b2feeeb9
child 279676 3dff06c8adbcfd8cb86681879f080dd0f9407f8c
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvp
bugs1171821
milestone41.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 1171821 - Children markers should not be hidden when filtering out their parent markers. r=vp
browser/devtools/performance/modules/logic/waterfall-utils.js
browser/devtools/performance/test/browser.ini
browser/devtools/performance/test/browser_timeline-filters-01.js
browser/devtools/performance/test/browser_timeline-filters-02.js
browser/devtools/performance/test/browser_timeline-filters.js
browser/devtools/performance/views/details-waterfall.js
--- a/browser/devtools/performance/modules/logic/waterfall-utils.js
+++ b/browser/devtools/performance/modules/logic/waterfall-utils.js
@@ -2,33 +2,38 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 /**
  * Utility functions for collapsing markers into a waterfall.
  */
 
-loader.lazyRequireGetter(this, "getBlueprintFor",
-  "devtools/performance/marker-utils", true);
+loader.lazyRequireGetter(this, "MarkerUtils",
+  "devtools/performance/marker-utils");
 
 /**
  * Collapses markers into a tree-like structure.
  * @param object markerNode
  * @param array markersList
+ * @param array filter
  */
-function collapseMarkersIntoNode({ markerNode, markersList }) {
+function collapseMarkersIntoNode({ markerNode, markersList, filter }) {
   let { getCurrentParentNode, collapseMarker, addParentNode, popParentNode } = createParentNodeFactory(markerNode);
 
   for (let i = 0, len = markersList.length; i < len; i++) {
     let curr = markersList[i];
 
+    // If this marker type should not be displayed, just skip
+    if (!MarkerUtils.isMarkerValid(curr, filter)) {
+      continue;
+    }
+
     let parentNode = getCurrentParentNode();
-    let blueprint = getBlueprintFor(curr);
-
+    let blueprint = MarkerUtils.getBlueprintFor(curr);
     let collapse = blueprint.collapseFunc || (() => null);
     let peek = distance => markersList[i + distance];
 
     let collapseInfo = collapse(parentNode, curr, peek);
     if (collapseInfo) {
       let { collapse, toParent, finalize } = collapseInfo;
 
       // If `toParent` is an object, use it as the next parent marker
--- a/browser/devtools/performance/test/browser.ini
+++ b/browser/devtools/performance/test/browser.ini
@@ -131,14 +131,15 @@ support-files =
 [browser_profiler_tree-view-03.js]
 [browser_profiler_tree-view-04.js]
 [browser_profiler_tree-view-05.js]
 [browser_profiler_tree-view-06.js]
 [browser_profiler_tree-view-07.js]
 [browser_profiler_tree-view-08.js]
 [browser_profiler_tree-view-09.js]
 [browser_profiler_tree-view-10.js]
-[browser_timeline-filters.js]
+[browser_timeline-filters-01.js]
+[browser_timeline-filters-02.js]
 [browser_timeline-waterfall-background.js]
 [browser_timeline-waterfall-generic.js]
 [browser_timeline-waterfall-rerender.js]
 [browser_timeline-waterfall-sidebar.js]
 skip-if = os == 'linux' # Bug 1161817
rename from browser/devtools/performance/test/browser_timeline-filters.js
rename to browser/devtools/performance/test/browser_timeline-filters-01.js
new file mode 100644
--- /dev/null
+++ b/browser/devtools/performance/test/browser_timeline-filters-02.js
@@ -0,0 +1,46 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests markers filtering mechanism.
+ */
+
+const URL = EXAMPLE_URL + "doc_innerHTML.html";
+
+function* spawnTest() {
+  let { panel } = yield initPerformance(URL);
+  let { $, $$, EVENTS, PerformanceController, OverviewView, WaterfallView } = panel.panelWin;
+
+  yield startRecording(panel);
+  ok(true, "Recording has started.");
+
+  yield waitUntil(() => {
+    let markers = PerformanceController.getCurrentRecording().getMarkers();
+    return markers.some(m => m.name == "Parse HTML") &&
+           markers.some(m => m.name == "Javascript");
+  });
+
+  let waterfallRendered = WaterfallView.once(EVENTS.WATERFALL_RENDERED);
+  yield stopRecording(panel);
+
+  $("#filter-button").click();
+  let filterJS = $("menuitem[marker-type=Javascript]");
+
+  yield waterfallRendered;
+
+  ok($(".waterfall-marker-bar[type=Javascript]"), "Found at least one 'Javascript' marker");
+  ok(!$(".waterfall-marker-bar[type='Parse HTML']"), "Found no Parse HTML markers as they are nested still");
+
+  EventUtils.synthesizeMouseAtCenter(filterJS, {type: "mouseup"}, panel.panelWin);
+  yield Promise.all([
+    WaterfallView.once(EVENTS.WATERFALL_RENDERED),
+    once(filterJS, "command")
+  ]);
+
+  ok(!$(".waterfall-marker-bar[type=Javascript]"), "Javascript markers are all hidden.");
+  ok($(".waterfall-marker-bar[type='Parse HTML']"),
+    "Found at least one 'Parse HTML' marker still visible after hiding JS markers");
+
+  yield teardown(panel);
+  finish();
+}
--- a/browser/devtools/performance/views/details-waterfall.js
+++ b/browser/devtools/performance/views/details-waterfall.js
@@ -108,16 +108,20 @@ let WaterfallView = Heritage.extend(Deta
     });
   },
 
   /**
    * Called whenever an observed pref is changed.
    */
   _onObservedPrefChange: function(_, prefName) {
     this._hiddenMarkers = PerformanceController.getPref("hidden-markers");
+
+    // Clear the cache as we'll need to recompute the collapsed
+    // marker model
+    this._cache = new WeakMap();
   },
 
   /**
    * Called when MarkerDetails view emits an event to view source.
    */
   _onViewSource: function (_, file, line) {
     gToolbox.viewSourceInDebugger(file, line);
   },
@@ -132,16 +136,17 @@ let WaterfallView = Heritage.extend(Deta
       return cached;
     }
 
     let rootMarkerNode = WaterfallUtils.makeParentMarkerNode({ name: "(root)" });
 
     WaterfallUtils.collapseMarkersIntoNode({
       markerNode: rootMarkerNode,
       markersList: markers,
+      filter: this._hiddenMarkers
     });
 
     this._cache.set(markers, rootMarkerNode);
     return rootMarkerNode;
   },
 
   /**
    * Renders the waterfall tree.