Bug 1394804 - Lazy load all dependencies from DAMP. r=bgrins draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 29 Aug 2017 16:28:42 +0200
changeset 662446 b6d2956570ffd5c6432a986fe75fe7cdd15d067a
parent 662089 a5f163da8a9be5d2e86138c57d59be69723b5457
child 662447 9a3075eaad2938b19eb1afaf218b0ae2c5c6c8ea
push id79086
push userbmo:poirot.alex@gmail.com
push dateMon, 11 Sep 2017 17:57:03 +0000
reviewersbgrins
bugs1394804
milestone57.0a1
Bug 1394804 - Lazy load all dependencies from DAMP. r=bgrins MozReview-Commit-ID: EeT3bm6U2ZF
testing/talos/talos/tests/devtools/addon/content/damp.html
testing/talos/talos/tests/devtools/addon/content/damp.js
--- a/testing/talos/talos/tests/devtools/addon/content/damp.html
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.html
@@ -5,31 +5,31 @@
 
 <script type="application/x-javascript">
 // Empty subtests interpreted as all subtests, since otherwise meaningless.
 var config = {subtests: [], repeat: 1};
 var defaultConfig = {
   repeat: 1,
   rest: 100,
   subtests: {
+    inspectorOpen: true,
     webconsoleOpen: true,
-    inspectorOpen: true,
     debuggerOpen: true,
     styleEditorOpen: true,
     performanceOpen: true,
     netmonitorOpen: true,
     saveAndReadHeapSnapshot: true,
     consoleBulkLogging: true,
     consoleStreamLogging: true,
   }
 };
 
 var testsInfo = {
+  inspectorOpen: "Measure open/close toolbox on inspector panel",
   webconsoleOpen: "Measure open/close toolbox on webconsole panel",
-  inspectorOpen: "Measure open/close toolbox on inspector panel",
   debuggerOpen: "Measure open/close toolbox on debugger panel",
   styleEditorOpen: "Measure open/close toolbox on style editor panel",
   performanceOpen: "Measure open/close toolbox on performance panel",
   netmonitorOpen: "Measure open/close toolbox on network monitor panel",
   saveAndReadHeapSnapshot: "Measure open/close toolbox on memory panel and save/read heap snapshot",
   consoleBulkLogging: "Measure time for a bunch of sync console.log statements to appear",
   consoleStreamLogging: "Measure rAF on page during a stream of console.log statements",
 };
--- a/testing/talos/talos/tests/devtools/addon/content/damp.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp.js
@@ -1,16 +1,32 @@
-Components.utils.import("resource://devtools/client/framework/gDevTools.jsm");
-Components.utils.import("resource://gre/modules/Services.jsm");
+const { Services } = Components.utils.import("resource://gre/modules/Services.jsm", {});
+const { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
+const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
 
-const { devtools } =
-  Components.utils.import("resource://devtools/shared/Loader.jsm", {});
-const ThreadSafeChromeUtils = devtools.require("ThreadSafeChromeUtils");
-const { EVENTS } = devtools.require("devtools/client/netmonitor/src/constants");
-const { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
+XPCOMUtils.defineLazyGetter(this, "require", function () {
+  let { require } =
+    Components.utils.import("resource://devtools/shared/Loader.jsm", {});
+  return require;
+});
+XPCOMUtils.defineLazyGetter(this, "gDevTools", function () {
+  let { gDevTools } = require("devtools/client/framework/devtools");
+  return gDevTools;
+});
+XPCOMUtils.defineLazyGetter(this, "EVENTS", function () {
+  let { EVENTS } = require("devtools/client/netmonitor/src/constants");
+  return EVENTS;
+});
+XPCOMUtils.defineLazyGetter(this, "TargetFactory", function () {
+  let { TargetFactory } = require("devtools/client/framework/target");
+  return TargetFactory;
+});
+XPCOMUtils.defineLazyGetter(this, "ThreadSafeChromeUtils", function () {
+  return require("ThreadSafeChromeUtils");
+});
 
 const webserver = Services.prefs.getCharPref("addon.test.damp.webserver");
 
 const SIMPLE_URL = webserver + "/tests/devtools/addon/content/pages/simple.html";
 const COMPLICATED_URL = webserver + "/tests/tp5n/bild.de/www.bild.de/index.html";
 
 function getMostRecentBrowserWindow() {
   return Services.wm.getMostRecentWindow("navigator:browser");
@@ -60,44 +76,44 @@ Damp.prototype = {
         });
       }, {capture: true, once: true});
       browser.reload();
     });
   },
 
   openToolbox(tool = "webconsole") {
     let tab = getActiveTab(getMostRecentBrowserWindow());
-    let target = devtools.TargetFactory.forTab(tab);
+    let target = TargetFactory.forTab(tab);
     let startRecordTimestamp = performance.now();
     let showPromise = gDevTools.showToolbox(target, tool);
 
     return showPromise.then(toolbox => {
       let stopRecordTimestamp = performance.now();
       return {
         toolbox,
         time: stopRecordTimestamp - startRecordTimestamp
       };
     });
   },
 
   closeToolbox: Task.async(function* () {
     let tab = getActiveTab(getMostRecentBrowserWindow());
-    let target = devtools.TargetFactory.forTab(tab);
+    let target = TargetFactory.forTab(tab);
     yield target.client.waitForRequestsToSettle();
     let startRecordTimestamp = performance.now();
     yield gDevTools.closeToolbox(target);
     let stopRecordTimestamp = performance.now();
     return {
       time: stopRecordTimestamp - startRecordTimestamp
     };
   }),
 
   saveHeapSnapshot(label) {
     let tab = getActiveTab(getMostRecentBrowserWindow());
-    let target = devtools.TargetFactory.forTab(tab);
+    let target = TargetFactory.forTab(tab);
     let toolbox = gDevTools.getToolbox(target);
     let panel = toolbox.getCurrentPanel();
     let memoryFront = panel.panelWin.gFront;
 
     let start = performance.now();
     return memoryFront.saveHeapSnapshot().then(filePath => {
       this._heapSnapshotFilePath = filePath;
       let end = performance.now();
@@ -460,17 +476,17 @@ Damp.prototype = {
    *   already in mid-flight will be ignored.
    * - the request start and end times are overlapping. If a new request starts a moment
    *   after the previous one was finished, the wait will be ended in the "interim"
    *   period.
    * @returns a promise that resolves when the wait is done.
    */
   waitForAllRequestsFinished() {
     let tab = getActiveTab(getMostRecentBrowserWindow());
-    let target = devtools.TargetFactory.forTab(tab);
+    let target = TargetFactory.forTab(tab);
     let toolbox = gDevTools.getToolbox(target);
     let window = toolbox.getCurrentPanel().panelWin;
 
     return new Promise(resolve => {
       // Key is the request id, value is a boolean - is request finished or not?
       let requests = new Map();
 
       function onRequest(_, id) {