Bug 1237606 - Ensure reloading gDevTools dependencies from the reload addon. r=jryans

This commit is contained in:
Alexandre Poirot 2016-01-13 02:55:33 -08:00
parent d2b3b8649d
commit 8e2329706f
2 changed files with 35 additions and 13 deletions

View File

@ -80,6 +80,10 @@ function reload(event) {
// 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;

View File

@ -10,21 +10,34 @@ 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);
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 {defaultTools: DefaultTools, defaultThemes: DefaultThemes} =
require("devtools/client/definitions");
const EventEmitter = require("devtools/shared/event-emitter");
const Telemetry = require("devtools/client/shared/telemetry");
const {JsonView} = require("devtools/client/jsonview/main");
@ -511,6 +524,11 @@ DevTools.prototype = {
// 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.
*/