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.

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

mercurial