summaryrefslogtreecommitdiffstats
path: root/browser/extensions/formautofill/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /browser/extensions/formautofill/test
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/extensions/formautofill/test')
-rw-r--r--browser/extensions/formautofill/test/browser/address/browser_address_doorhanger_state.js4
-rw-r--r--browser/extensions/formautofill/test/browser/address/browser_edit_address_doorhanger_display_state.js5
-rw-r--r--browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js29
-rw-r--r--browser/extensions/formautofill/test/browser/browser_dropdown_layout.js30
-rw-r--r--browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_dropdown_layout.js2
-rw-r--r--browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js14
-rw-r--r--browser/extensions/formautofill/test/browser/head.js37
-rw-r--r--browser/extensions/formautofill/test/mochitest/creditCard/test_basic_creditcard_autocomplete_form.html31
-rw-r--r--browser/extensions/formautofill/test/mochitest/creditCard/test_creditcard_autocomplete_off.html9
-rw-r--r--browser/extensions/formautofill/test/mochitest/formautofill_common.js21
-rw-r--r--browser/extensions/formautofill/test/mochitest/test_autofill_and_ordinal_forms.html20
-rw-r--r--browser/extensions/formautofill/test/mochitest/test_autofocus_form.html8
-rw-r--r--browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html30
-rw-r--r--browser/extensions/formautofill/test/mochitest/test_form_changes.html21
-rw-r--r--browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html2
-rw-r--r--browser/extensions/formautofill/test/unit/test_addressComponent_state.js12
-rw-r--r--browser/extensions/formautofill/test/unit/test_getRecords.js28
-rw-r--r--browser/extensions/formautofill/test/unit/test_phoneNumber.js2
-rw-r--r--browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js93
19 files changed, 217 insertions, 181 deletions
diff --git a/browser/extensions/formautofill/test/browser/address/browser_address_doorhanger_state.js b/browser/extensions/formautofill/test/browser/address/browser_address_doorhanger_state.js
index f3b04d7f9c..003228c1cc 100644
--- a/browser/extensions/formautofill/test/browser/address/browser_address_doorhanger_state.js
+++ b/browser/extensions/formautofill/test/browser/address/browser_address_doorhanger_state.js
@@ -95,6 +95,10 @@ add_task(async function test_save_doorhanger_state_valid() {
expected: { "address-level1": "CA" },
},
{
+ filled: { "address-level1": "CA-BC" },
+ expected: { "address-level1": "CA-BC" },
+ },
+ {
filled: { "address-level1": "california" },
expected: { "address-level1": "california" },
},
diff --git a/browser/extensions/formautofill/test/browser/address/browser_edit_address_doorhanger_display_state.js b/browser/extensions/formautofill/test/browser/address/browser_edit_address_doorhanger_display_state.js
index 1d8933ad31..ccddbc743d 100644
--- a/browser/extensions/formautofill/test/browser/address/browser_edit_address_doorhanger_display_state.js
+++ b/browser/extensions/formautofill/test/browser/address/browser_edit_address_doorhanger_display_state.js
@@ -40,6 +40,10 @@ add_task(async function test_edit_doorhanger_display_state() {
filled: { "address-level1": "Washington" },
expected: { label: "WA" },
},
+ {
+ filled: { "address-level1": "CA-BC", country: "CA" },
+ expected: { label: "BC" },
+ },
];
for (const TEST of TEST_CASES) {
@@ -54,6 +58,7 @@ add_task(async function test_edit_doorhanger_display_state() {
"#organization": DEFAULT.organization,
"#street-address": DEFAULT["street-address"],
"#address-level1": TEST.filled["address-level1"],
+ "#country": TEST.filled.country || DEFAULT.country,
},
});
await onSavePopupShown;
diff --git a/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js b/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js
index 1e7ba523e8..1b4c934a38 100644
--- a/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js
+++ b/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js
@@ -14,6 +14,15 @@ add_setup(async function setup_storage() {
);
});
+function getFooterLabel(itemsBox) {
+ let footer = itemsBox.getItemAtIndex(itemsBox.itemCount - 1);
+ while (footer.collapsed) {
+ footer = footer.previousSibling;
+ }
+
+ return footer.querySelector(".line1-label");
+}
+
add_task(async function test_footer_has_correct_button_text_on_address() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: URL },
@@ -23,9 +32,7 @@ add_task(async function test_footer_has_correct_button_text_on_address() {
} = browser;
await openPopupOn(browser, "#organization");
- const footer = itemsBox.querySelector(
- ".autofill-footer-row.autofill-button"
- );
+ let footer = getFooterLabel(itemsBox);
Assert.equal(
footer.innerText,
l10n.formatValueSync("autofill-manage-addresses-label")
@@ -44,9 +51,7 @@ add_task(async function test_footer_has_correct_button_text_on_credit_card() {
} = browser;
await openPopupOn(browser, "#cc-number");
- const footer = itemsBox.querySelector(
- ".autofill-footer-row.autofill-button"
- );
+ let footer = getFooterLabel(itemsBox);
Assert.equal(
footer.innerText,
l10n.formatValueSync("autofill-manage-payment-methods-label")
@@ -65,6 +70,7 @@ add_task(async function test_press_enter_on_footer() {
} = browser;
await openPopupOn(browser, "#organization");
+
// Navigate to the footer and press enter.
const listItemElems = itemsBox.querySelectorAll(
".autocomplete-richlistitem"
@@ -75,7 +81,7 @@ add_task(async function test_press_enter_on_footer() {
true
);
for (let i = 0; i < listItemElems.length; i++) {
- if (!listItemElems[i].collapsed) {
+ if (!listItemElems[i].disabled) {
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
}
}
@@ -110,7 +116,6 @@ add_task(async function test_click_on_footer() {
while (optionButton.collapsed) {
optionButton = optionButton.previousElementSibling;
}
- optionButton = optionButton._optionButton;
const prefTabPromise = BrowserTestUtils.waitForNewTab(
gBrowser,
@@ -140,15 +145,7 @@ add_task(async function test_phishing_warning_single_category() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: URL },
async function (browser) {
- const {
- autoCompletePopup: { richlistbox: itemsBox },
- } = browser;
-
await openPopupOn(browser, "#tel");
- const warningBox = itemsBox.querySelector(
- ".autocomplete-richlistitem:last-child"
- )._warningTextBox;
- ok(warningBox, "Got phishing warning box");
await expectWarningText(browser, "Also autofills address");
await closePopup(browser);
}
diff --git a/browser/extensions/formautofill/test/browser/browser_dropdown_layout.js b/browser/extensions/formautofill/test/browser/browser_dropdown_layout.js
index bc1d2fccab..41d57c20df 100644
--- a/browser/extensions/formautofill/test/browser/browser_dropdown_layout.js
+++ b/browser/extensions/formautofill/test/browser/browser_dropdown_layout.js
@@ -7,22 +7,6 @@ add_task(async function setup_storage() {
await setStorage(TEST_ADDRESS_1, TEST_ADDRESS_2, TEST_ADDRESS_3);
});
-async function reopenPopupWithResizedInput(browser, selector, newSize) {
- await closePopup(browser);
- /* eslint no-shadow: ["error", { "allow": ["selector", "newSize"] }] */
- await SpecialPowers.spawn(
- browser,
- [{ selector, newSize }],
- async function ({ selector, newSize }) {
- const input = content.document.querySelector(selector);
-
- input.style.boxSizing = "border-box";
- input.style.width = newSize + "px";
- }
- );
- await openPopupOn(browser, selector);
-}
-
add_task(async function test_address_dropdown() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: URL },
@@ -33,20 +17,6 @@ add_task(async function test_address_dropdown() {
is(firstItem.getAttribute("ac-image"), "", "Should not show icon");
- // The breakpoint of two-lines layout is 150px
- await reopenPopupWithResizedInput(browser, focusInput, 140);
- is(
- firstItem._itemBox.getAttribute("size"),
- "small",
- "Show two-lines layout"
- );
- await reopenPopupWithResizedInput(browser, focusInput, 160);
- is(
- firstItem._itemBox.hasAttribute("size"),
- false,
- "Show one-line layout"
- );
-
await closePopup(browser);
}
);
diff --git a/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_dropdown_layout.js b/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_dropdown_layout.js
index 2b1fb9043c..ad28d857ae 100644
--- a/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_dropdown_layout.js
+++ b/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_dropdown_layout.js
@@ -79,7 +79,7 @@ add_task(async function test_credit_card_dropdown_icon_invalid_types_select() {
const creditCardItems = getDisplayedPopupItems(
browser,
- "[originaltype='autofill-profile']"
+ "[originaltype='autofill']"
);
for (const [index, creditCardItem] of creditCardItems.entries()) {
diff --git a/browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js b/browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js
index 5de499b942..09c2f7e195 100644
--- a/browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js
+++ b/browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js
@@ -55,28 +55,28 @@ add_task(async function test_insecure_form() {
urlPath: TEST_URL_PATH,
protocol: "https",
focusInput: "#organization",
- expectedType: "autofill-profile",
- expectedResultLength: 2,
+ expectedType: "autofill",
+ expectedResultLength: 3, // add one for the status row
},
{
urlPath: TEST_URL_PATH,
protocol: "http",
focusInput: "#organization",
- expectedType: "autofill-profile",
- expectedResultLength: 2,
+ expectedType: "autofill",
+ expectedResultLength: 3, // add one for the status row
},
{
urlPath: TEST_URL_PATH_CC,
protocol: "https",
focusInput: "#cc-name",
- expectedType: "autofill-profile",
- expectedResultLength: 3,
+ expectedType: "autofill",
+ expectedResultLength: 3, // no status row here
},
{
urlPath: TEST_URL_PATH_CC,
protocol: "http",
focusInput: "#cc-name",
- expectedType: "autofill-insecureWarning", // insecure warning field
+ expectedType: "insecureWarning", // insecure warning field
expectedResultLength: 1,
},
];
diff --git a/browser/extensions/formautofill/test/browser/head.js b/browser/extensions/formautofill/test/browser/head.js
index 8de8488f1f..3f87f7b5ef 100644
--- a/browser/extensions/formautofill/test/browser/head.js
+++ b/browser/extensions/formautofill/test/browser/head.js
@@ -535,25 +535,6 @@ async function runAndWaitForAutocompletePopupOpen(browser, taskFn) {
await taskFn();
await popupShown;
- await BrowserTestUtils.waitForMutationCondition(
- browser.autoCompletePopup.richlistbox,
- { childList: true, subtree: true, attributes: true },
- () => {
- const listItemElems = getDisplayedPopupItems(browser);
- return (
- !![...listItemElems].length &&
- [...listItemElems].every(item => {
- return (
- (item.getAttribute("originaltype") == "autofill-profile" ||
- item.getAttribute("originaltype") == "autofill-insecureWarning" ||
- item.getAttribute("originaltype") == "autofill-clear-button" ||
- item.getAttribute("originaltype") == "autofill-footer") &&
- item.hasAttribute("formautofillattached")
- );
- })
- );
- }
- );
}
async function waitForPopupEnabled(browser) {
@@ -595,7 +576,7 @@ function waitPopupStateInChild(bc, messageName) {
async function openPopupOn(browser, selector) {
let childNotifiedPromise = waitPopupStateInChild(
browser,
- "FormAutoComplete:PopupOpened"
+ "AutoComplete:PopupOpened"
);
await SimpleTest.promiseFocus(browser);
@@ -613,7 +594,7 @@ async function openPopupOn(browser, selector) {
async function openPopupOnSubframe(browser, frameBrowsingContext, selector) {
let childNotifiedPromise = waitPopupStateInChild(
frameBrowsingContext,
- "FormAutoComplete:PopupOpened"
+ "AutoComplete:PopupOpened"
);
await SimpleTest.promiseFocus(browser);
@@ -637,7 +618,7 @@ async function closePopup(browser) {
let childNotifiedPromise = waitPopupStateInChild(
browser,
- "FormAutoComplete:PopupClosed"
+ "AutoComplete:PopupClosed"
);
let popupClosePromise = BrowserTestUtils.waitForPopupEvent(
browser.autoCompletePopup,
@@ -655,7 +636,7 @@ async function closePopup(browser) {
async function closePopupForSubframe(browser, frameBrowsingContext) {
let childNotifiedPromise = waitPopupStateInChild(
browser,
- "FormAutoComplete:PopupClosed"
+ "AutoComplete:PopupClosed"
);
let popupClosePromise = BrowserTestUtils.waitForPopupEvent(
@@ -850,14 +831,8 @@ async function expectWarningText(browser, expectedText) {
const {
autoCompletePopup: { richlistbox: itemsBox },
} = browser;
- let warningBox = itemsBox.querySelector(
- ".autocomplete-richlistitem:last-child"
- );
-
- while (warningBox.collapsed) {
- warningBox = warningBox.previousSibling;
- }
- warningBox = warningBox._warningTextBox;
+ let warningBox = itemsBox.querySelector(".ac-status");
+ ok(warningBox.parentNode.disabled, "Got warning box and is disabled");
await BrowserTestUtils.waitForMutationCondition(
warningBox,
diff --git a/browser/extensions/formautofill/test/mochitest/creditCard/test_basic_creditcard_autocomplete_form.html b/browser/extensions/formautofill/test/mochitest/creditCard/test_basic_creditcard_autocomplete_form.html
index 8d1333b727..717d40946f 100644
--- a/browser/extensions/formautofill/test/mochitest/creditCard/test_basic_creditcard_autocomplete_form.html
+++ b/browser/extensions/formautofill/test/mochitest/creditCard/test_basic_creditcard_autocomplete_form.html
@@ -59,6 +59,11 @@ async function setupFormHistory() {
]);
}
+function replaceStars(str)
+{
+ return str.replaceAll("*", "•")
+}
+
initPopupListener();
// Form with history only.
@@ -86,7 +91,7 @@ add_task(async function all_saved_fields_less_than_threshold() {
synthesizeKey("KEY_ArrowDown");
checkMenuEntries([reducedMockRecord].map(patchRecordCCNumber).map(({ cc, expected }) => JSON.stringify({
primary: cc["cc-name"],
- secondary: cc.ccNumberFmt,
+ secondary: replaceStars(cc.ccNumberFmt),
ariaLabel: `Visa ${cc["cc-name"]} ${cc.ccNumberFmt}`,
image: expected.image,
})));
@@ -102,8 +107,8 @@ add_task(async function check_menu_when_both_existed() {
await expectPopup();
synthesizeKey("KEY_ArrowDown");
checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(({ cc, expected }) => JSON.stringify({
- primary: cc.ccNumberFmt,
- secondary: cc["cc-name"],
+ primary: replaceStars(cc.ccNumberFmt),
+ secondary: cc["cc-name"].toString(),
ariaLabel: `${getCCTypeName(cc)} ${cc.ccNumberFmt.replaceAll("*", "")} ${cc["cc-name"]}`,
image: expected.image,
})));
@@ -112,8 +117,8 @@ add_task(async function check_menu_when_both_existed() {
await expectPopup();
synthesizeKey("KEY_ArrowDown");
checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(({ cc, expected }) => JSON.stringify({
- primary: cc["cc-name"],
- secondary: cc.ccNumberFmt,
+ primary: cc["cc-name"].toString(),
+ secondary: replaceStars(cc.ccNumberFmt),
ariaLabel: `${getCCTypeName(cc)} ${cc["cc-name"]} ${cc.ccNumberFmt}`,
image: expected.image,
})));
@@ -122,8 +127,8 @@ add_task(async function check_menu_when_both_existed() {
await expectPopup();
synthesizeKey("KEY_ArrowDown");
checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(({ cc, expected }) => JSON.stringify({
- primary: cc["cc-exp-year"],
- secondary: cc.ccNumberFmt,
+ primary: cc["cc-exp-year"].toString(),
+ secondary: replaceStars(cc.ccNumberFmt),
ariaLabel: `${getCCTypeName(cc)} ${cc["cc-exp-year"]} ${cc.ccNumberFmt}`,
image: expected.image,
})));
@@ -132,8 +137,8 @@ add_task(async function check_menu_when_both_existed() {
await expectPopup();
synthesizeKey("KEY_ArrowDown");
checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(({ cc, expected }) => JSON.stringify({
- primary: cc["cc-exp-month"],
- secondary: cc.ccNumberFmt,
+ primary: cc["cc-exp-month"].toString(),
+ secondary: replaceStars(cc.ccNumberFmt),
ariaLabel: `${getCCTypeName(cc)} ${cc["cc-exp-month"]} ${cc.ccNumberFmt}`,
image: expected.image,
})));
@@ -185,8 +190,8 @@ add_task(async function check_fields_after_form_autofill() {
// The popup doesn't auto-show on focus because the field isn't empty
await expectPopup();
checkMenuEntries(MOCK_STORAGE.slice(1).map(patchRecordCCNumber).map(({ cc, expected }) => JSON.stringify({
- primary: cc["cc-exp-year"],
- secondary: cc.ccNumberFmt,
+ primary: cc["cc-exp-year"].toString(),
+ secondary: replaceStars(cc.ccNumberFmt),
ariaLabel: `${getCCTypeName(cc)} ${cc["cc-exp-year"]} ${cc.ccNumberFmt}`,
image: expected.image,
})));
@@ -220,7 +225,7 @@ add_task(async function check_cc_popup_on_field_blank() {
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(({ cc, expected }) => JSON.stringify({
primary: cc["cc-name"],
- secondary: cc.ccNumberFmt,
+ secondary: replaceStars(cc.ccNumberFmt),
ariaLabel: `${getCCTypeName(cc)} ${cc["cc-name"]} ${cc.ccNumberFmt}`,
image: expected.image,
})));
@@ -240,7 +245,7 @@ add_task(async function check_form_autofill_resume() {
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(({ cc, expected }) => JSON.stringify({
primary: cc["cc-name"],
- secondary: cc.ccNumberFmt,
+ secondary: replaceStars(cc.ccNumberFmt),
ariaLabel: `${getCCTypeName(cc)} ${cc["cc-name"]} ${cc.ccNumberFmt}`,
image: expected.image,
})));
diff --git a/browser/extensions/formautofill/test/mochitest/creditCard/test_creditcard_autocomplete_off.html b/browser/extensions/formautofill/test/mochitest/creditCard/test_creditcard_autocomplete_off.html
index 04ff6ff85c..c42a1ad2d0 100644
--- a/browser/extensions/formautofill/test/mochitest/creditCard/test_creditcard_autocomplete_off.html
+++ b/browser/extensions/formautofill/test/mochitest/creditCard/test_creditcard_autocomplete_off.html
@@ -49,6 +49,11 @@ async function setupFormHistory() {
]);
}
+function replaceStars(str)
+{
+ return str.replaceAll("*", "•")
+}
+
initPopupListener();
// Show Form History popup for non-autocomplete="off" field only
@@ -73,7 +78,7 @@ add_task(async function check_menu_when_both_with_autocomplete_off() {
synthesizeKey("KEY_ArrowDown");
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(({ cc, expected }) => JSON.stringify({
- primary: cc.ccNumberFmt,
+ primary: replaceStars(cc.ccNumberFmt),
secondary: cc["cc-name"],
ariaLabel: `${getCCTypeName(cc)} ${cc.ccNumberFmt.replaceAll("*", "")} ${cc["cc-name"]}`,
image: expected.image,
@@ -84,7 +89,7 @@ add_task(async function check_menu_when_both_with_autocomplete_off() {
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(patchRecordCCNumber).map(({ cc, expected }) => JSON.stringify({
primary: cc["cc-name"],
- secondary: cc.ccNumberFmt,
+ secondary: replaceStars(cc.ccNumberFmt),
ariaLabel: `${getCCTypeName(cc)} ${cc["cc-name"]} ${cc.ccNumberFmt}`,
image: expected.image,
})));
diff --git a/browser/extensions/formautofill/test/mochitest/formautofill_common.js b/browser/extensions/formautofill/test/mochitest/formautofill_common.js
index 6cdf9ca86b..0e371ba3af 100644
--- a/browser/extensions/formautofill/test/mochitest/formautofill_common.js
+++ b/browser/extensions/formautofill/test/mochitest/formautofill_common.js
@@ -80,8 +80,9 @@ function clickOnElement(selector) {
SimpleTest.executeSoon(() => element.click());
}
-// The equivalent helper function to getAdaptedProfiles in FormAutofillHandler.jsm that
-// transforms the given profile to expected filled profile.
+// The equivalent helper function to getAdaptedProfiles in
+// FormAutofillSection.sys.mjs that transforms the given profile to expected
+// filled profile.
function _getAdaptedProfile(profile) {
const adaptedProfile = Object.assign({}, profile);
@@ -270,12 +271,18 @@ async function onStorageChanged(type) {
});
}
-function checkMenuEntries(expectedValues, isFormAutofillResult = true) {
+function makeAddressLabel({ primary, secondary, status }) {
+ return JSON.stringify({
+ primary,
+ secondary,
+ status,
+ ariaLabel: primary + " " + secondary + " " + status,
+ });
+}
+
+function checkMenuEntries(expectedValues, extraRows = 1) {
let actualValues = getMenuEntries();
- // Expect one more item would appear at the bottom as the footer if the result is from form autofill.
- let expectedLength = isFormAutofillResult
- ? expectedValues.length + 1
- : expectedValues.length;
+ let expectedLength = expectedValues.length + extraRows;
is(actualValues.length, expectedLength, " Checking length of expected menu");
for (let i = 0; i < expectedValues.length; i++) {
diff --git a/browser/extensions/formautofill/test/mochitest/test_autofill_and_ordinal_forms.html b/browser/extensions/formautofill/test/mochitest/test_autofill_and_ordinal_forms.html
index ab3c08e89a..f3213d3708 100644
--- a/browser/extensions/formautofill/test/mochitest/test_autofill_and_ordinal_forms.html
+++ b/browser/extensions/formautofill/test/mochitest/test_autofill_and_ordinal_forms.html
@@ -31,6 +31,8 @@ let MOCK_STORAGE = [{
initPopupListener();
+let statusText = 'Also autofills address, name, organization';
+
add_task(async function setupStorage() {
await addAddress(MOCK_STORAGE[0]);
@@ -46,9 +48,13 @@ add_task(async function check_switch_autofill_form_popup() {
await expectPopup();
checkMenuEntries(
[
- `{"primary":"+13453453456","secondary":"123 Sesame Street."}`,
+ makeAddressLabel({
+ primary: "+13453453456",
+ secondary: "123 Sesame Street.",
+ status: statusText
+ }),
+ `{"primary":"","secondary":"","status":"${statusText}","style":"status"}`,
],
- true
);
await testMenuEntry(0, "!(el instanceof MozElements.MozAutocompleteRichlistitem)");
@@ -60,7 +66,7 @@ add_task(async function check_switch_oridnal_form_popup() {
await setInput("#username", "");
synthesizeKey("KEY_ArrowDown");
await expectPopup();
- checkMenuEntries(["petya"], false);
+ checkMenuEntries(["petya"], 0);
await testMenuEntry(0, "el instanceof MozElements.MozAutocompleteRichlistitem");
});
@@ -73,9 +79,13 @@ add_task(async function check_switch_autofill_form_popup_back() {
await expectPopup();
checkMenuEntries(
[
- `{"primary":"+13453453456","secondary":"123 Sesame Street."}`,
+ makeAddressLabel({
+ primary: "+13453453456",
+ secondary: "123 Sesame Street.",
+ status: statusText
+ }),
+ `{"primary":"","secondary":"","status":"${statusText}","style":"status"}`,
],
- true
);
await testMenuEntry(0, "!(el instanceof MozElements.MozAutocompleteRichlistitem)");
diff --git a/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html b/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html
index e2240474c8..2aa34f0c54 100644
--- a/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html
+++ b/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html
@@ -39,8 +39,12 @@ add_task(async function check_autocomplete_on_autofocus_field() {
synthesizeKey("KEY_ArrowDown");
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(address =>
- JSON.stringify({primary: address.organization, secondary: address["street-address"]})
- ));
+ makeAddressLabel({
+ primary: address.organization,
+ secondary: address["street-address"],
+ status: "Also autofills address, phone"
+ })
+ ), 2);
});
</script>
diff --git a/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html b/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
index a642b2abca..b8a50c7d7c 100644
--- a/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
+++ b/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
@@ -81,44 +81,48 @@ add_task(async function check_menu_when_both_existed() {
synthesizeKey("KEY_ArrowDown");
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(address =>
- JSON.stringify({
+ makeAddressLabel({
primary: address.organization,
secondary: FormAutofillUtils.toOneLineAddress(address["street-address"]),
+ status: "Also autofills address, phone"
})
- ));
+ ), 2);
await setInput("#street-address", "");
await notExpectPopup();
synthesizeKey("KEY_ArrowDown");
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(address =>
- JSON.stringify({
+ makeAddressLabel({
primary: FormAutofillUtils.toOneLineAddress(address["street-address"]),
secondary: address.organization,
+ status: "Also autofills organization, phone"
})
- ));
+ ), 2);
await setInput("#tel", "");
await notExpectPopup();
synthesizeKey("KEY_ArrowDown");
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(address =>
- JSON.stringify({
+ makeAddressLabel({
primary: address.tel,
secondary: FormAutofillUtils.toOneLineAddress(address["street-address"]),
+ status: "Also autofills address, organization"
})
- ));
+ ), 2);
await setInput("#address-line1", "");
await notExpectPopup();
synthesizeKey("KEY_ArrowDown");
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(address =>
- JSON.stringify({
+ makeAddressLabel({
primary: FormAutofillUtils.toOneLineAddress(address["street-address"]),
secondary: address.organization,
+ status: "Also autofills organization, phone"
})
- ));
+ ), 2);
});
// Display history search result if no matched data in addresses.
@@ -152,11 +156,12 @@ add_task(async function check_fields_after_form_autofill() {
synthesizeKey("KEY_ArrowDown");
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(address =>
- JSON.stringify({
+ makeAddressLabel({
primary: address.organization,
secondary: FormAutofillUtils.toOneLineAddress(address["street-address"]),
+ status: "Also autofills address, phone"
})
- ).slice(1));
+ ).slice(1), 2);
synthesizeKey("KEY_ArrowDown");
await triggerAutofillAndCheckProfile(MOCK_STORAGE[1]);
synthesizeKey("KEY_Escape");
@@ -180,11 +185,12 @@ add_task(async function check_form_autofill_resume() {
await setInput("#tel", "");
await triggerPopupAndHoverItem("#tel", 0);
checkMenuEntries(MOCK_STORAGE.map(address =>
- JSON.stringify({
+ makeAddressLabel({
primary: address.tel,
secondary: FormAutofillUtils.toOneLineAddress(address["street-address"]),
+ status: "Also autofills address, organization"
})
- ));
+ ), 2);
await triggerAutofillAndCheckProfile(MOCK_STORAGE[0]);
});
diff --git a/browser/extensions/formautofill/test/mochitest/test_form_changes.html b/browser/extensions/formautofill/test/mochitest/test_form_changes.html
index 1bfc655328..dfe91a63e1 100644
--- a/browser/extensions/formautofill/test/mochitest/test_form_changes.html
+++ b/browser/extensions/formautofill/test/mochitest/test_form_changes.html
@@ -61,8 +61,12 @@ async function checkFormChangeHappened(formId) {
await expectPopup();
synthesizeKey("KEY_ArrowDown");
checkMenuEntries(MOCK_STORAGE.map(address =>
- JSON.stringify({primary: address.tel, secondary: address.name})
- ));
+ makeAddressLabel({
+ primary: address.tel,
+ secondary: address.name,
+ status: "Also autofills name, organization"
+ })
+ ), 2);
// Click the first entry of the autocomplete popup and make sure all fields are autofilled
synthesizeKey("KEY_Enter");
@@ -76,8 +80,9 @@ async function checkFormChangeHappened(formId) {
// Click on an autofilled field would show an autocomplete popup with "clear form" entry
checkMenuEntries([
- JSON.stringify({primary: "", secondary: ""}), // Clear Autofill Form
- ], true);
+ "Clear Autofill Form", // Clear Autofill Form
+ "Manage addresses" // FormAutofill Preferemce
+ ], 0);
// This is for checking the changes of element removed and added then.
document.querySelector(`#${formId} input[name=address-level2]`).remove();
@@ -87,8 +92,12 @@ async function checkFormChangeHappened(formId) {
synthesizeKey("KEY_ArrowDown");
await expectPopup();
checkMenuEntries(MOCK_STORAGE.map(address =>
- JSON.stringify({primary: address["address-level2"], secondary: address.name})
- ));
+ makeAddressLabel({
+ primary: address["address-level2"],
+ secondary: address.name,
+ status: "Also autofills name, organization, phone"
+ })
+ ), 2);
// Make sure everything is autofilled in the end
synthesizeKey("KEY_ArrowDown");
diff --git a/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html b/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html
index 3a372ae34e..19c7a82fe4 100644
--- a/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html
+++ b/browser/extensions/formautofill/test/mochitest/test_formautofill_preview_highlight.html
@@ -81,7 +81,7 @@ add_task(async function check_preview() {
// Navigate to the footer
synthesizeKey("KEY_ArrowDown");
- await notifySelectedIndex(MOCK_STORAGE.length);
+ await notifySelectedIndex(MOCK_STORAGE.length + 1); // skip over the status row
await checkFormFieldsStyle(null);
synthesizeKey("KEY_ArrowDown");
diff --git a/browser/extensions/formautofill/test/unit/test_addressComponent_state.js b/browser/extensions/formautofill/test/unit/test_addressComponent_state.js
index 41d83e78c9..4e4c390008 100644
--- a/browser/extensions/formautofill/test/unit/test_addressComponent_state.js
+++ b/browser/extensions/formautofill/test/unit/test_addressComponent_state.js
@@ -7,14 +7,26 @@ const VALID_TESTS = [
["CA", true],
["CA.", true],
["CC", false],
+
+ // change region to CA
+ { region: "CA" },
+ ["BC", true],
+ ["British Columbia", true],
+ ["CA-BC", true],
];
const COMPARE_TESTS = [
["California", "california", SAME], // case insensitive
["CA", "california", SAME],
["CA", "ca", SAME],
+ ["CA", "CA.", SAME],
["California", "New Jersey", DIFFERENT],
["New York", "New Jersey", DIFFERENT],
+
+ // change region to CA
+ { region: "CA" },
+ ["British Columbia", "BC", SAME],
+ ["CA-BC", "BC", SAME],
];
const TEST_FIELD_NAME = "address-level1";
diff --git a/browser/extensions/formautofill/test/unit/test_getRecords.js b/browser/extensions/formautofill/test/unit/test_getRecords.js
index 9a7e5e6ac7..1ecbccab22 100644
--- a/browser/extensions/formautofill/test/unit/test_getRecords.js
+++ b/browser/extensions/formautofill/test/unit/test_getRecords.js
@@ -85,7 +85,7 @@ add_task(async function test_getRecords() {
sinon.stub(collection, "getAll");
collection.getAll.returns(Promise.resolve(expectedResult));
}
- await FormAutofillParent._getRecords({ collectionName });
+ await FormAutofillParent.getRecords({ collectionName });
if (collection) {
Assert.equal(collection.getAll.called, true);
collection.getAll.restore();
@@ -105,7 +105,7 @@ add_task(async function test_getRecords_addresses() {
description: "If the search string could match 1 address",
filter: {
collectionName: "addresses",
- info: { fieldName: "street-address" },
+ fieldName: "street-address",
searchString: "Some",
},
expectedResult: [TEST_ADDRESS_2],
@@ -114,7 +114,7 @@ add_task(async function test_getRecords_addresses() {
description: "If the search string could match multiple addresses",
filter: {
collectionName: "addresses",
- info: { fieldName: "country" },
+ fieldName: "country",
searchString: "u",
},
expectedResult: [TEST_ADDRESS_1, TEST_ADDRESS_2],
@@ -123,7 +123,7 @@ add_task(async function test_getRecords_addresses() {
description: "If the search string could not match any address",
filter: {
collectionName: "addresses",
- info: { fieldName: "street-address" },
+ fieldName: "street-address",
searchString: "test",
},
expectedResult: [],
@@ -132,7 +132,7 @@ add_task(async function test_getRecords_addresses() {
description: "If the search string is empty",
filter: {
collectionName: "addresses",
- info: { fieldName: "street-address" },
+ fieldName: "street-address",
searchString: "",
},
expectedResult: [TEST_ADDRESS_1, TEST_ADDRESS_2],
@@ -142,7 +142,7 @@ add_task(async function test_getRecords_addresses() {
"Check if the filtering logic is free from searching special chars",
filter: {
collectionName: "addresses",
- info: { fieldName: "street-address" },
+ fieldName: "street-address",
searchString: ".*",
},
expectedResult: [],
@@ -152,7 +152,7 @@ add_task(async function test_getRecords_addresses() {
"Prevent broken while searching the property that does not exist",
filter: {
collectionName: "addresses",
- info: { fieldName: "tel" },
+ fieldName: "tel",
searchString: "1",
},
expectedResult: [],
@@ -161,7 +161,7 @@ add_task(async function test_getRecords_addresses() {
for (let testCase of testCases) {
info("Starting testcase: " + testCase.description);
- let result = await FormAutofillParent._getRecords(testCase.filter);
+ let result = await FormAutofillParent.getRecords(testCase.filter);
Assert.deepEqual(result, testCase.expectedResult);
}
});
@@ -195,7 +195,7 @@ add_task(async function test_getRecords_creditCards() {
description: "If the search string could match multiple creditCards",
filter: {
collectionName: "creditCards",
- info: { fieldName: "cc-name" },
+ fieldName: "cc-name",
searchString: "John",
},
expectedResult: encryptedCCRecords,
@@ -204,7 +204,7 @@ add_task(async function test_getRecords_creditCards() {
description: "If the search string could not match any creditCard",
filter: {
collectionName: "creditCards",
- info: { fieldName: "cc-name" },
+ fieldName: "cc-name",
searchString: "T",
},
expectedResult: [],
@@ -215,7 +215,7 @@ add_task(async function test_getRecords_creditCards() {
"if the search string could match multiple creditCards",
filter: {
collectionName: "creditCards",
- info: { fieldName: "cc-number" },
+ fieldName: "cc-number",
searchString: "4",
},
expectedResult: encryptedCCRecords,
@@ -224,7 +224,7 @@ add_task(async function test_getRecords_creditCards() {
description: "If the search string could match 1 creditCard",
filter: {
collectionName: "creditCards",
- info: { fieldName: "cc-name" },
+ fieldName: "cc-name",
searchString: "John Doe",
},
mpEnabled: true,
@@ -234,7 +234,7 @@ add_task(async function test_getRecords_creditCards() {
description: "Return all creditCards if focused field is cc number",
filter: {
collectionName: "creditCards",
- info: { fieldName: "cc-number" },
+ fieldName: "cc-number",
searchString: "411",
},
mpEnabled: true,
@@ -252,7 +252,7 @@ add_task(async function test_getRecords_creditCards() {
token.reset();
token.initPassword("password");
}
- let result = await FormAutofillParent._getRecords(testCase.filter);
+ let result = await FormAutofillParent.getRecords(testCase.filter);
Assert.deepEqual(result, testCase.expectedResult);
}
});
diff --git a/browser/extensions/formautofill/test/unit/test_phoneNumber.js b/browser/extensions/formautofill/test/unit/test_phoneNumber.js
index 133e54f6d7..b776bfd8b5 100644
--- a/browser/extensions/formautofill/test/unit/test_phoneNumber.js
+++ b/browser/extensions/formautofill/test/unit/test_phoneNumber.js
@@ -1,5 +1,5 @@
/**
- * Tests PhoneNumber.jsm and PhoneNumberNormalizer.jsm.
+ * Tests PhoneNumber.sys.mjs and PhoneNumberNormalizer.sys.mjs.
*/
"use strict";
diff --git a/browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js b/browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js
index 7200bc8975..30cdae3d8a 100644
--- a/browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js
+++ b/browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js
@@ -51,6 +51,15 @@ let allFieldNames = [
"tel",
];
+function makeAddressLabel({ primary, secondary, status }) {
+ return JSON.stringify({
+ primary,
+ secondary,
+ status,
+ ariaLabel: primary + " " + secondary + " " + status,
+ });
+}
+
let addressTestCases = [
{
description: "Focus on an `organization` field",
@@ -65,21 +74,23 @@ let addressTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "Sesame Street",
secondary: "123 Sesame Street.",
+ status: "Also autofills address, name, phone",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "Mozilla",
secondary: "331 E. Evelyn Avenue",
+ status: "Also autofills address, name, phone",
}),
image: "",
},
@@ -99,31 +110,34 @@ let addressTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "1-345-345-3456.",
secondary: "123 Sesame Street.",
+ status: "Also autofills address, name, organization",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "1-650-903-0800",
secondary: "331 E. Evelyn Avenue",
+ status: "Also autofills address, name, organization",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[2]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "1-000-000-0000",
secondary: "321, No Name St. 2nd line 3rd line",
+ status: "Also autofills address",
}),
image: "",
},
@@ -143,31 +157,34 @@ let addressTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "123 Sesame Street.",
secondary: "Timothy Berners-Lee",
+ status: "Also autofills name, organization, phone",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "331 E. Evelyn Avenue",
secondary: "John Doe",
+ status: "Also autofills name, organization, phone",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[2]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "321, No Name St. 2nd line 3rd line",
secondary: "1-000-000-0000",
+ status: "Also autofills phone",
}),
image: "",
},
@@ -187,31 +204,34 @@ let addressTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "123 Sesame Street.",
secondary: "Timothy Berners-Lee",
+ status: "Also autofills name, organization, phone",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "331 E. Evelyn Avenue",
secondary: "John Doe",
+ status: "Also autofills name, organization, phone",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[2]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "321, No Name St.",
secondary: "1-000-000-0000",
+ status: "Also autofills phone",
}),
image: "",
},
@@ -287,11 +307,11 @@ let creditCardTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
label: JSON.stringify({
primary: "Timothy Berners-Lee",
- secondary: "****6785",
+ secondary: "••••6785",
ariaLabel: "Visa Timothy Berners-Lee ****6785",
image: "chrome://formautofill/content/third-party/cc-logo-visa.svg",
}),
@@ -299,11 +319,11 @@ let creditCardTestCases = [
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
label: JSON.stringify({
primary: "John Doe",
- secondary: "****1234",
+ secondary: "••••1234",
ariaLabel: "American Express John Doe ****1234",
image: "chrome://formautofill/content/third-party/cc-logo-amex.png",
}),
@@ -325,10 +345,10 @@ let creditCardTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
label: JSON.stringify({
- primary: "****6785",
+ primary: "••••6785",
secondary: "Timothy Berners-Lee",
ariaLabel: "Visa 6785 Timothy Berners-Lee",
image: "chrome://formautofill/content/third-party/cc-logo-visa.svg",
@@ -337,10 +357,10 @@ let creditCardTestCases = [
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
label: JSON.stringify({
- primary: "****1234",
+ primary: "••••1234",
secondary: "John Doe",
ariaLabel: "American Express 1234 John Doe",
image: "chrome://formautofill/content/third-party/cc-logo-amex.png",
@@ -349,10 +369,10 @@ let creditCardTestCases = [
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[2]),
label: JSON.stringify({
- primary: "****5678",
+ primary: "••••5678",
secondary: "",
ariaLabel: "5678",
image: "chrome://formautofill/content/icon-credit-card-generic.svg",
@@ -416,7 +436,14 @@ add_task(async function test_all_patterns() {
let expectedItemLength = expectedValue.items.length;
// If the last item shows up as a footer, we expect one more item
// than expected.
- if (actual.getStyleAt(actual.matchCount - 1) == "autofill-footer") {
+ if (actual.getStyleAt(actual.matchCount - 1) == "action") {
+ expectedItemLength++;
+ }
+ // Add one row for the status.
+ if (
+ actual.matchCount > 2 &&
+ actual.getStyleAt(actual.matchCount - 2) == "status"
+ ) {
expectedItemLength++;
}