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

View File

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