Bug 1160371 - use mock storage in the oauth token test to avoid intermittent orange on b2g. r=zaach
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 08 May 2015 11:01:00 +1000
changeset 274321 406c618c6cac430a253e142e38ea9951c34aaa25
parent 274320 4dc08dfc1fbfe0deff1f13bba3ce5983c29d94ce
child 274322 1bae19c2d494d4ca9f8fddcd27dc5c7b2dc5ec17
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszaach
bugs1160371
milestone40.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 1160371 - use mock storage in the oauth token test to avoid intermittent orange on b2g. r=zaach
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);
       });
     },
   });
 }