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 --- .../browser_creditCard_dropdown_layout.js | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_dropdown_layout.js (limited to 'browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_dropdown_layout.js') 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 new file mode 100644 index 0000000000..d69f7129ee --- /dev/null +++ b/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_dropdown_layout.js @@ -0,0 +1,57 @@ +"use strict"; + +const CC_URL = + "https://example.org/browser/browser/extensions/formautofill/test/browser/creditCard/autocomplete_creditcard_basic.html"; + +add_task(async function setup_storage() { + await setStorage(TEST_CREDIT_CARD_1, TEST_CREDIT_CARD_2, TEST_CREDIT_CARD_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_credit_card_dropdown() { + await BrowserTestUtils.withNewTab( + { gBrowser, url: CC_URL }, + async function (browser) { + const focusInput = "#cc-number"; + await openPopupOn(browser, focusInput); + const firstItem = getDisplayedPopupItems(browser)[0]; + + isnot(firstItem.getAttribute("ac-image"), "", "Should show icon"); + ok( + firstItem.getAttribute("aria-label").startsWith("Visa "), + "aria-label should start with Visa" + ); + + // The breakpoint of two-lines layout is 185px + await reopenPopupWithResizedInput(browser, focusInput, 175); + is( + firstItem._itemBox.getAttribute("size"), + "small", + "Show two-lines layout" + ); + await reopenPopupWithResizedInput(browser, focusInput, 195); + is( + firstItem._itemBox.hasAttribute("size"), + false, + "Show one-line layout" + ); + + await closePopup(browser); + } + ); +}); -- cgit v1.2.3