Backing out bug 993029 due to Win8 debug test failures. CLOSED TREE

This commit is contained in:
Dave Townsend 2014-04-17 10:20:49 -07:00
parent b1524fb953
commit 8d9237bdbb
5 changed files with 32 additions and 168 deletions

View File

@ -1167,9 +1167,9 @@ let RemoteDebugger = {
}; };
#ifdef MOZ_WIDGET_GONK #ifdef MOZ_WIDGET_GONK
DebuggerServer.on("connectionchange", function() { DebuggerServer.onConnectionChange = function(what) {
AdbController.updateState(); AdbController.updateState();
}); }
#endif #endif
} }

View File

@ -16,13 +16,9 @@ Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
Cu.import("resource://gre/modules/devtools/Loader.jsm"); Cu.import("resource://gre/modules/devtools/Loader.jsm");
let require = devtools.require; let require = devtools.require;
let Telemetry = require("devtools/shared/telemetry"); let Telemetry = require("devtools/shared/telemetry");
let EventEmitter = require("devtools/toolkit/event-emitter");
const { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
this.EXPORTED_SYMBOLS = ["BrowserToolboxProcess"]; this.EXPORTED_SYMBOLS = ["BrowserToolboxProcess"];
let processes = Set();
/** /**
* Constructor for creating a process that will hold a chrome toolbox. * Constructor for creating a process that will hold a chrome toolbox.
* *
@ -34,33 +30,15 @@ let processes = Set();
* An object with properties for configuring BrowserToolboxProcess. * An object with properties for configuring BrowserToolboxProcess.
*/ */
this.BrowserToolboxProcess = function BrowserToolboxProcess(aOnClose, aOnRun, aOptions) { 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);
}
// If first argument is an object, use those properties instead of // If first argument is an object, use those properties instead of
// all three arguments // all three arguments
if (typeof aOnClose === "object") { if (typeof aOnClose === "object") {
if (aOnClose.onClose) { this._closeCallback = aOnClose.onClose;
this.on("close", aOnClose.onClose); this._runCallback = aOnClose.onRun;
}
if (aOnClose.onRun) {
this.on("run", aOnClose.onRun);
}
this._options = aOnClose; this._options = aOnClose;
} else { } else {
if (aOnClose) { this._closeCallback = aOnClose;
this.on("close", aOnClose); this._runCallback = aOnRun;
}
if (aOnRun) {
this.on("run", aOnRun);
}
this._options = aOptions || {}; this._options = aOptions || {};
} }
@ -71,12 +49,8 @@ this.BrowserToolboxProcess = function BrowserToolboxProcess(aOnClose, aOnRun, aO
this._initServer(); this._initServer();
this._initProfile(); this._initProfile();
this._create(); this._create();
processes.add(this);
}; };
EventEmitter.decorate(BrowserToolboxProcess);
/** /**
* Initializes and starts a chrome toolbox process. * Initializes and starts a chrome toolbox process.
* @return object * @return object
@ -85,25 +59,6 @@ BrowserToolboxProcess.init = function(aOnClose, aOnRun, aOptions) {
return new BrowserToolboxProcess(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 = { BrowserToolboxProcess.prototype = {
/** /**
* Initializes the debugger server. * Initializes the debugger server.
@ -122,9 +77,6 @@ BrowserToolboxProcess.prototype = {
this.loader.main("devtools/server/main"); this.loader.main("devtools/server/main");
this.debuggerServer = this.loader.DebuggerServer; this.debuggerServer = this.loader.DebuggerServer;
dumpn("Created a separate loader instance for the DebuggerServer."); dumpn("Created a separate loader instance for the DebuggerServer.");
// Forward interesting events.
this.debuggerServer.on("connectionchange", this.emit.bind(this));
} }
if (!this.debuggerServer.initialized) { if (!this.debuggerServer.initialized) {
@ -217,7 +169,9 @@ BrowserToolboxProcess.prototype = {
this._telemetry.toolOpened("jsbrowserdebugger"); this._telemetry.toolOpened("jsbrowserdebugger");
dumpn("Chrome toolbox is now running..."); dumpn("Chrome toolbox is now running...");
this.emit("run", this); if (typeof this._runCallback == "function") {
this._runCallback.call({}, this);
}
}, },
/** /**
@ -242,8 +196,9 @@ BrowserToolboxProcess.prototype = {
dumpn("Chrome toolbox is now closed..."); dumpn("Chrome toolbox is now closed...");
this.closed = true; this.closed = true;
this.emit("close", this); if (typeof this._closeCallback == "function") {
processes.delete(this); this._closeCallback.call({}, this);
}
} }
}; };

View File

@ -1113,7 +1113,6 @@ function BrowserAddonActor(aConnection, aAddon) {
this._addon = aAddon; this._addon = aAddon;
this._contextPool = null; this._contextPool = null;
this._threadActor = null; this._threadActor = null;
this._global = null;
AddonManager.addAddonListener(this); AddonManager.addAddonListener(this);
} }
@ -1136,10 +1135,6 @@ BrowserAddonActor.prototype = {
return this._threadActor; return this._threadActor;
}, },
get global() {
return this._global;
},
form: function BAA_form() { form: function BAA_form() {
dbg_assert(this.actorID, "addon should have an actorID."); dbg_assert(this.actorID, "addon should have an actorID.");
@ -1153,36 +1148,20 @@ BrowserAddonActor.prototype = {
}, },
disconnect: function BAA_disconnect() { disconnect: function BAA_disconnect() {
this._addon = null;
this._global = null;
AddonManager.removeAddonListener(this); AddonManager.removeAddonListener(this);
}, },
setOptions: function BAA_setOptions(aOptions) {
if ("global" in aOptions) {
this._global = aOptions.global;
}
},
onDisabled: function BAA_onDisabled(aAddon) {
if (aAddon != this._addon) {
return;
}
this._global = null;
},
onUninstalled: function BAA_onUninstalled(aAddon) { onUninstalled: function BAA_onUninstalled(aAddon) {
if (aAddon != this._addon) { if (aAddon != this._addon)
return; return;
}
if (this.attached) { if (this.attached) {
this.onDetach(); this.onDetach();
this.conn.send({ from: this.actorID, type: "tabDetached" }); this.conn.send({ from: this.actorID, type: "tabDetached" });
} }
this.disconnect(); this._addon = null;
AddonManager.removeAddonListener(this);
}, },
onAttach: function BAA_onAttach() { onAttach: function BAA_onAttach() {

View File

@ -11,7 +11,6 @@
*/ */
let DevToolsUtils = require("devtools/toolkit/DevToolsUtils.js"); let DevToolsUtils = require("devtools/toolkit/DevToolsUtils.js");
let Services = require("Services"); let Services = require("Services");
let EventEmitter = require("devtools/toolkit/event-emitter");
// Until all Debugger server code is converted to SDK modules, // Until all Debugger server code is converted to SDK modules,
// imports Components.* alias from chrome module. // imports Components.* alias from chrome module.
@ -185,6 +184,19 @@ var DebuggerServer = {
*/ */
chromeWindowType: null, chromeWindowType: null,
/**
* Set that to a function that will be called anytime a new connection
* is opened or one is closed.
*/
onConnectionChange: null,
_fireConnectionChange: function(aWhat) {
if (this.onConnectionChange &&
typeof this.onConnectionChange === "function") {
this.onConnectionChange(aWhat);
}
},
/** /**
* Prompt the user to accept or decline the incoming connection. This is the * Prompt the user to accept or decline the incoming connection. This is the
* default implementation that products embedding the debugger server may * default implementation that products embedding the debugger server may
@ -284,6 +296,8 @@ var DebuggerServer = {
this._transportInitialized = false; this._transportInitialized = false;
this._initialized = false; this._initialized = false;
this._fireConnectionChange("closed");
dumpn("Debugger server is shut down."); dumpn("Debugger server is shut down.");
}, },
@ -402,30 +416,6 @@ var DebuggerServer = {
} }
}, },
/**
* 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.
*/
setAddonOptions: function DS_setAddonOptions(aId, aOptions) {
if (!this._initialized) {
return;
}
let promises = [];
// Pass to all connections
for (let connID of Object.getOwnPropertyNames(this._connections)) {
promises.push(this._connections[connID].setAddonOptions(aId, aOptions));
}
return all(promises);
},
/** /**
* Listens on the given port or socket file for remote debugger connections. * Listens on the given port or socket file for remote debugger connections.
* *
@ -718,7 +708,7 @@ var DebuggerServer = {
} }
aTransport.ready(); aTransport.ready();
this.emit("connectionchange", "opened", conn); this._fireConnectionChange("opened");
return conn; return conn;
}, },
@ -727,7 +717,7 @@ var DebuggerServer = {
*/ */
_connectionClosed: function DS_connectionClosed(aConnection) { _connectionClosed: function DS_connectionClosed(aConnection) {
delete this._connections[aConnection.prefix]; delete this._connections[aConnection.prefix];
this.emit("connectionchange", "closed", aConnection); this._fireConnectionChange("closed");
}, },
// DebuggerServer extension API. // DebuggerServer extension API.
@ -822,8 +812,6 @@ var DebuggerServer = {
} }
}; };
EventEmitter.decorate(DebuggerServer);
if (this.exports) { if (this.exports) {
exports.DebuggerServer = DebuggerServer; exports.DebuggerServer = DebuggerServer;
} }
@ -1073,31 +1061,6 @@ DebuggerServerConnection.prototype = {
}; };
}, },
/**
* 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.
*/
setAddonOptions: function DSC_setAddonOptions(aId, aOptions) {
let addonList = this.rootActor._parameters.addonList;
if (!addonList) {
return resolve();
}
return addonList.getList().then((addonActors) => {
for (let actor of addonActors) {
if (actor.id != aId) {
continue;
}
actor.setOptions(aOptions);
return;
}
});
},
/* Forwarding packets to other transports based on actor name prefixes. */ /* Forwarding packets to other transports based on actor name prefixes. */
/* /*

View File

@ -35,8 +35,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm"); "resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OS", XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm"); "resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BrowserToolboxProcess",
"resource:///modules/devtools/ToolboxProcess.jsm");
XPCOMUtils.defineLazyServiceGetter(this, XPCOMUtils.defineLazyServiceGetter(this,
"ChromeRegistry", "ChromeRegistry",
@ -1872,14 +1870,6 @@ this.XPIProvider = {
Services.prefs.addObserver(PREF_EM_MIN_COMPAT_PLATFORM_VERSION, this, false); Services.prefs.addObserver(PREF_EM_MIN_COMPAT_PLATFORM_VERSION, this, false);
Services.obs.addObserver(this, NOTIFICATION_FLUSH_PERMISSIONS, false); Services.obs.addObserver(this, NOTIFICATION_FLUSH_PERMISSIONS, false);
try {
BrowserToolboxProcess.on("connectionchange",
this.onDebugConnectionChange.bind(this));
}
catch (e) {
// BrowserToolboxProcess is not available in all applications
}
let flushCaches = this.checkForChanges(aAppChanged, aOldAppVersion, let flushCaches = this.checkForChanges(aAppChanged, aOldAppVersion,
aOldPlatformVersion); aOldPlatformVersion);
@ -3865,15 +3855,6 @@ this.XPIProvider = {
} }
}, },
onDebugConnectionChange: function(aEvent, aWhat, aConnection) {
if (aWhat != "opened")
return;
for (let id of Object.keys(this.bootstrapScopes)) {
aConnection.setAddonOptions(id, { global: this.bootstrapScopes[id] });
}
},
/** /**
* Notified when a preference we're interested in has changed. * Notified when a preference we're interested in has changed.
* *
@ -4138,13 +4119,6 @@ this.XPIProvider = {
catch (e) { catch (e) {
logger.warn("Error loading bootstrap.js for " + aId, e); logger.warn("Error loading bootstrap.js for " + aId, e);
} }
try {
BrowserToolboxProcess.setAddonOptions(aId, { global: this.bootstrapScopes[aId] });
}
catch (e) {
// BrowserToolboxProcess is not available in all applications
}
}, },
/** /**
@ -4159,13 +4133,6 @@ this.XPIProvider = {
delete this.bootstrappedAddons[aId]; delete this.bootstrappedAddons[aId];
this.persistBootstrappedAddons(); this.persistBootstrappedAddons();
this.addAddonsToCrashReporter(); this.addAddonsToCrashReporter();
try {
BrowserToolboxProcess.setAddonOptions(aId, { global: null });
}
catch (e) {
// BrowserToolboxProcess is not available in all applications
}
}, },
/** /**