From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../test/browser/browser_autocomplete_footer.js | 137 +++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js (limited to 'browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js') diff --git a/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js b/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js new file mode 100644 index 0000000000..d2f5c72f16 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js @@ -0,0 +1,137 @@ +"use strict"; + +const URL = BASE_URL + "autocomplete_basic.html"; + +add_task(async function setup_storage() { + await setStorage( + TEST_ADDRESS_2, + TEST_ADDRESS_3, + TEST_ADDRESS_4, + TEST_ADDRESS_5 + ); +}); + +add_task(async function test_press_enter_on_footer() { + await BrowserTestUtils.withNewTab( + { gBrowser, url: URL }, + async function (browser) { + const { + autoCompletePopup: { richlistbox: itemsBox }, + } = browser; + + await openPopupOn(browser, "#organization"); + // Navigate to the footer and press enter. + const listItemElems = itemsBox.querySelectorAll( + ".autocomplete-richlistitem" + ); + const prefTabPromise = BrowserTestUtils.waitForNewTab( + gBrowser, + PRIVACY_PREF_URL, + true + ); + for (let i = 0; i < listItemElems.length; i++) { + if (!listItemElems[i].collapsed) { + await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); + } + } + await BrowserTestUtils.synthesizeKey("VK_RETURN", {}, browser); + info(`expecting tab: about:preferences#privacy opened`); + const prefTab = await prefTabPromise; + info(`expecting tab: about:preferences#privacy removed`); + BrowserTestUtils.removeTab(prefTab); + ok( + true, + "Tab: preferences#privacy was successfully opened by pressing enter on the footer" + ); + + await closePopup(browser); + } + ); +}); + +add_task(async function test_click_on_footer() { + await BrowserTestUtils.withNewTab( + { gBrowser, url: URL }, + async function (browser) { + const { + autoCompletePopup: { richlistbox: itemsBox }, + } = browser; + + await openPopupOn(browser, "#organization"); + // Click on the footer + let optionButton = itemsBox.querySelector( + ".autocomplete-richlistitem:last-child" + ); + while (optionButton.collapsed) { + optionButton = optionButton.previousElementSibling; + } + optionButton = optionButton._optionButton; + + const prefTabPromise = BrowserTestUtils.waitForNewTab( + gBrowser, + PRIVACY_PREF_URL, + true + ); + // Make sure dropdown is visible before continuing mouse synthesizing. + await BrowserTestUtils.waitForCondition(() => + BrowserTestUtils.is_visible(optionButton) + ); + await EventUtils.synthesizeMouseAtCenter(optionButton, {}); + info(`expecting tab: about:preferences#privacy opened`); + const prefTab = await prefTabPromise; + info(`expecting tab: about:preferences#privacy removed`); + BrowserTestUtils.removeTab(prefTab); + ok( + true, + "Tab: preferences#privacy was successfully opened by clicking on the footer" + ); + + await closePopup(browser); + } + ); +}); + +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, "Autofills phone"); + is( + warningBox.ownerGlobal.getComputedStyle(warningBox).backgroundColor, + "rgba(248, 232, 28, 0.2)", + "Check warning text background color" + ); + + await closePopup(browser); + } + ); +}); + +add_task(async function test_phishing_warning_complex_categories() { + await BrowserTestUtils.withNewTab( + { gBrowser, url: URL }, + async function (browser) { + await openPopupOn(browser, "#street-address"); + + await expectWarningText(browser, "Also autofills organization, email"); + await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); + await expectWarningText(browser, "Autofills address"); + await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); + await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); + await expectWarningText(browser, "Also autofills organization, email"); + await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); + await expectWarningText(browser, "Also autofills organization, email"); + + await closePopup(browser); + } + ); +}); -- cgit v1.2.3