mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Backed out changeset 240237473d9e (bug 1463624) for failing eslint at builds/worker/checkouts/gecko/services/sync/tests/unit/test_browserid_identity.js:279:9 on a CLOSED TREE
This commit is contained in:
parent
5f934337c0
commit
e186d16906
@ -224,6 +224,11 @@ this.BrowserIDManager.prototype = {
|
||||
switch (topic) {
|
||||
case fxAccountsCommon.ONLOGIN_NOTIFICATION: {
|
||||
this._log.info("A user has logged in");
|
||||
// If our existing Sync state is that we needed to reauth, clear that
|
||||
// state now - it will get reset back if a problem persists.
|
||||
if (Weave.Status.login == LOGIN_FAILED_LOGIN_REJECTED) {
|
||||
Weave.Status.login = LOGIN_SUCCEEDED;
|
||||
}
|
||||
this.resetCredentials();
|
||||
let accountData = await this._fxaService.getSignedInUser();
|
||||
this._updateSignedInUser(accountData);
|
||||
@ -233,7 +238,6 @@ this.BrowserIDManager.prototype = {
|
||||
this._log.info("The user is not verified");
|
||||
break;
|
||||
}
|
||||
// intentional fall-through - the user is verified.
|
||||
}
|
||||
// We've been configured with an already verified user, so fall-through.
|
||||
case fxAccountsCommon.ONVERIFIED_NOTIFICATION: {
|
||||
@ -242,18 +246,16 @@ this.BrowserIDManager.prototype = {
|
||||
// Set the username now - that will cause Sync to know it is configured
|
||||
let accountData = await this._fxaService.getSignedInUser();
|
||||
this.username = accountData.email;
|
||||
Weave.Status.login = LOGIN_SUCCEEDED;
|
||||
|
||||
// And actually sync. If we've never synced before, we force a full sync.
|
||||
// If we have, then we are probably just reauthenticating so it's a normal sync.
|
||||
// We can use any pref that must be set if we've synced before, and check
|
||||
// the sync lock state because we might already be doing that first sync.
|
||||
let isFirstSync = !Weave.Service.locked && !Svc.Prefs.get("client.syncID", null);
|
||||
// We can use any pref that must be set if we've synced before.
|
||||
let isFirstSync = !Svc.Prefs.get("client.syncID", null);
|
||||
if (isFirstSync) {
|
||||
this._log.info("Doing initial sync actions");
|
||||
Svc.Prefs.set("firstSync", "resetClient");
|
||||
Services.obs.notifyObservers(null, "weave:service:setup-complete");
|
||||
}
|
||||
Services.obs.notifyObservers(null, "weave:service:setup-complete");
|
||||
// There's no need to wait for sync to complete and it would deadlock
|
||||
// our AsyncObserver.
|
||||
Weave.Service.sync({why: "login"});
|
||||
|
@ -265,34 +265,6 @@ add_task(async function test_ensureLoggedIn() {
|
||||
Assert.equal(Status.login, LOGIN_SUCCEEDED, "final ensureLoggedIn worked");
|
||||
});
|
||||
|
||||
add_task(async function test_syncState() {
|
||||
// Avoid polling for an unverified user.
|
||||
let identityConfig = makeIdentityConfig();
|
||||
let fxaInternal = makeFxAccountsInternalMock(identityConfig);
|
||||
fxaInternal.startVerifiedCheck = () => {};
|
||||
configureFxAccountIdentity(globalBrowseridManager, globalIdentityConfig, fxaInternal);
|
||||
|
||||
// arrange for no logged in user.
|
||||
let fxa = globalBrowseridManager._fxaService;
|
||||
let signedInUser = fxa.internal.currentAccountState.storageManager.accountData;
|
||||
fxa.internal.currentAccountState.storageManager.accountData = null;
|
||||
await Assert.rejects(globalBrowseridManager._ensureValidToken(true), "expecting rejection due to no user");
|
||||
// Restore to an unverified user.
|
||||
signedInUser.verified = false;
|
||||
fxa.internal.currentAccountState.storageManager.accountData = signedInUser;
|
||||
Status.login = LOGIN_FAILED_LOGIN_REJECTED;
|
||||
// The browserid_identity observers are async, so call them directly.
|
||||
await globalBrowseridManager.observe(null, ONLOGIN_NOTIFICATION, "");
|
||||
Assert.equal(Status.login, LOGIN_FAILED_LOGIN_REJECTED,
|
||||
"should not have changed the login state for an unverified user");
|
||||
|
||||
// now pretend the user because verified.
|
||||
signedInUser.verified = true;
|
||||
await globalBrowseridManager.observe(null, ONVERIFIED_NOTIFICATION, "");
|
||||
Assert.equal(Status.login, LOGIN_SUCCEEDED,
|
||||
"should have changed the login state to success");
|
||||
});
|
||||
|
||||
add_task(async function test_tokenExpiration() {
|
||||
_("BrowserIDManager notices token expiration:");
|
||||
let bimExp = new BrowserIDManager();
|
||||
|
Loading…
Reference in New Issue
Block a user