Bug 1239750 - Refactor DAMP openToolbox, closeToolbox, and reloadPage to mutate results state;r=fitzgen
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 20 Jan 2016 20:42:58 -0800
changeset 280734 57cd47c177f6
parent 280733 e1f6239bfa33
child 280735 24afa30a759c
push id17139
push userbgrinstead@mozilla.com
push dateThu, 21 Jan 2016 04:44:26 +0000
treeherderfx-team@63e4b33812a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1239750
milestone46.0a1
Bug 1239750 - Refactor DAMP openToolbox, closeToolbox, and reloadPage to mutate results state;r=fitzgen
testing/talos/talos/tests/devtools/addon/content/damp.js
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -34,53 +34,57 @@ Damp.prototype = {
     });
   },
 
   closeCurrentTab: function() {
     this._win.BrowserCloseTabOrWindow();
     return this._win.gBrowser.selectedTab;
   },
 
-  reloadPage: function(name) {
+  reloadPage: function() {
     let startReloadTimestamp = performance.now();
     return new Promise((resolve, reject) => {
       let browser = gBrowser.selectedBrowser;
       let self = this;
       browser.addEventListener("load", function onload() {
         browser.removeEventListener("load", onload, true);
         let stopReloadTimestamp = performance.now();
-        self._results.push({name: name + ".reload.DAMP", value: stopReloadTimestamp - startReloadTimestamp});
-        resolve();
+        resolve({
+          time: stopReloadTimestamp - startReloadTimestamp
+        });
       }, true);
       browser.reload();
     });
   },
 
-  openToolbox: function (name, tool = "webconsole") {
+  openToolbox: function (tool = "webconsole") {
     let tab = getActiveTab(getMostRecentBrowserWindow());
     let target = devtools.TargetFactory.forTab(tab);
     let startRecordTimestamp = performance.now();
     let showPromise = gDevTools.showToolbox(target, tool);
 
     return showPromise.then(toolbox => {
       let stopRecordTimestamp = performance.now();
-      this._results.push({name: name + ".open.DAMP", value: stopRecordTimestamp - startRecordTimestamp});
-
-      return toolbox;
+      return {
+        toolbox,
+        time: stopRecordTimestamp - startRecordTimestamp
+      };
     });
   },
 
-  closeToolbox: function(name) {
+  closeToolbox: function() {
     let tab = getActiveTab(getMostRecentBrowserWindow());
     let target = devtools.TargetFactory.forTab(tab);
     let startRecordTimestamp = performance.now();
     let closePromise = gDevTools.closeToolbox(target);
     return closePromise.then(() => {
       let stopRecordTimestamp = performance.now();
-      this._results.push({name: name + ".close.DAMP", value: stopRecordTimestamp - startRecordTimestamp});
+      return {
+        time: stopRecordTimestamp - startRecordTimestamp
+      };
     });
   },
 
   saveHeapSnapshot: function(label) {
     let tab = getActiveTab(getMostRecentBrowserWindow());
     let target = devtools.TargetFactory.forTab(tab);
     let toolbox = gDevTools.getToolbox(target);
     let panel = toolbox.getCurrentPanel();
@@ -140,73 +144,90 @@ Damp.prototype = {
       name: label + ".takeCensus",
       value: end - start
     });
 
     return Promise.resolve();
   },
 
   _getToolLoadingTests: function(url, label) {
+
+    let openToolboxAndLog = Task.async(function*(name, tool) {
+      let {time, toolbox} = yield this.openToolbox(tool);
+      this._results.push({name: name + ".open.DAMP", value: time });
+      return toolbox;
+    }.bind(this));
+
+    let closeToolboxAndLog = Task.async(function*(name) {
+      let {time} = yield this.closeToolbox();
+      this._results.push({name: name + ".close.DAMP", value: time });
+    }.bind(this));
+
+    let reloadPageAndLog = Task.async(function*(name) {
+      let {time} = yield this.reloadPage();
+      this._results.push({name: name + ".reload.DAMP", value: time });
+    }.bind(this));
+
     let subtests = {
       webconsoleOpen: Task.async(function*() {
         yield this.testSetup(url);
-        yield this.openToolbox(label + ".webconsole", "webconsole");
-        yield this.reloadPage(label + ".webconsole");
-        yield this.closeToolbox(label + ".webconsole");
+        yield openToolboxAndLog(label + ".webconsole", "webconsole");
+        yield reloadPageAndLog(label + ".webconsole");
+        yield closeToolboxAndLog(label + ".webconsole");
         yield this.testTeardown();
       }),
 
       inspectorOpen: Task.async(function*() {
         yield this.testSetup(url);
-        yield this.openToolbox(label + ".inspector", "inspector");
-        yield this.reloadPage(label + ".inspector");
-        yield this.closeToolbox(label + ".inspector");
+        yield openToolboxAndLog(label + ".inspector", "inspector");
+        yield reloadPageAndLog(label + ".inspector");
+        yield closeToolboxAndLog(label + ".inspector");
         yield this.testTeardown();
       }),
 
       debuggerOpen: Task.async(function*() {
         yield this.testSetup(url);
-        yield this.openToolbox(label + ".jsdebugger", "jsdebugger");
-        yield this.reloadPage(label + ".jsdebugger");
-        yield this.closeToolbox(label + ".jsdebugger");
+        yield openToolboxAndLog(label + ".jsdebugger", "jsdebugger");
+        yield reloadPageAndLog(label + ".jsdebugger");
+        yield closeToolboxAndLog(label + ".jsdebugger");
         yield this.testTeardown();
       }),
 
       styleEditorOpen: Task.async(function*() {
         yield this.testSetup(url);
-        yield this.openToolbox(label + ".styleeditor", "styleeditor");
-        yield this.reloadPage(label + ".styleeditor");
-        yield this.closeToolbox(label + ".styleeditor");
+        yield openToolboxAndLog(label + ".styleeditor", "styleeditor");
+        yield reloadPageAndLog(label + ".styleeditor");
+        yield closeToolboxAndLog(label + ".styleeditor");
         yield this.testTeardown();
       }),
 
       performanceOpen: Task.async(function*() {
         yield this.testSetup(url);
-        yield this.openToolbox(label + ".performance", "performance");
-        yield this.reloadPage(label + ".performance");
-        yield this.closeToolbox(label + ".performance");
+        yield openToolboxAndLog(label + ".performance", "performance");
+        yield reloadPageAndLog(label + ".performance");
+        yield closeToolboxAndLog(label + ".performance");
         yield this.testTeardown();
       }),
 
       netmonitorOpen: Task.async(function*() {
         yield this.testSetup(url);
-        yield this.openToolbox(label + ".netmonitor", "netmonitor");
-        yield this.reloadPage(label + ".netmonitor");
-        yield this.closeToolbox(label + ".netmonitor");
+        yield openToolboxAndLog(label + ".netmonitor", "netmonitor");
+        yield reloadPageAndLog(label + ".netmonitor");
+        yield closeToolboxAndLog(label + ".netmonitor");
         yield this.testTeardown();
       }),
 
       saveAndReadHeapSnapshot: Task.async(function*() {
         yield this.testSetup(url);
-        yield this.openToolbox(label + ".memory", "memory");
-        yield this.reloadPage(label + ".memory");
+        yield openToolboxAndLog(label + ".memory", "memory");
+        yield reloadPageAndLog(label + ".memory");
         yield this.saveHeapSnapshot(label);
         yield this.readHeapSnapshot(label);
         yield this.takeCensus(label);
-        yield this.closeToolbox(label + ".memory");
+        yield closeToolboxAndLog(label + ".memory");
         yield this.testTeardown();
       }),
     };
 
     // Construct the sequence array: config.repeat times config.subtests
     let config = this._config;
     let sequenceArray = [];
     for (var i in config.subtests) {