Bug 1504985 - Remove dependency on the textoverflow attribute from browser_UrlbarInput_tooltip.js. r=mak
authorDão Gottwald <dao@mozilla.com>
Sun, 02 Dec 2018 14:20:33 +0000
changeset 508385 e65a1d1d653cadb25091dac2ec3758b5dba28eb3
parent 508384 7f9b27677bc015b40c879b7889be44c6d0878f3b
child 508386 dcc5dcceb8661d9c74ba44dc2b2280c3b37cf467
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1504985, 1419391
milestone65.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 1504985 - Remove dependency on the textoverflow attribute from browser_UrlbarInput_tooltip.js. r=mak The textoverflow attribute is set asynchronously thanks to bug 1419391, making this test more complicated than necessary. We can use the private _overflowing (UrlbarInput) and _inOverflow (urlbarBindings.xml) flags instead. Differential Revision: https://phabricator.services.mozilla.com/D13639
browser/components/urlbar/tests/browser/browser.ini
browser/components/urlbar/tests/browser/browser_UrlbarInput_tooltip.js
--- a/browser/components/urlbar/tests/browser/browser.ini
+++ b/browser/components/urlbar/tests/browser/browser.ini
@@ -4,13 +4,13 @@
 
 [DEFAULT]
 support-files =
   head.js
 
 [browser_UrlbarInput_formatValue.js]
 [browser_UrlbarInput_overflow.js]
 [browser_UrlbarInput_tooltip.js]
-skip-if = os == "win" || asan # Bug 1511655 and bug 1504985
+skip-if = os == "win" # Bug 1511655
 [browser_UrlbarInput_trimURLs.js]
 subsuite = clipboard
 [browser_UrlbarInput_unit.js]
 support-files = empty.xul
--- a/browser/components/urlbar/tests/browser/browser_UrlbarInput_tooltip.js
+++ b/browser/components/urlbar/tests/browser/browser_UrlbarInput_tooltip.js
@@ -1,73 +1,77 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 function synthesizeMouseOver(element) {
-  window.windowUtils.disableNonTestMouseEvents(true);
-
-  let promise = BrowserTestUtils.waitForEvent(gURLBar.inputField, "mouseover");
+  let promise = BrowserTestUtils.waitForEvent(element, "mouseover");
 
   EventUtils.synthesizeMouse(element, 1, 1, {type: "mouseover"});
   EventUtils.synthesizeMouse(element, 2, 2, {type: "mousemove"});
   EventUtils.synthesizeMouse(element, 3, 3, {type: "mousemove"});
   EventUtils.synthesizeMouse(element, 4, 4, {type: "mousemove"});
 
   return promise;
 }
 
 function synthesizeMouseOut(element) {
-  let promise = BrowserTestUtils.waitForEvent(gURLBar.inputField, "mouseout");
+  let promise = BrowserTestUtils.waitForEvent(element, "mouseout");
 
   EventUtils.synthesizeMouse(element, 0, 0, {type: "mouseout"});
   EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
   EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
   EventUtils.synthesizeMouseAtCenter(document.documentElement, {type: "mousemove"});
 
-  window.windowUtils.disableNonTestMouseEvents(false);
-
   return promise;
 }
 
 async function expectTooltip(text) {
-  ok(gURLBar.hasAttribute("textoverflow"), "Urlbar is overflowing");
+  if (!gURLBar._overflowing && !gURLBar._inOverflow) {
+    info("waiting for overflow event");
+    await BrowserTestUtils.waitForEvent(gURLBar.inputField, "overflow");
+  }
 
   let tooltip = document.getElementById("aHTMLTooltip");
   let element = gURLBar.inputField;
 
   let popupShownPromise = BrowserTestUtils.waitForEvent(tooltip, "popupshown");
   await synthesizeMouseOver(element);
   await popupShownPromise;
 
   is(element.getAttribute("title"), text, "title attribute has expected text");
   is(tooltip.textContent, text, "tooltip shows expected text");
 
   await synthesizeMouseOut(element);
 }
 
 async function expectNoTooltip() {
-  ok(!gURLBar.hasAttribute("textoverflow"), "Urlbar isn't overflowing");
+  if (gURLBar._overflowing || gURLBar._inOverflow) {
+    info("waiting for underflow event");
+    await BrowserTestUtils.waitForEvent(gURLBar.inputField, "underflow");
+  }
 
   let element = gURLBar.inputField;
   await synthesizeMouseOver(element);
 
   is(element.getAttribute("title"), null, "title attribute shouldn't be set");
 
   await synthesizeMouseOut(element);
 }
 
 add_task(async function() {
+  window.windowUtils.disableNonTestMouseEvents(true);
+  registerCleanupFunction(() => {
+    window.windowUtils.disableNonTestMouseEvents(false);
+  });
+
   // Ensure the URL bar isn't focused.
   gBrowser.selectedBrowser.focus();
 
   gURLBar.value = "short string";
   await expectNoTooltip();
 
   let longURL = "http://longurl.com/" + "foobar/".repeat(30);
-  let overflowPromise = BrowserTestUtils.waitForEvent(gURLBar.inputField, "overflow");
-  await window.promiseDocumentFlushed(() => {});
   gURLBar.value = longURL;
-  await overflowPromise;
   is(gURLBar.inputField.value, longURL.replace(/^http:\/\//, ""), "Urlbar value has http:// stripped");
   await expectTooltip(longURL);
 });