Bug 1775855 - Wait for tooltip shown before in browser_protectionUI.js to fix race condition. r=bvandersloot

Differential Revision: https://phabricator.services.mozilla.com/D198015
This commit is contained in:
Paul Zuehlcke 2024-01-22 18:43:53 +00:00
parent ae2443b884
commit aaa4bbff2a

View file

@ -30,7 +30,10 @@ async function waitForProtectionsPanelToast() {
gProtectionsHandler._protectionsPopup,
"popupshown"
);
Assert.ok(gProtectionsHandler._protectionsPopup.hasAttribute("toast"), "Protections panel toast is shown.");
Assert.ok(
gProtectionsHandler._protectionsPopup.hasAttribute("toast"),
"Protections panel toast is shown."
);
await BrowserTestUtils.waitForEvent(
gProtectionsHandler._protectionsPopup,
@ -49,6 +52,13 @@ async function openProtectionsPanel(toast, win = window) {
"tracking-protection-icon-container"
);
// Register a promise to wait for the tooltip to be shown.
let tooltip = win.document.getElementById("tracking-protection-icon-tooltip");
let tooltipShownPromise = BrowserTestUtils.waitForPopupEvent(
tooltip,
"shown"
);
// Move out than move over the shield icon to trigger the hover event in
// order to fetch tracker count.
EventUtils.synthesizeMouseAtCenter(
@ -66,6 +76,9 @@ async function openProtectionsPanel(toast, win = window) {
win
);
// Wait for the tooltip to be shown.
await tooltipShownPromise;
if (!toast) {
EventUtils.synthesizeMouseAtCenter(shieldIconContainer, {}, win);
} else {