1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/forms/test/test_bug665540.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,107 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=665540 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 665540 Select dropdown position in fullscreen window</title> 1.11 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 1.13 + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> 1.14 +</head> 1.15 +<body onload="openFullscreenWindow()"> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=665540">Mozilla Bug 665540</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 + 1.20 +</div> 1.21 +<pre id="test"> 1.22 +<script type="application/javascript"> 1.23 + 1.24 +/** Test for Bug 665540 **/ 1.25 + 1.26 +SimpleTest.waitForExplicitFinish(); 1.27 + 1.28 +var win; 1.29 +var select; 1.30 +var optiona; 1.31 +var eventType = "mouseover"; 1.32 +var timeoutID; 1.33 +var eventOffsetX = 2; 1.34 +var eventOffsetY = 2; 1.35 + 1.36 +function openFullscreenWindow() { 1.37 + win = open("bug665540_window.xul", "_blank", "resizable=yes,chrome"); 1.38 + // Close our window if the test times out so that it doesn't interfere 1.39 + // with later tests. 1.40 + timeoutID = setTimeout(function () { 1.41 + ok(false, "Test timed out."); 1.42 + // Provide some time for a screenshot 1.43 + setTimeout(finish, 1000); 1.44 + }, 20000); 1.45 +} 1.46 + 1.47 +function childFocused() { 1.48 + ok(win.fullScreen, "window should be fullscreen"); 1.49 + is(win.windowState, win.STATE_FULLSCREEN, 1.50 + "window state should be fullscreen"); 1.51 + 1.52 + // The select doesn't open if the mouse click is fired too soon 1.53 + // (on X11 at least). 1.54 + setTimeout(openSelect, 1000); 1.55 +} 1.56 + 1.57 +function openSelect() { 1.58 + select = win.document.getElementById("select"); 1.59 + synthesizeMouseAtCenter(select, {}, win); 1.60 + // A yield was required on X11 tinderbox machines. 1.61 + // (Wasn't required on other platforms nor on an X11 system with kwin.) 1.62 + setTimeout(checkPosition, 1000); 1.63 +} 1.64 + 1.65 +function checkPosition() { 1.66 + optiona = win.document.getElementById("optiona"); 1.67 + optiona.addEventListener(eventType, eventReceived, false); 1.68 + 1.69 + // If the select dropdown is opened in the position where 1.70 + // getBoundingClientRect() predicts, then optiona will receive the event. 1.71 + // The event is received asynchronously (I don't know why), so the handler 1.72 + // is removed later. 1.73 + synthesizeMouse(optiona, eventOffsetX, eventOffsetY, 1.74 + { type: eventType }, win); 1.75 +} 1.76 + 1.77 +function eventReceived(event) { 1.78 + clearTimeout(timeoutID); 1.79 + optiona.removeEventListener(eventType, eventReceived, false); 1.80 + 1.81 + var rect = optiona.getBoundingClientRect(); 1.82 + 1.83 + // Note that fullscreen only fully covers one monitor, so win.screenX can 1.84 + // be non-zero. 1.85 + is(event.screenX, win.screenX + rect.left + eventOffsetX, 1.86 + "event.screenX should match sent event"); 1.87 + is(event.screenY, win.screenY + rect.top + eventOffsetY, 1.88 + "event.screenY should match sent event"); 1.89 + 1.90 + finish(); 1.91 +} 1.92 + 1.93 +function finish() { 1.94 + if (select && navigator.platform.indexOf("Win") >= 0) { 1.95 + todo(false, 1.96 + "Should not have to close select before closing its window"); 1.97 + // This avoids mochitest "Unable to restore focus" errors (bug 670053). 1.98 + synthesizeMouseAtCenter(select, {}, win); 1.99 + } 1.100 + 1.101 + is(win.windowState, win.STATE_FULLSCREEN, 1.102 + "window state should still be fullscreen"); 1.103 + 1.104 + win.close(); 1.105 + SimpleTest.finish(); 1.106 +} 1.107 +</script> 1.108 +</pre> 1.109 +</body> 1.110 +</html>