mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1211606 - Only fetch keys when Sync is enabled via 'services.sync.enabled' pref changed from Gaia. r=fabrice
This commit is contained in:
parent
a33627e32b
commit
fb7eb31a2a
@ -698,6 +698,10 @@ var settingsToObserve = {
|
|||||||
prefName: 'dom.sms.maxReadAheadEntries',
|
prefName: 'dom.sms.maxReadAheadEntries',
|
||||||
defaultValue: 7
|
defaultValue: 7
|
||||||
},
|
},
|
||||||
|
'services.sync.enabled': {
|
||||||
|
defaultValue: false,
|
||||||
|
notifyChange: true
|
||||||
|
},
|
||||||
'ui.touch.radius.leftmm': {
|
'ui.touch.radius.leftmm': {
|
||||||
resetToPref: true
|
resetToPref: true
|
||||||
},
|
},
|
||||||
@ -717,6 +721,18 @@ var settingsToObserve = {
|
|||||||
'wap.UAProf.url': ''
|
'wap.UAProf.url': ''
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function settingObserver(setPref, prefName, setting) {
|
||||||
|
return value => {
|
||||||
|
setPref(prefName, value);
|
||||||
|
if (setting.notifyChange) {
|
||||||
|
SystemAppProxy._sendCustomEvent('mozPrefChromeEvent', {
|
||||||
|
prefName: prefName,
|
||||||
|
value: value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
for (let key in settingsToObserve) {
|
for (let key in settingsToObserve) {
|
||||||
let setting = settingsToObserve[key];
|
let setting = settingsToObserve[key];
|
||||||
|
|
||||||
@ -766,7 +782,6 @@ for (let key in settingsToObserve) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsListener.observe(key, defaultValue, function(value) {
|
SettingsListener.observe(key, defaultValue,
|
||||||
setPref(prefName, value);
|
settingObserver(setPref, prefName, setting));
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
@ -156,7 +156,8 @@ this.FxAccountsMgmtService = {
|
|||||||
case "signIn":
|
case "signIn":
|
||||||
case "signUp":
|
case "signUp":
|
||||||
case "refreshAuthentication":
|
case "refreshAuthentication":
|
||||||
FxAccountsManager[data.method](data.email, data.password).then(
|
FxAccountsManager[data.method](data.email, data.password,
|
||||||
|
data.fetchKeys).then(
|
||||||
user => {
|
user => {
|
||||||
self._onFulfill(msg.id, user);
|
self._onFulfill(msg.id, user);
|
||||||
},
|
},
|
||||||
|
@ -99,7 +99,7 @@ this.FxAccountsManager = {
|
|||||||
return this._fxAccounts.getAccountsClient();
|
return this._fxAccounts.getAccountsClient();
|
||||||
},
|
},
|
||||||
|
|
||||||
_signInSignUp: function(aMethod, aEmail, aPassword) {
|
_signInSignUp: function(aMethod, aEmail, aPassword, aFetchKeys) {
|
||||||
if (Services.io.offline) {
|
if (Services.io.offline) {
|
||||||
return this._error(ERROR_OFFLINE);
|
return this._error(ERROR_OFFLINE);
|
||||||
}
|
}
|
||||||
@ -127,15 +127,7 @@ this.FxAccountsManager = {
|
|||||||
user: this._user
|
user: this._user
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let syncEnabled = false;
|
return client[aMethod](aEmail, aPassword, aFetchKeys);
|
||||||
try {
|
|
||||||
syncEnabled = Services.prefs.getBoolPref("services.sync.enabled");
|
|
||||||
} catch(e) {
|
|
||||||
dump(e + "\n");
|
|
||||||
}
|
|
||||||
// XXX Refetch FxA credentials if services.sync.enabled preference
|
|
||||||
// changes. Bug 1183103
|
|
||||||
return client[aMethod](aEmail, aPassword, syncEnabled);
|
|
||||||
}
|
}
|
||||||
).then(
|
).then(
|
||||||
user => {
|
user => {
|
||||||
@ -164,6 +156,15 @@ this.FxAccountsManager = {
|
|||||||
this._activeSession = user;
|
this._activeSession = user;
|
||||||
log.debug("User signed in: " + JSON.stringify(this._user) +
|
log.debug("User signed in: " + JSON.stringify(this._user) +
|
||||||
" - Account created " + (aMethod == "signUp"));
|
" - Account created " + (aMethod == "signUp"));
|
||||||
|
|
||||||
|
// There is no way to obtain the key fetch token afterwards
|
||||||
|
// without login out the user and asking her to log in again.
|
||||||
|
// Also, key fetch tokens are designed to be short-lived, so
|
||||||
|
// we need to fetch kB as soon as we have the key fetch token.
|
||||||
|
if (aFetchKeys) {
|
||||||
|
this._fxAccounts.getKeys();
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
accountCreated: aMethod === "signUp",
|
accountCreated: aMethod === "signUp",
|
||||||
user: this._user
|
user: this._user
|
||||||
@ -359,12 +360,12 @@ this.FxAccountsManager = {
|
|||||||
|
|
||||||
// -- API --
|
// -- API --
|
||||||
|
|
||||||
signIn: function(aEmail, aPassword) {
|
signIn: function(aEmail, aPassword, aFetchKeys) {
|
||||||
return this._signInSignUp("signIn", aEmail, aPassword);
|
return this._signInSignUp("signIn", aEmail, aPassword, aFetchKeys);
|
||||||
},
|
},
|
||||||
|
|
||||||
signUp: function(aEmail, aPassword) {
|
signUp: function(aEmail, aPassword, aFetchKeys) {
|
||||||
return this._signInSignUp("signUp", aEmail, aPassword);
|
return this._signInSignUp("signUp", aEmail, aPassword, aFetchKeys);
|
||||||
},
|
},
|
||||||
|
|
||||||
signOut: function() {
|
signOut: function() {
|
||||||
|
@ -204,9 +204,10 @@ var FakeFxAccountsClient = {
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
signIn: function(user, password) {
|
signIn: function(user, password, getKeys) {
|
||||||
this._signInCalled = true;
|
this._signInCalled = true;
|
||||||
this._password = password;
|
this._password = password;
|
||||||
|
this._keyFetchToken = getKeys ? "token" : null;
|
||||||
let deferred = Promise.defer();
|
let deferred = Promise.defer();
|
||||||
this._reject ? deferred.reject()
|
this._reject ? deferred.reject()
|
||||||
: deferred.resolve({ email: user,
|
: deferred.resolve({ email: user,
|
||||||
@ -806,6 +807,50 @@ add_test(function(test_signIn_already_signed_user) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
add_test(function(test_signIn_getKeys_true) {
|
||||||
|
do_print("= signIn, getKeys true =");
|
||||||
|
FxAccountsManager.signOut().then(() => {
|
||||||
|
FxAccountsManager.signIn("user@domain.org", "password", true).then(
|
||||||
|
result => {
|
||||||
|
do_check_true(FakeFxAccountsClient._signInCalled);
|
||||||
|
do_check_true(FxAccountsManager._fxAccounts._getSignedInUserCalled);
|
||||||
|
do_check_eq(FxAccountsManager._fxAccounts._signedInUser.email, "user@domain.org");
|
||||||
|
do_check_eq(FakeFxAccountsClient._password, "password");
|
||||||
|
do_check_eq(FakeFxAccountsClient._keyFetchToken, "token");
|
||||||
|
do_check_eq(result.user.email, "user@domain.org");
|
||||||
|
FakeFxAccountsClient._reset();
|
||||||
|
FxAccountsManager._fxAccounts._reset();
|
||||||
|
run_next_test();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
do_throw("Unexpected error");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
add_test(function(test_signIn_getKeys_false) {
|
||||||
|
do_print("= signIn, getKeys false =");
|
||||||
|
FxAccountsManager.signOut().then(() => {
|
||||||
|
FxAccountsManager.signIn("user@domain.org", "password", false).then(
|
||||||
|
result => {
|
||||||
|
do_check_true(FakeFxAccountsClient._signInCalled);
|
||||||
|
do_check_true(FxAccountsManager._fxAccounts._getSignedInUserCalled);
|
||||||
|
do_check_eq(FxAccountsManager._fxAccounts._signedInUser.email, "user@domain.org");
|
||||||
|
do_check_eq(FakeFxAccountsClient._password, "password");
|
||||||
|
do_check_eq(FakeFxAccountsClient._keyFetchToken, null);
|
||||||
|
do_check_eq(result.user.email, "user@domain.org");
|
||||||
|
FakeFxAccountsClient._reset();
|
||||||
|
FxAccountsManager._fxAccounts._reset();
|
||||||
|
run_next_test();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
do_throw("Unexpected error");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
add_test(function(test_resendVerificationEmail_error_handling) {
|
add_test(function(test_resendVerificationEmail_error_handling) {
|
||||||
do_print("= resendVerificationEmail smoke test =");
|
do_print("= resendVerificationEmail smoke test =");
|
||||||
let user = FxAccountsManager._fxAccounts._signedInUser;
|
let user = FxAccountsManager._fxAccounts._signedInUser;
|
||||||
|
Loading…
Reference in New Issue
Block a user