layout/forms/test/test_bug665540.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=665540
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 665540 Select dropdown position in fullscreen window</title>
michael@0 8 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
michael@0 11 </head>
michael@0 12 <body onload="openFullscreenWindow()">
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=665540">Mozilla Bug 665540</a>
michael@0 14 <p id="display"></p>
michael@0 15 <div id="content" style="display: none">
michael@0 16
michael@0 17 </div>
michael@0 18 <pre id="test">
michael@0 19 <script type="application/javascript">
michael@0 20
michael@0 21 /** Test for Bug 665540 **/
michael@0 22
michael@0 23 SimpleTest.waitForExplicitFinish();
michael@0 24
michael@0 25 var win;
michael@0 26 var select;
michael@0 27 var optiona;
michael@0 28 var eventType = "mouseover";
michael@0 29 var timeoutID;
michael@0 30 var eventOffsetX = 2;
michael@0 31 var eventOffsetY = 2;
michael@0 32
michael@0 33 function openFullscreenWindow() {
michael@0 34 win = open("bug665540_window.xul", "_blank", "resizable=yes,chrome");
michael@0 35 // Close our window if the test times out so that it doesn't interfere
michael@0 36 // with later tests.
michael@0 37 timeoutID = setTimeout(function () {
michael@0 38 ok(false, "Test timed out.");
michael@0 39 // Provide some time for a screenshot
michael@0 40 setTimeout(finish, 1000);
michael@0 41 }, 20000);
michael@0 42 }
michael@0 43
michael@0 44 function childFocused() {
michael@0 45 ok(win.fullScreen, "window should be fullscreen");
michael@0 46 is(win.windowState, win.STATE_FULLSCREEN,
michael@0 47 "window state should be fullscreen");
michael@0 48
michael@0 49 // The select doesn't open if the mouse click is fired too soon
michael@0 50 // (on X11 at least).
michael@0 51 setTimeout(openSelect, 1000);
michael@0 52 }
michael@0 53
michael@0 54 function openSelect() {
michael@0 55 select = win.document.getElementById("select");
michael@0 56 synthesizeMouseAtCenter(select, {}, win);
michael@0 57 // A yield was required on X11 tinderbox machines.
michael@0 58 // (Wasn't required on other platforms nor on an X11 system with kwin.)
michael@0 59 setTimeout(checkPosition, 1000);
michael@0 60 }
michael@0 61
michael@0 62 function checkPosition() {
michael@0 63 optiona = win.document.getElementById("optiona");
michael@0 64 optiona.addEventListener(eventType, eventReceived, false);
michael@0 65
michael@0 66 // If the select dropdown is opened in the position where
michael@0 67 // getBoundingClientRect() predicts, then optiona will receive the event.
michael@0 68 // The event is received asynchronously (I don't know why), so the handler
michael@0 69 // is removed later.
michael@0 70 synthesizeMouse(optiona, eventOffsetX, eventOffsetY,
michael@0 71 { type: eventType }, win);
michael@0 72 }
michael@0 73
michael@0 74 function eventReceived(event) {
michael@0 75 clearTimeout(timeoutID);
michael@0 76 optiona.removeEventListener(eventType, eventReceived, false);
michael@0 77
michael@0 78 var rect = optiona.getBoundingClientRect();
michael@0 79
michael@0 80 // Note that fullscreen only fully covers one monitor, so win.screenX can
michael@0 81 // be non-zero.
michael@0 82 is(event.screenX, win.screenX + rect.left + eventOffsetX,
michael@0 83 "event.screenX should match sent event");
michael@0 84 is(event.screenY, win.screenY + rect.top + eventOffsetY,
michael@0 85 "event.screenY should match sent event");
michael@0 86
michael@0 87 finish();
michael@0 88 }
michael@0 89
michael@0 90 function finish() {
michael@0 91 if (select && navigator.platform.indexOf("Win") >= 0) {
michael@0 92 todo(false,
michael@0 93 "Should not have to close select before closing its window");
michael@0 94 // This avoids mochitest "Unable to restore focus" errors (bug 670053).
michael@0 95 synthesizeMouseAtCenter(select, {}, win);
michael@0 96 }
michael@0 97
michael@0 98 is(win.windowState, win.STATE_FULLSCREEN,
michael@0 99 "window state should still be fullscreen");
michael@0 100
michael@0 101 win.close();
michael@0 102 SimpleTest.finish();
michael@0 103 }
michael@0 104 </script>
michael@0 105 </pre>
michael@0 106 </body>
michael@0 107 </html>

mercurial