зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1441156 - Ensure FxA storage tests don't initialize Sync. r=markh
MozReview-Commit-ID: IOtWAkxmbGD --HG-- extra : rebase_source : ea4a6f1828f6fa9e1a37ec2fbfeab942b2c4b2df
This commit is contained in:
Родитель
73ac8a3582
Коммит
a41f5e2a9e
|
@ -75,20 +75,6 @@ var publicProperties = [
|
|||
"whenVerified",
|
||||
];
|
||||
|
||||
// A poor-man's "registry" of promise-returning functions to call before we
|
||||
// send observer notifications. Primarily used so parts of Firefox which are
|
||||
// yet to load for performance reasons can be force-loaded and thus not miss
|
||||
// the notification.
|
||||
const OBSERVER_PRELOADS = [
|
||||
// Sync
|
||||
() => {
|
||||
let scope = {};
|
||||
ChromeUtils.import("resource://services-sync/main.js", scope);
|
||||
return scope.Weave.Service.promiseInitialized;
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
// An AccountState object holds all state related to one specific account.
|
||||
// Only one AccountState is ever "current" in the FxAccountsInternal object -
|
||||
// whenever a user logs out or logs in, the current AccountState is discarded,
|
||||
|
@ -352,6 +338,21 @@ var FxAccounts = function(mockInternal) {
|
|||
});
|
||||
}
|
||||
|
||||
if (!internal.observerPreloads) {
|
||||
// A registry of promise-returning functions that `notifyObservers` should
|
||||
// call before sending notifications. Primarily used so parts of Firefox
|
||||
// which have yet to load for performance reasons can be force-loaded, and
|
||||
// thus not miss notifications.
|
||||
internal.observerPreloads = [
|
||||
// Sync
|
||||
() => {
|
||||
let scope = {};
|
||||
ChromeUtils.import("resource://services-sync/main.js", scope);
|
||||
return scope.Weave.Service.promiseInitialized;
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// wait until after the mocks are setup before initializing.
|
||||
internal.initialize();
|
||||
|
||||
|
@ -1272,7 +1273,7 @@ FxAccountsInternal.prototype = {
|
|||
},
|
||||
|
||||
async notifyObservers(topic, data) {
|
||||
for (let f of OBSERVER_PRELOADS) {
|
||||
for (let f of this.observerPreloads) {
|
||||
try {
|
||||
await f();
|
||||
} catch (O_o) {}
|
||||
|
@ -1600,7 +1601,7 @@ FxAccountsInternal.prototype = {
|
|||
if (sessionToken && deviceId) {
|
||||
await this.fxAccountsClient.signOutAndDestroyDevice(sessionToken, deviceId);
|
||||
}
|
||||
this.currentAccountState.updateUserAccountData({
|
||||
await this.currentAccountState.updateUserAccountData({
|
||||
deviceId: null,
|
||||
deviceRegistrationVersion: null
|
||||
});
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
// Tests for FxAccounts, storage and the master password.
|
||||
|
||||
// Stop us hitting the real auth server.
|
||||
Services.prefs.setCharPref("identity.fxaccounts.auth.uri", "http://localhost");
|
||||
// See verbose logging from FxAccounts.jsm
|
||||
Services.prefs.setCharPref("identity.fxaccounts.loglevel", "Trace");
|
||||
|
||||
|
@ -41,16 +39,30 @@ function getLoginMgrData() {
|
|||
|
||||
function createFxAccounts() {
|
||||
return new FxAccounts({
|
||||
_fxAccountsClient: {
|
||||
async registerDevice() {
|
||||
return { id: "deviceAAAAAA" };
|
||||
},
|
||||
async recoveryEmailStatus() {
|
||||
return { verified: true };
|
||||
},
|
||||
async signOutAndDestroyDevice() {},
|
||||
},
|
||||
_getDeviceName() {
|
||||
return "mock device name";
|
||||
},
|
||||
observerPreloads: [],
|
||||
fxaPushService: {
|
||||
registerPushEndpoint() {
|
||||
return new Promise((resolve) => {
|
||||
resolve({
|
||||
endpoint: "http://mochi.test:8888"
|
||||
});
|
||||
});
|
||||
async registerPushEndpoint() {
|
||||
return {
|
||||
endpoint: "http://mochi.test:8888",
|
||||
getKey() {
|
||||
return null;
|
||||
},
|
||||
};
|
||||
},
|
||||
async unsubscribe() {
|
||||
return true;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче