sendMouseEvent() doesn't work in mochitests with hovering mouse. (test_selection_move_commands.xul + test_tooltip + test_tooltip_noautohide)

RESOLVED FIXED in mozilla1.9.3a1

Status

()

RESOLVED FIXED
11 years ago
6 years ago

People

(Reporter: cpearce, Assigned: Natch)

Tracking

({intermittent-failure})

Trunk
mozilla1.9.3a1
x86
All
intermittent-failure
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(status1.9.2 beta1-fixed)

Details

(Whiteboard: )

Attachments

(1 attachment, 3 obsolete attachments)

(Reporter)

Description

11 years ago
If you're running a mochitest which uses SimpleTest/EventUtils.js synthesizeMouse(), and you call synthesizeMouse() when the user's mouse is hovering over the window which the mouse event is being set to, the mouse event isn't sent properly, or is otherwise ineffective.

This happens a lot in the "toolkit" mochitests, notably toolkit\content\tests\widgets\test_tooltip_noautohide.xul

STR:
1. Run mochitest on the "toolkit" tests, don't --autorun.
2. Scroll the test list down, and click the mouse on the test_tooltip_noautohide.xul link so that test loads.

Observed result: The test just sits there and does nothing.

Expected result: mouse events should be synthesized by the test so that a tooltip appears, and after 6 seconds the mochitest checks to see if the tooltip is still there, and if so the test passes and finishes.

Note if you start the test by itself directly from the command line and don't touch the mouse, the test will pass. This is because if you don't touch the mouse, it won't appear above the mochitest window, and it won't interfere with the sendMouseEvent() call.

I've observed this on Windows and Linux, I'm not sure if Mac is affected too.
Probably not this bug, but wanted to mention it, just in case.

[
http://tinderbox.mozilla.org/showlog.cgi?log=Firefox/1220736734.1220743799.23127.gz#err20
Linux mozilla-central qm-centos5-moz2-01 dep unit test on 2008/09/06 14:32:14

a bunch of
*** 32289 INFO Error: Unable to restore focus, expect failures and timeouts.
...
*** 32737 INFO Error: Unable to restore focus, expect failures and timeouts.

then
*** 67523 ERROR TEST-UNEXPECTED-FAIL | /tests/toolkit/content/tests/widgets/test_tooltip.xul | Test timed out.
*** 67526 INFO Error: Unable to restore focus, expect failures and timeouts.
*** 67527 ERROR TEST-UNEXPECTED-FAIL | /tests/toolkit/content/tests/widgets/test_tooltip_noautohide.xul | Test timed out.
*** 67530 INFO Error: Unable to restore focus, expect failures and timeouts.
]
Summary: sendMouseEvent() doesn't work in mochitests with hovering mouse → sendMouseEvent() doesn't work in mochitests with hovering mouse. (test_tooltip / test_tooltip_noautohide)
(In reply to comment #1)
> Probably not this bug, but wanted to mention it, just in case.

http://tinderbox.mozilla.org/showlog.cgi?log=SeaMonkey/1220928899.1220933808.23056.gz
Linux comm-central dep unit test on 2008/09/08 19:54:59
New typical log, since quite some time:

http://tinderbox.mozilla.org/showlog.cgi?log=SeaMonkey/1224090412.1224094932.7175.gz
Linux comm-central dep unit test on 2008/10/15 10:06:52
{
a bunch of
*** 36895 INFO Error: Unable to restore focus, expect failures and timeouts.

a bunch of
*** 37347 ERROR TEST-UNEXPECTED-FAIL | /tests/editor/libeditor/base/tests/test_selection_move_commands.xul | [...]

*** 37395 INFO Error: Unable to restore focus, expect failures and timeouts.
*** 71580 ERROR TEST-UNEXPECTED-FAIL | /tests/toolkit/content/tests/widgets/test_tooltip.xul | Test timed out.
*** 71583 INFO Error: Unable to restore focus, expect failures and timeouts.
*** 71584 ERROR TEST-UNEXPECTED-FAIL | /tests/toolkit/content/tests/widgets/test_tooltip_noautohide.xul | Test timed out.
*** 71587 INFO Error: Unable to restore focus, expect failures and timeouts.
}

This happens +/- "regularly" :-(
Flags: wanted1.9.1?
Summary: sendMouseEvent() doesn't work in mochitests with hovering mouse. (test_tooltip / test_tooltip_noautohide) → sendMouseEvent() doesn't work in mochitests with hovering mouse. (test_selection_move_commands.xul + test_tooltip + test_tooltip_noautohide)
Blocks: 438871
Whiteboard: [orange]
(Assignee)

Comment 7

9 years ago
Created attachment 398447 [details] [diff] [review]
patch

This should fix the issues with mouse moving during these tests, uses the new disableNonTestMouseEvent. Also consolidates the test into one window, I had to add some functionality to popup_shared to be able to do that. Also, needs the timeout when run individually.
Assignee: nobody → highmind63
Status: NEW → ASSIGNED
Attachment #398447 - Flags: review?(enndeakin)
(Assignee)

Updated

9 years ago
Flags: wanted1.9.1? → wanted1.9.2?
(Assignee)

Comment 8

9 years ago
Created attachment 398451 [details] [diff] [review]
patch

I'm a little behind the times...
Attachment #398447 - Attachment is obsolete: true
Attachment #398451 - Flags: review?(enndeakin)
Attachment #398447 - Flags: review?(enndeakin)
(Assignee)

Comment 9

9 years ago
Created attachment 398459 [details] [diff] [review]
patch

Instead of the timeout, use the new waitForFocus (didn't realize that's what obsoleted my previous patch). Works great!!
Attachment #398451 - Attachment is obsolete: true
Attachment #398459 - Flags: review?(enndeakin)
Attachment #398451 - Flags: review?(enndeakin)

Comment 10

9 years ago
Comment on attachment 398459 [details] [diff] [review]
patch

>+  gIsSameWindow = !!isSameWindow;

Why negate twice here?

> function ok(condition, message) {
>-  window.opener.SimpleTest.ok(condition, message);
>+  if (gIsSameWindow)
>+    SimpleTest.ok(condition, message);
>+  else
>+    window.opener.SimpleTest.ok(condition, message);

The current waitForFocus outputs debugging info, when gIsSameWindow isn't yet set and fails because of this. It would be better to just check if there's a window.opener instead.
(Assignee)

Comment 11

9 years ago
Created attachment 399244 [details] [diff] [review]
patch ver. 2
Attachment #398459 - Attachment is obsolete: true
Attachment #399244 - Flags: review?(enndeakin)
Attachment #398459 - Flags: review?(enndeakin)

Comment 12

9 years ago
Comment on attachment 399244 [details] [diff] [review]
patch ver. 2

>diff --git a/toolkit/content/tests/widgets/Makefile.in b/toolkit/content/tests/widgets/Makefile.in
>--- a/toolkit/content/tests/widgets/Makefile.in
>+++ b/toolkit/content/tests/widgets/Makefile.in
>@@ -39,19 +39,16 @@ DEPTH		= ../../../..
> topsrcdir	= @top_srcdir@
> srcdir		= @srcdir@
> VPATH		= @srcdir@
> relativesrcdir  = toolkit/content/tests/widgets
> 
> include $(DEPTH)/config/autoconf.mk
> include $(topsrcdir)/config/rules.mk
> 
>-# disabled, see bug 506038
>-#		test_tooltip.xul \
>-
> _TEST_FILES = 	test_bug360220.xul \
> 		test_bug359754.xul \
> 		test_bug365773.xul \
> 		test_bug382990.xul \
> 		test_bug457632.xul \
> 		test_button.xul \
> 		test_closemenu_attribute.xul \
> 		test_colorpicker_popup.xul \
>@@ -68,17 +65,17 @@ _TEST_FILES = 	test_bug360220.xul \
> 		test_scale.xul \
> 		test_radio.xul \
> 		test_tabbox.xul \
> 		test_tooltip_noautohide.xul \
> 		popup_shared.js \
> 		popup_trigger.js \
> 		window_popup_button.xul \
> 		window_popup_attribute.xul \
>-		window_tooltip.xul \
>+		test_tooltip.xul \
> 		test_progressmeter.xul \
> 		test_props.xul \
> 		test_statusbar.xul \
> 		test_datepicker.xul \
> 		test_timepicker.xul \
> 		test_tree.xul \
> 		test_tree_single.xul \
> 		test_tree_hier.xul \
>diff --git a/toolkit/content/tests/widgets/popup_shared.js b/toolkit/content/tests/widgets/popup_shared.js
>--- a/toolkit/content/tests/widgets/popup_shared.js
>+++ b/toolkit/content/tests/widgets/popup_shared.js
>@@ -29,47 +29,67 @@
> const menuactiveAttribute = "_moz-menuactive";
> 
> var gPopupTests = null;
> var gTestIndex = -1;
> var gTestStepIndex = 0;
> var gTestEventIndex = 0;
> var gAutoHide = false;
> var gExpectedEventDetails = null;
>+var gWindowUtils;
> 
> function startPopupTests(tests)
> {
>   document.addEventListener("popupshowing", eventOccured, false);
>   document.addEventListener("popupshown", eventOccured, false);
>   document.addEventListener("popuphiding", eventOccured, false);
>   document.addEventListener("popuphidden", eventOccured, false);
>   document.addEventListener("command", eventOccured, false);
>   document.addEventListener("DOMMenuItemActive", eventOccured, false);
>   document.addEventListener("DOMMenuItemInactive", eventOccured, false);
>   document.addEventListener("DOMMenuInactive", eventOccured, false);
>   document.addEventListener("DOMMenuBarActive", eventOccured, false);
>   document.addEventListener("DOMMenuBarInactive", eventOccured, false);
> 
>   gPopupTests = tests;
>+  gWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
>+                       .getInterface(Components.interfaces.nsIDOMWindowUtils);
> 
>   goNext();
> }
> 
> function finish()
> {
>-  window.close();
>-  window.opener.SimpleTest.finish();
>+  if (window.opener) {
>+    window.close();
>+    window.opener.SimpleTest.finish();
>+    return;
>+  }
>+  SimpleTest.finish();
>+  return;
> }
> 
> function ok(condition, message) {
>-  window.opener.SimpleTest.ok(condition, message);
>+  if (window.opener)
>+    window.opener.SimpleTest.ok(condition, message);
>+  else
>+    SimpleTest.ok(condition, message);
> }
> 
> function is(left, right, message) {
>-  window.opener.SimpleTest.is(left, right, message);
>+  if (window.opener)
>+    window.opener.SimpleTest.is(left, right, message);
>+  else
>+    SimpleTest.is(left, right, message);
>+}
>+
>+function disableNonTestMouse(aDisable) {
>+  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
>+
>+  gWindowUtils.disableNonTestMouseEvents(aDisable);
> }
> 
> function eventOccured(event)
> {
>    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
> 
>   if (gPopupTests.length <= gTestIndex) {
>     ok(false, "Extra " + event.type + " event fired");
>diff --git a/toolkit/content/tests/widgets/test_tooltip.xul b/toolkit/content/tests/widgets/test_tooltip.xul
>--- a/toolkit/content/tests/widgets/test_tooltip.xul
>+++ b/toolkit/content/tests/widgets/test_tooltip.xul
>@@ -1,28 +1,227 @@
> <?xml version="1.0"?>
> <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
> <?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
> 
> <window title="Tooltip Tests"
>-  onload="setTimeout(runTest, 0);"
>   xmlns:html="http://www.w3.org/1999/xhtml"
>   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
> 
>   <title>Tooltip Tests</title>
>   <script type="application/javascript" src="/MochiKit/packed.js"></script>
>-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>      
>-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>      
>+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
>+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
>+  <script type="application/javascript" src="popup_shared.js"></script>
> 
>-<script>
>+<tooltip id="thetooltip">
>+  <label id="label" value="This is a tooltip"/>
>+</tooltip>
>+
>+<box tooltiptext="Box Tooltip">
>+  <button id="withtext" label="Tooltip Text" tooltiptext="Button Tooltip"
>+          style="-moz-appearance: none; padding: 0;"/>
>+  <button id="without" label="No Tooltip" style="-moz-appearance: none; padding: 0;"/>
>+  <!-- remove the native theme and borders to avoid some platform
>+       specific sizing differences -->
>+  <button id="withtooltip" label="Tooltip Element" tooltip="thetooltip"
>+          class="plain" style="-moz-appearance: none; padding: 0;"/>
>+</box>
>+
>+<script class="testbody" type="application/javascript">
>+<![CDATA[
>+
> SimpleTest.waitForExplicitFinish();
>+var gOriginalWidth = -1;
>+var gOriginalHeight = -1;
>+var gButton = null;
>+
> function runTest()
> {
>-  window.open("window_tooltip.xul", "_blank", "width=600,height=600");
>+  startPopupTests(popupTests);
> }
>+
>+function checkCoords(event)
>+{
>+  // all but one test open the tooltip at the button location offset by 6
>+  // in each direction. Test 5 opens it at 4 in each direction.
>+  var mod = (gTestIndex == 5) ? 4 : 6;
>+
>+  var rect = gButton.getBoundingClientRect();
>+  var popupstyle = window.getComputedStyle(gButton, "");
>+  is(event.clientX, Math.round(rect.left + mod),
>+     "step " + (gTestIndex + 1) + " clientX");
>+  is(event.clientY, Math.round(rect.top + mod),
>+     "step " + (gTestIndex + 1) + " clientY");
>+  ok(event.screenX > 0, "step " + (gTestIndex + 1) + " screenX");
>+  ok(event.screenY > 0, "step " + (gTestIndex + 1) + " screenY");
>+}
>+
>+var popupTests = [
>+{
>+  testname: "hover tooltiptext attribute",
>+  events: [ "popupshowing #tooltip", "popupshown #tooltip" ],
>+  test: function() {
>+    gButton = document.getElementById("withtext");
>+    disableNonTestMouse(true);
>+    synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
>+    synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
>+    synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
>+    disableNonTestMouse(false);
>+  }
>+},
>+{
>+  testname: "close tooltip",
>+  events: [ "popuphiding #tooltip", "popuphidden #tooltip",
>+            "DOMMenuInactive #tooltip" ],
>+  test: function() {
>+    disableNonTestMouse(true);
>+    synthesizeMouse(document.documentElement, 2, 2, { type: "mousemove" });
>+    disableNonTestMouse(false);
>+  },
>+},
>+{
>+  testname: "hover inherited tooltip",
>+  events: [ "popupshowing #tooltip", "popupshown #tooltip" ],
>+  test: function() {
>+    gButton = document.getElementById("without");
>+    disableNonTestMouse(true);
>+    synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
>+    synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
>+    synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
>+    disableNonTestMouse(false);
>+  }
>+},
>+{
>+  testname: "hover tooltip attribute",
>+  events: [ "popuphiding #tooltip", "popuphidden #tooltip",
>+            "DOMMenuInactive #tooltip",
>+            "popupshowing thetooltip", "popupshown thetooltip" ],
>+  test: function() {
>+    gButton = document.getElementById("withtooltip");
>+    disableNonTestMouse(true);
>+    synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
>+    synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
>+    synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
>+    disableNonTestMouse(false);
>+  },
>+  result: function(testname) {
>+    var buttonrect = document.getElementById("withtooltip").getBoundingClientRect();
>+    var rect = document.getElementById("thetooltip").getBoundingClientRect();
>+    var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"), "");
>+
>+    is(Math.round(rect.left),
>+       Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6),
>+       testname + " top position of tooltip");
>+    is(Math.round(rect.top),
>+       Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6),
>+       testname + " top position of tooltip");
>+
>+    var labelrect = document.getElementById("label").getBoundingClientRect();
>+    ok(labelrect.right < rect.right, testname + " tooltip width");
>+    ok(labelrect.bottom < rect.bottom, testname + " tooltip height");
>+
>+    gOriginalWidth = rect.right - rect.left;
>+    gOriginalHeight = rect.bottom - rect.top;
>+  }
>+},
>+{
>+  testname: "click to close tooltip",
>+  events: [ "popuphiding thetooltip", "popuphidden thetooltip",
>+            "command withtooltip", "DOMMenuInactive thetooltip" ],
>+  test: function() {
>+    gButton = document.getElementById("withtooltip");
>+    synthesizeMouse(gButton, 2, 2, { });
>+  },
>+},
>+{
>+  testname: "hover tooltip after size increased",
>+  events: [ "popupshowing thetooltip", "popupshown thetooltip" ],
>+  test: function() {
>+    var label = document.getElementById("label");
>+    label.removeAttribute("value");
>+    label.textContent = "This is a longer tooltip than before\nIt has multiple lines\nIt is testing tooltip sizing\n";
>+    gButton = document.getElementById("withtooltip");
>+    disableNonTestMouse(true);
>+    synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
>+    synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
>+    synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
>+    disableNonTestMouse(false);
>+  },
>+  result: function(testname) {
>+    var buttonrect = document.getElementById("withtooltip").getBoundingClientRect();
>+    var rect = document.getElementById("thetooltip").getBoundingClientRect();
>+    var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"), "");
>+    var buttonstyle = window.getComputedStyle(document.getElementById("withtooltip"), "");
>+
>+    is(Math.round(rect.left),
>+       Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 4),
>+       testname + " top position of tooltip");
>+    is(Math.round(rect.top),
>+       Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 4),
>+       testname + " top position of tooltip");
>+
>+    var labelrect = document.getElementById("label").getBoundingClientRect();
>+    ok(labelrect.right < rect.right, testname + " tooltip width");
>+    ok(labelrect.bottom < rect.bottom, testname + " tooltip height");
>+
>+    // make sure that the tooltip is larger than it was before by just
>+    // checking against the original height plus an arbitrary 15 pixels
>+    ok(gOriginalWidth + 15 < rect.right - rect.left, testname + " tooltip is wider");
>+    ok(gOriginalHeight + 15 < rect.bottom - rect.top, testname + " tooltip is taller");
>+  }
>+},
>+{
>+  testname: "close tooltip with hidePopup",
>+  events: [ "popuphiding thetooltip", "popuphidden thetooltip",
>+            "DOMMenuInactive thetooltip" ],
>+  test: function() {
>+    document.getElementById("thetooltip").hidePopup();
>+  },
>+},
>+{
>+  testname: "hover tooltip after size decreased",
>+  events: [ "popupshowing thetooltip", "popupshown thetooltip" ],
>+  autohide: "thetooltip",
>+  test: function() {
>+    var label = document.getElementById("label");
>+    label.value = "This is a tooltip";
>+    gButton = document.getElementById("withtooltip");
>+    disableNonTestMouse(true);
>+    synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
>+    synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
>+    synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
>+    disableNonTestMouse(false);
>+  },
>+  result: function(testname) {
>+    var buttonrect = document.getElementById("withtooltip").getBoundingClientRect();
>+    var rect = document.getElementById("thetooltip").getBoundingClientRect();
>+    var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"), "");
>+    var buttonstyle = window.getComputedStyle(document.getElementById("withtooltip"), "");
>+
>+    is(Math.round(rect.left),
>+       Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6),
>+       testname + " top position of tooltip");
>+    is(Math.round(rect.top),
>+       Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6),
>+       testname + " top position of tooltip");
>+
>+    var labelrect = document.getElementById("label").getBoundingClientRect();
>+    ok(labelrect.right < rect.right, testname + " tooltip width");
>+    ok(labelrect.bottom < rect.bottom, testname + " tooltip height");
>+
>+    is(gOriginalWidth, rect.right - rect.left, testname + " tooltip is original width");
>+    is(gOriginalHeight, rect.bottom - rect.top, testname + " tooltip is original height");
>+  }
>+},
>+
>+];
>+
>+SimpleTest.waitForFocus(runTest);
>+]]>
> </script>
> 
> <body xmlns="http://www.w3.org/1999/xhtml">
> <p id="display">
> </p>
> <div id="content" style="display: none">
> </div>
> <pre id="test">
>diff --git a/toolkit/content/tests/widgets/test_tooltip_noautohide.xul b/toolkit/content/tests/widgets/test_tooltip_noautohide.xul
>--- a/toolkit/content/tests/widgets/test_tooltip_noautohide.xul
>+++ b/toolkit/content/tests/widgets/test_tooltip_noautohide.xul
>@@ -19,20 +19,25 @@
> 
> <script class="testbody" type="application/javascript">
> <![CDATA[
> 
> var gChecked = false;
> 
> function runTests()
> {
>+  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
>   var button = document.getElementById("button");
>+  var windowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
>+                          .getInterface(Components.interfaces.nsIDOMWindowUtils);
>+  windowUtils.disableNonTestMouseEvents(true);
>   synthesizeMouse(button, 2, 2, { type: "mouseover" });
>   synthesizeMouse(button, 4, 4, { type: "mousemove" });
>   synthesizeMouse(button, 6, 6, { type: "mousemove" });
>+  windowUtils.disableNonTestMouseEvents(false);
> }
> 
> function tooltipStillShown()
> {
>   gChecked = true;
>   document.getElementById("thetooltip").hidePopup();
> }
> 
>diff --git a/toolkit/content/tests/widgets/window_tooltip.xul b/toolkit/content/tests/widgets/window_tooltip.xul
>deleted file mode 100644
>--- a/toolkit/content/tests/widgets/window_tooltip.xul
>+++ /dev/null
>@@ -1,207 +0,0 @@
>-<?xml version="1.0"?>
>-<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
>-
>-<window title="Tooltip Tests"
>-        onpopupshowing="checkCoords(event)"
>-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
>-
>-  <title>Tooltip Tests</title>
>-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>      
>-  <script type="application/javascript" src="popup_shared.js"></script>      
>-
>-<tooltip id="thetooltip">
>-  <label id="label" value="This is a tooltip"/>
>-</tooltip>
>-
>-<box tooltiptext="Box Tooltip">
>-  <button id="withtext" label="Tooltip Text" tooltiptext="Button Tooltip"
>-          style="-moz-appearance: none; padding: 0;"/>
>-  <button id="without" label="No Tooltip" style="-moz-appearance: none; padding: 0;"/>
>-  <!-- remove the native theme and borders to avoid some platform
>-       specific sizing differences -->
>-  <button id="withtooltip" label="Tooltip Element" tooltip="thetooltip"
>-          class="plain" style="-moz-appearance: none; padding: 0;"/>
>-</box>
>-
>-<script class="testbody" type="application/javascript">
>-<![CDATA[
>-
>-var gOriginalWidth = -1;
>-var gOriginalHeight = -1;
>-var gButton = null;
>-
>-function runTests()
>-{
>-  startPopupTests(popupTests);
>-}
>-
>-function checkCoords(event)
>-{
>-  // all but one test open the tooltip at the button location offset by 6
>-  // in each direction. Test 5 opens it at 4 in each direction.
>-  var mod = (gTestIndex == 5) ? 4 : 6;
>-
>-  var rect = gButton.getBoundingClientRect();
>-  var popupstyle = window.getComputedStyle(gButton, "");
>-  is(event.clientX, Math.round(rect.left + mod),
>-     "step " + (gTestIndex + 1) + " clientX");
>-  is(event.clientY, Math.round(rect.top + mod),
>-     "step " + (gTestIndex + 1) + " clientY");
>-  ok(event.screenX > 0, "step " + (gTestIndex + 1) + " screenX");
>-  ok(event.screenY > 0, "step " + (gTestIndex + 1) + " screenY");
>-}
>-
>-var popupTests = [
>-{
>-  testname: "hover tooltiptext attribute",
>-  events: [ "popupshowing #tooltip", "popupshown #tooltip" ],
>-  test: function() {
>-    gButton = document.getElementById("withtext");
>-    synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
>-    synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
>-    synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
>-  }
>-},
>-{
>-  testname: "close tooltip",
>-  events: [ "popuphiding #tooltip", "popuphidden #tooltip",
>-            "DOMMenuInactive #tooltip" ],
>-  test: function() {
>-    synthesizeMouse(document.documentElement, 2, 2, { type: "mousemove" });
>-  },
>-},
>-{
>-  testname: "hover inherited tooltip",
>-  events: [ "popupshowing #tooltip", "popupshown #tooltip" ],
>-  test: function() {
>-    gButton = document.getElementById("without");
>-    synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
>-    synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
>-    synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
>-  }
>-},
>-{
>-  testname: "hover tooltip attribute",
>-  events: [ "popuphiding #tooltip", "popuphidden #tooltip",
>-            "DOMMenuInactive #tooltip",
>-            "popupshowing thetooltip", "popupshown thetooltip" ],
>-  test: function() {
>-    gButton = document.getElementById("withtooltip");
>-    synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
>-    synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
>-    synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
>-  },
>-  result: function(testname) {
>-    var buttonrect = document.getElementById("withtooltip").getBoundingClientRect();
>-    var rect = document.getElementById("thetooltip").getBoundingClientRect();
>-    var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"), "");
>-
>-    is(Math.round(rect.left),
>-       Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6),
>-       testname + " top position of tooltip");
>-    is(Math.round(rect.top),
>-       Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6),
>-       testname + " top position of tooltip");
>-
>-    var labelrect = document.getElementById("label").getBoundingClientRect();
>-    ok(labelrect.right < rect.right, testname + " tooltip width");
>-    ok(labelrect.bottom < rect.bottom, testname + " tooltip height");
>-
>-    gOriginalWidth = rect.right - rect.left;
>-    gOriginalHeight = rect.bottom - rect.top;
>-  }
>-},
>-{
>-  testname: "click to close tooltip",
>-  events: [ "popuphiding thetooltip", "popuphidden thetooltip",
>-            "command withtooltip", "DOMMenuInactive thetooltip" ],
>-  test: function() {
>-    gButton = document.getElementById("withtooltip");
>-    synthesizeMouse(gButton, 2, 2, { });
>-  },
>-},
>-{
>-  testname: "hover tooltip after size increased",
>-  events: [ "popupshowing thetooltip", "popupshown thetooltip" ],
>-  test: function() {
>-    var label = document.getElementById("label");
>-    label.removeAttribute("value");
>-    label.textContent = "This is a longer tooltip than before\nIt has multiple lines\nIt is testing tooltip sizing\n";
>-    gButton = document.getElementById("withtooltip");
>-    synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
>-    synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
>-    synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
>-  },
>-  result: function(testname) {
>-    var buttonrect = document.getElementById("withtooltip").getBoundingClientRect();
>-    var rect = document.getElementById("thetooltip").getBoundingClientRect();
>-    var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"), "");
>-    var buttonstyle = window.getComputedStyle(document.getElementById("withtooltip"), "");
>-
>-    is(Math.round(rect.left),
>-       Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 4),
>-       testname + " top position of tooltip");
>-    is(Math.round(rect.top),
>-       Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 4),
>-       testname + " top position of tooltip");
>-
>-    var labelrect = document.getElementById("label").getBoundingClientRect();
>-    ok(labelrect.right < rect.right, testname + " tooltip width");
>-    ok(labelrect.bottom < rect.bottom, testname + " tooltip height");
>-
>-    // make sure that the tooltip is larger than it was before by just
>-    // checking against the original height plus an arbitrary 15 pixels
>-    ok(gOriginalWidth + 15 < rect.right - rect.left, testname + " tooltip is wider");
>-    ok(gOriginalHeight + 15 < rect.bottom - rect.top, testname + " tooltip is taller");
>-  }
>-},
>-{
>-  testname: "close tooltip with hidePopup",
>-  events: [ "popuphiding thetooltip", "popuphidden thetooltip",
>-            "DOMMenuInactive thetooltip" ],
>-  test: function() {
>-    document.getElementById("thetooltip").hidePopup();
>-  },
>-},
>-{
>-  testname: "hover tooltip after size decreased",
>-  events: [ "popupshowing thetooltip", "popupshown thetooltip" ],
>-  autohide: "thetooltip",
>-  test: function() {
>-    var label = document.getElementById("label");
>-    label.value = "This is a tooltip";
>-    gButton = document.getElementById("withtooltip");
>-    synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
>-    synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
>-    synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
>-  },
>-  result: function(testname) {
>-    var buttonrect = document.getElementById("withtooltip").getBoundingClientRect();
>-    var rect = document.getElementById("thetooltip").getBoundingClientRect();
>-    var popupstyle = window.getComputedStyle(document.getElementById("thetooltip"), "");
>-    var buttonstyle = window.getComputedStyle(document.getElementById("withtooltip"), "");
>-
>-    is(Math.round(rect.left),
>-       Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6),
>-       testname + " top position of tooltip");
>-    is(Math.round(rect.top),
>-       Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6),
>-       testname + " top position of tooltip");
>-
>-    var labelrect = document.getElementById("label").getBoundingClientRect();
>-    ok(labelrect.right < rect.right, testname + " tooltip width");
>-    ok(labelrect.bottom < rect.bottom, testname + " tooltip height");
>-
>-    is(gOriginalWidth, rect.right - rect.left, testname + " tooltip is original width");
>-    is(gOriginalHeight, rect.bottom - rect.top, testname + " tooltip is original height");
>-  }
>-},
>-
>-];
>-
>-window.opener.SimpleTest.waitForFocus(runTests, window);
>-
>-]]>
>-</script>
>-
>-</window>
Attachment #399244 - Flags: review?(enndeakin) → review+
(Assignee)

Comment 13

9 years ago
Thanks Enn.
Keywords: checkin-needed

Comment 14

9 years ago
http://hg.mozilla.org/mozilla-central/rev/6145f214008b
Status: ASSIGNED → RESOLVED
Last Resolved: 9 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
(Assignee)

Comment 16

9 years ago
Comment on attachment 399244 [details] [diff] [review]
patch ver. 2

This should fix bug 506038 which was showing up on 1.9.2 quite a bit.
Attachment #399244 - Flags: approval1.9.2?
Target Milestone: --- → mozilla1.9.3a1

Updated

9 years ago
Attachment #399244 - Flags: approval1.9.2? → approval1.9.2+
(Assignee)

Updated

9 years ago
Flags: wanted1.9.2? → in-testsuite+
Keywords: checkin-needed
Whiteboard: [orange] → [orange] [needs 192 landing]
(Reporter)

Comment 17

9 years ago
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/7dc101470e8b
status1.9.2: --- → beta1-fixed
Whiteboard: [orange] [needs 192 landing] → [orange]
(Reporter)

Updated

9 years ago
Keywords: checkin-needed
Comment hidden (Treeherder Robot)
Keywords: intermittent-failure
Whiteboard: [orange] →
You need to log in before you can comment on or make changes to this bug.