Bug 1600059, remove some usages of waitForCondition in formautofill tests and replace with waitForMutationCondition and waiting for popup event notifications in the child process to see if this fixes the intermittent failures, r=mak

This is the same issue as bug 1701078.

Differential Revision: https://phabricator.services.mozilla.com/D112979
This commit is contained in:
Neil Deakin 2021-04-26 15:29:36 +00:00
Родитель dd27439769
Коммит 513e659b72
5 изменённых файлов: 128 добавлений и 60 удалений

Просмотреть файл

@ -6,27 +6,18 @@ support-files =
../fixtures/autocomplete_simple_basic.html
[browser_autocomplete_footer.js]
skip-if = (verify || (!debug && os == "mac")) # perma-fail see Bug 1600059
skip-if = verify # 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 || (!debug && os == "mac") # perma-fail see Bug 1600059
skip-if = verify
[browser_first_time_use_doorhanger.js]
skip-if = verify || (!debug && os == "mac") # perma-fail see Bug 1600059
skip-if = verify
[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

Просмотреть файл

@ -17,8 +17,12 @@ 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, expectPopupClose(browser)]);
await Promise.all([osKeyStoreLoginShown, popupClosePromise]);
await SpecialPowers.spawn(browser, [], async function() {
is(content.document.querySelector("#cc-name").value, "", "Check name");

Просмотреть файл

@ -688,14 +688,16 @@ add_task(async function test_submit_creditCard_new_with_hidden_ui() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_URL },
async function(browser) {
await openPopupOn(browser, "form #cc-number").then(
() => {
return Promise.reject("Popup should not be displayed");
},
() => {
ok(true, "Popup has not been displayed");
}
);
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 SpecialPowers.spawn(browser, [], async function() {
let form = content.document.getElementById("form");
@ -715,7 +717,12 @@ add_task(async function test_submit_creditCard_new_with_hidden_ui() {
});
await sleep(1000);
is(PopupNotifications.panel.state, "closed", "Doorhanger is hidden");
is(
PopupNotifications.panel.state,
"closed",
"Doorhanger is still hidden"
);
browser.removeEventListener("popupshowing", rejectPopup, true);
}
);

Просмотреть файл

@ -90,11 +90,15 @@ 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 expectPopupClose(browser);
await popupClosePromise;
const inputValue = await SpecialPowers.spawn(
browser,
[],
@ -116,9 +120,15 @@ 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 expectPopupClose(browser);
await popupClosePromise;
const inputValue = await SpecialPowers.spawn(
browser,
[],

Просмотреть файл

@ -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, expectPopupClose, closePopup, closePopupForSubframe,
sleep, expectPopupOpen, openPopupOn, openPopupForSubframe, closePopup, closePopupForSubframe,
clickDoorhangerButton, getAddresses, saveAddress, removeAddresses, saveCreditCard,
getDisplayedPopupItems, getDoorhangerCheckbox, waitForPopupEnabled,
getNotification, getDoorhangerButton, removeAllRecords, expectWarningText, testDialog */
@ -283,39 +283,68 @@ async function focusAndWaitForFieldsIdentified(browserOrContext, selector) {
async function expectPopupOpen(browser) {
info("expectPopupOpen");
const { autoCompletePopup } = browser;
await BrowserTestUtils.waitForCondition(
() => autoCompletePopup.popupOpen,
"popup should be open"
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")
);
})
);
}
);
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;
const listItemElems = itemsBox.querySelectorAll(".autocomplete-richlistitem");
await TestUtils.waitForCondition(
() => !listItemElems[0].disabled,
"Wait for list elements to become enabled"
info("Wait for list elements to become enabled");
await BrowserTestUtils.waitForMutationCondition(
itemsBox,
{ subtree: true, attributes: true, attributeFilter: ["disabled"] },
() => !itemsBox.querySelectorAll(".autocomplete-richlistitem")[0].disabled
);
}
// 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-")) {
@ -323,9 +352,14 @@ 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-")) {
@ -333,29 +367,49 @@ async function openPopupForSubframe(browser, frameBrowsingContext, selector) {
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, frameBrowsingContext);
}
await expectPopupOpen(browser);
}
async function expectPopupClose(browser) {
await BrowserTestUtils.waitForCondition(
() => !browser.autoCompletePopup.popupOpen,
"popup should have closed"
);
await childNotifiedPromise;
}
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 expectPopupClose(browser);
await popupClosePromise;
await childNotifiedPromise;
}
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 expectPopupClose(browser);
await popupClosePromise;
await childNotifiedPromise;
}
function emulateMessageToBrowser(name, data) {
@ -495,9 +549,11 @@ async function expectWarningText(browser, expectedText) {
}
warningBox = warningBox._warningTextBox;
await BrowserTestUtils.waitForCondition(() => {
return warningBox.textContent == expectedText;
}, `Waiting for expected warning text: ${expectedText}, Got ${warningBox.textContent}`);
await BrowserTestUtils.waitForMutationCondition(
warningBox,
{ childList: true, characterData: true },
() => warningBox.textContent == expectedText
);
ok(true, `Got expected warning text: ${expectedText}`);
}