Bug 1237606 - Ensure reloading gDevTools dependencies from the reload addon. r=jryans
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 13 Jan 2016 02:55:33 -0800
changeset 279776 b3e626983fe5cd35a8546086f519d683e0f3ddd9
parent 279775 8cd5149485cb02d37d6dfac259af4eda6fa02f9e
child 279777 2f7239cd52bae11012cb4ce596b6577cbfe32a3a
push id29888
push userryanvm@gmail.com
push dateThu, 14 Jan 2016 01:20:48 +0000
treeherdermozilla-central@fe17b0691543 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1237606
milestone46.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 1237606 - Ensure reloading gDevTools dependencies from the reload addon. r=jryans
devtools/bootstrap.js
devtools/client/framework/gDevTools.jsm
--- a/devtools/bootstrap.js
+++ b/devtools/bootstrap.js
@@ -75,16 +75,20 @@ function reload(event) {
   dump("Reload DevTools.  (reload-toolbox:"+reloadToolbox+")\n");
 
   // Invalidate xul cache in order to see changes made to chrome:// files
   Services.obs.notifyObservers(null, "startupcache-invalidate", null);
 
   // Ask the loader to update itself and reopen the toolbox if needed
   const {devtools} = Cu.import("resource://devtools/shared/Loader.jsm", {});
   devtools.reload(reloadToolbox);
+
+  // Also tells gDevTools to reload its dependencies
+  const {gDevTools} = Cu.import("resource://devtools/client/framework/gDevTools.jsm", {});
+  gDevTools.reload();
 }
 
 let listener;
 function startup() {
   dump("DevTools addon started.\n");
   listener = new MultiWindowKeyListener({
     keyCode: Ci.nsIDOMKeyEvent.DOM_VK_R, ctrlKey: true, altKey: true,
     callback: reload
--- a/devtools/client/framework/gDevTools.jsm
+++ b/devtools/client/framework/gDevTools.jsm
@@ -5,31 +5,44 @@
 "use strict";
 
 this.EXPORTED_SYMBOLS = [ "gDevTools", "DevTools", "gDevToolsBrowser" ];
 
 const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
-const { require, loader } = Cu.import("resource://devtools/shared/Loader.jsm", {});
-const promise = require("promise");
-// Load target and toolbox lazily as they need gDevTools to be fully initialized
-loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true);
-loader.lazyRequireGetter(this, "Toolbox", "devtools/client/framework/toolbox", true);
 
-XPCOMUtils.defineLazyModuleGetter(this, "console",
-                                  "resource://gre/modules/Console.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
-                                  "resource:///modules/CustomizableUI.jsm");
-loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
-loader.lazyRequireGetter(this, "DebuggerClient", "devtools/shared/client/main", true);
+// Make most dependencies be reloadable so that the reload addon
+// can update all of them while keeping gDevTools.jsm as-is
+// Bug 1188405 is going to refactor this JSM into a commonjs module
+// so that it can be reloaded as other modules.
+let require, loader, promise, DefaultTools, DefaultThemes;
+let loadDependencies = () => {
+  let l = Cu.import("resource://devtools/shared/Loader.jsm", {});
+  require = l.require;
+  loader = l.loader;
+  promise = require("promise");
+  // Load target and toolbox lazily as they need gDevTools to be fully initialized
+  loader.lazyRequireGetter(this, "TargetFactory", "devtools/client/framework/target", true);
+  loader.lazyRequireGetter(this, "Toolbox", "devtools/client/framework/toolbox", true);
 
-const {defaultTools: DefaultTools, defaultThemes: DefaultThemes} =
-  require("devtools/client/definitions");
+  XPCOMUtils.defineLazyModuleGetter(this, "console",
+                                    "resource://gre/modules/Console.jsm");
+  XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
+                                    "resource:///modules/CustomizableUI.jsm");
+  loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
+  loader.lazyRequireGetter(this, "DebuggerClient", "devtools/shared/client/main", true);
+
+  let d = require("devtools/client/definitions");
+  DefaultTools = d.defaultTools;
+  DefaultThemes = d.defaultThemes;
+};
+loadDependencies();
+
 const EventEmitter = require("devtools/shared/event-emitter");
 const Telemetry = require("devtools/client/shared/telemetry");
 const {JsonView} = require("devtools/client/jsonview/main");
 
 const TABS_OPEN_PEAK_HISTOGRAM = "DEVTOOLS_TABS_OPEN_PEAK_LINEAR";
 const TABS_OPEN_AVG_HISTOGRAM = "DEVTOOLS_TABS_OPEN_AVERAGE_LINEAR";
 const TABS_PINNED_PEAK_HISTOGRAM = "DEVTOOLS_TABS_PINNED_PEAK_LINEAR";
 const TABS_PINNED_AVG_HISTOGRAM = "DEVTOOLS_TABS_PINNED_AVERAGE_LINEAR";
@@ -506,16 +519,21 @@ DevTools.prototype = {
     this._pingTelemetry();
     this._telemetry = null;
 
     // Cleaning down the toolboxes: i.e.
     //   for (let [target, toolbox] of this._toolboxes) toolbox.destroy();
     // Is taken care of by the gDevToolsBrowser.forgetBrowserWindow
   },
 
+  // Force reloading dependencies if the loader happens to have reloaded
+  reload() {
+    loadDependencies();
+  },
+
   /**
    * Iterator that yields each of the toolboxes.
    */
   *[Symbol.iterator]() {
     for (let toolbox of this._toolboxes) {
       yield toolbox;
     }
   }