Bug 992371 - avoid 'A promise chain failed to handle a rejection' errors using FxAccounts. r=jedp

This commit is contained in:
Mark Hammond 2014-04-29 08:46:14 +10:00
parent 9f1b61fa92
commit 043b20ef46
2 changed files with 18 additions and 5 deletions

View File

@ -698,8 +698,14 @@ FxAccountsInternal.prototype = {
// Login is truly complete once keys have been fetched, so once getKeys()
// obtains and stores kA and kB, it will fire the onverified observer
// notification.
return this.whenVerified(data)
.then(() => this.getKeys());
// The callers of startVerifiedCheck never consume a returned promise (ie,
// this is simply kicking off a background fetch) so we must add a rejection
// handler to avoid runtime warnings about the rejection not being handled.
this.whenVerified(data).then(
() => this.getKeys(),
err => log.info("startVerifiedCheck promise was rejected: " + err)
);
},
whenVerified: function(data) {

View File

@ -321,9 +321,16 @@ add_test(function test_fetchAndUnwrapKeys_no_token() {
});
});
fxa.setSignedInUser(user).then((user) => {
fxa.internal.fetchAndUnwrapKeys();
});
fxa.setSignedInUser(user).then(
user => {
return fxa.internal.fetchAndUnwrapKeys();
}
).then(
null,
error => {
log.info("setSignedInUser correctly rejected");
}
)
});
// Alice (User A) signs up but never verifies her email. Then Bob (User B)