Bug 1481025: Fix devtools code which calls message manager methods with a null target. r=ochameau
authorKris Maglione <maglione.k@gmail.com>
Sat, 04 Aug 2018 15:51:56 -0700
changeset 431136 ffc96a72ae14f9dcd9ba0245cc6f8f9a6dcb6e81
parent 431135 c2e822179070687fce86468933a404f558490df7
child 431137 e3cec7443adffef026b98c41bb709a4c48baecb9
child 431141 14f33f70fa0c3bc615a19f0b104b63a7421e6fab
push id34425
push usercsabou@mozilla.com
push dateSun, 12 Aug 2018 09:43:48 +0000
treeherdermozilla-central@ffc96a72ae14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1481025
milestone63.0a1
first release with
nightly linux32
ffc96a72ae14 / 63.0a1 / 20180812100044 / files
nightly linux64
ffc96a72ae14 / 63.0a1 / 20180812100044 / files
nightly mac
ffc96a72ae14 / 63.0a1 / 20180812100044 / files
nightly win32
ffc96a72ae14 / 63.0a1 / 20180812100044 / files
nightly win64
ffc96a72ae14 / 63.0a1 / 20180812100044 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1481025: Fix devtools code which calls message manager methods with a null target. r=ochameau MozReview-Commit-ID: KJeQjwhfJbw
devtools/server/actors/storage.js
devtools/server/main.js
--- a/devtools/server/actors/storage.js
+++ b/devtools/server/actors/storage.js
@@ -748,18 +748,17 @@ StorageActors.createActor({
         cookieHelpers.removeCookie.bind(cookieHelpers);
       this.removeAllCookies =
         cookieHelpers.removeAllCookies.bind(cookieHelpers);
       this.removeAllSessionCookies =
         cookieHelpers.removeAllSessionCookies.bind(cookieHelpers);
       return;
     }
 
-    const { sendSyncMessage, addMessageListener } =
-      this.conn.parentMessageManager;
+    const mm = this.conn.parentMessageManager;
 
     this.conn.setupInParent({
       module: "devtools/server/actors/storage",
       setupParent: "setupParentProcessForCookies"
     });
 
     this.getCookiesFromHost =
       callParentProcess.bind(null, "getCookiesFromHost");
@@ -771,21 +770,21 @@ StorageActors.createActor({
       callParentProcess.bind(null, "editCookie");
     this.removeCookie =
       callParentProcess.bind(null, "removeCookie");
     this.removeAllCookies =
       callParentProcess.bind(null, "removeAllCookies");
     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
       });
 
       if (reply.length === 0) {
         console.error("ERR_DIRECTOR_CHILD_NO_REPLY from " + methodName);
       } else if (reply.length > 1) {
         console.error("ERR_DIRECTOR_CHILD_MULTIPLE_REPLIES from " + methodName);
@@ -1892,34 +1891,33 @@ StorageActors.createActor({
       this.openWithPrincipal = indexedDBHelpers.openWithPrincipal;
       this.removeDB = indexedDBHelpers.removeDB;
       this.removeDBRecord = indexedDBHelpers.removeDBRecord;
       this.splitNameAndStorage = indexedDBHelpers.splitNameAndStorage;
       this.getInternalHosts = indexedDBHelpers.getInternalHosts;
       return;
     }
 
-    const { sendAsyncMessage, addMessageListener } =
-      this.conn.parentMessageManager;
+    const mm = this.conn.parentMessageManager;
 
     this.conn.setupInParent({
       module: "devtools/server/actors/storage",
       setupParent: "setupParentProcessForIndexedDB"
     });
 
     this.getDBMetaData = callParentProcessAsync.bind(null, "getDBMetaData");
     this.splitNameAndStorage = callParentProcessAsync.bind(null, "splitNameAndStorage");
     this.getInternalHosts = callParentProcessAsync.bind(null, "getInternalHosts");
     this.getDBNamesForHost = callParentProcessAsync.bind(null, "getDBNamesForHost");
     this.getValuesForHost = callParentProcessAsync.bind(null, "getValuesForHost");
     this.removeDB = callParentProcessAsync.bind(null, "removeDB");
     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;
           const deferred = unresolvedPromises.get(func);
           if (deferred) {
             unresolvedPromises.delete(func);
             deferred.resolve(rv);
           }
@@ -1933,17 +1931,17 @@ StorageActors.createActor({
     });
 
     const unresolvedPromises = new Map();
     function callParentProcessAsync(methodName, ...args) {
       const deferred = defer();
 
       unresolvedPromises.set(methodName, deferred);
 
-      sendAsyncMessage("debug:storage-indexedDB-request-parent", {
+      mm.sendAsyncMessage("debug:storage-indexedDB-request-parent", {
         method: methodName,
         args: args
       });
 
       return deferred.promise;
     }
   },
 
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -1848,19 +1848,17 @@ DebuggerServerConnection.prototype = {
    * @return boolean
    *         true if the setup helper returned successfully
    */
   setupInParent({ module, setupParent }) {
     if (!this.parentMessageManager) {
       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
     });
   },
 
   /**
    * Instanciates a protocol.js actor in the parent process, from the content process
@@ -1877,31 +1875,30 @@ DebuggerServerConnection.prototype = {
    * @param args array
    *        Arguments to pass to its constructor
    */
   spawnActorInParentProcess(spawnedByActorID, { module, constructor, args }) {
     if (!this.parentMessageManager) {
       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,
       args,
       spawnedByActorID,
     });
 
     return onResponse;