Bug 1448165 p4 - Remove skipDeviceRegistration pref. r?markh draft
authorEdouard Oger <eoger@fastmail.com>
Wed, 28 Mar 2018 15:15:31 -0400
changeset 774430 21d7dc1ed5e9f4f55daddb8f12e4810bd2edf852
parent 774429 f029cb58f86254b5fe3c1a76e4c7599cd7eb7975
push id104396
push userbmo:eoger@fastmail.com
push dateWed, 28 Mar 2018 21:42:47 +0000
reviewersmarkh
bugs1448165
milestone61.0a1
Bug 1448165 p4 - Remove skipDeviceRegistration pref. r?markh MozReview-Commit-ID: Ktibgc7SPfo
browser/components/uitour/test/browser_fxa.js
services/fxaccounts/FxAccounts.jsm
services/fxaccounts/tests/xpcshell/test_oauth_grant_client.js
testing/profiles/prefs_general.js
--- a/browser/components/uitour/test/browser_fxa.js
+++ b/browser/components/uitour/test/browser_fxa.js
@@ -19,53 +19,29 @@ function test() {
 const oldState = UIState.get();
 registerCleanupFunction(async function() {
   await signOut();
   gSync.updateAllUI(oldState);
 });
 
 var tests = [
   taskify(async function test_highlight_accountStatus_loggedOut() {
-    let userData = await fxAccounts.getSignedInUser();
-    is(userData, null, "Not logged in initially");
     await showMenuPromise("appMenu");
     await showHighlightPromise("accountStatus");
     let highlight = document.getElementById("UITourHighlightContainer");
     is(highlight.getAttribute("targetName"), "accountStatus", "Correct highlight target");
   }),
 
   taskify(async function test_highlight_accountStatus_loggedIn() {
-    await setSignedInUser();
-    let userData = await fxAccounts.getSignedInUser();
-    isnot(userData, null, "Logged in now");
     gSync.updateAllUI({ status: UIState.STATUS_SIGNED_IN, lastSync: new Date(), email: "foo@example.com" });
     await showMenuPromise("appMenu");
     await showHighlightPromise("accountStatus");
     let highlight = document.getElementById("UITourHighlightContainer");
     let expectedTarget = "appMenu-fxa-avatar";
     is(highlight.popupBoxObject.anchorNode.id, expectedTarget, "Anchored on avatar");
     is(highlight.getAttribute("targetName"), "accountStatus", "Correct highlight target");
   }),
 ];
 
-// Watch out - these will fire observers which if you aren't careful, may
-// interfere with the tests.
-function setSignedInUser(data) {
-  if (!data) {
-    data = {
-      email: "foo@example.com",
-      uid: "1234@lcip.org",
-      assertion: "foobar",
-      sessionToken: "dead",
-      kSync: "beef",
-      kXCS: "cafe",
-      kExtSync: "bacon",
-      kExtKbHash: "cheese",
-      verified: true
-    };
-  }
- return fxAccounts.setSignedInUser(data);
-}
-
 function signOut() {
   // we always want a "localOnly" signout here...
   return fxAccounts.signOut(true);
 }
--- a/services/fxaccounts/FxAccounts.jsm
+++ b/services/fxaccounts/FxAccounts.jsm
@@ -1639,22 +1639,16 @@ FxAccountsInternal.prototype = {
       profileCache
     });
   },
 
   // If you change what we send to the FxA servers during device registration,
   // you'll have to bump the DEVICE_REGISTRATION_VERSION number to force older
   // devices to re-register when Firefox updates
   async _registerOrUpdateDevice(signedInUser) {
-    // Allow tests to skip device registration because it makes remote requests
-    // to the auth server and _getDeviceName does not work from xpcshell.
-    if (Services.prefs.getBoolPref("identity.fxaccounts.skipDeviceRegistration", false)) {
-      return null;
-    }
-
     const {sessionToken, device: currentDevice} = signedInUser;
     if (!sessionToken) {
       throw new Error("_registerOrUpdateDevice called without a session token");
     }
 
     try {
       const subscription = await this.fxaPushService.registerPushEndpoint();
       const deviceName = this._getDeviceName();
--- a/services/fxaccounts/tests/xpcshell/test_oauth_grant_client.js
+++ b/services/fxaccounts/tests/xpcshell/test_oauth_grant_client.js
@@ -136,26 +136,24 @@ add_task(async function serverErrorRespo
     });
 });
 
 add_task(async function networkErrorResponse() {
   let client = new FxAccountsOAuthGrantClient({
     serverURL: "https://domain.dummy",
     client_id: "abc123"
   });
-  Services.prefs.setBoolPref("identity.fxaccounts.skipDeviceRegistration", true);
   client.getTokenFromAssertion("assertion", "scope")
     .catch(function(e) {
       Assert.equal(e.name, "FxAccountsOAuthGrantClientError");
       Assert.equal(e.code, null);
       Assert.equal(e.errno, ERRNO_NETWORK);
       Assert.equal(e.error, ERROR_NETWORK);
       run_next_test();
-    }).catch(() => {}).then(() =>
-      Services.prefs.clearUserPref("identity.fxaccounts.skipDeviceRegistration"));
+    });
 });
 
 add_test(function unsupportedMethod() {
   let client = new FxAccountsOAuthGrantClient(CLIENT_OPTIONS);
 
   return client._createRequest("/", "PUT")
     .catch(function(e) {
       Assert.equal(e.name, "FxAccountsOAuthGrantClientError");
@@ -266,26 +264,24 @@ add_test(function errorTests() {
 });
 
 
 add_test(function networkErrorResponse() {
   let client = new FxAccountsOAuthGrantClient({
     serverURL: "https://domain.dummy",
     client_id: "abc123"
   });
-  Services.prefs.setBoolPref("identity.fxaccounts.skipDeviceRegistration", true);
   client.getTokenFromAssertion("assertion", "scope")
     .catch(function(e) {
       Assert.equal(e.name, "FxAccountsOAuthGrantClientError");
       Assert.equal(e.code, null);
       Assert.equal(e.errno, ERRNO_NETWORK);
       Assert.equal(e.error, ERROR_NETWORK);
       run_next_test();
-    }).catch(() => {}).then(() =>
-      Services.prefs.clearUserPref("identity.fxaccounts.skipDeviceRegistration"));
+    });
 });
 
 
 /**
  * Quick way to test the "FxAccountsOAuthGrantClient" constructor.
  *
  * @param {Object} options
  *        FxAccountsOAuthGrantClient constructor options
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -262,19 +262,16 @@ user_pref("toolkit.telemetry.test.pref2"
 // We don't want to hit the real Firefox Accounts server for tests.  We don't
 // actually need a functioning FxA server, so just set it to something that
 // resolves and accepts requests, even if they all fail.
 user_pref("identity.fxaccounts.auth.uri", "https://%(server)s/fxa-dummy/");
 
 // Ditto for all the FxA content root URI.
 user_pref("identity.fxaccounts.remote.root", "https://%(server)s/");
 
-// We don't want browser tests to perform FxA device registration.
-user_pref("identity.fxaccounts.skipDeviceRegistration", true);
-
 // Increase the APZ content response timeout in tests to 1 minute.
 // This is to accommodate the fact that test environments tends to be slower
 // than production environments (with the b2g emulator being the slowest of them
 // all), resulting in the production timeout value sometimes being exceeded
 // and causing false-positive test failures. See bug 1176798, bug 1177018,
 // bug 1210465.
 user_pref("apz.content_response_timeout", 60000);