Bug 834033 - Fix JS ReferenceErrors in PushService.jsm error handling. r=dougt
authorChris Peterson <cpeterson@mozilla.com>
Thu, 02 May 2013 11:46:45 -0700
changeset 141989 0bf3505c02b2e8062c685b8804e6ac308f777208
parent 141988 fb926cf3a068ee6a857a273eba82a88b07b31474
child 141990 75c66fa0109eb60b867adeabe3047796563c0bf2
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
bugs834033
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 834033 - Fix JS ReferenceErrors in PushService.jsm error handling. r=dougt
dom/push/src/PushService.jsm
--- a/dom/push/src/PushService.jsm
+++ b/dom/push/src/PushService.jsm
@@ -58,16 +58,17 @@ this.PushDB.prototype = {
   upgradeSchema: function(aTransaction, aDb, aOldVersion, aNewVersion) {
     debug("PushDB.upgradeSchema()")
 
     let objectStore = aDb.createObjectStore(kPUSHDB_STORE_NAME,
                                             { keyPath: "channelID" });
 
     // index to fetch records based on endpoints. used by unregister
     objectStore.createIndex("pushEndpoint", "pushEndpoint", { unique: true });
+
     // index to fetch records per manifest, so we can identify endpoints
     // associated with an app. Since an app can have multiple endpoints
     // uniqueness cannot be enforced
     objectStore.createIndex("manifestURL", "manifestURL", { unique: false });
   },
 
   /*
    * @param aChannelRecord
@@ -727,17 +728,17 @@ this.PushService = {
 
   /*
    * Must be used only by request/response style calls over the websocket.
    */
   _sendRequest: function(action, data) {
     debug("sendRequest() " + action);
     if (typeof data.channelID !== "string") {
       debug("Received non-string channelID");
-      return;
+      return Promise.reject("Received non-string channelID");
     }
 
     var deferred = Promise.defer();
 
     if (Object.keys(this._pendingRequests).length == 0) {
       // start the timer since we now have at least one request
       if (!this._requestTimeoutTimer)
         this._requestTimeoutTimer = Cc["@mozilla.org/timer;1"]
@@ -922,30 +923,28 @@ this.PushService = {
    * navigator.push, identifying the sending page and other fields.
    */
   register: function(aPageRecord, aMessageManager) {
     debug("register()");
 
     let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
                           .getService(Ci.nsIUUIDGenerator);
     // generateUUID() gives a UUID surrounded by {...}, slice them off.
-    var channelID = uuidGenerator.generateUUID().toString()
-                      .slice(1)
-                      .slice(0, -1);
+    var channelID = uuidGenerator.generateUUID().toString().slice(1, -1);
 
     this._sendRequest("register", {channelID: channelID})
       .then(
         this._onRegisterSuccess.bind(this, aPageRecord, channelID),
         this._onRegisterError.bind(this, aPageRecord, aMessageManager)
       )
       .then(
         function(message) {
           aMessageManager.sendAsyncMessage("PushService:Register:OK", message);
         },
-        function() {
+        function(message) {
           aMessageManager.sendAsyncMessage("PushService:Register:KO", message);
       });
   },
 
   /**
    * Exceptions thrown in _onRegisterSuccess are caught by the promise obtained
    * from _sendRequest, causing the promise to be rejected instead.
    */