|
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"> |
|
16 |
|
17 </div> |
|
18 <pre id="test"> |
|
19 <script type="application/javascript"> |
|
20 |
|
21 /** Test for Bug 665540 **/ |
|
22 |
|
23 SimpleTest.waitForExplicitFinish(); |
|
24 |
|
25 var win; |
|
26 var select; |
|
27 var optiona; |
|
28 var eventType = "mouseover"; |
|
29 var timeoutID; |
|
30 var eventOffsetX = 2; |
|
31 var eventOffsetY = 2; |
|
32 |
|
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 } |
|
43 |
|
44 function childFocused() { |
|
45 ok(win.fullScreen, "window should be fullscreen"); |
|
46 is(win.windowState, win.STATE_FULLSCREEN, |
|
47 "window state should be fullscreen"); |
|
48 |
|
49 // The select doesn't open if the mouse click is fired too soon |
|
50 // (on X11 at least). |
|
51 setTimeout(openSelect, 1000); |
|
52 } |
|
53 |
|
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 } |
|
61 |
|
62 function checkPosition() { |
|
63 optiona = win.document.getElementById("optiona"); |
|
64 optiona.addEventListener(eventType, eventReceived, false); |
|
65 |
|
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 } |
|
73 |
|
74 function eventReceived(event) { |
|
75 clearTimeout(timeoutID); |
|
76 optiona.removeEventListener(eventType, eventReceived, false); |
|
77 |
|
78 var rect = optiona.getBoundingClientRect(); |
|
79 |
|
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"); |
|
86 |
|
87 finish(); |
|
88 } |
|
89 |
|
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 } |
|
97 |
|
98 is(win.windowState, win.STATE_FULLSCREEN, |
|
99 "window state should still be fullscreen"); |
|
100 |
|
101 win.close(); |
|
102 SimpleTest.finish(); |
|
103 } |
|
104 </script> |
|
105 </pre> |
|
106 </body> |
|
107 </html> |