Skip to content

Commit

Permalink
Bug 1362970 - Part 3 - Fix indentation and one misuse of "catch". r=f…
Browse files Browse the repository at this point in the history
…lorian

MozReview-Commit-ID: 2oFOmye7EUr
  • Loading branch information
Paolo Amadini committed Jun 16, 2017
1 parent 6d3eae2 commit 2c9351d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 46 deletions.
12 changes: 4 additions & 8 deletions dom/crypto/test/test_WebCrypto.html
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,7 @@

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'])
Expand Down Expand Up @@ -539,8 +538,7 @@

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'])
Expand Down Expand Up @@ -587,8 +585,7 @@

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'])
Expand Down Expand Up @@ -635,8 +632,7 @@

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'])
Expand Down
2 changes: 1 addition & 1 deletion dom/promise/tests/unit/test_monitor_uncaught.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ add_task(function* test_observe_uncaught() {
};
yield {
promise: Promise.resolve(0).catch(null),
name: "`then(null, null)`"
name: "`catch(null)`"
};
yield {
promise: Promise.reject(0).catch(() => {}),
Expand Down
64 changes: 29 additions & 35 deletions services/fxaccounts/tests/xpcshell/test_oauth_grant_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,13 @@ add_test(function parseErrorResponse() {
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() {
Expand All @@ -132,8 +131,7 @@ add_test(function serverErrorResponse() {
do_check_eq(e.error, "Bad Request");
do_check_eq(e.message, "Unauthorized");
run_next_test();
}
);
});
});

add_test(function networkErrorResponse() {
Expand All @@ -144,13 +142,12 @@ add_test(function networkErrorResponse() {
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"));
});

Expand All @@ -159,29 +156,27 @@ add_test(function unsupportedMethod() {

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() {
Expand All @@ -200,8 +195,7 @@ add_test(function incorrectErrno() {
do_check_eq(e.error, "Bad Request");
do_check_eq(e.message, "Unauthorized");
run_next_test();
}
);
});
});

add_test(function constructorTests() {
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/osfile/modules/osfile_async_front.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ var Scheduler = this.Scheduler = {
// 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();
},

/**
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/places/PlacesUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -3069,7 +3069,7 @@ PlacesCreateLivemarkTransaction.prototype = {
// 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);
});
}
Expand Down

0 comments on commit 2c9351d

Please sign in to comment.