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 458879 9d792d03c36b6dfef975265cc8952856ca0e44bc
parent 458878 a11b90e9e698ac9d82bf754037dad5ad0f559d72
child 458880 7cb353ea123dd67b04b6e07358e875116a799ac6
push id78076
push userjdescottes@mozilla.com
push dateWed, 13 Feb 2019 10:06:32 +0000
treeherderautoland@e381b765ee73 [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);
 };