Bug 1158862 - Rerendering waterfall graph ignores current selection, r=jsantell
authorVictor Porof <vporof@mozilla.com>
Wed, 27 May 2015 17:24:33 -0400
changeset 245998 7d9ba48b1f3c88542fffc2c1fd25353f75984f19
parent 245997 37d2acb3c1f17c80435414c64b94116cee5bbcd1
child 245999 634e5b445a5723e39757dc27b926360d8a1b2e2c
push id60333
push userryanvm@gmail.com
push dateThu, 28 May 2015 14:20:47 +0000
treeherdermozilla-inbound@8225a3b75df6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjsantell
bugs1158862
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 1158862 - Rerendering waterfall graph ignores current selection, r=jsantell
browser/devtools/performance/test/browser.ini
browser/devtools/performance/test/browser_timeline-waterfall-rerender.js
browser/devtools/performance/test/browser_timeline-waterfall-sidebar.js
browser/devtools/performance/views/details-waterfall.js
--- a/browser/devtools/performance/test/browser.ini
+++ b/browser/devtools/performance/test/browser.ini
@@ -140,10 +140,11 @@ skip-if = e10s # GC events seem unreliab
 [browser_profiler_tree-view-07.js]
 [browser_profiler_tree-view-08.js]
 [browser_profiler_tree-view-09.js]
 [browser_profiler-frame-utils-01.js]
 [browser_timeline-blueprint.js]
 [browser_timeline-filters.js]
 [browser_timeline-waterfall-background.js]
 [browser_timeline-waterfall-generic.js]
+[browser_timeline-waterfall-rerender.js]
 [browser_timeline-waterfall-sidebar.js]
 [browser_waterfall-collapse.js]
new file mode 100644
--- /dev/null
+++ b/browser/devtools/performance/test/browser_timeline-waterfall-rerender.js
@@ -0,0 +1,48 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests if the waterfall remembers the selection when rerendering.
+ */
+
+function* spawnTest() {
+  let { target, panel } = yield initPerformance(SIMPLE_URL);
+  let { $, $$, EVENTS, PerformanceController, OverviewView, WaterfallView } = panel.panelWin;
+
+  yield startRecording(panel);
+  ok(true, "Recording has started.");
+
+  let updated = 0;
+  OverviewView.on(EVENTS.OVERVIEW_RENDERED, () => updated++);
+
+  ok((yield waitUntil(() => updated > 0)),
+    "The overview graphs were updated a bunch of times.");
+  ok((yield waitUntil(() => PerformanceController.getCurrentRecording().getMarkers().length > 0)),
+    "There are some markers available.");
+
+  yield stopRecording(panel);
+  ok(true, "Recording has ended.");
+
+  let initialBarsCount = $$(".waterfall-marker-bar").length;
+
+  // Select a portion of the overview.
+  let timeline = OverviewView.graphs.get("timeline");
+  let rerendered = WaterfallView.once(EVENTS.WATERFALL_RENDERED);
+  timeline.setSelection({ start: 0, end: timeline.width / 2 })
+  yield rerendered;
+
+  let beforeResizeBarsCount = $$(".waterfall-marker-bar").length;
+  ok(beforeResizeBarsCount < initialBarsCount,
+    "A subset of the total markers was selected.");
+
+  rerendered = WaterfallView.once(EVENTS.WATERFALL_RENDERED);
+  EventUtils.sendMouseEvent({ type: "mouseup" }, WaterfallView.detailsSplitter);
+  yield rerendered;
+
+  let afterResizeBarsCount = $$(".waterfall-marker-bar").length;
+  is(afterResizeBarsCount, beforeResizeBarsCount,
+    "The same subset of the total markers remained visible.");
+
+  yield teardown(panel);
+  finish();
+}
--- a/browser/devtools/performance/test/browser_timeline-waterfall-sidebar.js
+++ b/browser/devtools/performance/test/browser_timeline-waterfall-sidebar.js
@@ -29,17 +29,20 @@ function* spawnTest() {
            markers.some(m => m.name == "Reflow") &&
            markers.some(m => m.name == "Paint");
   });
 
   yield stopRecording(panel);
   ok(true, "Recording has ended.");
 
   // Select everything
-  OverviewView.graphs.get("timeline").setSelection({ start: 0, end: OverviewView.graphs.get("timeline").width })
+  let timeline = OverviewView.graphs.get("timeline");
+  let rerendered = WaterfallView.once(EVENTS.WATERFALL_RENDERED);
+  timeline.setSelection({ start: 0, end: timeline.width })
+  yield rerendered;
 
   let bars = $$(".waterfall-marker-bar");
   let markers = PerformanceController.getCurrentRecording().getMarkers();
 
   ok(bars.length > 2, "Got at least 3 markers (1)");
   ok(markers.length > 2, "Got at least 3 markers (2)");
 
   for (let i = 0; i < bars.length; i++) {
--- a/browser/devtools/performance/views/details-waterfall.js
+++ b/browser/devtools/performance/views/details-waterfall.js
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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";
 
+const WATERFALL_RESIZE_EVENTS_DRAIN = 100; // ms
 const MARKER_DETAILS_WIDTH = 200;
 
 /**
  * Waterfall view containing the timeline markers, controlled by DetailsView.
  */
 let WaterfallView = Heritage.extend(DetailsSubview, {
 
   observedPrefs: [
@@ -33,29 +34,31 @@ let WaterfallView = Heritage.extend(Deta
     this.headerContainer = $("#waterfall-header");
     this.breakdownContainer = $("#waterfall-breakdown");
     this.detailsContainer = $("#waterfall-details");
     this.detailsSplitter = $("#waterfall-view > splitter");
 
     this.details = new MarkerDetails($("#waterfall-details"), $("#waterfall-view > splitter"));
     this.details.on("resize", this._onResize);
     this.details.on("view-source", this._onViewSource);
+    window.addEventListener("resize", this._onResize);
 
     // TODO bug 1167093 save the previously set width, and ensure minimum width
     this.details.width = MARKER_DETAILS_WIDTH;
   },
 
   /**
    * Unbinds events.
    */
   destroy: function () {
     DetailsSubview.destroy.call(this);
 
     this.details.off("resize", this._onResize);
     this.details.off("view-source", this._onViewSource);
+    window.removeEventListener("resize", this._onResize);
   },
 
   /**
    * Method for handling all the set up for rendering a new waterfall.
    *
    * @param object interval [optional]
    *        The { startTime, endTime }, in milliseconds.
    */
@@ -85,18 +88,20 @@ let WaterfallView = Heritage.extend(Deta
       this.details.empty();
     }
   },
 
   /**
    * Called when the marker details view is resized.
    */
   _onResize: function () {
-    this._markersRoot.recalculateBounds();
-    this.render();
+    setNamedTimeout("waterfall-resize", WATERFALL_RESIZE_EVENTS_DRAIN, () => {
+      this._markersRoot.recalculateBounds();
+      this.render(OverviewView.getTimeInterval());
+    });
   },
 
   /**
    * Called whenever an observed pref is changed.
    */
   _onObservedPrefChange: function(_, prefName) {
     let blueprint = PerformanceController.getTimelineBlueprint();
     this._markersRoot.blueprint = blueprint;