зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset b144c73dd03f (bug 1860619) for causing failures in browser_edit_address_doorhanger_display.js
This commit is contained in:
Родитель
ef611334bf
Коммит
94e09b188f
|
@ -14,8 +14,6 @@ support-files = [
|
|||
|
||||
["browser_address_doorhanger_not_shown.js"]
|
||||
|
||||
["browser_address_doorhanger_state.js"]
|
||||
|
||||
["browser_address_doorhanger_tel.js"]
|
||||
|
||||
["browser_address_doorhanger_ui.js"]
|
||||
|
@ -27,8 +25,5 @@ skip-if = ["a11y_checks"] # Bug 1859968 - Add accessibility support for address
|
|||
["browser_edit_address_doorhanger_display.js"]
|
||||
skip-if = ["a11y_checks"] # Bug 1859968 - Add accessibility support for address doorhanger
|
||||
|
||||
["browser_edit_address_doorhanger_display_state.js"]
|
||||
skip-if = ["a11y_checks"] # Bug 1859968 - Add accessibility support for address doorhanger
|
||||
|
||||
["browser_edit_address_doorhanger_save_edited_fields.js"]
|
||||
skip-if = ["a11y_checks"] # Bug 1859968 - Add accessibility support for address doorhanger
|
||||
|
|
|
@ -44,23 +44,12 @@ const TESTCASES = [
|
|||
"#tel": "1-650-903-0800",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Should not trigger the address save doorhanger when pref off",
|
||||
document: DEFAULT_TEST_DOC,
|
||||
targetElementId: TARGET_ELEMENT_ID,
|
||||
formValue: {
|
||||
"#street-addr": "331 E. Evelyn Avenue",
|
||||
"#email": "test@mozilla.org",
|
||||
"#tel": "1-650-903-0800",
|
||||
},
|
||||
prefs: [["extensions.formautofill.addresses.capture.v2.enabled", false]],
|
||||
},
|
||||
];
|
||||
|
||||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["extensions.formautofill.addresses.capture.v2.enabled", true],
|
||||
["extensions.formautofill.addresses.capture.enabled", true],
|
||||
["extensions.formautofill.addresses.supported", "on"],
|
||||
],
|
||||
});
|
||||
|
@ -69,11 +58,6 @@ add_setup(async function () {
|
|||
add_task(async function test_save_doorhanger_not_shown() {
|
||||
for (const TEST of TESTCASES) {
|
||||
info(`Test ${TEST.description}`);
|
||||
if (TEST.prefs) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: TEST.prefs,
|
||||
});
|
||||
}
|
||||
|
||||
await BrowserTestUtils.withNewTab(EMPTY_URL, async function (browser) {
|
||||
await SpecialPowers.spawn(browser, [TEST.document], doc => {
|
||||
|
@ -89,9 +73,5 @@ add_task(async function test_save_doorhanger_not_shown() {
|
|||
|
||||
await ensureNoDoorhanger(browser);
|
||||
});
|
||||
|
||||
if (TEST.prefs) {
|
||||
await SpecialPowers.popPrefEnv();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,125 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
async function expectSavedAddresses(expectedAddresses) {
|
||||
const addresses = await getAddresses();
|
||||
is(
|
||||
addresses.length,
|
||||
expectedAddresses.length,
|
||||
`${addresses.length} address in the storage`
|
||||
);
|
||||
|
||||
for (let i = 0; i < expectedAddresses.length; i++) {
|
||||
for (const [key, value] of Object.entries(expectedAddresses[i])) {
|
||||
is(addresses[i][key] ?? "", value, `field ${key} should be equal`);
|
||||
}
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.formautofill.addresses.capture.v2.enabled", true]],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_save_doorhanger_state_invalid() {
|
||||
const DEFAULT = {
|
||||
"given-name": "Test User",
|
||||
organization: "Mozilla",
|
||||
"street-address": "123 Sesame Street",
|
||||
country: "US",
|
||||
};
|
||||
|
||||
const TEST_CASES = [
|
||||
{
|
||||
filled: { "address-level1": "floridaa" }, // typo
|
||||
expected: { "address-level1": "" },
|
||||
},
|
||||
{
|
||||
filled: { "address-level1": "AB" }, // non-exist region code
|
||||
expected: { "address-level1": "" },
|
||||
},
|
||||
];
|
||||
|
||||
for (const TEST of TEST_CASES) {
|
||||
await expectSavedAddresses([]);
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: ADDRESS_FORM_URL },
|
||||
async function (browser) {
|
||||
let onPopupShown = waitForPopupShown();
|
||||
|
||||
await focusUpdateSubmitForm(browser, {
|
||||
focusSelector: "#given-name",
|
||||
newValues: {
|
||||
"#given-name": DEFAULT["given-name"],
|
||||
"#organization": DEFAULT.organization,
|
||||
"#street-address": DEFAULT["street-address"],
|
||||
"#address-level1": TEST.filled["address-level1"],
|
||||
},
|
||||
});
|
||||
|
||||
await onPopupShown;
|
||||
await clickDoorhangerButton(MAIN_BUTTON, 0);
|
||||
}
|
||||
);
|
||||
|
||||
await expectSavedAddresses([Object.assign(DEFAULT, TEST.expected)]);
|
||||
await removeAllRecords();
|
||||
}
|
||||
});
|
||||
|
||||
add_task(async function test_save_doorhanger_state_valid() {
|
||||
const DEFAULT = {
|
||||
"given-name": "Test User",
|
||||
organization: "Mozilla",
|
||||
"street-address": "123 Sesame Street",
|
||||
country: "US",
|
||||
};
|
||||
|
||||
const TEST_CASES = [
|
||||
{
|
||||
filled: { "address-level1": "ca" },
|
||||
expected: { "address-level1": "ca" },
|
||||
},
|
||||
{
|
||||
filled: { "address-level1": "CA" },
|
||||
expected: { "address-level1": "CA" },
|
||||
},
|
||||
{
|
||||
filled: { "address-level1": "california" },
|
||||
expected: { "address-level1": "california" },
|
||||
},
|
||||
{
|
||||
filled: { "address-level1": "California" },
|
||||
expected: { "address-level1": "California" },
|
||||
},
|
||||
];
|
||||
|
||||
for (const TEST of TEST_CASES) {
|
||||
await expectSavedAddresses([]);
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: ADDRESS_FORM_URL },
|
||||
async function (browser) {
|
||||
let onPopupShown = waitForPopupShown();
|
||||
|
||||
await focusUpdateSubmitForm(browser, {
|
||||
focusSelector: "#given-name",
|
||||
newValues: {
|
||||
"#given-name": DEFAULT["given-name"],
|
||||
"#organization": DEFAULT.organization,
|
||||
"#street-address": DEFAULT["street-address"],
|
||||
"#address-level1": TEST.filled["address-level1"],
|
||||
},
|
||||
});
|
||||
|
||||
await onPopupShown;
|
||||
await clickDoorhangerButton(MAIN_BUTTON, 0);
|
||||
}
|
||||
);
|
||||
|
||||
await expectSavedAddresses([Object.assign(DEFAULT, TEST.expected)]);
|
||||
await removeAllRecords();
|
||||
}
|
||||
});
|
|
@ -1,76 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.formautofill.addresses.capture.v2.enabled", true]],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_edit_doorhanger_display_state() {
|
||||
const DEFAULT = {
|
||||
"given-name": "Test User",
|
||||
organization: "Mozilla",
|
||||
"street-address": "123 Sesame Street",
|
||||
country: "US",
|
||||
};
|
||||
|
||||
const TEST_CASES = [
|
||||
{
|
||||
filled: { "address-level1": "floridaa" }, // typo
|
||||
expected: { label: "" },
|
||||
},
|
||||
{
|
||||
filled: { "address-level1": "AB" }, // non-exist region code
|
||||
expected: { label: "" },
|
||||
},
|
||||
{
|
||||
filled: { "address-level1": "CA" },
|
||||
expected: { label: "CA" },
|
||||
},
|
||||
{
|
||||
filled: { "address-level1": "fl" },
|
||||
expected: { label: "FL" },
|
||||
},
|
||||
{
|
||||
filled: { "address-level1": "New York" },
|
||||
expected: { label: "NY" },
|
||||
},
|
||||
{
|
||||
filled: { "address-level1": "Washington" },
|
||||
expected: { label: "WA" },
|
||||
},
|
||||
];
|
||||
|
||||
for (const TEST of TEST_CASES) {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: ADDRESS_FORM_URL },
|
||||
async function (browser) {
|
||||
const onSavePopupShown = waitForPopupShown();
|
||||
await focusUpdateSubmitForm(browser, {
|
||||
focusSelector: "#given-name",
|
||||
newValues: {
|
||||
"#given-name": DEFAULT["given-name"],
|
||||
"#organization": DEFAULT.organization,
|
||||
"#street-address": DEFAULT["street-address"],
|
||||
"#address-level1": TEST.filled["address-level1"],
|
||||
},
|
||||
});
|
||||
await onSavePopupShown;
|
||||
|
||||
const onEditPopupShown = waitForPopupShown();
|
||||
await clickAddressDoorhangerButton(EDIT_ADDRESS_BUTTON);
|
||||
await onEditPopupShown;
|
||||
|
||||
const notification = getNotification();
|
||||
const id = AddressEditDoorhanger.getInputId("address-level1");
|
||||
const element = notification.querySelector(`#${id}`);
|
||||
|
||||
is(
|
||||
element.label,
|
||||
TEST.expected.label,
|
||||
"Edit address doorhanger shows the expected address-level1 select option"
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
|
@ -733,10 +733,10 @@ export class AddressEditDoorhanger extends AutofillDoorhanger {
|
|||
menuitem.setAttribute("value", "");
|
||||
menupopup.appendChild(menuitem);
|
||||
|
||||
for (const [regionCode, regionName] of this.layout.addressLevel1Options) {
|
||||
for (const [regionCode] of this.layout.addressLevel1Options) {
|
||||
menuitem = this.doc.createXULElement("menuitem");
|
||||
menuitem.setAttribute("label", regionCode);
|
||||
menuitem.setAttribute("value", regionName);
|
||||
menuitem.setAttribute("value", regionCode);
|
||||
menupopup.appendChild(menuitem);
|
||||
}
|
||||
|
||||
|
@ -780,13 +780,12 @@ export class AddressEditDoorhanger extends AutofillDoorhanger {
|
|||
div.appendChild(label);
|
||||
|
||||
let input;
|
||||
let popup;
|
||||
if ("street-address".includes(fieldName)) {
|
||||
input = this.doc.createElement("textarea");
|
||||
input.setAttribute("rows", 3);
|
||||
} else if (fieldName == "country") {
|
||||
input = this.doc.createXULElement("menulist");
|
||||
popup = this.#buildCountryMenupopup();
|
||||
const popup = this.#buildCountryMenupopup();
|
||||
popup.addEventListener("popuphidden", e => e.stopPropagation());
|
||||
input.appendChild(popup);
|
||||
|
||||
|
@ -801,7 +800,7 @@ export class AddressEditDoorhanger extends AutofillDoorhanger {
|
|||
this.layout.addressLevel1Options
|
||||
) {
|
||||
input = this.doc.createXULElement("menulist");
|
||||
popup = this.#buildAddressLevel1Menupopup();
|
||||
const popup = this.#buildAddressLevel1Menupopup();
|
||||
popup.addEventListener("popuphidden", e => e.stopPropagation());
|
||||
input.appendChild(popup);
|
||||
} else {
|
||||
|
@ -809,19 +808,7 @@ export class AddressEditDoorhanger extends AutofillDoorhanger {
|
|||
}
|
||||
|
||||
input.setAttribute("id", AddressEditDoorhanger.getInputId(fieldName));
|
||||
|
||||
const value = this.#getFieldDisplayData(fieldName) ?? null;
|
||||
if (popup) {
|
||||
const menuitem = Array.from(popup.childNodes).find(
|
||||
item =>
|
||||
item.label.toLowerCase() === value?.toLowerCase() ||
|
||||
item.value.toLowerCase() === value?.toLowerCase()
|
||||
);
|
||||
input.selectedItem = menuitem;
|
||||
} else {
|
||||
input.value = value;
|
||||
}
|
||||
|
||||
input.value = this.#getFieldDisplayData(fieldName) ?? null;
|
||||
div.appendChild(input);
|
||||
|
||||
return div;
|
||||
|
|
Загрузка…
Ссылка в новой задаче