mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 05:37:11 +00:00
a7bc0406ee
- Bug 1155006: Fix unified build sensitivities in js/src/jit. r=shu (6e24e1af1) - Bug 1162766 - Fix more bad implicit constructors in js. r=evilpie (39961b06d) - Bug 1151606 - Stream atoms instead of raw pointers for native functions in tracked optimizations. (r=djvj) (7641ee9d6) - pointer style (540728104) - Bug 1154997 - Deal with self-hosted builtins when stringifying tracked optimization type info. (r=djvj) (92f9a54e6) - pointer style (45742d820) - Bug 1154115 - Rewrite the JSAPI profiling API to use a FrameHandle, as to avoid multiple lookups in JitcodeGlobalTable. (r=djvj) (4d202ba9e) - Bug 1119023 - Timeline in new perf tool should filter out markers, r=jsantell (6fc1a8bbe) - Bug 1132755 - Allocations tree has a bunch of columns that don't make sense, r=jsantell (1ae9ee7e2) - Bug 1142744 - Fix tests broken by bug 1132755, r=me (cc495f72d) - Bug 1133058 - OptionsView button, when clicked, should have an 'open' attribute. r=vp (65a78d896) - Bug 1132765 - Pass through performance memory options for 'probability' and 'maxLogLength' from the front to the memory actor. r=vp (f9bbbe098) - Bug 1141817 - Fix yield statement to correctly return memory actor state so that the performance tool can poll for allocations during recording. r=vp (2ddf7d528) - Bug 1141817 - Followup to fix additional intermittents like bug 1132370, r=vp (eab962f01) - Bug 1142748 - Use a single configuration for starting/stopping recordings, r=jsantell (0181b319a) - bit of Bug 879008 - New UI for the sampling Profiler (32c4d0fe8) - Bug 1123815 - Merge gum into fx-team to enable the Performance++ tool, r=me (84aabbd61) - Bug 1143933 - Expose raw JIT optimization information in performance front end. r=vp,shu (f68a6df50) - Bug 1143915 - Allow multiple calls to memory and timeline actor's start methods, to return the local start time from the actor. r=vp (028ac4187) - Bug 978948 - Add animation generator support for setTimeout in the canvas debugger. r=vp (42d623452) - Bug 985488 - Allow canvas debugger to time out and stop recording frames. Canvas debugger 'wait' style now matches other media styles. Update labels in canvas debugger to explicitly state that it's waiting for rAF cycles, rather than appearing as if something went wrong. r=vporof (b4670d843) - Bug 1144163 - Add a rulers highlighter; added unit test. r=pbrosset (5811a67d0) - Bug 1144163 - Add a rulers highlighter; added highlighter. r=pbrosset (779f88bdd) - Bug 1144163 - Add a rulers highlighter; added gcli command and button. r=pbrosset (d0d13da51) - Bug 1110550 - Enable performance overview graphs to rerender and change on devtools theme switch. r=vp (bd91ca7cf) - Bug 1149630 - Performance graphs should inherit from a common graph and be similarly styled. r=vporof (481c841f1) - Bug 1150733 - Correctly internationalize jit samples label. r=vporof, r=flod (b5612d1a6) - Bug 1137518 - FlameGraph's destroy function should be async, r=jsantell (f103e4c15) - Bug 1137503 - Avoid potential infinite loops in `findOptimalTickInterval` functions, r=jsantell (95df6c04a) - Bug 1121194 - Support vertical panning for the flamegraph in the new performance tool, r=jsantell (06241b5b2) - Bug 1121180 - Support dark theme in flamecharts for the performance tool. r=vp (c76abe237) - Bug 1059308 - Add Target.isTabActor to tell if the remote tab actor supports attach/detach requests. r=jryans (e03dcef93) - Bug 1132370 - Wrong State: Expected 'attached', but current state is 'detached', r=jsantell (e884e8db9) - No Bug - Fix documentation for _startMemory and _stopMemory in performance/modules/front.js, r=me DONTBUILD (d79090b31) - Bug 1147656 - Remove duplicate profiler defaults from the front end and just use on the server. r=vp (35c015dd0) - Bug 1046234 - Add more DevTools Telemetry measures (display size etc) r=pbrosset, r=gijs (a235681b4) - actually package telemetry.js (e8f3a58a4) - Bug 1077464 - Wire console.profile/profileEnd to the new performance tool. Move most of the recording-model logic from the front end into the PerformanceFront and PerformanceActorConnection so it can manage recordings without the front end being viewed. r=vp,jryans,pbrosset (eef8e18c3) - Bug 1144363 - Fix this._telemetry is undefined in gDevTools. r=bgrins (ba7d02902) - init telemetry, missing parts of Bug 866642 (1e70df975) - do not use sysctl.h on Linux anymore, since it is not provided by recent glibc (b2467d7ce) - clean up some telemetry issues of histogram, parts of Bug 974171 (d30c8d0ad) - move devtools to browser - part 1 (9a856f452) - Bug 1291423: Explicitly qualify the destructor call that we invoke in Maybe::reset. r=Waldo (944904a7d) - Bug 1148075 - Dynamically add XUL commands for the debugger frontend. r=vporof (60bc91f8f) - Bug 1147945 - Let the profiler's buffer size and sample rate be configurable via prefs. r=vp (acebcbdd9) - Bug 1124326 - Improve packageDir support for Cordova. r=ochameau (4b736580a) - Bug 1124326 - Support Cordova w/o build file. r=ochameau (d4b50aeae) - Bug 1134029 - Fix 'Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIURI.host]' timeouts, r=jsantell (18d16a5d0) - Bug 1147806 - Content frame filtering is confused when profiling FxOS, r=jsantell (b3c62c552) - Bug 1108843 - Generalize platform data in call tree view when platform data is hidden. r=vporof (354553ed7) - Bug 1138928 - Display only function name and file, instead of full url, in flame graphs. r=vp (4169689c1) - Bug 1152605 - Should not show host names for chrome URIs. r=vporof (c6dcf9e78) - Bug 1147604 - Inverted call trees should list (root) as leaves. r=jsantell (01768267f) - Bug 1075450 - Disable some Awesomebar actions for private windows r=mak (21d5586e7) - Bug 1120616 - Part 1: Implement filter styles in rule view r=bgrins (b66ee0282) - Bug 1120616 - Part 2: Add unit tests for filter styles in rule view r=bgrins (2892503d8) - Bug 1120616 - Part 3: Adjust the styles in the computed view's filter style search r=bgrins (41f8fae1b) - Bug 1120616 - Part 4: Add textbox context menu for rule and computed view r=bgrins (ff3f868ad) - Bug 1120616 - Part 5: Refactor style inspector tests to use synthesizeKeys r=bgrins (41db021d7) - Bug 1102219 - Part 5: Replace more `String.prototype.contains` with `String.prototype.includes` in chrome code. r=till (86ed03588) - Bug 1154018 - Check to see that nsIURI's host exists when parsing location for framenodes, and cache failures. r=vp (9494d52e7) - Bug 1160691 - Optimize FrameUtils.isContent and FrameUtils.parseLocation. (r=jsantell) (09118fd5d) - Bug 1154115 - Make the performance devtool handle the new profiler JSON format. (r=jsantell,vporof) (e3e5be7a4) - Bug 1059308 - Make frame selection button to work in browser toolbox. r=jryans,past (30fe6e61e) - Bug 1059308 - Fix tests to support chrome actor. r=jryans (01cf3926c) - Bug 1147042 - Rename attachProcess to getProcess. r=ochameau (0393ffb80) - Bug 1145824 - Profiler actor and performance tools now handle passing in a startTime to filter out SPS profiles on platform rather than client. r=vp,fitzgen (f225116ba) - Bug 1157718 - Do not use Array.prototype.includes in production code that leaves nightly in performance tool. r=fitzgen (ff06d284e) - Bug 1140728 - Rename 'Memory' to 'Allocations' in the new performance tool. r=jsantell (f584e720f) - Bug 1137500 - Always wait for the overview to be rendered in tests after a recording finishes, unless otherwise specified, r=jsantell (59825e179) - Bug 1137487 - AbstractCanvasGraph's destroy function should be async, r=jsantell (a17ae00b5) - Bug 1132758 - Performance feature visibility now based on a per recording-basis, dependent on features enabled and server support. r=vp (0d080a7c2) - Bug 1147035 - Make DeveloperToolbar.jsm use the gBrowser.contentDocumentAsCPOW shortcut. r=past. (251eff125) - Bug 1151168 - Don't flush profiled threads that are pending deletion on JS shutdown and don't delete expired markers when resetting the profile buffer. (r=djvj) (90721313a)
434 lines
16 KiB
JavaScript
434 lines
16 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Manages the addon-sdk loader instance used to load the developer tools.
|
|
*/
|
|
|
|
let { Constructor: CC, classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", "resource://gre/modules/NetUtil.jsm");
|
|
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", "resource://gre/modules/FileUtils.jsm");
|
|
XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
|
|
|
|
let loader = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {}).Loader;
|
|
let promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
|
|
|
|
this.EXPORTED_SYMBOLS = ["DevToolsLoader", "devtools", "BuiltinProvider",
|
|
"SrcdirProvider"];
|
|
|
|
/**
|
|
* Providers are different strategies for loading the devtools.
|
|
*/
|
|
|
|
let loaderModules = {
|
|
"Services": Object.create(Services),
|
|
"toolkit/loader": loader,
|
|
"promise": promise,
|
|
"PromiseDebugging": PromiseDebugging
|
|
};
|
|
XPCOMUtils.defineLazyGetter(loaderModules, "Debugger", () => {
|
|
// addDebuggerToGlobal only allows adding the Debugger object to a global. The
|
|
// this object is not guaranteed to be a global (in particular on B2G, due to
|
|
// compartment sharing), so add the Debugger object to a sandbox instead.
|
|
let sandbox = Cu.Sandbox(CC('@mozilla.org/systemprincipal;1', 'nsIPrincipal')());
|
|
Cu.evalInSandbox(
|
|
"Components.utils.import('resource://gre/modules/jsdebugger.jsm');" +
|
|
"addDebuggerToGlobal(this);",
|
|
sandbox
|
|
);
|
|
return sandbox.Debugger;
|
|
});
|
|
XPCOMUtils.defineLazyGetter(loaderModules, "Timer", () => {
|
|
let {setTimeout, clearTimeout} = Cu.import("resource://gre/modules/Timer.jsm", {});
|
|
// Do not return Cu.import result, as SDK loader would freeze Timer.jsm globals...
|
|
return {
|
|
setTimeout,
|
|
clearTimeout
|
|
};
|
|
});
|
|
XPCOMUtils.defineLazyGetter(loaderModules, "xpcInspector", () => {
|
|
return Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
|
|
});
|
|
XPCOMUtils.defineLazyGetter(loaderModules, "indexedDB", () => {
|
|
// On xpcshell, we can't instantiate indexedDB without crashing
|
|
try {
|
|
return Cu.Sandbox(this, {wantGlobalProperties:["indexedDB"]}).indexedDB;
|
|
} catch(e) {
|
|
return {};
|
|
}
|
|
});
|
|
|
|
let sharedGlobalBlacklist = ["sdk/indexed-db"];
|
|
|
|
// Used when the tools should be loaded from the Firefox package itself (the default)
|
|
function BuiltinProvider() {}
|
|
BuiltinProvider.prototype = {
|
|
load: function() {
|
|
this.loader = new loader.Loader({
|
|
id: "fx-devtools",
|
|
modules: loaderModules,
|
|
paths: {
|
|
// When you add a line to this mapping, don't forget to make a
|
|
// corresponding addition to the SrcdirProvider mapping below as well.
|
|
"": "resource://gre/modules/commonjs/",
|
|
"main": "resource:///modules/devtools/main.js",
|
|
"devtools": "resource://gre/modules/devtools",
|
|
"devtools/toolkit": "resource://gre/modules/devtools",
|
|
"devtools/server": "resource://gre/modules/devtools/server",
|
|
"devtools/toolkit/webconsole": "resource://gre/modules/devtools/toolkit/webconsole",
|
|
"devtools/app-actor-front": "resource://gre/modules/devtools/app-actor-front.js",
|
|
"devtools/styleinspector/css-logic": "resource://gre/modules/devtools/styleinspector/css-logic",
|
|
"devtools/css-color": "resource://gre/modules/devtools/css-color",
|
|
"devtools/output-parser": "resource://gre/modules/devtools/output-parser",
|
|
"devtools/touch-events": "resource://gre/modules/devtools/touch-events",
|
|
"devtools/client": "resource://gre/modules/devtools/client",
|
|
"devtools/pretty-fast": "resource://gre/modules/devtools/pretty-fast.js",
|
|
"devtools/jsbeautify": "resource://gre/modules/devtools/jsbeautify/beautify.js",
|
|
"devtools/async-utils": "resource://gre/modules/devtools/async-utils",
|
|
"devtools/content-observer": "resource://gre/modules/devtools/content-observer",
|
|
"gcli": "resource://gre/modules/devtools/gcli",
|
|
"projecteditor": "resource://gre/modules/devtools/projecteditor",
|
|
"acorn": "resource://gre/modules/devtools/acorn",
|
|
"acorn/util/walk": "resource://gre/modules/devtools/acorn/walk.js",
|
|
"tern": "resource://gre/modules/devtools/tern",
|
|
"source-map": "resource://gre/modules/devtools/SourceMap.jsm",
|
|
|
|
// Allow access to xpcshell test items from the loader.
|
|
"xpcshell-test": "resource://test"
|
|
},
|
|
globals: this.globals,
|
|
invisibleToDebugger: this.invisibleToDebugger,
|
|
sharedGlobal: true,
|
|
sharedGlobalBlacklist: sharedGlobalBlacklist
|
|
});
|
|
|
|
return promise.resolve(undefined);
|
|
},
|
|
|
|
unload: function(reason) {
|
|
loader.unload(this.loader, reason);
|
|
delete this.loader;
|
|
},
|
|
};
|
|
|
|
// Used when the tools should be loaded from a mozilla-central checkout. In addition
|
|
// to different paths, it needs to write chrome.manifest files to override chrome urls
|
|
// from the builtin tools.
|
|
function SrcdirProvider() {}
|
|
SrcdirProvider.prototype = {
|
|
fileURI: function(path) {
|
|
let file = new FileUtils.File(path);
|
|
return Services.io.newFileURI(file).spec;
|
|
},
|
|
|
|
load: function() {
|
|
let srcdir = Services.prefs.getComplexValue("devtools.loader.srcdir",
|
|
Ci.nsISupportsString);
|
|
srcdir = OS.Path.normalize(srcdir.data.trim());
|
|
let devtoolsDir = OS.Path.join(srcdir, "browser", "devtools");
|
|
let toolkitDir = OS.Path.join(srcdir, "toolkit", "devtools");
|
|
let mainURI = this.fileURI(OS.Path.join(devtoolsDir, "main.js"));
|
|
let devtoolsURI = this.fileURI(devtoolsDir);
|
|
let toolkitURI = this.fileURI(toolkitDir);
|
|
let serverURI = this.fileURI(OS.Path.join(toolkitDir, "server"));
|
|
let webconsoleURI = this.fileURI(OS.Path.join(toolkitDir, "webconsole"));
|
|
let appActorURI = this.fileURI(OS.Path.join(toolkitDir, "apps", "app-actor-front.js"));
|
|
let cssLogicURI = this.fileURI(OS.Path.join(toolkitDir, "styleinspector", "css-logic"));
|
|
let cssColorURI = this.fileURI(OS.Path.join(toolkitDir, "css-color"));
|
|
let outputParserURI = this.fileURI(OS.Path.join(toolkitDir, "output-parser"));
|
|
let touchEventsURI = this.fileURI(OS.Path.join(toolkitDir, "touch-events"));
|
|
let clientURI = this.fileURI(OS.Path.join(toolkitDir, "client"));
|
|
let prettyFastURI = this.fileURI(OS.Path.join(toolkitDir), "pretty-fast.js");
|
|
let jsBeautifyURI = this.fileURI(OS.Path.join(toolkitDir, "jsbeautify", "beautify.js"));
|
|
let asyncUtilsURI = this.fileURI(OS.Path.join(toolkitDir), "async-utils.js");
|
|
let contentObserverURI = this.fileURI(OS.Path.join(toolkitDir), "content-observer.js");
|
|
let gcliURI = this.fileURI(OS.Path.join(toolkitDir, "gcli", "source", "lib", "gcli"));
|
|
let projecteditorURI = this.fileURI(OS.Path.join(devtoolsDir, "projecteditor"));
|
|
let acornURI = this.fileURI(OS.Path.join(toolkitDir, "acorn"));
|
|
let acornWalkURI = OS.Path.join(acornURI, "walk.js");
|
|
let ternURI = OS.Path.join(toolkitDir, "tern");
|
|
let sourceMapURI = this.fileURI(OS.Path.join(toolkitDir), "SourceMap.jsm");
|
|
this.loader = new loader.Loader({
|
|
id: "fx-devtools",
|
|
modules: loaderModules,
|
|
paths: {
|
|
"": "resource://gre/modules/commonjs/",
|
|
"main": mainURI,
|
|
"devtools": devtoolsURI,
|
|
"devtools/toolkit": toolkitURI,
|
|
"devtools/server": serverURI,
|
|
"devtools/toolkit/webconsole": webconsoleURI,
|
|
"devtools/app-actor-front": appActorURI,
|
|
"devtools/styleinspector/css-logic": cssLogicURI,
|
|
"devtools/css-color": cssColorURI,
|
|
"devtools/output-parser": outputParserURI,
|
|
"devtools/touch-events": touchEventsURI,
|
|
"devtools/client": clientURI,
|
|
"devtools/pretty-fast": prettyFastURI,
|
|
"devtools/jsbeautify": jsBeautifyURI,
|
|
"devtools/async-utils": asyncUtilsURI,
|
|
"devtools/content-observer": contentObserverURI,
|
|
"gcli": gcliURI,
|
|
"projecteditor": projecteditorURI,
|
|
"acorn": acornURI,
|
|
"acorn/util/walk": acornWalkURI,
|
|
"tern": ternURI,
|
|
"source-map": sourceMapURI,
|
|
},
|
|
globals: this.globals,
|
|
invisibleToDebugger: this.invisibleToDebugger,
|
|
sharedGlobal: true,
|
|
sharedGlobalBlacklist: sharedGlobalBlacklist
|
|
});
|
|
|
|
return this._writeManifest(devtoolsDir).then(null, Cu.reportError);
|
|
},
|
|
|
|
unload: function(reason) {
|
|
loader.unload(this.loader, reason);
|
|
delete this.loader;
|
|
},
|
|
|
|
_readFile: function(filename) {
|
|
let deferred = promise.defer();
|
|
let file = new FileUtils.File(filename);
|
|
NetUtil.asyncFetch2(
|
|
file,
|
|
(inputStream, status) => {
|
|
if (!Components.isSuccessCode(status)) {
|
|
deferred.reject(new Error("Couldn't load manifest: " + filename + "\n"));
|
|
return;
|
|
}
|
|
var data = NetUtil.readInputStreamToString(inputStream, inputStream.available());
|
|
deferred.resolve(data);
|
|
},
|
|
null, // aLoadingNode
|
|
Services.scriptSecurityManager.getSystemPrincipal(),
|
|
null, // aTriggeringPrincipal
|
|
Ci.nsILoadInfo.SEC_NORMAL,
|
|
Ci.nsIContentPolicy.TYPE_OTHER);
|
|
|
|
return deferred.promise;
|
|
},
|
|
|
|
_writeFile: function(filename, data) {
|
|
let promise = OS.File.writeAtomic(filename, data, {encoding: "utf-8"});
|
|
return promise.then(null, (ex) => new Error("Couldn't write manifest: " + ex + "\n"));
|
|
},
|
|
|
|
_writeManifest: function(dir) {
|
|
return this._readFile(OS.Path.join(dir, "jar.mn")).then((data) => {
|
|
// The file data is contained within inputStream.
|
|
// You can read it into a string with
|
|
let entries = [];
|
|
let lines = data.split(/\n/);
|
|
let preprocessed = /^\s*\*/;
|
|
let contentEntry = new RegExp("^\\s+content/(\\w+)/(\\S+)\\s+\\((\\S+)\\)");
|
|
for (let line of lines) {
|
|
if (preprocessed.test(line)) {
|
|
dump("Unable to override preprocessed file: " + line + "\n");
|
|
continue;
|
|
}
|
|
let match = contentEntry.exec(line);
|
|
if (match) {
|
|
let pathComponents = match[3].split("/");
|
|
pathComponents.unshift(dir);
|
|
let path = OS.Path.join.apply(OS.Path, pathComponents);
|
|
let uri = this.fileURI(path);
|
|
let entry = "override chrome://" + match[1] + "/content/" + match[2] + "\t" + uri;
|
|
entries.push(entry);
|
|
}
|
|
}
|
|
return this._writeFile(OS.Path.join(dir, "chrome.manifest"), entries.join("\n"));
|
|
}).then(() => {
|
|
Components.manager.addBootstrappedManifestLocation(new FileUtils.File(dir));
|
|
});
|
|
}
|
|
};
|
|
|
|
/**
|
|
* The main devtools API.
|
|
* In addition to a few loader-related details, this object will also include all
|
|
* exports from the main module. The standard instance of this loader is
|
|
* exported as |devtools| below, but if a fresh copy of the loader is needed,
|
|
* then a new one can also be created.
|
|
*/
|
|
this.DevToolsLoader = function DevToolsLoader() {
|
|
this.require = this.require.bind(this);
|
|
this.lazyGetter = XPCOMUtils.defineLazyGetter.bind(XPCOMUtils);
|
|
this.lazyImporter = XPCOMUtils.defineLazyModuleGetter.bind(XPCOMUtils);
|
|
this.lazyServiceGetter = XPCOMUtils.defineLazyServiceGetter.bind(XPCOMUtils);
|
|
this.lazyRequireGetter = this.lazyRequireGetter.bind(this);
|
|
};
|
|
|
|
DevToolsLoader.prototype = {
|
|
get provider() {
|
|
if (!this._provider) {
|
|
this._chooseProvider();
|
|
}
|
|
return this._provider;
|
|
},
|
|
|
|
_provider: null,
|
|
|
|
/**
|
|
* A dummy version of require, in case a provider hasn't been chosen yet when
|
|
* this is first called. This will then be replaced by the real version.
|
|
* @see setProvider
|
|
*/
|
|
require: function() {
|
|
if (!this._provider) {
|
|
this._chooseProvider();
|
|
}
|
|
return this.require.apply(this, arguments);
|
|
},
|
|
|
|
/**
|
|
* Define a getter property on the given object that requires the given
|
|
* module. This enables delaying importing modules until the module is
|
|
* actually used.
|
|
*
|
|
* @param Object obj
|
|
* The object to define the property on.
|
|
* @param String property
|
|
* The property name.
|
|
* @param String module
|
|
* The module path.
|
|
* @param Boolean destructure
|
|
* Pass true if the property name is a member of the module's exports.
|
|
*/
|
|
lazyRequireGetter: function (obj, property, module, destructure) {
|
|
Object.defineProperty(obj, property, {
|
|
get: () => destructure
|
|
? this.require(module)[property]
|
|
: this.require(module || property),
|
|
configurable: true
|
|
});
|
|
},
|
|
|
|
/**
|
|
* Add a URI to the loader.
|
|
* @param string id
|
|
* The module id that can be used within the loader to refer to this module.
|
|
* @param string uri
|
|
* The URI to load as a module.
|
|
* @returns The module's exports.
|
|
*/
|
|
loadURI: function(id, uri) {
|
|
let module = loader.Module(id, uri);
|
|
return loader.load(this.provider.loader, module).exports;
|
|
},
|
|
|
|
/**
|
|
* Let the loader know the ID of the main module to load.
|
|
*
|
|
* The loader doesn't need a main module, but it's nice to have. This
|
|
* will be called by the browser devtools to load the devtools/main module.
|
|
*
|
|
* When only using the server, there's no main module, and this method
|
|
* can be ignored.
|
|
*/
|
|
main: function(id) {
|
|
// Ensure the main module isn't loaded twice, because it may have observable
|
|
// side-effects.
|
|
if (this._mainid) {
|
|
return;
|
|
}
|
|
this._mainid = id;
|
|
this._main = loader.main(this.provider.loader, id);
|
|
|
|
// Mirror the main module's exports on this object.
|
|
Object.getOwnPropertyNames(this._main).forEach(key => {
|
|
XPCOMUtils.defineLazyGetter(this, key, () => this._main[key]);
|
|
});
|
|
},
|
|
|
|
/**
|
|
* Override the provider used to load the tools.
|
|
*/
|
|
setProvider: function(provider) {
|
|
if (provider === this._provider) {
|
|
return;
|
|
}
|
|
|
|
if (this._provider) {
|
|
var events = this.require("sdk/system/events");
|
|
events.emit("devtools-unloaded", {});
|
|
delete this.require;
|
|
this._provider.unload("newprovider");
|
|
}
|
|
this._provider = provider;
|
|
|
|
// Pass through internal loader settings specific to this loader instance
|
|
this._provider.invisibleToDebugger = this.invisibleToDebugger;
|
|
this._provider.globals = {
|
|
isWorker: false,
|
|
reportError: Cu.reportError,
|
|
btoa: btoa,
|
|
_Iterator: Iterator,
|
|
loader: {
|
|
lazyGetter: this.lazyGetter,
|
|
lazyImporter: this.lazyImporter,
|
|
lazyServiceGetter: this.lazyServiceGetter,
|
|
lazyRequireGetter: this.lazyRequireGetter
|
|
},
|
|
};
|
|
// Lazy define console in order to load Console.jsm only when it is used
|
|
XPCOMUtils.defineLazyGetter(this._provider.globals, "console", () => {
|
|
return Cu.import("resource://gre/modules/devtools/Console.jsm", {}).console;
|
|
});
|
|
|
|
this._provider.load();
|
|
this.require = loader.Require(this._provider.loader, { id: "devtools" });
|
|
|
|
if (this._mainid) {
|
|
this.main(this._mainid);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Choose a default tools provider based on the preferences.
|
|
*/
|
|
_chooseProvider: function() {
|
|
if (Services.prefs.prefHasUserValue("devtools.loader.srcdir")) {
|
|
this.setProvider(new SrcdirProvider());
|
|
} else {
|
|
this.setProvider(new BuiltinProvider());
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Reload the current provider.
|
|
*/
|
|
reload: function() {
|
|
var events = this.require("sdk/system/events");
|
|
events.emit("startupcache-invalidate", {});
|
|
events.emit("devtools-unloaded", {});
|
|
|
|
this._provider.unload("reload");
|
|
delete this._provider;
|
|
this._chooseProvider();
|
|
},
|
|
|
|
/**
|
|
* Sets whether the compartments loaded by this instance should be invisible
|
|
* to the debugger. Invisibility is needed for loaders that support debugging
|
|
* of chrome code. This is true of remote target environments, like Fennec or
|
|
* B2G. It is not the default case for desktop Firefox because we offer the
|
|
* Browser Toolbox for chrome debugging there, which uses its own, separate
|
|
* loader instance.
|
|
* @see browser/devtools/framework/ToolboxProcess.jsm
|
|
*/
|
|
invisibleToDebugger: Services.appinfo.name !== "Firefox"
|
|
};
|
|
|
|
// Export the standard instance of DevToolsLoader used by the tools.
|
|
this.devtools = new DevToolsLoader();
|