test for bug 665540
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 08 Jul 2011 11:06:54 +1200
changeset 72596 e3e1c16c1af4bcd369ab13b59ea092cdc94912bc
parent 72595 5618a1b01989cd30a6464e4e8c6b0dee65bae27c
child 72597 7082861aa0c73bc449bb46207e20a4980815ddd7
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs665540
milestone8.0a1
test for bug 665540
layout/forms/test/Makefile.in
layout/forms/test/bug665540_window.xul
layout/forms/test/test_bug665540.html
--- a/layout/forms/test/Makefile.in
+++ b/layout/forms/test/Makefile.in
@@ -76,15 +76,17 @@ include $(topsrcdir)/config/rules.mk
 		test_bug36619.html \
 		test_bug620936.html \
 		test_bug595310.html \
 		test_bug644542.html \
 		$(NULL)
 
 _CHROME_FILES = \
 		test_bug536567.html \
+		test_bug665540.html \
+		     bug665540_window.xul \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
 libs:: $(_CHROME_FILES)
 	$(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/layout/forms/test/bug665540_window.xul
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+
+<window title="Test Select Dropdown Positioning in Fullscreen Window"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        sizemode="fullscreen">
+
+  <title><label>Test Select Dropdown Positioning in Fullscreen Window</label></title>
+
+  <script>
+    opener.SimpleTest.waitForFocus(opener.childFocused, window);
+  </script>
+
+  <body xmlns="http://www.w3.org/1999/xhtml">
+    <select id="select" style="-moz-appearance:none">
+      <option id="optiona">a</option>
+      <option>b</option>
+    </select>
+  </body>
+</window>
new file mode 100644
--- /dev/null
+++ b/layout/forms/test/test_bug665540.html
@@ -0,0 +1,104 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=665540
+-->
+<head>
+  <title>Test for Bug 665540 Select dropdown position in fullscreen window</title>
+  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+</head>
+<body onload="openFullscreenWindow()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=665540">Mozilla Bug 665540</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 665540 **/
+
+SimpleTest.waitForExplicitFinish();
+
+var win;
+var optiona;
+var eventType = "mouseover";
+var timeoutID;
+var eventOffsetX = 2;
+var eventOffsetY = 2;
+
+function openFullscreenWindow() {
+    win = open("bug665540_window.xul", "_blank", "resizable=yes,chrome");
+    // Close our window if the test times out so that it doesn't interfere
+    // with later tests.
+    timeoutID = setTimeout(function () {
+        ok(false, "Test timed out.");
+        // Provide some time for a screenshot
+        setTimeout(finish, 1000);
+    }, 20000);
+}
+
+function childFocused() {
+    ok(win.fullScreen, "window should be fullscreen");
+    // bug 670026
+    ((navigator.platform.indexOf("Mac") < 0) ? is : todo_is)
+        (win.windowState, win.STATE_FULLSCREEN,
+         "window state should be fullscreen");
+
+    // The select doesn't open if the mouse click is fired too soon
+    // (on X11 at least).
+    setTimeout(openSelect, 1000);
+}
+
+function openSelect() {
+    var select = win.document.getElementById("select");
+    synthesizeMouseAtCenter(select, {}, win);
+    // A yield was required on X11 tinderbox machines.
+    // (Wasn't required on other platforms nor on an X11 system with kwin.)
+    setTimeout(checkPosition, 1000);
+}
+
+function checkPosition() {
+    optiona = win.document.getElementById("optiona");
+    optiona.addEventListener(eventType, eventReceived, false);
+
+    // If the select dropdown is opened in the position where
+    // getBoundingClientRect() predicts, then optiona will receive the event.
+    // The event is received asynchronously (I don't know why), so the handler
+    // is removed later.
+    synthesizeMouse(optiona, eventOffsetX, eventOffsetY,
+                    { type: eventType }, win);
+}
+
+function eventReceived(event) {
+    clearTimeout(timeoutID);
+    optiona.removeEventListener(eventType, eventReceived, false);
+
+    var rect = optiona.getBoundingClientRect();
+
+    // Note that fullscreen only fully covers one monitor, so win.screenX can
+    // be non-zero.
+    is(event.screenX, win.screenX + rect.left + eventOffsetX,
+       "event.screenX should match sent event");
+    is(event.screenY, win.screenY + rect.top + eventOffsetY,
+       "event.screenY should match sent event");
+
+    finish();
+}
+
+function finish() {
+    // bug 670026
+    ((navigator.platform.indexOf("Mac") < 0) ? is : todo_is)
+        (win.windowState, win.STATE_FULLSCREEN,
+         "window state should still be fullscreen");
+
+    win.close();
+    SimpleTest.finish();
+}
+</script>
+</pre>
+</body>
+</html>