From aaa4bbff2a6d4beae9e916c5d5c2739bfafcdb9e Mon Sep 17 00:00:00 2001 From: Paul Zuehlcke Date: Mon, 22 Jan 2024 18:43:53 +0000 Subject: [PATCH] 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 --- browser/base/content/test/protectionsUI/head.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/browser/base/content/test/protectionsUI/head.js b/browser/base/content/test/protectionsUI/head.js index 13447f962143..98e5063129cc 100644 --- a/browser/base/content/test/protectionsUI/head.js +++ b/browser/base/content/test/protectionsUI/head.js @@ -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 {