gecko/browser/devtools/framework/ToolboxProcess.jsm

282 lines
9.3 KiB
JavaScript
Raw Normal View History

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* 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";
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
const DBG_XUL = "chrome://browser/content/devtools/framework/toolbox-process-window.xul";
const CHROME_DEBUGGER_PROFILE_NAME = "chrome_debugger_profile";
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm")
XPCOMUtils.defineLazyModuleGetter(this, "DevToolsLoader",
"resource://gre/modules/devtools/Loader.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource://gre/modules/devtools/Loader.jsm");
XPCOMUtils.defineLazyGetter(this, "Telemetry", function () {
return devtools.require("devtools/shared/telemetry");
});
XPCOMUtils.defineLazyGetter(this, "EventEmitter", function () {
return devtools.require("devtools/toolkit/event-emitter");
});
const { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
this.EXPORTED_SYMBOLS = ["BrowserToolboxProcess"];
let processes = new Set();
/**
* Constructor for creating a process that will hold a chrome toolbox.
*
* @param function aOnClose [optional]
* A function called when the process stops running.
* @param function aOnRun [optional]
* A function called when the process starts running.
Bug 911098 - Implement Addon Debugger UI, r=fitzgen,harthur,mossop From 8af4148dc10f18bf67e39442ee93169cb66382d5 Mon Sep 17 00:00:00 2001 --- browser/devtools/debugger/debugger-controller.js | 36 ++++++- browser/devtools/debugger/debugger-panes.js | 17 +++- browser/devtools/debugger/test/browser.ini | 1 + .../debugger/test/browser_dbg_addon-sources.js | 108 ++++++++++++++++++++ browser/devtools/debugger/test/head.js | 29 ++++++ browser/devtools/framework/ToolboxProcess.jsm | 31 ++++-- .../devtools/framework/toolbox-process-window.js | 18 +++- modules/libpref/src/init/all.js | 3 + .../en-US/chrome/mozapps/extensions/extensions.dtd | 1 + toolkit/mozapps/extensions/content/extensions.js | 55 +++++++--- toolkit/mozapps/extensions/content/extensions.xml | 31 +++++- toolkit/mozapps/extensions/content/extensions.xul | 6 ++ .../mozapps/extensions/internal/XPIProvider.jsm | 4 + .../extensions/internal/XPIProviderUtils.js | 2 +- .../test/addons/test_jetpack/bootstrap.js | 17 ++++ .../test/addons/test_jetpack/harness-options.json | 1 + .../test/addons/test_jetpack/install.rdf | 28 ++++++ .../extensions/test/browser/browser-common.ini | 1 + .../test/browser/browser_debug_button.js | 112 +++++++++++++++++++++ toolkit/mozapps/extensions/test/browser/head.js | 3 + .../extensions/test/xpcshell/test_isDebuggable.js | 36 +++++++ .../extensions/test/xpcshell/xpcshell-shared.ini | 1 + 22 files changed, 508 insertions(+), 33 deletions(-) create mode 100644 browser/devtools/debugger/test/browser_dbg_addon-sources.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf create mode 100644 toolkit/mozapps/extensions/test/browser/browser_debug_button.js create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js * * * Leak fix
2014-03-25 10:59:14 -07:00
* @param object aOptions [optional]
* An object with properties for configuring BrowserToolboxProcess.
*/
Bug 911098 - Implement Addon Debugger UI, r=fitzgen,harthur,mossop From 8af4148dc10f18bf67e39442ee93169cb66382d5 Mon Sep 17 00:00:00 2001 --- browser/devtools/debugger/debugger-controller.js | 36 ++++++- browser/devtools/debugger/debugger-panes.js | 17 +++- browser/devtools/debugger/test/browser.ini | 1 + .../debugger/test/browser_dbg_addon-sources.js | 108 ++++++++++++++++++++ browser/devtools/debugger/test/head.js | 29 ++++++ browser/devtools/framework/ToolboxProcess.jsm | 31 ++++-- .../devtools/framework/toolbox-process-window.js | 18 +++- modules/libpref/src/init/all.js | 3 + .../en-US/chrome/mozapps/extensions/extensions.dtd | 1 + toolkit/mozapps/extensions/content/extensions.js | 55 +++++++--- toolkit/mozapps/extensions/content/extensions.xml | 31 +++++- toolkit/mozapps/extensions/content/extensions.xul | 6 ++ .../mozapps/extensions/internal/XPIProvider.jsm | 4 + .../extensions/internal/XPIProviderUtils.js | 2 +- .../test/addons/test_jetpack/bootstrap.js | 17 ++++ .../test/addons/test_jetpack/harness-options.json | 1 + .../test/addons/test_jetpack/install.rdf | 28 ++++++ .../extensions/test/browser/browser-common.ini | 1 + .../test/browser/browser_debug_button.js | 112 +++++++++++++++++++++ toolkit/mozapps/extensions/test/browser/head.js | 3 + .../extensions/test/xpcshell/test_isDebuggable.js | 36 +++++++ .../extensions/test/xpcshell/xpcshell-shared.ini | 1 + 22 files changed, 508 insertions(+), 33 deletions(-) create mode 100644 browser/devtools/debugger/test/browser_dbg_addon-sources.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf create mode 100644 toolkit/mozapps/extensions/test/browser/browser_debug_button.js create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js * * * Leak fix
2014-03-25 10:59:14 -07:00
this.BrowserToolboxProcess = function BrowserToolboxProcess(aOnClose, aOnRun, aOptions) {
let emitter = new EventEmitter();
this.on = emitter.on.bind(emitter);
this.off = emitter.off.bind(emitter);
this.once = emitter.once.bind(emitter);
// Forward any events to the shared emitter.
this.emit = function(...args) {
emitter.emit(...args);
BrowserToolboxProcess.emit(...args);
}
Bug 911098 - Implement Addon Debugger UI, r=fitzgen,harthur,mossop From 8af4148dc10f18bf67e39442ee93169cb66382d5 Mon Sep 17 00:00:00 2001 --- browser/devtools/debugger/debugger-controller.js | 36 ++++++- browser/devtools/debugger/debugger-panes.js | 17 +++- browser/devtools/debugger/test/browser.ini | 1 + .../debugger/test/browser_dbg_addon-sources.js | 108 ++++++++++++++++++++ browser/devtools/debugger/test/head.js | 29 ++++++ browser/devtools/framework/ToolboxProcess.jsm | 31 ++++-- .../devtools/framework/toolbox-process-window.js | 18 +++- modules/libpref/src/init/all.js | 3 + .../en-US/chrome/mozapps/extensions/extensions.dtd | 1 + toolkit/mozapps/extensions/content/extensions.js | 55 +++++++--- toolkit/mozapps/extensions/content/extensions.xml | 31 +++++- toolkit/mozapps/extensions/content/extensions.xul | 6 ++ .../mozapps/extensions/internal/XPIProvider.jsm | 4 + .../extensions/internal/XPIProviderUtils.js | 2 +- .../test/addons/test_jetpack/bootstrap.js | 17 ++++ .../test/addons/test_jetpack/harness-options.json | 1 + .../test/addons/test_jetpack/install.rdf | 28 ++++++ .../extensions/test/browser/browser-common.ini | 1 + .../test/browser/browser_debug_button.js | 112 +++++++++++++++++++++ toolkit/mozapps/extensions/test/browser/head.js | 3 + .../extensions/test/xpcshell/test_isDebuggable.js | 36 +++++++ .../extensions/test/xpcshell/xpcshell-shared.ini | 1 + 22 files changed, 508 insertions(+), 33 deletions(-) create mode 100644 browser/devtools/debugger/test/browser_dbg_addon-sources.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf create mode 100644 toolkit/mozapps/extensions/test/browser/browser_debug_button.js create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js * * * Leak fix
2014-03-25 10:59:14 -07:00
// If first argument is an object, use those properties instead of
// all three arguments
if (typeof aOnClose === "object") {
if (aOnClose.onClose) {
this.on("close", aOnClose.onClose);
}
if (aOnClose.onRun) {
this.on("run", aOnClose.onRun);
}
Bug 911098 - Implement Addon Debugger UI, r=fitzgen,harthur,mossop From 8af4148dc10f18bf67e39442ee93169cb66382d5 Mon Sep 17 00:00:00 2001 --- browser/devtools/debugger/debugger-controller.js | 36 ++++++- browser/devtools/debugger/debugger-panes.js | 17 +++- browser/devtools/debugger/test/browser.ini | 1 + .../debugger/test/browser_dbg_addon-sources.js | 108 ++++++++++++++++++++ browser/devtools/debugger/test/head.js | 29 ++++++ browser/devtools/framework/ToolboxProcess.jsm | 31 ++++-- .../devtools/framework/toolbox-process-window.js | 18 +++- modules/libpref/src/init/all.js | 3 + .../en-US/chrome/mozapps/extensions/extensions.dtd | 1 + toolkit/mozapps/extensions/content/extensions.js | 55 +++++++--- toolkit/mozapps/extensions/content/extensions.xml | 31 +++++- toolkit/mozapps/extensions/content/extensions.xul | 6 ++ .../mozapps/extensions/internal/XPIProvider.jsm | 4 + .../extensions/internal/XPIProviderUtils.js | 2 +- .../test/addons/test_jetpack/bootstrap.js | 17 ++++ .../test/addons/test_jetpack/harness-options.json | 1 + .../test/addons/test_jetpack/install.rdf | 28 ++++++ .../extensions/test/browser/browser-common.ini | 1 + .../test/browser/browser_debug_button.js | 112 +++++++++++++++++++++ toolkit/mozapps/extensions/test/browser/head.js | 3 + .../extensions/test/xpcshell/test_isDebuggable.js | 36 +++++++ .../extensions/test/xpcshell/xpcshell-shared.ini | 1 + 22 files changed, 508 insertions(+), 33 deletions(-) create mode 100644 browser/devtools/debugger/test/browser_dbg_addon-sources.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf create mode 100644 toolkit/mozapps/extensions/test/browser/browser_debug_button.js create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js * * * Leak fix
2014-03-25 10:59:14 -07:00
this._options = aOnClose;
} else {
if (aOnClose) {
this.on("close", aOnClose);
}
if (aOnRun) {
this.on("run", aOnRun);
}
Bug 911098 - Implement Addon Debugger UI, r=fitzgen,harthur,mossop From 8af4148dc10f18bf67e39442ee93169cb66382d5 Mon Sep 17 00:00:00 2001 --- browser/devtools/debugger/debugger-controller.js | 36 ++++++- browser/devtools/debugger/debugger-panes.js | 17 +++- browser/devtools/debugger/test/browser.ini | 1 + .../debugger/test/browser_dbg_addon-sources.js | 108 ++++++++++++++++++++ browser/devtools/debugger/test/head.js | 29 ++++++ browser/devtools/framework/ToolboxProcess.jsm | 31 ++++-- .../devtools/framework/toolbox-process-window.js | 18 +++- modules/libpref/src/init/all.js | 3 + .../en-US/chrome/mozapps/extensions/extensions.dtd | 1 + toolkit/mozapps/extensions/content/extensions.js | 55 +++++++--- toolkit/mozapps/extensions/content/extensions.xml | 31 +++++- toolkit/mozapps/extensions/content/extensions.xul | 6 ++ .../mozapps/extensions/internal/XPIProvider.jsm | 4 + .../extensions/internal/XPIProviderUtils.js | 2 +- .../test/addons/test_jetpack/bootstrap.js | 17 ++++ .../test/addons/test_jetpack/harness-options.json | 1 + .../test/addons/test_jetpack/install.rdf | 28 ++++++ .../extensions/test/browser/browser-common.ini | 1 + .../test/browser/browser_debug_button.js | 112 +++++++++++++++++++++ toolkit/mozapps/extensions/test/browser/head.js | 3 + .../extensions/test/xpcshell/test_isDebuggable.js | 36 +++++++ .../extensions/test/xpcshell/xpcshell-shared.ini | 1 + 22 files changed, 508 insertions(+), 33 deletions(-) create mode 100644 browser/devtools/debugger/test/browser_dbg_addon-sources.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf create mode 100644 toolkit/mozapps/extensions/test/browser/browser_debug_button.js create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js * * * Leak fix
2014-03-25 10:59:14 -07:00
this._options = aOptions || {};
}
this._telemetry = new Telemetry();
this.close = this.close.bind(this);
Services.obs.addObserver(this.close, "quit-application", false);
this._initServer();
this._initProfile();
this._create();
processes.add(this);
};
EventEmitter.decorate(BrowserToolboxProcess);
/**
* Initializes and starts a chrome toolbox process.
* @return object
*/
Bug 911098 - Implement Addon Debugger UI, r=fitzgen,harthur,mossop From 8af4148dc10f18bf67e39442ee93169cb66382d5 Mon Sep 17 00:00:00 2001 --- browser/devtools/debugger/debugger-controller.js | 36 ++++++- browser/devtools/debugger/debugger-panes.js | 17 +++- browser/devtools/debugger/test/browser.ini | 1 + .../debugger/test/browser_dbg_addon-sources.js | 108 ++++++++++++++++++++ browser/devtools/debugger/test/head.js | 29 ++++++ browser/devtools/framework/ToolboxProcess.jsm | 31 ++++-- .../devtools/framework/toolbox-process-window.js | 18 +++- modules/libpref/src/init/all.js | 3 + .../en-US/chrome/mozapps/extensions/extensions.dtd | 1 + toolkit/mozapps/extensions/content/extensions.js | 55 +++++++--- toolkit/mozapps/extensions/content/extensions.xml | 31 +++++- toolkit/mozapps/extensions/content/extensions.xul | 6 ++ .../mozapps/extensions/internal/XPIProvider.jsm | 4 + .../extensions/internal/XPIProviderUtils.js | 2 +- .../test/addons/test_jetpack/bootstrap.js | 17 ++++ .../test/addons/test_jetpack/harness-options.json | 1 + .../test/addons/test_jetpack/install.rdf | 28 ++++++ .../extensions/test/browser/browser-common.ini | 1 + .../test/browser/browser_debug_button.js | 112 +++++++++++++++++++++ toolkit/mozapps/extensions/test/browser/head.js | 3 + .../extensions/test/xpcshell/test_isDebuggable.js | 36 +++++++ .../extensions/test/xpcshell/xpcshell-shared.ini | 1 + 22 files changed, 508 insertions(+), 33 deletions(-) create mode 100644 browser/devtools/debugger/test/browser_dbg_addon-sources.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf create mode 100644 toolkit/mozapps/extensions/test/browser/browser_debug_button.js create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js * * * Leak fix
2014-03-25 10:59:14 -07:00
BrowserToolboxProcess.init = function(aOnClose, aOnRun, aOptions) {
return new BrowserToolboxProcess(aOnClose, aOnRun, aOptions);
};
/**
* Passes a set of options to the BrowserAddonActors for the given ID.
*
* @param aId string
* The ID of the add-on to pass the options to
* @param aOptions object
* The options.
* @return a promise that will be resolved when complete.
*/
BrowserToolboxProcess.setAddonOptions = function DSC_setAddonOptions(aId, aOptions) {
let promises = [];
for (let process of processes.values()) {
promises.push(process.debuggerServer.setAddonOptions(aId, aOptions));
}
return promise.all(promises);
};
BrowserToolboxProcess.prototype = {
/**
* Initializes the debugger server.
*/
_initServer: function() {
if (this.debuggerServer) {
dumpn("The chrome toolbox server is already running.");
return;
}
dumpn("Initializing the chrome toolbox server.");
// Create a separate loader instance, so that we can be sure to receive a
// separate instance of the DebuggingServer from the rest of the devtools.
// This allows us to safely use the tools against even the actors and
// DebuggingServer itself, especially since we can mark this loader as
// invisible to the debugger (unlike the usual loader settings).
this.loader = new DevToolsLoader();
this.loader.invisibleToDebugger = true;
this.loader.main("devtools/server/main");
this.debuggerServer = this.loader.DebuggerServer;
dumpn("Created a separate loader instance for the DebuggerServer.");
// Forward interesting events.
this.debuggerServer.on("connectionchange", this.emit.bind(this));
this.debuggerServer.init();
this.debuggerServer.addBrowserActors();
this.debuggerServer.allowChromeProcess = true;
dumpn("initialized and added the browser actors for the DebuggerServer.");
let chromeDebuggingPort =
Services.prefs.getIntPref("devtools.debugger.chrome-debugging-port");
let listener = this.debuggerServer.createListener();
listener.portOrPath = chromeDebuggingPort;
listener.open();
dumpn("Finished initializing the chrome toolbox server.");
dumpn("Started listening on port: " + chromeDebuggingPort);
},
/**
* Initializes a profile for the remote debugger process.
*/
_initProfile: function() {
dumpn("Initializing the chrome toolbox user profile.");
let debuggingProfileDir = Services.dirsvc.get("ProfLD", Ci.nsIFile);
debuggingProfileDir.append(CHROME_DEBUGGER_PROFILE_NAME);
try {
debuggingProfileDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
} catch (ex) {
// Don't re-copy over the prefs again if this profile already exists
if (ex.result === Cr.NS_ERROR_FILE_ALREADY_EXISTS) {
this._dbgProfilePath = debuggingProfileDir.path;
} else {
dumpn("Error trying to create a profile directory, failing.");
dumpn("Error: " + (ex.message || ex));
}
return;
}
this._dbgProfilePath = debuggingProfileDir.path;
// We would like to copy prefs into this new profile...
let prefsFile = debuggingProfileDir.clone();
prefsFile.append("prefs.js");
// ... but unfortunately, when we run tests, it seems the starting profile
// clears out the prefs file before re-writing it, and in practice the
// file is empty when we get here. So just copying doesn't work in that
// case.
// We could force a sync pref flush and then copy it... but if we're doing
// that, we might as well just flush directly to the new profile, which
// always works:
Services.prefs.savePrefFile(prefsFile);
dumpn("Finished creating the chrome toolbox user profile at: " + this._dbgProfilePath);
},
/**
* Creates and initializes the profile & process for the remote debugger.
*/
_create: function() {
dumpn("Initializing chrome debugging process.");
let process = this._dbgProcess = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
process.init(Services.dirsvc.get("XREExeF", Ci.nsIFile));
Bug 911098 - Implement Addon Debugger UI, r=fitzgen,harthur,mossop From 8af4148dc10f18bf67e39442ee93169cb66382d5 Mon Sep 17 00:00:00 2001 --- browser/devtools/debugger/debugger-controller.js | 36 ++++++- browser/devtools/debugger/debugger-panes.js | 17 +++- browser/devtools/debugger/test/browser.ini | 1 + .../debugger/test/browser_dbg_addon-sources.js | 108 ++++++++++++++++++++ browser/devtools/debugger/test/head.js | 29 ++++++ browser/devtools/framework/ToolboxProcess.jsm | 31 ++++-- .../devtools/framework/toolbox-process-window.js | 18 +++- modules/libpref/src/init/all.js | 3 + .../en-US/chrome/mozapps/extensions/extensions.dtd | 1 + toolkit/mozapps/extensions/content/extensions.js | 55 +++++++--- toolkit/mozapps/extensions/content/extensions.xml | 31 +++++- toolkit/mozapps/extensions/content/extensions.xul | 6 ++ .../mozapps/extensions/internal/XPIProvider.jsm | 4 + .../extensions/internal/XPIProviderUtils.js | 2 +- .../test/addons/test_jetpack/bootstrap.js | 17 ++++ .../test/addons/test_jetpack/harness-options.json | 1 + .../test/addons/test_jetpack/install.rdf | 28 ++++++ .../extensions/test/browser/browser-common.ini | 1 + .../test/browser/browser_debug_button.js | 112 +++++++++++++++++++++ toolkit/mozapps/extensions/test/browser/head.js | 3 + .../extensions/test/xpcshell/test_isDebuggable.js | 36 +++++++ .../extensions/test/xpcshell/xpcshell-shared.ini | 1 + 22 files changed, 508 insertions(+), 33 deletions(-) create mode 100644 browser/devtools/debugger/test/browser_dbg_addon-sources.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf create mode 100644 toolkit/mozapps/extensions/test/browser/browser_debug_button.js create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js * * * Leak fix
2014-03-25 10:59:14 -07:00
let xulURI = DBG_XUL;
if (this._options.addonID) {
xulURI += "?addonID=" + this._options.addonID;
}
dumpn("Running chrome debugging process.");
let args = ["-no-remote", "-foreground", "-profile", this._dbgProfilePath, "-chrome", xulURI];
Bug 911098 - Implement Addon Debugger UI, r=fitzgen,harthur,mossop From 8af4148dc10f18bf67e39442ee93169cb66382d5 Mon Sep 17 00:00:00 2001 --- browser/devtools/debugger/debugger-controller.js | 36 ++++++- browser/devtools/debugger/debugger-panes.js | 17 +++- browser/devtools/debugger/test/browser.ini | 1 + .../debugger/test/browser_dbg_addon-sources.js | 108 ++++++++++++++++++++ browser/devtools/debugger/test/head.js | 29 ++++++ browser/devtools/framework/ToolboxProcess.jsm | 31 ++++-- .../devtools/framework/toolbox-process-window.js | 18 +++- modules/libpref/src/init/all.js | 3 + .../en-US/chrome/mozapps/extensions/extensions.dtd | 1 + toolkit/mozapps/extensions/content/extensions.js | 55 +++++++--- toolkit/mozapps/extensions/content/extensions.xml | 31 +++++- toolkit/mozapps/extensions/content/extensions.xul | 6 ++ .../mozapps/extensions/internal/XPIProvider.jsm | 4 + .../extensions/internal/XPIProviderUtils.js | 2 +- .../test/addons/test_jetpack/bootstrap.js | 17 ++++ .../test/addons/test_jetpack/harness-options.json | 1 + .../test/addons/test_jetpack/install.rdf | 28 ++++++ .../extensions/test/browser/browser-common.ini | 1 + .../test/browser/browser_debug_button.js | 112 +++++++++++++++++++++ toolkit/mozapps/extensions/test/browser/head.js | 3 + .../extensions/test/xpcshell/test_isDebuggable.js | 36 +++++++ .../extensions/test/xpcshell/xpcshell-shared.ini | 1 + 22 files changed, 508 insertions(+), 33 deletions(-) create mode 100644 browser/devtools/debugger/test/browser_dbg_addon-sources.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/bootstrap.js create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/harness-options.json create mode 100644 toolkit/mozapps/extensions/test/addons/test_jetpack/install.rdf create mode 100644 toolkit/mozapps/extensions/test/browser/browser_debug_button.js create mode 100644 toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js * * * Leak fix
2014-03-25 10:59:14 -07:00
// During local development, incremental builds can trigger the main process
// to clear its startup cache with the "flag file" .purgecaches, but this
// file is removed during app startup time, so we aren't able to know if it
// was present in order to also clear the child profile's startup cache as
// well.
//
// As an approximation of "isLocalBuild", check for an unofficial build.
if (!Services.appinfo.isOfficial) {
args.push("-purgecaches");
}
// Disable safe mode for the new process in case this was opened via the
// keyboard shortcut.
let nsIEnvironment = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
let originalValue = nsIEnvironment.get("MOZ_DISABLE_SAFE_MODE_KEY");
nsIEnvironment.set("MOZ_DISABLE_SAFE_MODE_KEY", "1");
process.runwAsync(args, args.length, { observe: () => this.close() });
// Now that the process has started, it's safe to reset the env variable.
nsIEnvironment.set("MOZ_DISABLE_SAFE_MODE_KEY", originalValue);
this._telemetry.toolOpened("jsbrowserdebugger");
dumpn("Chrome toolbox is now running...");
this.emit("run", this);
},
/**
* Closes the remote debugging server and kills the toolbox process.
*/
close: function() {
if (this.closed) {
return;
}
dumpn("Cleaning up the chrome debugging process.");
Services.obs.removeObserver(this.close, "quit-application");
if (this._dbgProcess.isRunning) {
this._dbgProcess.kill();
}
this._telemetry.toolClosed("jsbrowserdebugger");
if (this.debuggerServer) {
this.debuggerServer.destroy();
}
dumpn("Chrome toolbox is now closed...");
this.closed = true;
this.emit("close", this);
processes.delete(this);
}
};
/**
* Helper method for debugging.
* @param string
*/
function dumpn(str) {
if (wantLogging) {
dump("DBG-FRONTEND: " + str + "\n");
}
}
let wantLogging = Services.prefs.getBoolPref("devtools.debugger.log");
Services.prefs.addObserver("devtools.debugger.log", {
observe: (...args) => wantLogging = Services.prefs.getBoolPref(args.pop())
}, false);
Services.obs.notifyObservers(null, "ToolboxProcessLoaded", null);