Bug 1521197 - Include uid in UIState.get. r=markh
authorEdouard Oger <eoger@fastmail.com>
Wed, 23 Jan 2019 22:55:03 +0000
changeset 515341 20bf765a66a3fd4b39cc002eaef2015ba63e45ec
parent 515340 9969ea8e9a58bbb10b6cd54eadba0754e5b45b10
child 515342 ec5b5e910ce1a4c77b19dbdd35e37bbfd849328d
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs1521197
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521197 - Include uid in UIState.get. r=markh Differential Revision: https://phabricator.services.mozilla.com/D17034
services/sync/modules/UIState.jsm
services/sync/tests/unit/test_uistate.js
--- a/services/sync/modules/UIState.jsm
+++ b/services/sync/modules/UIState.jsm
@@ -158,16 +158,17 @@ const UIStateInternal = {
       let loginFailed = await this._loginFailed();
       if (loginFailed) {
         status = STATUS_LOGIN_FAILED;
       } else if (!userData.verified) {
         status = STATUS_NOT_VERIFIED;
       } else {
         status = STATUS_SIGNED_IN;
       }
+      state.uid = userData.uid;
       state.email = userData.email;
     }
     state.status = status;
   },
 
   _populateWithProfile(state, profile) {
     state.displayName = profile.displayName;
     state.avatarURL = profile.avatar;
--- a/services/sync/tests/unit/test_uistate.js
+++ b/services/sync/tests/unit/test_uistate.js
@@ -47,24 +47,25 @@ add_task(async function test_refreshStat
   UIState.reset();
   const fxAccountsOrig = UIStateInternal.fxAccounts;
 
   const now = new Date().toString();
   Services.prefs.setCharPref("services.sync.lastSync", now);
   UIStateInternal.syncing = false;
 
   UIStateInternal.fxAccounts = {
-    getSignedInUser: () => Promise.resolve({ verified: true, email: "foo@bar.com" }),
+    getSignedInUser: () => Promise.resolve({ verified: true, uid: "123", email: "foo@bar.com" }),
     getSignedInUserProfile: () => Promise.resolve({ displayName: "Foo Bar", avatar: "https://foo/bar" }),
     hasLocalSession: () => Promise.resolve(true),
   };
 
   let state = await UIState.refresh();
 
   equal(state.status, UIState.STATUS_SIGNED_IN);
+  equal(state.uid, "123");
   equal(state.email, "foo@bar.com");
   equal(state.displayName, "Foo Bar");
   equal(state.avatarURL, "https://foo/bar");
   equal(state.lastSync, now);
   equal(state.syncing, false);
 
   UIStateInternal.fxAccounts = fxAccountsOrig;
 });
@@ -80,16 +81,17 @@ add_task(async function test_refreshStat
 
   UIStateInternal.fxAccounts = {
     getSignedInUser: () => Promise.resolve(null),
   };
 
   let state = await UIState.refresh();
 
   equal(state.status, UIState.STATUS_LOGIN_FAILED);
+  equal(state.uid, undefined);
   equal(state.email, "test@test.com");
   equal(state.displayName, undefined);
   equal(state.avatarURL, undefined);
   equal(state.lastSync, undefined); // only set when STATUS_SIGNED_IN.
   equal(state.syncing, false);
 
   UIStateInternal.fxAccounts = fxAccountsOrig;
   Services.prefs.clearUserPref("services.sync.lastSync");
@@ -101,24 +103,25 @@ add_task(async function test_refreshStat
   UIState.reset();
   const fxAccountsOrig = UIStateInternal.fxAccounts;
 
   const now = new Date().toString();
   Services.prefs.setCharPref("services.sync.lastSync", now);
   UIStateInternal.syncing = false;
 
   UIStateInternal.fxAccounts = {
-    getSignedInUser: () => Promise.resolve({ verified: true, email: "foo@bar.com" }),
+    getSignedInUser: () => Promise.resolve({ verified: true, uid: "123", email: "foo@bar.com" }),
     getSignedInUserProfile: () => Promise.reject(new Error("Profile unavailable")),
     hasLocalSession: () => Promise.resolve(true),
   };
 
   let state = await UIState.refresh();
 
   equal(state.status, UIState.STATUS_SIGNED_IN);
+  equal(state.uid, "123");
   equal(state.email, "foo@bar.com");
   equal(state.displayName, undefined);
   equal(state.avatarURL, undefined);
   equal(state.lastSync, now);
   equal(state.syncing, false);
 
   UIStateInternal.fxAccounts = fxAccountsOrig;
 });
@@ -147,49 +150,51 @@ add_task(async function test_refreshStat
 });
 
 add_task(async function test_refreshState_unverified() {
   UIState.reset();
   const fxAccountsOrig = UIStateInternal.fxAccounts;
 
   let getSignedInUserProfile = sinon.spy();
   UIStateInternal.fxAccounts = {
-    getSignedInUser: () => Promise.resolve({ verified: false, email: "foo@bar.com" }),
+    getSignedInUser: () => Promise.resolve({ verified: false, uid: "123", email: "foo@bar.com" }),
     getSignedInUserProfile,
     hasLocalSession: () => Promise.resolve(true),
   };
 
   let state = await UIState.refresh();
 
   equal(state.status, UIState.STATUS_NOT_VERIFIED);
+  equal(state.uid, "123");
   equal(state.email, "foo@bar.com");
   equal(state.displayName, undefined);
   equal(state.avatarURL, undefined);
   equal(state.lastSync, undefined);
 
   ok(!getSignedInUserProfile.called);
 
   UIStateInternal.fxAccounts = fxAccountsOrig;
 });
 
 add_task(async function test_refreshState_unverified_nosession() {
   UIState.reset();
   const fxAccountsOrig = UIStateInternal.fxAccounts;
 
   let getSignedInUserProfile = sinon.spy();
   UIStateInternal.fxAccounts = {
-    getSignedInUser: () => Promise.resolve({ verified: false, email: "foo@bar.com" }),
+    getSignedInUser: () => Promise.resolve({ verified: false, uid: "123", email: "foo@bar.com" }),
     getSignedInUserProfile,
     hasLocalSession: () => Promise.resolve(false),
   };
 
   let state = await UIState.refresh();
 
   // No session should "win" over the unverified state.
   equal(state.status, UIState.STATUS_LOGIN_FAILED);
+  equal(state.uid, "123");
   equal(state.email, "foo@bar.com");
   equal(state.displayName, undefined);
   equal(state.avatarURL, undefined);
   equal(state.lastSync, undefined);
 
   ok(!getSignedInUserProfile.called);
 
   UIStateInternal.fxAccounts = fxAccountsOrig;
@@ -199,23 +204,24 @@ add_task(async function test_refreshStat
   UIState.reset();
   const fxAccountsOrig = UIStateInternal.fxAccounts;
 
   let loginFailed = sinon.stub(UIStateInternal, "_loginFailed");
   loginFailed.returns(true);
 
   let getSignedInUserProfile = sinon.spy();
   UIStateInternal.fxAccounts = {
-    getSignedInUser: () => Promise.resolve({ verified: true, email: "foo@bar.com" }),
+    getSignedInUser: () => Promise.resolve({ verified: true, uid: "123", email: "foo@bar.com" }),
     getSignedInUserProfile,
   };
 
   let state = await UIState.refresh();
 
   equal(state.status, UIState.STATUS_LOGIN_FAILED);
+  equal(state.uid, "123");
   equal(state.email, "foo@bar.com");
   equal(state.displayName, undefined);
   equal(state.avatarURL, undefined);
   equal(state.lastSync, undefined);
 
   ok(!getSignedInUserProfile.called);
 
   loginFailed.restore();
@@ -245,17 +251,17 @@ add_task(async function test_observer_re
 async function configureUIState(syncing, lastSync = new Date()) {
   UIState.reset();
   const fxAccountsOrig = UIStateInternal.fxAccounts;
 
   UIStateInternal._syncing = syncing;
   Services.prefs.setCharPref("services.sync.lastSync", lastSync.toString());
 
   UIStateInternal.fxAccounts = {
-    getSignedInUser: () => Promise.resolve({ verified: true, email: "foo@bar.com" }),
+    getSignedInUser: () => Promise.resolve({ verified: true, uid: "123", email: "foo@bar.com" }),
     getSignedInUserProfile: () => Promise.resolve({ displayName: "Foo Bar", avatar: "https://foo/bar" }),
     hasLocalSession: () => Promise.resolve(true),
   };
   await UIState.refresh();
   UIStateInternal.fxAccounts = fxAccountsOrig;
 }
 
 add_task(async function test_syncStarted() {