зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 961eac228e3e (bug 1585299) for ES Lint failures on FxAccounts.jsm && test_accounts.js CLOSED TREE
This commit is contained in:
Родитель
c0a71bf7f1
Коммит
11b09d510c
|
@ -1452,13 +1452,25 @@ FxAccountsInternal.prototype = {
|
|||
log.debug("startVerifiedCheck with user data", data);
|
||||
}
|
||||
|
||||
// Get us to the verified state. This returns a promise that will fire when
|
||||
// verification is complete.
|
||||
// Get us to the verified state, then get the keys. This returns a promise
|
||||
// that will fire when we are completely ready.
|
||||
//
|
||||
// Login is truly complete once keys have been fetched, so once getKeys()
|
||||
// obtains and stores kSync kXCS kExtSync and kExtKbHash, it will fire the
|
||||
// onverified observer notification.
|
||||
|
||||
// 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).catch(
|
||||
|
||||
this.whenVerified(data).then(
|
||||
() => {
|
||||
log.info("the user became verified");
|
||||
// We are now ready for business. This should only be invoked once
|
||||
// per setSignedInUser(), regardless of whether we've rebooted since
|
||||
// setSignedInUser() was called.
|
||||
return this.notifyObservers(ONVERIFIED_NOTIFICATION);
|
||||
},
|
||||
err => log.info("startVerifiedCheck promise was rejected: " + err)
|
||||
);
|
||||
},
|
||||
|
@ -1508,13 +1520,7 @@ FxAccountsInternal.prototype = {
|
|||
// is yet to start up.) This might cause "A promise chain failed to
|
||||
// handle a rejection" messages, so add an error handler directly
|
||||
// on the promise to log the error.
|
||||
currentState.whenVerifiedDeferred.promise.then(() => {
|
||||
log.info("the user became verified");
|
||||
// We are now ready for business. This should only be invoked once
|
||||
// per setSignedInUser(), regardless of whether we've rebooted since
|
||||
// setSignedInUser() was called.
|
||||
this.notifyObservers(ONVERIFIED_NOTIFICATION);
|
||||
}, err => {
|
||||
currentState.whenVerifiedDeferred.promise.catch(err => {
|
||||
log.info("the wait for user verification was stopped: " + err);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -564,52 +564,6 @@ add_test(function test_polling_timeout() {
|
|||
});
|
||||
});
|
||||
|
||||
// For bug 1585299 - ensure we only get a single ONVERIFIED notification.
|
||||
add_task(async function test_onverified_once() {
|
||||
let fxa = new MockFxAccounts();
|
||||
let user = getTestUser("francine");
|
||||
|
||||
let numNotifications = 0;
|
||||
|
||||
function observe(aSubject, aTopic, aData) {
|
||||
numNotifications += 1;
|
||||
}
|
||||
Services.obs.addObserver(observe, ONVERIFIED_NOTIFICATION);
|
||||
|
||||
fxa._internal.POLL_SESSION = 1;
|
||||
|
||||
await fxa.setSignedInUser(user);
|
||||
|
||||
Assert.ok(!(await fxa.getSignedInUser()).verified, "starts unverified");
|
||||
|
||||
await fxa._internal
|
||||
.startPollEmailStatus(
|
||||
fxa._internal.currentAccountState,
|
||||
user.sessionToken,
|
||||
"start"
|
||||
);
|
||||
|
||||
Assert.ok(!(await fxa.getSignedInUser()).verified, "still unverified");
|
||||
|
||||
log.debug("Mocking verification of francine's email");
|
||||
fxa._internal.fxAccountsClient._email = user.email;
|
||||
fxa._internal.fxAccountsClient._verified = true;
|
||||
|
||||
await fxa._internal
|
||||
.startPollEmailStatus(
|
||||
fxa._internal.currentAccountState,
|
||||
user.sessionToken,
|
||||
"again"
|
||||
);
|
||||
|
||||
Assert.ok((await fxa.getSignedInUser()).verified, "now verified");
|
||||
|
||||
Assert.equal(numNotifications, 1, "expect exactly 1 ONVERIFIED");
|
||||
|
||||
Services.obs.removeObserver(observe, ONVERIFIED_NOTIFICATION);
|
||||
await fxa.signOut();
|
||||
});
|
||||
|
||||
add_test(function test_pollEmailStatus_start_verified() {
|
||||
let fxa = new MockFxAccounts();
|
||||
let test_user = getTestUser("carol");
|
||||
|
|
Загрузка…
Ссылка в новой задаче