Bug 1544749 - Fix HTML Tooltip tests when running in content frame r=bgrins
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 23 Apr 2019 15:00:23 +0000
changeset 470502 970ef36e6c09e748140ebf96c9ccfec6eb52ab5e
parent 470501 4a753a263c3835e7e52f0c3419a3b7c43e12ab54
child 470503 4f8806f0c9f0db51948b14556c24658de1753a9a
push id35906
push useraciure@mozilla.com
push dateTue, 23 Apr 2019 22:14:56 +0000
treeherdermozilla-central@0ce3633f8b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1544749
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1544749 - Fix HTML Tooltip tests when running in content frame r=bgrins Depends on D27680 Not strictly related to win.top/parent, but those tests would fail if the toolbox is in a content frame. tooltip-01.js is creating a blank tab for no reason which prevents interacting with the actual test frame. tooltip-02.js is not properly targeting an iframe to simulate a click Differential Revision: https://phabricator.services.mozilla.com/D27674
devtools/client/shared/test/browser_html_tooltip-01.js
devtools/client/shared/test/browser_html_tooltip-02.js
--- a/devtools/client/shared/test/browser_html_tooltip-01.js
+++ b/devtools/client/shared/test/browser_html_tooltip-01.js
@@ -32,33 +32,31 @@ add_task(async function() {
   await runTests(doc);
 
   info("Run tests for a Tooltip with a XUL panel");
   useXulWrapper = true;
   await runTests(doc);
 });
 
 async function runTests(doc) {
-  await addTab("about:blank");
   const tooltip = new HTMLTooltip(doc, {useXulWrapper});
 
   info("Set tooltip content");
   tooltip.panel.appendChild(getTooltipContent(doc));
   tooltip.setContentSize({width: 100, height: 50});
 
   is(tooltip.isVisible(), false, "Tooltip is not visible");
 
   info("Show the tooltip and check the expected events are fired.");
 
   let shown = 0;
   tooltip.on("shown", () => shown++);
 
   const onShown = tooltip.once("shown");
   tooltip.show(doc.getElementById("box1"));
-
   await onShown;
   is(shown, 1, "Event shown was fired once");
 
   await waitForReflow(tooltip);
   is(tooltip.isVisible(), true, "Tooltip is visible");
 
   info("Hide the tooltip and check the expected events are fired.");
 
--- a/devtools/client/shared/test/browser_html_tooltip-02.js
+++ b/devtools/client/shared/test/browser_html_tooltip-02.js
@@ -139,22 +139,32 @@ async function testClickInOuterIframe(do
 async function testClickInInnerIframe(doc) {
   info("Test clicking an iframe inside the tooltip content does not close the tooltip");
 
   const tooltip = new HTMLTooltip(doc, {consumeOutsideClicks: false, useXulWrapper});
 
   const iframe = doc.createElementNS(HTML_NS, "iframe");
   iframe.style.width = "100px";
   iframe.style.height = "50px";
+
   tooltip.panel.appendChild(iframe);
+
+  const onFrameLoad = new Promise(r => {
+    iframe.addEventListener("load", r, true);
+  });
+  iframe.src = "data:text/html,<div id=test style='height:50px;'></div>";
+  await onFrameLoad;
+
   tooltip.setContentSize({width: 100, height: 50});
   await showTooltip(tooltip, doc.getElementById("box1"));
 
-  const onTooltipContainerClick = once(tooltip.container, "click");
-  EventUtils.synthesizeMouseAtCenter(tooltip.container, {}, doc.defaultView);
+  const target = iframe.contentWindow.document.documentElement;
+  const onTooltipContainerClick = once(target, "click");
+
+  EventUtils.synthesizeMouseAtCenter(target, {}, target.ownerDocument.defaultView);
   await onTooltipContainerClick;
 
   is(tooltip.isVisible(), true, "Tooltip is still visible");
 
   tooltip.destroy();
 }
 
 function getTooltipContent(doc) {