From e3f5ad16b57fd98dbb4b146ed7495726f0bccb2d Mon Sep 17 00:00:00 2001 From: Cosmin Sabou Date: Mon, 26 Apr 2021 23:24:18 +0300 Subject: [PATCH] Backed out 2 changesets (bug 1600059) for bc failures on browser_autocomplete_footer.js. CLOSED TREE Backed out changeset 6e03b1a45863 (bug 1600059) Backed out changeset 9a742ac1be88 (bug 1600059) --- .../formautofill/test/browser/browser.ini | 15 ++- .../browser/browser_autocomplete_footer.js | 13 +- .../browser_creditCard_fill_cancel_login.js | 6 +- .../browser_creditCard_telemetry.js | 25 ++-- .../creditCard/browser_insecure_form.js | 16 +-- .../formautofill/test/browser/head.js | 126 +++++------------- 6 files changed, 63 insertions(+), 138 deletions(-) diff --git a/browser/extensions/formautofill/test/browser/browser.ini b/browser/extensions/formautofill/test/browser/browser.ini index a9dbd86c2d82..31bc10b8b1ad 100644 --- a/browser/extensions/formautofill/test/browser/browser.ini +++ b/browser/extensions/formautofill/test/browser/browser.ini @@ -6,18 +6,27 @@ support-files = ../fixtures/autocomplete_simple_basic.html [browser_autocomplete_footer.js] -skip-if = verify # perma-fail see Bug 1600059 +skip-if = (verify || (!debug && os == "mac")) # perma-fail see Bug 1600059 [browser_autocomplete_marked_back_forward.js] +skip-if = !debug && os == "mac" # perma-fail see Bug 1600059 [browser_autocomplete_marked_detached_tab.js] skip-if = (verify && (os == 'win')) || (os == 'mac') [browser_check_installed.js] +skip-if = !debug && os == "mac" # perma-fail see Bug 1600059 [browser_dropdown_layout.js] +skip-if = !debug && os == "mac" # perma-fail see Bug 1600059 [browser_editAddressDialog.js] -skip-if = verify +skip-if = verify || (!debug && os == "mac") # perma-fail see Bug 1600059 [browser_first_time_use_doorhanger.js] -skip-if = verify +skip-if = verify || (!debug && os == "mac") # perma-fail see Bug 1600059 [browser_manageAddressesDialog.js] +skip-if = !debug && os == "mac" # perma-fail see Bug 1600059 [browser_remoteiframe.js] +skip-if = + !debug && os == "mac" # perma-fail see Bug 1600059 + os == 'linux' && (debug || asan || tsan) #Bug 1701078 + os == 'win' && bits == 64 && asan #Bug 1701078 [browser_submission_in_private_mode.js] +skip-if = !debug && os == "mac" # perma-fail see Bug 1600059 [browser_update_doorhanger.js] skip-if = true # bug 1426981 # Bug 1445538 diff --git a/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js b/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js index feea20f1641c..0dd1921596b8 100644 --- a/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js +++ b/browser/extensions/formautofill/test/browser/browser_autocomplete_footer.js @@ -29,9 +29,7 @@ add_task(async function test_press_enter_on_footer() { true ); for (let i = 0; i < listItemElems.length; i++) { - if (!listItemElems[i].collapsed) { - await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); - } + await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); } await BrowserTestUtils.synthesizeKey("VK_RETURN", {}, browser); info(`expecting tab: about:preferences#privacy opened`); @@ -57,14 +55,9 @@ add_task(async function test_click_on_footer() { await openPopupOn(browser, "#organization"); // Click on the footer - let optionButton = itemsBox.querySelector( + const optionButton = itemsBox.querySelector( ".autocomplete-richlistitem:last-child" - ); - while (optionButton.collapsed) { - optionButton = optionButton.previousElementSibling; - } - optionButton = optionButton._optionButton; - + )._optionButton; const prefTabPromise = BrowserTestUtils.waitForNewTab( gBrowser, PRIVACY_PREF_URL, diff --git a/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_fill_cancel_login.js b/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_fill_cancel_login.js index 9a0d19d491b6..602b989d0444 100644 --- a/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_fill_cancel_login.js +++ b/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_fill_cancel_login.js @@ -17,12 +17,8 @@ add_task(async function test_fill_creditCard_but_cancel_login() { async function(browser) { await openPopupOn(browser, "#cc-name"); const ccItem = getDisplayedPopupItems(browser)[0]; - let popupClosePromise = BrowserTestUtils.waitForPopupEvent( - browser.autoCompletePopup, - "hidden" - ); await EventUtils.synthesizeMouseAtCenter(ccItem, {}); - await Promise.all([osKeyStoreLoginShown, popupClosePromise]); + await Promise.all([osKeyStoreLoginShown, expectPopupClose(browser)]); await SpecialPowers.spawn(browser, [], async function() { is(content.document.querySelector("#cc-name").value, "", "Check name"); diff --git a/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_telemetry.js b/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_telemetry.js index 38fada2e6a9e..48c4d7733aa4 100644 --- a/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_telemetry.js +++ b/browser/extensions/formautofill/test/browser/creditCard/browser_creditCard_telemetry.js @@ -688,16 +688,14 @@ add_task(async function test_submit_creditCard_new_with_hidden_ui() { await BrowserTestUtils.withNewTab( { gBrowser, url: CREDITCARD_FORM_URL }, async function(browser) { - let rejectPopup = () => { - ok(false, "Popup should not be displayed"); - }; - browser.addEventListener("popupshowing", rejectPopup, true); - - await SimpleTest.promiseFocus(browser); - await focusAndWaitForFieldsIdentified(browser, "form #cc-number"); - await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); - - is(PopupNotifications.panel.state, "closed", "Doorhanger is hidden"); + await openPopupOn(browser, "form #cc-number").then( + () => { + return Promise.reject("Popup should not be displayed"); + }, + () => { + ok(true, "Popup has not been displayed"); + } + ); await SpecialPowers.spawn(browser, [], async function() { let form = content.document.getElementById("form"); @@ -717,12 +715,7 @@ add_task(async function test_submit_creditCard_new_with_hidden_ui() { }); await sleep(1000); - is( - PopupNotifications.panel.state, - "closed", - "Doorhanger is still hidden" - ); - browser.removeEventListener("popupshowing", rejectPopup, true); + is(PopupNotifications.panel.state, "closed", "Doorhanger is hidden"); } ); 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 f8ef8d050390..97e829db62ca 100644 --- a/browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js +++ b/browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js @@ -90,15 +90,11 @@ add_task(async function test_click_on_insecure_warning() { { gBrowser, url: "http" + TEST_URL_PATH_CC }, async function(browser) { await openPopupOn(browser, "#cc-name"); + const insecureItem = getDisplayedPopupItems(browser)[0]; - let popupClosePromise = BrowserTestUtils.waitForPopupEvent( - browser.autoCompletePopup, - "hidden" - ); await EventUtils.synthesizeMouseAtCenter(insecureItem, {}); // Check input's value after popup closed to ensure the completion of autofilling. - await popupClosePromise; - + await expectPopupClose(browser); const inputValue = await SpecialPowers.spawn( browser, [], @@ -120,15 +116,9 @@ add_task(async function test_press_enter_on_insecure_warning() { await openPopupOn(browser, "#cc-name"); await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); - - let popupClosePromise = BrowserTestUtils.waitForPopupEvent( - browser.autoCompletePopup, - "hidden" - ); await BrowserTestUtils.synthesizeKey("VK_RETURN", {}, browser); // Check input's value after popup closed to ensure the completion of autofilling. - await popupClosePromise; - + await expectPopupClose(browser); const inputValue = await SpecialPowers.spawn( browser, [], diff --git a/browser/extensions/formautofill/test/browser/head.js b/browser/extensions/formautofill/test/browser/head.js index 6347271608d8..455837daded9 100644 --- a/browser/extensions/formautofill/test/browser/head.js +++ b/browser/extensions/formautofill/test/browser/head.js @@ -6,7 +6,7 @@ FTU_PREF, ENABLED_AUTOFILL_ADDRESSES_PREF, ENABLED_AUTOFILL_ADDRESSES_CAPTURE_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, - sleep, expectPopupOpen, openPopupOn, openPopupForSubframe, closePopup, closePopupForSubframe, + sleep, expectPopupOpen, openPopupOn, openPopupForSubframe, expectPopupClose, closePopup, closePopupForSubframe, clickDoorhangerButton, getAddresses, saveAddress, removeAddresses, saveCreditCard, getDisplayedPopupItems, getDoorhangerCheckbox, waitForPopupEnabled, getNotification, getDoorhangerButton, removeAllRecords, expectWarningText, testDialog */ @@ -283,68 +283,39 @@ async function focusAndWaitForFieldsIdentified(browserOrContext, selector) { async function expectPopupOpen(browser) { info("expectPopupOpen"); - await BrowserTestUtils.waitForPopupEvent(browser.autoCompletePopup, "shown"); - 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-footer") && - item.hasAttribute("formautofillattached") - ); - }) - ); - } + const { autoCompletePopup } = browser; + await BrowserTestUtils.waitForCondition( + () => autoCompletePopup.popupOpen, + "popup should be open" ); + await BrowserTestUtils.waitForCondition(() => { + 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-footer") && + item.hasAttribute("formautofillattached") + ); + }) + ); + }, "The popup should be a form autofill one"); } async function waitForPopupEnabled(browser) { const { autoCompletePopup: { richlistbox: itemsBox }, } = browser; - info("Wait for list elements to become enabled"); - await BrowserTestUtils.waitForMutationCondition( - itemsBox, - { subtree: true, attributes: true, attributeFilter: ["disabled"] }, - () => !itemsBox.querySelectorAll(".autocomplete-richlistitem")[0].disabled + const listItemElems = itemsBox.querySelectorAll(".autocomplete-richlistitem"); + await TestUtils.waitForCondition( + () => !listItemElems[0].disabled, + "Wait for list elements to become enabled" ); } -// Wait for the popup state change notification to happen in a child process. -function waitPopupStateInChild(bc, messageName) { - return SpecialPowers.spawn(bc, [messageName], expectedMessage => { - return new Promise(resolve => { - const { AutoCompleteChild } = ChromeUtils.import( - "resource://gre/actors/AutoCompleteChild.jsm" - ); - - let listener = { - popupStateChanged: name => { - if (name != expectedMessage) { - info("Expected " + expectedMessage + " but received " + name); - return; - } - - AutoCompleteChild.removePopupStateListener(listener); - resolve(); - }, - }; - AutoCompleteChild.addPopupStateListener(listener); - }); - }); -} - async function openPopupOn(browser, selector) { - let childNotifiedPromise = waitPopupStateInChild( - browser, - "FormAutoComplete:PopupOpened" - ); await SimpleTest.promiseFocus(browser); await focusAndWaitForFieldsIdentified(browser, selector); if (!selector.includes("cc-")) { @@ -352,14 +323,9 @@ async function openPopupOn(browser, selector) { await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); } await expectPopupOpen(browser); - await childNotifiedPromise; } async function openPopupForSubframe(browser, frameBrowsingContext, selector) { - let childNotifiedPromise = waitPopupStateInChild( - frameBrowsingContext, - "FormAutoComplete:PopupOpened" - ); await SimpleTest.promiseFocus(browser); await focusAndWaitForFieldsIdentified(frameBrowsingContext, selector); if (!selector.includes("cc-")) { @@ -367,49 +333,29 @@ async function openPopupForSubframe(browser, frameBrowsingContext, selector) { await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, frameBrowsingContext); } await expectPopupOpen(browser); - await childNotifiedPromise; +} + +async function expectPopupClose(browser) { + await BrowserTestUtils.waitForCondition( + () => !browser.autoCompletePopup.popupOpen, + "popup should have closed" + ); } async function closePopup(browser) { - // Return if the popup isn't open. - if (!browser.autoCompletePopup.popupOpen) { - return; - } - - let childNotifiedPromise = waitPopupStateInChild( - browser, - "FormAutoComplete:PopupClosed" - ); - let popupClosePromise = BrowserTestUtils.waitForPopupEvent( - browser.autoCompletePopup, - "hidden" - ); - await SpecialPowers.spawn(browser, [], async function() { content.document.activeElement.blur(); }); - await popupClosePromise; - await childNotifiedPromise; + await expectPopupClose(browser); } async function closePopupForSubframe(browser, frameBrowsingContext) { - let childNotifiedPromise = waitPopupStateInChild( - browser, - "FormAutoComplete:PopupClosed" - ); - - let popupClosePromise = BrowserTestUtils.waitForPopupEvent( - browser.autoCompletePopup, - "hidden" - ); - await SpecialPowers.spawn(frameBrowsingContext, [], async function() { content.document.activeElement.blur(); }); - await popupClosePromise; - await childNotifiedPromise; + await expectPopupClose(browser); } function emulateMessageToBrowser(name, data) { @@ -549,11 +495,9 @@ async function expectWarningText(browser, expectedText) { } warningBox = warningBox._warningTextBox; - await BrowserTestUtils.waitForMutationCondition( - warningBox, - { childList: true, characterData: true }, - () => warningBox.textContent == expectedText - ); + await BrowserTestUtils.waitForCondition(() => { + return warningBox.textContent == expectedText; + }, `Waiting for expected warning text: ${expectedText}, Got ${warningBox.textContent}`); ok(true, `Got expected warning text: ${expectedText}`); }