зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1627545 - Update FormAutoFill to new Region.jsm api. r=MattN
Differential Revision: https://phabricator.services.mozilla.com/D76949
This commit is contained in:
Родитель
d51967f492
Коммит
ab8d86b7da
|
@ -11,11 +11,14 @@ const { XPCOMUtils } = ChromeUtils.import(
|
|||
);
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Region: "resource://gre/modules/Region.jsm",
|
||||
});
|
||||
|
||||
const ADDRESSES_FIRST_TIME_USE_PREF = "extensions.formautofill.firstTimeUse";
|
||||
const AUTOFILL_CREDITCARDS_AVAILABLE_PREF =
|
||||
"extensions.formautofill.creditCards.available";
|
||||
const CREDITCARDS_USED_STATUS_PREF = "extensions.formautofill.creditCards.used";
|
||||
const DEFAULT_REGION_PREF = "browser.search.region";
|
||||
const ENABLED_AUTOFILL_ADDRESSES_PREF =
|
||||
"extensions.formautofill.addresses.enabled";
|
||||
const ENABLED_AUTOFILL_CREDITCARDS_PREF =
|
||||
|
@ -52,6 +55,9 @@ var FormAutofill = {
|
|||
ADDRESSES_FIRST_TIME_USE_PREF,
|
||||
CREDITCARDS_USED_STATUS_PREF,
|
||||
|
||||
get DEFAULT_REGION() {
|
||||
return Region.home || "US";
|
||||
},
|
||||
get isAutofillEnabled() {
|
||||
return (
|
||||
FormAutofill.isAutofillAddressesEnabled ||
|
||||
|
@ -81,12 +87,6 @@ var FormAutofill = {
|
|||
},
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
FormAutofill,
|
||||
"DEFAULT_REGION",
|
||||
DEFAULT_REGION_PREF,
|
||||
"US"
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
FormAutofill,
|
||||
"isAutofillAddressesEnabled",
|
||||
|
|
|
@ -4,6 +4,10 @@ const { FormAutofillUtils } = ChromeUtils.import(
|
|||
"resource://formautofill/FormAutofillUtils.jsm"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Region: "resource://gre/modules/Region.jsm",
|
||||
});
|
||||
|
||||
requestLongerTimeout(6);
|
||||
|
||||
add_task(async function setup_supportedCountries() {
|
||||
|
@ -25,7 +29,7 @@ add_task(async function test_cancelEditAddressDialogWithESC() {
|
|||
});
|
||||
|
||||
add_task(async function test_defaultCountry() {
|
||||
await SpecialPowers.pushPrefEnv({ set: [[DEFAULT_REGION_PREF, "CA"]] });
|
||||
Region._setRegion("CA", false);
|
||||
await testDialog(EDIT_ADDRESS_DIALOG_URL, win => {
|
||||
let doc = win.document;
|
||||
is(
|
||||
|
@ -35,7 +39,7 @@ add_task(async function test_defaultCountry() {
|
|||
);
|
||||
doc.querySelector("#cancel").click();
|
||||
});
|
||||
await SpecialPowers.pushPrefEnv({ set: [[DEFAULT_REGION_PREF, "DE"]] });
|
||||
Region._setRegion("DE", false);
|
||||
await testDialog(EDIT_ADDRESS_DIALOG_URL, win => {
|
||||
let doc = win.document;
|
||||
is(
|
||||
|
@ -46,13 +50,13 @@ add_task(async function test_defaultCountry() {
|
|||
doc.querySelector("#cancel").click();
|
||||
});
|
||||
// Test unsupported country
|
||||
await SpecialPowers.pushPrefEnv({ set: [[DEFAULT_REGION_PREF, "XX"]] });
|
||||
Region._setRegion("XX", false);
|
||||
await testDialog(EDIT_ADDRESS_DIALOG_URL, win => {
|
||||
let doc = win.document;
|
||||
is(doc.querySelector("#country").value, "", "Default country set to empty");
|
||||
doc.querySelector("#cancel").click();
|
||||
});
|
||||
await SpecialPowers.pushPrefEnv({ set: [[DEFAULT_REGION_PREF, "US"]] });
|
||||
Region._setRegion("US", false);
|
||||
});
|
||||
|
||||
add_task(async function test_saveAddress() {
|
||||
|
@ -860,7 +864,7 @@ add_task(async function test_hiddenFieldRemovedWhenCountryChanged() {
|
|||
});
|
||||
|
||||
add_task(async function test_countrySpecificFieldsGetRequiredness() {
|
||||
await SpecialPowers.pushPrefEnv({ set: [[DEFAULT_REGION_PREF, "RO"]] });
|
||||
Region._setRegion("RO", false);
|
||||
await testDialog(EDIT_ADDRESS_DIALOG_URL, async win => {
|
||||
let doc = win.document;
|
||||
is(
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
FTU_PREF, ENABLED_AUTOFILL_ADDRESSES_PREF, AUTOFILL_CREDITCARDS_AVAILABLE_PREF, ENABLED_AUTOFILL_CREDITCARDS_PREF,
|
||||
SUPPORTED_COUNTRIES_PREF,
|
||||
SYNC_USERNAME_PREF, SYNC_ADDRESSES_PREF, SYNC_CREDITCARDS_PREF, SYNC_CREDITCARDS_AVAILABLE_PREF, CREDITCARDS_USED_STATUS_PREF,
|
||||
DEFAULT_REGION_PREF,
|
||||
sleep, expectPopupOpen, openPopupOn, openPopupForSubframe, expectPopupClose, closePopup, closePopupForSubframe,
|
||||
clickDoorhangerButton, getAddresses, saveAddress, removeAddresses, saveCreditCard,
|
||||
getDisplayedPopupItems, getDoorhangerCheckbox,
|
||||
|
@ -51,7 +50,6 @@ const SYNC_ADDRESSES_PREF = "services.sync.engine.addresses";
|
|||
const SYNC_CREDITCARDS_PREF = "services.sync.engine.creditcards";
|
||||
const SYNC_CREDITCARDS_AVAILABLE_PREF =
|
||||
"services.sync.engine.creditcards.available";
|
||||
const DEFAULT_REGION_PREF = "browser.search.region";
|
||||
|
||||
const TEST_ADDRESS_1 = {
|
||||
"given-name": "John",
|
||||
|
|
Загрузка…
Ссылка в новой задаче