diff --git a/devtools/client/shared/test/browser_html_tooltip-02.js b/devtools/client/shared/test/browser_html_tooltip-02.js index d58138ceeff0..c818428fc592 100644 --- a/devtools/client/shared/test/browser_html_tooltip-02.js +++ b/devtools/client/shared/test/browser_html_tooltip-02.js @@ -167,24 +167,24 @@ async function testClickInInnerIframe(doc) { tooltip.panel.appendChild(iframe); - const onFrameLoad = new Promise(r => { - iframe.addEventListener("load", r, true); - }); - iframe.srcdoc = "
"; - await onFrameLoad; - tooltip.setContentSize({ width: 100, height: 50 }); await showTooltip(tooltip, doc.getElementById("box1")); - const target = iframe.contentWindow.document.documentElement; - const onTooltipContainerClick = once(target, "click"); + iframe.srcdoc = ""; + await new Promise(r => { + const domHelper = new DOMHelpers(iframe.contentWindow); + const frameLoad = () => { + r(); + }; + domHelper.onceDOMReady(frameLoad); + }); - EventUtils.synthesizeMouseAtCenter( - target, - {}, - target.ownerDocument.defaultView - ); - await onTooltipContainerClick; + await waitUntil(() => iframe.contentWindow.document.getElementById("test")); + + const target = iframe.contentWindow.document.getElementById("test"); + const onTooltipClick = once(target, "click"); + EventUtils.synthesizeMouseAtCenter(target, {}, target.ownerGlobal); + await onTooltipClick; is(tooltip.isVisible(), true, "Tooltip is still visible");