Back out changeset 9dce1a90205e (bug 1139657) for B2G emulator xpcshell test failures.
authorL. David Baron <dbaron@dbaron.org>
Tue, 24 Mar 2015 21:16:21 -0700
changeset 265792 cf60b84ee25882958cca70ce59603efbfca96a89
parent 265791 a6619aed2c9db82339cdc3fee8ae3f915468bd62
child 265793 7b0077c342f5d3a8bb927aed3137e3f626b9eee6
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1139657
milestone39.0a1
backs out9dce1a90205efc057259abc390c0fa218d9bee0e
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
Back out changeset 9dce1a90205e (bug 1139657) for B2G emulator xpcshell test failures. Since this landed, every B2G ICS emulator opt xpcshell run has failed with: TEST-UNEXPECTED-TIMEOUT | services/fxaccounts/tests/xpcshell/test_accounts.js | Test timed out DMError: Timeout exceeded for shell call
browser/base/content/test/general/browser_fxa_profile_channel.html
browser/base/content/test/general/browser_fxa_profile_channel.js
services/fxaccounts/FxAccounts.jsm
services/fxaccounts/FxAccountsCommon.js
services/fxaccounts/FxAccountsProfile.jsm
services/fxaccounts/FxAccountsProfileChannel.jsm
services/fxaccounts/moz.build
services/fxaccounts/tests/xpcshell/test_accounts.js
services/fxaccounts/tests/xpcshell/test_profile.js
services/fxaccounts/tests/xpcshell/test_profile_channel.js
services/fxaccounts/tests/xpcshell/xpcshell.ini
--- a/browser/base/content/test/general/browser_fxa_profile_channel.html
+++ b/browser/base/content/test/general/browser_fxa_profile_channel.html
@@ -6,17 +6,17 @@
 </head>
 <body>
 <script>
   window.onload = function(){
     var event = new window.CustomEvent("WebChannelMessageToChrome", {
       detail: {
         id: "account_updates",
         message: {
-          command: "profile:change",
+          command: "profile:image:change",
           data: {
             uid: "abc123",
           },
         },
       },
     });
 
     window.dispatchEvent(event);
--- a/browser/base/content/test/general/browser_fxa_profile_channel.js
+++ b/browser/base/content/test/general/browser_fxa_profile_channel.js
@@ -29,17 +29,17 @@ let gTests = [
 
           tabOpened = true;
         });
 
         let client = new FxAccountsProfileChannel({
           content_uri: HTTP_PATH,
         });
 
-        makeObserver(FxAccountsCommon.ON_PROFILE_CHANGE_NOTIFICATION, function (subject, topic, data) {
+        makeObserver(FxAccountsCommon.ONPROFILE_IMAGE_CHANGE_NOTIFICATION, function (subject, topic, data) {
           Assert.ok(tabOpened);
           Assert.equal(data, "abc123");
           resolve();
           gBrowser.removeCurrentTab();
         });
 
         gBrowser.selectedTab = gBrowser.addTab(properUrl);
       });
--- a/services/fxaccounts/FxAccounts.jsm
+++ b/services/fxaccounts/FxAccounts.jsm
@@ -21,30 +21,26 @@ XPCOMUtils.defineLazyModuleGetter(this, 
   "resource://gre/modules/FxAccountsClient.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "jwcrypto",
   "resource://gre/modules/identity/jwcrypto.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsOAuthGrantClient",
   "resource://gre/modules/FxAccountsOAuthGrantClient.jsm");
 
-XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsProfile",
-  "resource://gre/modules/FxAccountsProfile.jsm");
-
 // All properties exposed by the public FxAccounts API.
 let publicProperties = [
   "accountStatus",
   "getAccountsClient",
   "getAccountsSignInURI",
   "getAccountsSignUpURI",
   "getAssertion",
   "getKeys",
   "getSignedInUser",
   "getOAuthToken",
-  "getSignedInUserProfile",
   "loadAndPoll",
   "localtimeOffsetMsec",
   "now",
   "promiseAccountsForceSigninURI",
   "resendVerificationEmail",
   "setSignedInUser",
   "signOut",
   "version",
@@ -74,43 +70,35 @@ let AccountState = function(fxaInternal)
 };
 
 AccountState.prototype = {
   cert: null,
   keyPair: null,
   signedInUser: null,
   whenVerifiedDeferred: null,
   whenKeysReadyDeferred: null,
-  profile: null,
 
   get isCurrent() this.fxaInternal && this.fxaInternal.currentAccountState === this,
 
   abort: function() {
     if (this.whenVerifiedDeferred) {
       this.whenVerifiedDeferred.reject(
         new Error("Verification aborted; Another user signing in"));
       this.whenVerifiedDeferred = null;
     }
 
     if (this.whenKeysReadyDeferred) {
       this.whenKeysReadyDeferred.reject(
         new Error("Verification aborted; Another user signing in"));
       this.whenKeysReadyDeferred = null;
     }
-
     this.cert = null;
     this.keyPair = null;
     this.signedInUser = null;
     this.fxaInternal = null;
-    this.initProfilePromise = null;
-
-    if (this.profile) {
-      this.profile.tearDown();
-      this.profile = null;
-    }
   },
 
   getUserAccountData: function() {
     // Skip disk if user is cached.
     if (this.signedInUser) {
       return this.resolve(this.signedInUser.accountData);
     }
 
@@ -211,51 +199,16 @@ AccountState.prototype = {
       };
       log.debug("got keyPair");
       delete this.cert;
       d.resolve(this.keyPair.keyPair);
     });
     return d.promise.then(result => this.resolve(result));
   },
 
-  // Get the account's profile image URL from the profile server
-  getProfile: function () {
-    return this.initProfile()
-      .then(() => this.profile.getProfile());
-  },
-
-  // Instantiate a FxAccountsProfile with a fresh OAuth token if needed
-  initProfile: function () {
-
-    let profileServerUrl = Services.urlFormatter.formatURLPref("identity.fxaccounts.remote.profile.uri");
-
-    let oAuthOptions = {
-      scope: "profile"
-    };
-
-    if (this.initProfilePromise) {
-      return this.initProfilePromise;
-    }
-
-    this.initProfilePromise = this.fxaInternal.getOAuthToken(oAuthOptions)
-      .then(token => {
-        this.profile = new FxAccountsProfile(this, {
-          profileServerUrl: profileServerUrl,
-          token: token
-        });
-        this.initProfilePromise = null;
-      })
-      .then(null, err => {
-        this.initProfilePromise = null;
-        throw err;
-      });
-
-    return this.initProfilePromise;
-  },
-
   resolve: function(result) {
     if (!this.isCurrent) {
       log.info("An accountState promise was resolved, but was actually rejected" +
                " due to a different user being signed in. Originally resolved" +
                " with: " + result);
       return Promise.reject(new Error("A different user signed in"));
     }
     return Promise.resolve(result);
@@ -270,17 +223,17 @@ AccountState.prototype = {
       log.info("An accountState promise was rejected, but we are ignoring that" +
                "reason and rejecting it due to a different user being signed in." +
                "Originally rejected with: " + error);
       return Promise.reject(new Error("A different user signed in"));
     }
     return Promise.reject(error);
   },
 
-};
+}
 
 /**
  * Copies properties from a given object to another object.
  *
  * @param from (object)
  *        The object we read property descriptors from.
  * @param to (object)
  *        The object that we set property descriptors on.
@@ -1031,85 +984,32 @@ FxAccountsInternal.prototype = {
    *          NO_ACCOUNT
    *          UNVERIFIED_ACCOUNT
    */
   _errorToErrorClass: function (aError) {
     if (aError.errno) {
       let error = SERVER_ERRNO_TO_ERROR[aError.errno];
       return this._error(ERROR_TO_GENERAL_ERROR_CLASS[error] || ERROR_UNKNOWN, aError);
     } else if (aError.message &&
-        (aError.message === "INVALID_PARAMETER" ||
+        aError.message === "INVALID_PARAMETER" ||
         aError.message === "NO_ACCOUNT" ||
-        aError.message === "UNVERIFIED_ACCOUNT")) {
+        aError.message === "UNVERIFIED_ACCOUNT") {
       return Promise.reject(aError);
     }
     return this._error(ERROR_UNKNOWN, aError);
   },
 
   _error: function(aError, aDetails) {
     log.error("FxA rejecting with error ${aError}, details: ${aDetails}", {aError, aDetails});
     let reason = new Error(aError);
     if (aDetails) {
       reason.details = aDetails;
     }
     return Promise.reject(reason);
-  },
-
-  /**
-   * Get the user's account and profile data
-   *
-   * @param options
-   *        {
-   *          contentUrl: (string) Used by the FxAccountsProfileChannel.
-   *            Defaults to pref identity.fxaccounts.settings.uri
-   *          profileServerUrl: (string) Used by the FxAccountsProfileChannel.
-   *            Defaults to pref identity.fxaccounts.remote.profile.uri
-   *        }
-   *
-   * @return Promise.<object | Error>
-   *        The promise resolves to an accountData object with extra profile
-   *        information such as profileImageUrl, or rejects with
-   *        an error object ({error: ERROR, details: {}}) of the following:
-   *          INVALID_PARAMETER
-   *          NO_ACCOUNT
-   *          UNVERIFIED_ACCOUNT
-   *          NETWORK_ERROR
-   *          AUTH_ERROR
-   *          UNKNOWN_ERROR
-   */
-  getSignedInUserProfile: function () {
-    let accountState = this.currentAccountState;
-    return accountState.getProfile()
-      .then(
-        (profileData) => {
-          let profile = JSON.parse(JSON.stringify(profileData));
-          // profileData doesn't include "verified", but it must be true
-          // if we've gotten this far.
-          profile.verified = true;
-          return accountState.resolve(profile);
-        },
-        (error) => {
-          log.error("Could not retrieve profile data", error);
-
-          return this.getSignedInUser().then(data => {
-            let profile = null;
-            if (data) {
-              // If we fail to fetch the profile and have no profile cached
-              // we resort to using the account data for basic profile data.
-              profile = {
-                email: data.email,
-                uid: data.uid,
-                verified: data.verified
-              };
-            }
-            return accountState.resolve(profile);
-          });
-      })
-      .then(null, err => this._errorToErrorClass(err));
-  },
+  }
 };
 
 /**
  * JSONStorage constructor that creates instances that may set/get
  * to a specified file, in a directory that will be created if it
  * doesn't exist.
  *
  * @param options {
--- a/services/fxaccounts/FxAccountsCommon.js
+++ b/services/fxaccounts/FxAccountsCommon.js
@@ -85,17 +85,17 @@ exports.POLL_SESSION       = 1000 * 60 *
 
 // Observer notifications.
 exports.ONLOGIN_NOTIFICATION = "fxaccounts:onlogin";
 exports.ONVERIFIED_NOTIFICATION = "fxaccounts:onverified";
 exports.ONLOGOUT_NOTIFICATION = "fxaccounts:onlogout";
 // Internal to services/fxaccounts only
 exports.ON_FXA_UPDATE_NOTIFICATION = "fxaccounts:update";
 
-exports.ON_PROFILE_CHANGE_NOTIFICATION = "fxaccounts:profilechange";
+exports.ONPROFILE_IMAGE_CHANGE_NOTIFICATION = "fxaccounts:profileimagechange";
 
 // UI Requests.
 exports.UI_REQUEST_SIGN_IN_FLOW = "signInFlow";
 exports.UI_REQUEST_REFRESH_AUTH = "refreshAuthentication";
 
 // The OAuth client ID for Firefox Desktop
 exports.FX_OAUTH_CLIENT_ID = "5882386c6d801776";
 
deleted file mode 100644
--- a/services/fxaccounts/FxAccountsProfile.jsm
+++ /dev/null
@@ -1,165 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-/**
- * Firefox Accounts Profile helper.
- *
- * This class abstracts interaction with the profile server for an account.
- * It will handle things like fetching profile data, listening for updates to
- * the user's profile in open browser tabs, and cacheing/invalidating profile data.
- */
-
-this.EXPORTED_SYMBOLS = ["FxAccountsProfile"];
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Log.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/FxAccountsCommon.js");
-
-XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsProfileClient",
-  "resource://gre/modules/FxAccountsProfileClient.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "FxAccountsProfileChannel",
-  "resource://gre/modules/FxAccountsProfileChannel.jsm");
-
-let fxAccountProfileChannel = null;
-
-// Based off of deepEqual from Assert.jsm
-function deepEqual(actual, expected) {
-  if (actual === expected) {
-    return true;
-  } else if (typeof actual != "object" && typeof expected != "object") {
-    return actual == expected;
-  } else {
-    return objEquiv(actual, expected);
-  }
-}
-
-function isUndefinedOrNull(value) {
-  return value === null || value === undefined;
-}
-
-function objEquiv(a, b) {
-  if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) {
-    return false;
-  }
-  if (a.prototype !== b.prototype) {
-    return false;
-  }
-  let ka, kb, key, i;
-  try {
-    ka = Object.keys(a);
-    kb = Object.keys(b);
-  } catch (e) {
-    return false;
-  }
-  if (ka.length != kb.length) {
-    return false;
-  }
-  ka.sort();
-  kb.sort();
-  for (i = ka.length - 1; i >= 0; i--) {
-    key = ka[i];
-    if (!deepEqual(a[key], b[key])) {
-      return false;
-    }
-  }
-  return true;
-}
-
-function hasChanged(oldData, newData) {
-  return !deepEqual(oldData, newData);
-}
-
-function FxAccountsProfile (accountState, options = {}) {
-  this.currentAccountState = accountState;
-  this.client = options.profileClient || new FxAccountsProfileClient({
-    serverURL: options.profileServerUrl,
-    token: options.token
-  });
-
-  // for testing
-  if (options.channel) {
-    this.channel = options.channel;
-  }
-}
-
-FxAccountsProfile.prototype = {
-
-  tearDown: function () {
-    this.currentAccountState = null;
-    this.client = null;
-  },
-
-  _getCachedProfile: function () {
-    let currentState = this.currentAccountState;
-    return currentState.getUserAccountData()
-      .then(cachedData => cachedData.profile);
-  },
-
-  _notifyProfileChange: function (uid) {
-    Services.obs.notifyObservers(null, ON_PROFILE_CHANGE_NOTIFICATION, uid);
-  },
-
-  // Cache fetched data if it is different from what's in the cache.
-  // Send out a notification if it has changed so that UI can update.
-  _cacheProfile: function (profileData) {
-    let currentState = this.currentAccountState;
-    if (!currentState) {
-      return;
-    }
-    return currentState.getUserAccountData()
-      .then(data => {
-        if (!hasChanged(data.profile, profileData)) {
-          return;
-        }
-        data.profile = profileData;
-        return currentState.setUserAccountData(data)
-          .then(() => this._notifyProfileChange(data.uid));
-      });
-  },
-
-  _fetchAndCacheProfile: function () {
-    return this.client.fetchProfile()
-      .then(profile => {
-        return this._cacheProfile(profile).then(() => profile);
-      });
-  },
-
-  // Initialize a profile channel to listen for account changes.
-  _listenForProfileChanges: function () {
-    if (! fxAccountProfileChannel) {
-      let contentUri = Services.urlFormatter.formatURLPref("identity.fxaccounts.settings.uri");
-
-      fxAccountProfileChannel = new FxAccountsProfileChannel({
-        content_uri: contentUri
-      });
-    }
-
-    return fxAccountProfileChannel;
-  },
-
-  // Returns cached data right away if available, then fetches the latest profile
-  // data in the background. After data is fetched a notification will be sent
-  // out if the profile has changed.
-  getProfile: function () {
-    this._listenForProfileChanges();
-
-    return this._getCachedProfile()
-      .then(cachedProfile => {
-        if (cachedProfile) {
-          this._fetchAndCacheProfile();
-          return cachedProfile;
-        }
-        return this._fetchAndCacheProfile();
-      })
-      .then(profile => {
-        return profile;
-      });
-  },
-};
--- a/services/fxaccounts/FxAccountsProfileChannel.jsm
+++ b/services/fxaccounts/FxAccountsProfileChannel.jsm
@@ -14,17 +14,17 @@ const {classes: Cc, interfaces: Ci, util
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/FxAccountsCommon.js");
 
 XPCOMUtils.defineLazyModuleGetter(this, "WebChannel",
                                   "resource://gre/modules/WebChannel.jsm");
 
-const PROFILE_CHANGE_COMMAND = "profile:change";
+const PROFILE_IMAGE_CHANGE_COMMAND = "profile:image:change";
 
 /**
  * Create a new FxAccountsProfileChannel to listen to profile updates
  *
  * @param {Object} options Options
  *   @param {Object} options.parameters
  *     @param {String} options.parameters.content_uri
  *     The FxA Content server uri
@@ -97,18 +97,18 @@ this.FxAccountsProfileChannel.prototype 
      *        Channel message event target
      * @private
      */
     let listener = (webChannelId, message, target) => {
       if (message) {
         let command = message.command;
         let data = message.data;
         switch (command) {
-          case PROFILE_CHANGE_COMMAND:
-            Services.obs.notifyObservers(null, ON_PROFILE_CHANGE_NOTIFICATION, data.uid);
+          case PROFILE_IMAGE_CHANGE_COMMAND:
+            Services.obs.notifyObservers(null, ONPROFILE_IMAGE_CHANGE_NOTIFICATION, data.uid);
           break;
         }
       }
     };
 
     this._channelCallback = listener;
     this._channel = new WebChannel(PROFILE_WEBCHANNEL_ID, this._webChannelOrigin);
     this._channel.listen(this._channelCallback);
--- a/services/fxaccounts/moz.build
+++ b/services/fxaccounts/moz.build
@@ -11,17 +11,16 @@ MOCHITEST_CHROME_MANIFESTS += ['tests/mo
 XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini']
 
 EXTRA_JS_MODULES += [
   'Credentials.jsm',
   'FxAccountsClient.jsm',
   'FxAccountsCommon.js',
   'FxAccountsOAuthClient.jsm',
   'FxAccountsOAuthGrantClient.jsm',
-  'FxAccountsProfile.jsm',
   'FxAccountsProfileChannel.jsm',
   'FxAccountsProfileClient.jsm',
 ]
 
 EXTRA_PP_JS_MODULES += [
   'FxAccounts.jsm',
 ]
 
--- a/services/fxaccounts/tests/xpcshell/test_accounts.js
+++ b/services/fxaccounts/tests/xpcshell/test_accounts.js
@@ -27,23 +27,16 @@ log.level = Log.Level.Debug;
 // See verbose logging from FxAccounts.jsm
 Services.prefs.setCharPref("identity.fxaccounts.loglevel", "DEBUG");
 
 // The oauth server is mocked, but set these prefs to pass param checks
 Services.prefs.setCharPref("identity.fxaccounts.remote.oauth.uri", "https://example.com/v1");
 Services.prefs.setCharPref("identity.fxaccounts.oauth.client_id", "abc123");
 
 
-const PROFILE_SERVER_URL = "http://example.com/v1";
-const CONTENT_URL = "http://accounts.example.com/";
-
-Services.prefs.setCharPref("identity.fxaccounts.remote.profile.uri", PROFILE_SERVER_URL);
-Services.prefs.setCharPref("identity.fxaccounts.settings.uri", CONTENT_URL);
-
-
 function run_test() {
   run_next_test();
 }
 
 /*
  * The FxAccountsClient communicates with the remote Firefox
  * Accounts auth server.  Mock the server calls, with a little
  * lag time to simulate some latency.
@@ -857,133 +850,16 @@ add_test(function test_getOAuthToken_unk
     fxa.getOAuthToken({ scope: "profile", client: client })
       .then(null, err => {
          do_check_eq(err.message, "UNKNOWN_ERROR");
          run_next_test();
       });
   });
 });
 
-add_test(function test_accountState_initProfile() {
-  let fxa = new MockFxAccounts();
-  let alice = getTestUser("alice");
-  alice.verified = true;
-
-  fxa.internal.getOAuthToken = function (opts) {
-    return Promise.resolve("token");
-  };
-
-  fxa.setSignedInUser(alice).then(() => {
-    let accountState = fxa.internal.currentAccountState;
-
-    accountState.initProfile(options)
-      .then(result => {
-         do_check_true(!!accountState.profile);
-         run_next_test();
-      });
-  });
-
-});
-
-add_test(function test_accountState_getProfile() {
-  let fxa = new MockFxAccounts();
-  let alice = getTestUser("alice");
-  alice.verified = true;
-
-  let mockProfile = {
-    getProfile: function () {
-      return Promise.resolve({ avatar: "image" });
-    }
-  };
-
-  fxa.setSignedInUser(alice).then(() => {
-    let accountState = fxa.internal.currentAccountState;
-    accountState.profile = mockProfile;
-    accountState.initProfilePromise = new Promise((resolve, reject) => resolve(mockProfile));
-
-    accountState.getProfile()
-      .then(result => {
-         do_check_true(!!result);
-         do_check_eq(result.avatar, "image");
-         run_next_test();
-      });
-  });
-
-});
-
-add_test(function test_getSignedInUserProfile_ok() {
-  let fxa = new MockFxAccounts();
-  let alice = getTestUser("alice");
-  alice.verified = true;
-
-  fxa.setSignedInUser(alice).then(() => {
-    let accountState = fxa.internal.currentAccountState;
-    accountState.getProfile = function () {
-      return Promise.resolve({ avatar: "image" });
-    };
-
-    fxa.getSignedInUserProfile()
-      .then(result => {
-         do_check_eq(result.avatar, "image");
-         do_check_true(result.verified);
-         run_next_test();
-      });
-  });
-
-});
-
-add_test(function test_getSignedInUserProfile_error_uses_account_data() {
-  let fxa = new MockFxAccounts();
-  let alice = getTestUser("alice");
-  alice.verified = true;
-
-  fxa.internal.getSignedInUser = function () {
-    return Promise.resolve({ email: "foo@bar.com" });
-  };
-
-  fxa.setSignedInUser(alice).then(() => {
-    let accountState = fxa.internal.currentAccountState;
-    accountState.getProfile = function () {
-      return Promise.reject("boom");
-    };
-
-    fxa.getSignedInUserProfile()
-      .then(result => {
-         do_check_eq(typeof result.avatar, "undefined");
-         do_check_eq(result.email, "foo@bar.com");
-         run_next_test();
-      });
-  });
-
-});
-
-add_test(function test_getSignedInUserProfile_no_account_data() {
-  let fxa = new MockFxAccounts();
-
-  fxa.internal.getSignedInUser = function () {
-    return Promise.resolve({ email: "foo@bar.com" });
-  };
-
-  let accountState = fxa.internal.currentAccountState;
-  accountState.getProfile = function () {
-    return Promise.reject("boom");
-  };
-
-  fxa.internal.getSignedInUser = function () {
-    return Promise.resolve(null);
-  };
-
-  fxa.getSignedInUserProfile()
-    .then(result => {
-       do_check_eq(result, null);
-       run_next_test();
-    });
-
-});
-
 /*
  * End of tests.
  * Utility functions follow.
  */
 
 function expandHex(two_hex) {
   // Return a 64-character hex string, encoding 32 identical bytes.
   let eight_hex = two_hex + two_hex + two_hex + two_hex;
deleted file mode 100644
--- a/services/fxaccounts/tests/xpcshell/test_profile.js
+++ /dev/null
@@ -1,286 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-Cu.import("resource://gre/modules/Promise.jsm");
-Cu.import("resource://gre/modules/FxAccountsCommon.js");
-Cu.import("resource://gre/modules/FxAccountsProfileClient.jsm");
-Cu.import("resource://gre/modules/FxAccountsProfile.jsm");
-
-const URL_STRING = "https://example.com";
-Services.prefs.setCharPref("identity.fxaccounts.settings.uri", "https://example.com/settings");
-
-const PROFILE_CLIENT_OPTIONS = {
-  token: "123ABC",
-  serverURL: "http://127.0.0.1:1111/v1",
-  profileServerUrl: "http://127.0.0.1:1111/v1"
-};
-
-const STATUS_SUCCESS = 200;
-
-/**
- * Mock request responder
- * @param {String} response
- *        Mocked raw response from the server
- * @returns {Function}
- */
-let mockResponse = function (response) {
-  let Request = function (requestUri) {
-    // Store the request uri so tests can inspect it
-    Request._requestUri = requestUri;
-    return {
-      setHeader: function () {},
-      head: function () {
-        this.response = response;
-        this.onComplete();
-      }
-    };
-  };
-
-  return Request;
-};
-
-/**
- * Mock request error responder
- * @param {Error} error
- *        Error object
- * @returns {Function}
- */
-let mockResponseError = function (error) {
-  return function () {
-    return {
-      setHeader: function () {},
-      head: function () {
-        this.onComplete(error);
-      }
-    };
-  };
-};
-
-let mockClient = function () {
-  let client = new FxAccountsProfileClient(PROFILE_CLIENT_OPTIONS);
-  return client;
-};
-
-const ACCOUNT_DATA = {
-  uid: "abc123"
-};
-
-function AccountData () {
-}
-AccountData.prototype = {
-  getUserAccountData: function () {
-    return Promise.resolve(ACCOUNT_DATA);
-  }
-};
-
-let mockAccountData = function () {
-  return new AccountData();
-};
-
-add_test(function getCachedProfile() {
-  let accountData = mockAccountData();
-  accountData.getUserAccountData = function () {
-    return Promise.resolve({
-      profile: { avatar: "myurl" }
-    });
-  };
-  let profile = new FxAccountsProfile(accountData, PROFILE_CLIENT_OPTIONS);
-
-  return profile._getCachedProfile()
-    .then(function (cached) {
-      do_check_eq(cached.avatar, "myurl");
-      run_next_test();
-    });
-});
-
-add_test(function cacheProfile_change() {
-  let accountData = mockAccountData();
-  let setUserAccountDataCalled = false;
-  accountData.setUserAccountData = function (data) {
-    setUserAccountDataCalled = true;
-    do_check_eq(data.profile.avatar, "myurl");
-    return Promise.resolve();
-  };
-  let profile = new FxAccountsProfile(accountData, PROFILE_CLIENT_OPTIONS);
-
-  makeObserver(ON_PROFILE_CHANGE_NOTIFICATION, function (subject, topic, data) {
-    do_check_eq(data, ACCOUNT_DATA.uid);
-    do_check_true(setUserAccountDataCalled);
-    run_next_test();
-  });
-
-  return profile._cacheProfile({ avatar: "myurl" });
-});
-
-add_test(function cacheProfile_no_change() {
-  let accountData = mockAccountData();
-  accountData.getUserAccountData = function () {
-    return Promise.resolve({
-      profile: { avatar: "myurl" }
-    });
-  };
-  accountData.setUserAccountData = function (data) {
-    throw new Error("should not update account data");
-  };
-  let profile = new FxAccountsProfile(accountData, PROFILE_CLIENT_OPTIONS);
-
-  return profile._cacheProfile({ avatar: "myurl" })
-    .then((result) => {
-      do_check_false(!!result);
-      run_next_test();
-    });
-});
-
-add_test(function fetchAndCacheProfile_ok() {
-  let client = mockClient();
-  client.fetchProfile = function () {
-    return Promise.resolve({ avatar: "myimg"});
-  };
-  let profile = new FxAccountsProfile(mockAccountData(), {
-    profileClient: client
-  });
-
-  profile._cacheProfile = function (toCache) {
-    do_check_eq(toCache.avatar, "myimg");
-    return Promise.resolve();
-  };
-
-  return profile._fetchAndCacheProfile()
-    .then(result => {
-      do_check_eq(result.avatar, "myimg");
-      run_next_test();
-    });
-});
-
-
-add_test(function profile_channel() {
-  let profile = new FxAccountsProfile(mockAccountData(), PROFILE_CLIENT_OPTIONS);
-
-  let channel = profile._listenForProfileChanges();
-  do_check_true(!!channel);
-
-  let channel2 = profile._listenForProfileChanges();
-
-  do_check_eq(channel, channel2);
-
-  run_next_test();
-});
-
-add_test(function tearDown_ok() {
-  let profile = new FxAccountsProfile(mockAccountData(), PROFILE_CLIENT_OPTIONS);
-
-  do_check_true(!!profile.client);
-  do_check_true(!!profile.currentAccountState);
-
-  profile.tearDown();
-  do_check_null(profile.currentAccountState);
-  do_check_null(profile.client);
-
-  run_next_test();
-});
-
-add_test(function getProfile_ok() {
-  let cachedUrl = "myurl";
-  let accountData = mockAccountData();
-  let didFetch = false;
-  let didListen = false;
-
-  let profile = new FxAccountsProfile(accountData, PROFILE_CLIENT_OPTIONS);
-  profile._getCachedProfile = function () {
-    return Promise.resolve({ avatar: cachedUrl });
-  };
-
-  profile._fetchAndCacheProfile = function () {
-    didFetch = true;
-  };
-  profile._listenForProfileChanges = function () {
-    didListen = true;
-  };
-
-  return profile.getProfile()
-    .then(result => {
-      do_check_eq(result.avatar, cachedUrl);
-      do_check_true(didFetch);
-      do_check_true(didListen);
-      run_next_test();
-    });
-});
-
-add_test(function getProfile_no_cache() {
-  let fetchedUrl = "newUrl";
-  let accountData = mockAccountData();
-  let didListen = false;
-
-  let profile = new FxAccountsProfile(accountData, PROFILE_CLIENT_OPTIONS);
-  profile._getCachedProfile = function () {
-    return Promise.resolve();
-  };
-
-  profile._fetchAndCacheProfile = function () {
-    return Promise.resolve({ avatar: fetchedUrl });
-  };
-  profile._listenForProfileChanges = function () {
-    didListen = true;
-  };
-
-  return profile.getProfile()
-    .then(result => {
-      do_check_eq(result.avatar, fetchedUrl);
-      do_check_true(didListen);
-      run_next_test();
-    });
-});
-
-add_test(function getProfile_has_cached_fetch_deleted() {
-  let cachedUrl = "myurl";
-  let didFetch = false;
-  let didListen = false;
-
-  let client = mockClient();
-  client.fetchProfile = function () {
-    return Promise.resolve({ avatar: null });
-  };
-
-  let accountData = mockAccountData();
-  accountData.getUserAccountData = function () {
-    return Promise.resolve({ profile: { avatar: cachedUrl } });
-  };
-  accountData.setUserAccountData = function (data) {
-    do_check_null(data.profile.avatar);
-    run_next_test();
-    return Promise.resolve();
-  };
-
-  let profile = new FxAccountsProfile(accountData, {
-    profileClient: client
-  });
-
-  return profile.getProfile()
-    .then(result => {
-      do_check_eq(result.avatar, "myurl");
-    });
-});
-
-function run_test() {
-  run_next_test();
-}
-
-function makeObserver(aObserveTopic, aObserveFunc) {
-  let callback = function (aSubject, aTopic, aData) {
-    log.debug("observed " + aTopic + " " + aData);
-    if (aTopic == aObserveTopic) {
-      removeMe();
-      aObserveFunc(aSubject, aTopic, aData);
-    }
-  };
-
-  function removeMe() {
-    log.debug("removing observer for " + aObserveTopic);
-    Services.obs.removeObserver(callback, aObserveTopic);
-  }
-
-  Services.obs.addObserver(callback, aObserveTopic, false);
-  return removeMe;
-}
--- a/services/fxaccounts/tests/xpcshell/test_profile_channel.js
+++ b/services/fxaccounts/tests/xpcshell/test_profile_channel.js
@@ -18,21 +18,21 @@ add_test(function () {
   validationHelper({ content_uri: 'bad uri' },
   /NS_ERROR_MALFORMED_URI/);
 
   run_next_test();
 });
 
 add_test(function () {
   var mockMessage = {
-    command: "profile:change",
+    command: "profile:image:change",
     data: { uid: "foo" }
   };
 
-  makeObserver(ON_PROFILE_CHANGE_NOTIFICATION, function (subject, topic, data) {
+  makeObserver(ONPROFILE_IMAGE_CHANGE_NOTIFICATION, function (subject, topic, data) {
     do_check_eq(data, "foo");
     run_next_test();
   });
 
   var channel = new FxAccountsProfileChannel({
     content_uri: URL_STRING
   });
 
--- a/services/fxaccounts/tests/xpcshell/xpcshell.ini
+++ b/services/fxaccounts/tests/xpcshell/xpcshell.ini
@@ -11,9 +11,8 @@ skip-if = toolkit == 'gonk' # times out,
 skip-if = appname == 'b2g' # login manager storage only used on desktop.
 [test_manager.js]
 skip-if = appname != 'b2g'
 reason = FxAccountsManager is only available for B2G for now
 [test_oauth_client.js]
 [test_oauth_grant_client.js]
 [test_profile_client.js]
 [test_profile_channel.js]
-[test_profile.js]