Bug 1481025: Fix devtools code which calls message manager methods with a null target. r=ochameau

MozReview-Commit-ID: KJeQjwhfJbw

--HG--
extra : rebase_source : 682a0007b1fa802643e5ec43e0ff40db8efded03
This commit is contained in:
Kris Maglione 2018-08-04 15:51:56 -07:00
parent 637cac1ea7
commit 7ce09e1fd8
2 changed files with 12 additions and 17 deletions

View File

@ -753,8 +753,7 @@ StorageActors.createActor({
return;
}
const { sendSyncMessage, addMessageListener } =
this.conn.parentMessageManager;
const mm = this.conn.parentMessageManager;
this.conn.setupInParent({
module: "devtools/server/actors/storage",
@ -776,11 +775,11 @@ StorageActors.createActor({
this.removeAllSessionCookies =
callParentProcess.bind(null, "removeAllSessionCookies");
addMessageListener("debug:storage-cookie-request-child",
cookieHelpers.handleParentRequest);
mm.addMessageListener("debug:storage-cookie-request-child",
cookieHelpers.handleParentRequest);
function callParentProcess(methodName, ...args) {
const reply = sendSyncMessage("debug:storage-cookie-request-parent", {
const reply = mm.sendSyncMessage("debug:storage-cookie-request-parent", {
method: methodName,
args: args
});
@ -1897,8 +1896,7 @@ StorageActors.createActor({
return;
}
const { sendAsyncMessage, addMessageListener } =
this.conn.parentMessageManager;
const mm = this.conn.parentMessageManager;
this.conn.setupInParent({
module: "devtools/server/actors/storage",
@ -1914,7 +1912,7 @@ StorageActors.createActor({
this.removeDBRecord = callParentProcessAsync.bind(null, "removeDBRecord");
this.clearDBStore = callParentProcessAsync.bind(null, "clearDBStore");
addMessageListener("debug:storage-indexedDB-request-child", msg => {
mm.addMessageListener("debug:storage-indexedDB-request-child", msg => {
switch (msg.json.method) {
case "backToChild": {
const [func, rv] = msg.json.args;
@ -1938,7 +1936,7 @@ StorageActors.createActor({
unresolvedPromises.set(methodName, deferred);
sendAsyncMessage("debug:storage-indexedDB-request-parent", {
mm.sendAsyncMessage("debug:storage-indexedDB-request-parent", {
method: methodName,
args: args
});

View File

@ -1853,9 +1853,7 @@ DebuggerServerConnection.prototype = {
return false;
}
const { sendSyncMessage } = this.parentMessageManager;
return sendSyncMessage("debug:setup-in-parent", {
return this.parentMessageManager.sendSyncMessage("debug:setup-in-parent", {
prefix: this.prefix,
module: module,
setupParent: setupParent
@ -1882,21 +1880,20 @@ DebuggerServerConnection.prototype = {
return null;
}
const { addMessageListener, removeMessageListener, sendAsyncMessage } =
this.parentMessageManager;
const mm = this.parentMessageManager;
const onResponse = new Promise(done => {
const listener = msg => {
if (msg.json.prefix != this.prefix) {
return;
}
removeMessageListener("debug:spawn-actor-in-parent:actor", listener);
mm.removeMessageListener("debug:spawn-actor-in-parent:actor", listener);
done(msg.json.actorID);
};
addMessageListener("debug:spawn-actor-in-parent:actor", listener);
mm.addMessageListener("debug:spawn-actor-in-parent:actor", listener);
});
sendAsyncMessage("debug:spawn-actor-in-parent", {
mm.sendAsyncMessage("debug:spawn-actor-in-parent", {
prefix: this.prefix,
module,
constructor,