diff --git a/browser/extensions/formautofill/test/unit/test_isAddressAutofillAvailable.js b/browser/extensions/formautofill/test/unit/test_isAddressAutofillAvailable.js index 40b024f193a4..9704f981d6f7 100644 --- a/browser/extensions/formautofill/test/unit/test_isAddressAutofillAvailable.js +++ b/browser/extensions/formautofill/test/unit/test_isAddressAutofillAvailable.js @@ -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); +}); diff --git a/toolkit/components/formautofill/FormAutofill.sys.mjs b/toolkit/components/formautofill/FormAutofill.sys.mjs index 77502afbbe96..88fb2c29f875 100644 --- a/toolkit/components/formautofill/FormAutofill.sys.mjs +++ b/toolkit/components/formautofill/FormAutofill.sys.mjs @@ -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" );