Bug 1500072 - Add browserLoader reference on window when flags.testing is true;r=ochameau
☠☠ backed out by a3ef08e9f99e ☠ ☠
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 13 Feb 2019 10:04:01 +0000
changeset 458866 9d792d03c36b
parent 458865 a11b90e9e698
child 458867 7cb353ea123d
push id35551
push usershindli@mozilla.com
push dateWed, 13 Feb 2019 21:34:09 +0000
treeherdermozilla-central@08f794a4928e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1500072
milestone67.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 1500072 - Add browserLoader reference on window when flags.testing is true;r=ochameau Depends on D19582 Differential Revision: https://phabricator.services.mozilla.com/D19638
devtools/client/framework/test/metrics/browser_metrics_webconsole.js
devtools/client/shared/browser-loader.js
devtools/client/webconsole/main.js
--- a/devtools/client/framework/test/metrics/browser_metrics_webconsole.js
+++ b/devtools/client/framework/test/metrics/browser_metrics_webconsole.js
@@ -12,20 +12,20 @@
  * of characters in those modules, when opening the webconsole. These metrics are
  * retrieved by perfherder via logs.
  */
 
 const TEST_URL = "data:text/html;charset=UTF-8,<div>Webconsole modules load test</div>";
 
 add_task(async function() {
   const toolbox = await openNewTabAndToolbox(TEST_URL, "webconsole");
-  const hud = toolbox.getCurrentPanel().hud;
+  const panel = toolbox.getCurrentPanel();
 
   // Retrieve the browser loader dedicated to the WebConsole.
-  const webconsoleLoader = hud.ui.browserLoader;
+  const webconsoleLoader = panel._frameWindow.getBrowserLoaderForWindow();
   const loaders = [loader.provider.loader, webconsoleLoader.loader];
 
   runMetricsTest({
     filterString: "devtools/client/webconsole",
     loaders,
     panelName: "webconsole",
   });
 });
--- a/devtools/client/shared/browser-loader.js
+++ b/devtools/client/shared/browser-loader.js
@@ -183,16 +183,20 @@ function BrowserLoaderBuilder({ baseURI,
         lazyServiceGetter: devtools.lazyServiceGetter,
         lazyRequireGetter: this.lazyRequireGetter.bind(this),
       },
     },
   };
 
   const mainModule = loaders.Module(baseURI, joinURI(baseURI, "main.js"));
   this.loader = loaders.Loader(opts);
+  // When running tests, expose the BrowserLoader instance for metrics tests.
+  if (flags.testing) {
+    window.getBrowserLoaderForWindow = () => this;
+  }
   this.require = loaders.Require(this.loader, mainModule);
 }
 
 BrowserLoaderBuilder.prototype = {
   /**
    * Define a getter property on the given object that requires the given
    * module. This enables delaying importing modules until the module is
    * actually used.
--- a/devtools/client/webconsole/main.js
+++ b/devtools/client/webconsole/main.js
@@ -7,19 +7,14 @@
 "use strict";
 
 const { BrowserLoader } = ChromeUtils.import("resource://devtools/client/shared/browser-loader.js");
 
 this.WebConsoleWrapper = function(parentNode, hud, toolbox, owner, document) {
   // Initialize module loader and load all modules of the new inline
   // preview feature. The entire code-base doesn't need any extra
   // privileges and runs entirely in content scope.
-  const browserLoader = BrowserLoader({
+  const WebConsoleWrapper = BrowserLoader({
     baseURI: "resource://devtools/client/webconsole/",
     window,
-  });
-
-  // Expose the browserLoader instance on the webconsole hud for metrics tests.
-  hud.browserLoader = browserLoader;
-
-  const WebConsoleWrapper = browserLoader.require("./webconsole-wrapper");
+  }).require("./webconsole-wrapper");
   return new WebConsoleWrapper(parentNode, hud, toolbox, owner, document);
 };