Bug 1190857 - Add loader alias to DevTools loader exports. r=jryans

This commit is contained in:
Alexandre Poirot 2015-08-13 10:57:13 -07:00
parent db9a62b70f
commit dfc163e577
7 changed files with 24 additions and 24 deletions

View File

@ -9,7 +9,7 @@
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/Task.jsm"); Cu.import("resource://gre/modules/Task.jsm");
let { devtools: loader, require } = Cu.import("resource://gre/modules/devtools/Loader.jsm"); let { loader, require } = Cu.import("resource://gre/modules/devtools/Loader.jsm");
Cu.import("resource://gre/modules/devtools/Console.jsm"); Cu.import("resource://gre/modules/devtools/Console.jsm");
Cu.import("resource:///modules/devtools/ViewHelpers.jsm"); Cu.import("resource:///modules/devtools/ViewHelpers.jsm");

View File

@ -10,7 +10,7 @@ const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
const {require, devtools: loader} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); const { require, loader } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
// Load target and toolbox lazily as they need gDevTools to be fully initialized // Load target and toolbox lazily as they need gDevTools to be fully initialized
loader.lazyRequireGetter(this, "TargetFactory", "devtools/framework/target", true); loader.lazyRequireGetter(this, "TargetFactory", "devtools/framework/target", true);
loader.lazyRequireGetter(this, "Toolbox", "devtools/framework/toolbox", true); loader.lazyRequireGetter(this, "Toolbox", "devtools/framework/toolbox", true);

View File

@ -4,7 +4,7 @@
"use strict"; "use strict";
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
const { devtools: loader, require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); const { loader, require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
const { Task } = require("resource://gre/modules/Task.jsm"); const { Task } = require("resource://gre/modules/Task.jsm");
const { Heritage, ViewHelpers, WidgetMethods } = require("resource:///modules/devtools/ViewHelpers.jsm"); const { Heritage, ViewHelpers, WidgetMethods } = require("resource:///modules/devtools/ViewHelpers.jsm");

View File

@ -43,7 +43,7 @@ const FALLBACK_CHARSET_LIST = "intl.fallbackCharsetList.ISO-8859-1";
const VARIABLES_VIEW_URL = "chrome://browser/content/devtools/widgets/VariablesView.xul"; const VARIABLES_VIEW_URL = "chrome://browser/content/devtools/widgets/VariablesView.xul";
const {require, devtools: loader} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); const {require, loader} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
const Telemetry = require("devtools/shared/telemetry"); const Telemetry = require("devtools/shared/telemetry");
const Editor = require("devtools/sourceeditor/editor"); const Editor = require("devtools/sourceeditor/editor");

View File

@ -4,14 +4,14 @@
"use strict"; "use strict";
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); const { loader } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
devtools.lazyImporter(this, "promise", "resource://gre/modules/Promise.jsm", "Promise"); loader.lazyImporter(this, "promise", "resource://gre/modules/Promise.jsm", "Promise");
devtools.lazyImporter(this, "Task", "resource://gre/modules/Task.jsm", "Task"); loader.lazyImporter(this, "Task", "resource://gre/modules/Task.jsm", "Task");
const loader = Cc["@mozilla.org/moz/jssubscript-loader;1"] const subScriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader); .getService(Ci.mozIJSSubScriptLoader);
let EventUtils = {}; let EventUtils = {};
loader.loadSubScript("chrome://marionette/content/EventUtils.js", EventUtils); subScriptLoader.loadSubScript("chrome://marionette/content/EventUtils.js", EventUtils);
devtools.lazyGetter(this, "nsIProfilerModule", () => { loader.lazyGetter(this, "nsIProfilerModule", () => {
return Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); return Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
}); });

View File

@ -10,7 +10,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/ViewHelpers.jsm"); Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm"); Cu.import("resource:///modules/devtools/gDevTools.jsm");
const { devtools: loader, require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); const { loader, require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
let { console } = Cu.import("resource://gre/modules/devtools/Console.jsm", {}); let { console } = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
let { EventTarget } = require("sdk/event/target"); let { EventTarget } = require("sdk/event/target");

View File

@ -17,11 +17,11 @@ XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", "resource://gre/modules/NetUt
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", "resource://gre/modules/FileUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", "resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
let loader = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {}).Loader; let { Loader } = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {});
let promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise; let promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
this.EXPORTED_SYMBOLS = ["DevToolsLoader", "devtools", "BuiltinProvider", this.EXPORTED_SYMBOLS = ["DevToolsLoader", "devtools", "BuiltinProvider",
"SrcdirProvider", "require"]; "SrcdirProvider", "require", "loader"];
/** /**
* Providers are different strategies for loading the devtools. * Providers are different strategies for loading the devtools.
@ -29,7 +29,7 @@ this.EXPORTED_SYMBOLS = ["DevToolsLoader", "devtools", "BuiltinProvider",
let loaderModules = { let loaderModules = {
"Services": Object.create(Services), "Services": Object.create(Services),
"toolkit/loader": loader, "toolkit/loader": Loader,
"PromiseDebugging": PromiseDebugging "PromiseDebugging": PromiseDebugging
}; };
XPCOMUtils.defineLazyGetter(loaderModules, "Debugger", () => { XPCOMUtils.defineLazyGetter(loaderModules, "Debugger", () => {
@ -70,7 +70,7 @@ let sharedGlobalBlacklist = ["sdk/indexed-db"];
function BuiltinProvider() {} function BuiltinProvider() {}
BuiltinProvider.prototype = { BuiltinProvider.prototype = {
load: function() { load: function() {
this.loader = new loader.Loader({ this.loader = new Loader.Loader({
id: "fx-devtools", id: "fx-devtools",
modules: loaderModules, modules: loaderModules,
paths: { paths: {
@ -113,7 +113,7 @@ BuiltinProvider.prototype = {
}, },
unload: function(reason) { unload: function(reason) {
loader.unload(this.loader, reason); Loader.unload(this.loader, reason);
delete this.loader; delete this.loader;
}, },
}; };
@ -157,7 +157,7 @@ SrcdirProvider.prototype = {
let acornWalkURI = OS.Path.join(acornURI, "walk.js"); let acornWalkURI = OS.Path.join(acornURI, "walk.js");
let ternURI = OS.Path.join(toolkitDir, "tern"); let ternURI = OS.Path.join(toolkitDir, "tern");
let sourceMapURI = this.fileURI(OS.Path.join(toolkitDir, "sourcemap", "source-map.js")); let sourceMapURI = this.fileURI(OS.Path.join(toolkitDir, "sourcemap", "source-map.js"));
this.loader = new loader.Loader({ this.loader = new Loader.Loader({
id: "fx-devtools", id: "fx-devtools",
modules: loaderModules, modules: loaderModules,
paths: { paths: {
@ -195,7 +195,7 @@ SrcdirProvider.prototype = {
}, },
unload: function(reason) { unload: function(reason) {
loader.unload(this.loader, reason); Loader.unload(this.loader, reason);
delete this.loader; delete this.loader;
}, },
@ -346,8 +346,8 @@ DevToolsLoader.prototype = {
* @returns The module's exports. * @returns The module's exports.
*/ */
loadURI: function(id, uri) { loadURI: function(id, uri) {
let module = loader.Module(id, uri); let module = Loader.Module(id, uri);
return loader.load(this.provider.loader, module).exports; return Loader.load(this.provider.loader, module).exports;
}, },
/** /**
@ -366,7 +366,7 @@ DevToolsLoader.prototype = {
return; return;
} }
this._mainid = id; this._mainid = id;
this._main = loader.main(this.provider.loader, id); this._main = Loader.main(this.provider.loader, id);
// Mirror the main module's exports on this object. // Mirror the main module's exports on this object.
Object.getOwnPropertyNames(this._main).forEach(key => { Object.getOwnPropertyNames(this._main).forEach(key => {
@ -411,7 +411,7 @@ DevToolsLoader.prototype = {
}); });
this._provider.load(); this._provider.load();
this.require = loader.Require(this._provider.loader, { id: "devtools" }); this.require = Loader.Require(this._provider.loader, { id: "devtools" });
if (this._mainid) { if (this._mainid) {
this.main(this._mainid); this.main(this._mainid);
@ -457,6 +457,6 @@ DevToolsLoader.prototype = {
}; };
// Export the standard instance of DevToolsLoader used by the tools. // Export the standard instance of DevToolsLoader used by the tools.
this.devtools = new DevToolsLoader(); this.devtools = this.loader = new DevToolsLoader();
this.require = this.devtools.require.bind(this.devtools); this.require = this.devtools.require.bind(this.devtools);