Bug 1362970 - Part 3 - Fix indentation and one misuse of "catch". r=florian draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Fri, 16 Jun 2017 11:16:00 +0100
changeset 595535 eb61cf8f77d22f0cf026056615a475c2e04f932a
parent 595534 c1e03e2ff8205675a4debb03ee41e8a857df840a
child 633710 35b08a023ab9071f919042c9bef53b4428f9a0bd
push id64344
push userpaolo.mozmail@amadzone.org
push dateFri, 16 Jun 2017 10:19:08 +0000
reviewersflorian
bugs1362970
milestone56.0a1
Bug 1362970 - Part 3 - Fix indentation and one misuse of "catch". r=florian MozReview-Commit-ID: 2oFOmye7EUr
dom/crypto/test/test_WebCrypto.html
dom/promise/tests/unit/test_monitor_uncaught.js
services/fxaccounts/tests/xpcshell/test_oauth_grant_client.js
toolkit/components/osfile/modules/osfile_async_front.jsm
toolkit/components/places/PlacesUtils.jsm
--- a/dom/crypto/test/test_WebCrypto.html
+++ b/dom/crypto/test/test_WebCrypto.html
@@ -486,18 +486,17 @@ TestArray.addTest(
     function encrypt(x, iv) {
       return crypto.subtle.encrypt(
         { name: "AES-CBC", iv: iv },
         x, tv.aes_cbc_enc.data);
     }
 
     function doEncrypt(x) {
       return encrypt(x, new Uint8Array(15))
-        .catch(function () { return encrypt(new Uint8Array(17)); }
-        );
+        .catch(function () { return encrypt(new Uint8Array(17)); });
     }
 
     crypto.subtle.importKey("raw", tv.aes_cbc_enc.key, "AES-CBC", false, ['encrypt'])
       .then(doEncrypt)
       .then(
         error(that),
         complete(that)
       );
@@ -534,18 +533,17 @@ TestArray.addTest(
     function decrypt(x, iv) {
       return crypto.subtle.decrypt(
         { name: "AES-CBC", iv: iv },
         x, tv.aes_cbc_dec.data);
     }
 
     function doDecrypt(x) {
       return decrypt(x, new Uint8Array(15))
-        .catch(function () { return decrypt(x, new Uint8Array(17)); }
-        );
+        .catch(function () { return decrypt(x, new Uint8Array(17)); });
     }
 
     crypto.subtle.importKey("raw", tv.aes_cbc_dec.key, "AES-CBC", false, ['decrypt'])
       .then(doDecrypt)
       .then(
         error(that),
         complete(that)
       );
@@ -582,18 +580,17 @@ TestArray.addTest(
     function encrypt(x, iv) {
       return crypto.subtle.encrypt(
         { name: "AES-CTR", counter: iv, length: 32 },
         x, tv.aes_ctr_enc.data);
     }
 
     function doEncrypt(x) {
       return encrypt(x, new Uint8Array(15))
-        .catch(function () { return encrypt(x, new Uint8Array(17)); }
-        );
+        .catch(function () { return encrypt(x, new Uint8Array(17)); });
     }
 
     crypto.subtle.importKey("raw", tv.aes_ctr_enc.key, "AES-CTR", false, ['encrypt'])
       .then(doEncrypt)
       .then(
         error(that),
         complete(that)
       );
@@ -630,18 +627,17 @@ TestArray.addTest(
     function doDecrypt(x, iv) {
       return crypto.subtle.decrypt(
         { name: "AES-CTR", counter: iv, length: 32 },
         x, tv.aes_ctr_dec.data);
     }
 
     function decrypt(x) {
       return decrypt(x, new Uint8Array(15))
-        .catch(function () { return decrypt(x, new Uint8Array(17)); }
-        );
+        .catch(function () { return decrypt(x, new Uint8Array(17)); });
     }
 
     crypto.subtle.importKey("raw", tv.aes_ctr_dec.key, "AES-CTR", false, ['decrypt'])
       .then(doDecrypt)
       .then(
         error(that),
         complete(that)
       );
--- a/dom/promise/tests/unit/test_monitor_uncaught.js
+++ b/dom/promise/tests/unit/test_monitor_uncaught.js
@@ -98,17 +98,17 @@ add_task(function* test_observe_uncaught
       name: "Promise.resolve",
     };
     yield {
       promise: Promise.resolve(resolve => resolve(0)),
       name: "Resolution callback",
     };
     yield {
       promise: Promise.resolve(0).catch(null),
-      name: "`then(null, null)`"
+      name: "`catch(null)`"
     };
     yield {
       promise: Promise.reject(0).catch(() => {}),
       name: "Reject and catch immediately",
     };
     yield {
       promise: resolveLater(),
       name: "Resolve later",
--- a/services/fxaccounts/tests/xpcshell/test_oauth_grant_client.js
+++ b/services/fxaccounts/tests/xpcshell/test_oauth_grant_client.js
@@ -101,24 +101,23 @@ add_test(function parseErrorResponse() {
     success: true,
     status: STATUS_SUCCESS,
     body: "unexpected",
   };
 
   client._Request = new mockResponse(response);
   client.getTokenFromAssertion("assertion", "scope")
     .catch(function(e) {
-        do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
-        do_check_eq(e.code, STATUS_SUCCESS);
-        do_check_eq(e.errno, ERRNO_PARSE);
-        do_check_eq(e.error, ERROR_PARSE);
-        do_check_eq(e.message, "unexpected");
-        run_next_test();
-      }
-    );
+      do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
+      do_check_eq(e.code, STATUS_SUCCESS);
+      do_check_eq(e.errno, ERRNO_PARSE);
+      do_check_eq(e.error, ERROR_PARSE);
+      do_check_eq(e.message, "unexpected");
+      run_next_test();
+    });
 });
 
 add_test(function serverErrorResponse() {
   let client = new FxAccountsOAuthGrantClient(CLIENT_OPTIONS);
   let response = {
     status: 400,
     body: "{ \"code\": 400, \"errno\": 104, \"error\": \"Bad Request\", \"message\": \"Unauthorized\", \"reason\": \"Invalid fxa assertion\" }",
   };
@@ -127,66 +126,62 @@ add_test(function serverErrorResponse() 
   client.getTokenFromAssertion("blah", "scope")
     .catch(function(e) {
       do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
       do_check_eq(e.code, 400);
       do_check_eq(e.errno, ERRNO_INVALID_FXA_ASSERTION);
       do_check_eq(e.error, "Bad Request");
       do_check_eq(e.message, "Unauthorized");
       run_next_test();
-    }
-  );
+    });
 });
 
 add_test(function networkErrorResponse() {
   let client = new FxAccountsOAuthGrantClient({
     serverURL: "http://domain.dummy",
     client_id: "abc123"
   });
   Services.prefs.setBoolPref("identity.fxaccounts.skipDeviceRegistration", true);
   client.getTokenFromAssertion("assertion", "scope")
     .catch(function(e) {
-        do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
-        do_check_eq(e.code, null);
-        do_check_eq(e.errno, ERRNO_NETWORK);
-        do_check_eq(e.error, ERROR_NETWORK);
-        run_next_test();
-      }
-    ).catch(() => {}).then(() =>
+      do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
+      do_check_eq(e.code, null);
+      do_check_eq(e.errno, ERRNO_NETWORK);
+      do_check_eq(e.error, ERROR_NETWORK);
+      run_next_test();
+    }).catch(() => {}).then(() =>
       Services.prefs.clearUserPref("identity.fxaccounts.skipDeviceRegistration"));
 });
 
 add_test(function unsupportedMethod() {
   let client = new FxAccountsOAuthGrantClient(CLIENT_OPTIONS);
 
   return client._createRequest("/", "PUT")
     .catch(function(e) {
-        do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
-        do_check_eq(e.code, ERROR_CODE_METHOD_NOT_ALLOWED);
-        do_check_eq(e.errno, ERRNO_NETWORK);
-        do_check_eq(e.error, ERROR_NETWORK);
-        do_check_eq(e.message, ERROR_MSG_METHOD_NOT_ALLOWED);
-        run_next_test();
-      }
-    );
+      do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
+      do_check_eq(e.code, ERROR_CODE_METHOD_NOT_ALLOWED);
+      do_check_eq(e.errno, ERRNO_NETWORK);
+      do_check_eq(e.error, ERROR_NETWORK);
+      do_check_eq(e.message, ERROR_MSG_METHOD_NOT_ALLOWED);
+      run_next_test();
+    });
 });
 
 add_test(function onCompleteRequestError() {
   let client = new FxAccountsOAuthGrantClient(CLIENT_OPTIONS);
   client._Request = new mockResponseError(new Error("onComplete error"));
   client.getTokenFromAssertion("assertion", "scope")
     .catch(function(e) {
-        do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
-        do_check_eq(e.code, null);
-        do_check_eq(e.errno, ERRNO_NETWORK);
-        do_check_eq(e.error, ERROR_NETWORK);
-        do_check_eq(e.message, "Error: onComplete error");
-        run_next_test();
-      }
-  );
+      do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
+      do_check_eq(e.code, null);
+      do_check_eq(e.errno, ERRNO_NETWORK);
+      do_check_eq(e.error, ERROR_NETWORK);
+      do_check_eq(e.message, "Error: onComplete error");
+      run_next_test();
+    });
 });
 
 add_test(function incorrectErrno() {
   let client = new FxAccountsOAuthGrantClient(CLIENT_OPTIONS);
   let response = {
     status: 400,
     body: "{ \"code\": 400, \"errno\": \"bad errno\", \"error\": \"Bad Request\", \"message\": \"Unauthorized\", \"reason\": \"Invalid fxa assertion\" }",
   };
@@ -195,18 +190,17 @@ add_test(function incorrectErrno() {
   client.getTokenFromAssertion("blah", "scope")
     .catch(function(e) {
       do_check_eq(e.name, "FxAccountsOAuthGrantClientError");
       do_check_eq(e.code, 400);
       do_check_eq(e.errno, ERRNO_UNKNOWN_ERROR);
       do_check_eq(e.error, "Bad Request");
       do_check_eq(e.message, "Unauthorized");
       run_next_test();
-    }
-  );
+    });
 });
 
 add_test(function constructorTests() {
   validationHelper(undefined,
     "Error: Missing configuration options");
 
   validationHelper({},
     "Error: Missing 'serverURL' parameter");
--- a/toolkit/components/osfile/modules/osfile_async_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_async_front.jsm
@@ -371,17 +371,17 @@ var Scheduler = this.Scheduler = {
    * @return {Promise} A promise with the same behavior as
    * the promise returned by |code|.
    */
   push: function(code) {
     let promise = this.queue.then(code);
     // By definition, |this.queue| can never reject.
     this.queue = promise.catch(() => undefined);
     // Fork |promise| to ensure that uncaught errors are reported
-    return promise.catch(null);
+    return promise.then();
   },
 
   /**
    * Post a message to the worker thread.
    *
    * @param {string} method The name of the method to call.
    * @param {...} args The arguments to pass to the method. These arguments
    * must be clonable.
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -3064,17 +3064,17 @@ PlacesCreateLivemarkTransaction.prototyp
         }
       }, Cu.reportError);
   },
 
   undoTransaction: function CLTXN_undoTransaction() {
     // The getLivemark callback may fail, but it is used just to serialize,
     // so it doesn't matter.
     this._promise = PlacesUtils.livemarks.getLivemark({ id: this.item.id })
-      .catch(null).then( () => {
+      .catch(() => {}).then(() => {
         PlacesUtils.bookmarks.removeItem(this.item.id);
       });
   }
 };
 
 
 /**
  * Transaction for removing a livemark item.