зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 0b5a1215fcc4 (bug 1882587) for causing bc failures on browser_address_autofill_nimbus.js CLOSED TREE
This commit is contained in:
Родитель
acf0a2f044
Коммит
6545691753
|
@ -11,31 +11,21 @@ const { FormAutofill } = ChromeUtils.importESModule(
|
|||
"resource://autofill/FormAutofill.sys.mjs"
|
||||
);
|
||||
|
||||
add_setup(async () => {
|
||||
Services.prefs.setBoolPref(
|
||||
"extensions.formautofill.addresses.experiments.enabled",
|
||||
false
|
||||
);
|
||||
registerCleanupFunction(function cleanupRegion() {
|
||||
Services.prefs.clearUserPref(
|
||||
"extensions.formautofill.addresses.experiments.enabled"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_defaultTestEnvironment() {
|
||||
Assert.equal(
|
||||
Services.prefs.getCharPref("extensions.formautofill.addresses.supported"),
|
||||
"on"
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
Services.prefs.getBoolPref(
|
||||
"extensions.formautofill.addresses.experiments.enabled"
|
||||
),
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_default_supported_module_and_autofill_region() {
|
||||
Services.prefs.setCharPref("browser.search.region", "US");
|
||||
registerCleanupFunction(function cleanupRegion() {
|
||||
Services.prefs.clearUserPref("browser.search.region");
|
||||
});
|
||||
|
||||
add_task(async function test_default_supported_address_region() {
|
||||
let addon = await AddonManager.getAddonByID(EXTENSION_ID);
|
||||
await addon.reload();
|
||||
|
||||
|
@ -43,44 +33,15 @@ add_task(async function test_default_supported_module_and_autofill_region() {
|
|||
Assert.equal(FormAutofill.isAutofillAddressesEnabled, true);
|
||||
});
|
||||
|
||||
add_task(
|
||||
async function test_supported_creditCard_region_unsupported_address_region() {
|
||||
Services.prefs.setCharPref(
|
||||
"extensions.formautofill.addresses.supported",
|
||||
"detect"
|
||||
);
|
||||
Services.prefs.setCharPref(
|
||||
"extensions.formautofill.creditCards.supported",
|
||||
"detect"
|
||||
);
|
||||
Services.prefs.setCharPref("browser.search.region", "FR");
|
||||
Services.prefs.setCharPref(
|
||||
"extensions.formautofill.addresses.supportedCountries",
|
||||
"US,CA"
|
||||
);
|
||||
Services.prefs.setCharPref(
|
||||
"extensions.formautofill.creditCards.supportedCountries",
|
||||
"US,CA,FR"
|
||||
);
|
||||
registerCleanupFunction(function cleanupPrefs() {
|
||||
Services.prefs.clearUserPref("browser.search.region");
|
||||
Services.prefs.clearUserPref(
|
||||
"extensions.formautofill.addresses.supportedCountries"
|
||||
);
|
||||
Services.prefs.clearUserPref(
|
||||
"extensions.formautofill.addresses.supported"
|
||||
);
|
||||
Services.prefs.clearUserPref(
|
||||
"extensions.formautofill.creditCards.supported"
|
||||
);
|
||||
});
|
||||
add_task(async function test_unsupported_address_region() {
|
||||
const addon = await AddonManager.getAddonByID(EXTENSION_ID);
|
||||
|
||||
let addon = await AddonManager.getAddonByID(EXTENSION_ID);
|
||||
await addon.reload();
|
||||
Assert.ok(
|
||||
Services.prefs.getBoolPref("extensions.formautofill.creditCards.enabled")
|
||||
);
|
||||
Assert.equal(FormAutofill.isAutofillAddressesAvailable, false);
|
||||
Assert.equal(FormAutofill.isAutofillAddressesEnabled, false);
|
||||
}
|
||||
);
|
||||
Services.prefs.setBoolPref(
|
||||
"extensions.formautofill.addresses.experiments.enabled",
|
||||
false
|
||||
);
|
||||
|
||||
await addon.reload();
|
||||
Assert.equal(FormAutofill.isAutofillAddressesAvailable, false);
|
||||
Assert.equal(FormAutofill.isAutofillAddressesEnabled, false);
|
||||
});
|
||||
|
|
|
@ -98,29 +98,6 @@ export const FormAutofill = {
|
|||
FormAutofill._creditCardAutofillSupportedCountries
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Determines if the address autofill feature is available to use in the browser.
|
||||
* If the feature is not available, then there are no user facing ways to enable it.
|
||||
* Two conditions must be met for the autofill feature to be considered available:
|
||||
* 1. Address autofill support is confirmed when:
|
||||
* - `extensions.formautofill.addresses.supported` is set to `on`.
|
||||
* - The user is located in a region supported by the feature
|
||||
* (`extensions.formautofill.creditCards.supportedCountries`).
|
||||
* 2. Address autofill is enabled through a Nimbus experiment:
|
||||
* - The experiment pref `extensions.formautofill.addresses.experiments.enabled` is set to true.
|
||||
*
|
||||
* @returns {boolean} `true` if address autofill is available
|
||||
*/
|
||||
get isAutofillAddressesAvailable() {
|
||||
const isUserInSupportedRegion = this._isSupportedRegion(
|
||||
FormAutofill._isAutofillAddressesAvailable,
|
||||
FormAutofill._addressAutofillSupportedCountries
|
||||
);
|
||||
return (
|
||||
isUserInSupportedRegion ||
|
||||
FormAutofill._isAutofillAddressesAvailableInExperiment
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Determines if the user has enabled or disabled credit card autofill.
|
||||
*
|
||||
|
@ -285,7 +262,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
FormAutofill,
|
||||
"_isAutofillAddressesAvailableInExperiment",
|
||||
"isAutofillAddressesAvailable",
|
||||
"extensions.formautofill.addresses.experiments.enabled"
|
||||
);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче