Bug 1160371 - Use mock storage in the oauth token test to avoid intermittent orange on b2g. r=zaach, a=test-only
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 08 May 2015 11:01:00 +1000
changeset 265958 aabebacf72a5d96b7c39eee3112aab5775aae6a9
parent 265957 cc162b5c443c01c4b3e826bea9a43afca4ff9210
child 265959 55ee778e1bed4d8e936a210ac1ebe8b6c8313417
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszaach, test-only
bugs1160371
milestone39.0a2
Bug 1160371 - Use mock storage in the oauth token test to avoid intermittent orange on b2g. r=zaach, a=test-only
services/fxaccounts/tests/xpcshell/test_oauth_tokens.js
--- a/services/fxaccounts/tests/xpcshell/test_oauth_tokens.js
+++ b/services/fxaccounts/tests/xpcshell/test_oauth_tokens.js
@@ -14,17 +14,36 @@ function promiseNotification(topic) {
     let observe = () => {
       Services.obs.removeObserver(observe, topic);
       resolve();
     }
     Services.obs.addObserver(observe, topic, false);
   });
 }
 
-// Just enough mocks so we can avoid hawk etc.
+// Just enough mocks so we can avoid hawk and storage.
+let MockStorage = function() {
+  this.data = null;
+};
+MockStorage.prototype = Object.freeze({
+  set: function (contents) {
+    this.data = contents;
+    return Promise.resolve(null);
+  },
+  get: function () {
+    return Promise.resolve(this.data);
+  },
+  getOAuthTokens() {
+    return Promise.resolve(null);
+  },
+  setOAuthTokens(contents) {
+    return Promise.resolve();
+  },
+});
+
 function MockFxAccountsClient() {
   this._email = "nobody@example.com";
   this._verified = false;
 
   this.accountStatus = function(uid) {
     let deferred = Promise.defer();
     deferred.resolve(!!uid && (!this._deletedOnServer));
     return deferred.promise;
@@ -38,16 +57,17 @@ function MockFxAccountsClient() {
 MockFxAccountsClient.prototype = {
   __proto__: FxAccountsClient.prototype
 }
 
 function MockFxAccounts(mockGrantClient) {
   return new FxAccounts({
     fxAccountsClient: new MockFxAccountsClient(),
     getAssertion: () => Promise.resolve("assertion"),
+    signedInUserStorage: new MockStorage(),
     _destroyOAuthToken: function(tokenData) {
       // somewhat sad duplication of _destroyOAuthToken, but hard to avoid.
       return mockGrantClient.destroyToken(tokenData.token).then( () => {
         Services.obs.notifyObservers(null, "testhelper-fxa-revoke-complete", null);
       });
     },
   });
 }