зеркало из https://github.com/mozilla/pjs.git
test for bug 624329
--HG-- extra : rebase_source : 04799e53a86060cf9532c2a2d72f716288997c6d
This commit is contained in:
Родитель
3e0e85fb00
Коммит
c6369b83a5
|
@ -70,6 +70,8 @@ _TEST_FILES = findbar_window.xul \
|
|||
test_bug451540.xul \
|
||||
test_bug471776.xul \
|
||||
test_bug570192.xul \
|
||||
test_bug624329.xul \
|
||||
bug624329_window.xul \
|
||||
test_bug649840.xul \
|
||||
test_popup_preventdefault_chrome.xul \
|
||||
window_popup_preventdefault_chrome.xul \
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
|
||||
<window title="Test for bug 624329 context menu position"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
context="menu">
|
||||
|
||||
<title><label>Test for bug 624329 context menu position</label></title>
|
||||
|
||||
<script>
|
||||
opener.SimpleTest.waitForFocus(opener.childFocused, window);
|
||||
</script>
|
||||
|
||||
<menupopup id="menu">
|
||||
<!-- The bug demonstrated only when the accesskey was presented separately
|
||||
from the label.
|
||||
e.g. because the accesskey is not a letter in the label.
|
||||
|
||||
The bug demonstrates only on the first show of the context menu
|
||||
unless menu items are removed/added each time the menu is
|
||||
constructed. -->
|
||||
<menuitem label="Long label to ensure the popup would hit the right of the screen" accesskey="1"/>
|
||||
</menupopup>
|
||||
</window>
|
|
@ -0,0 +1,125 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
|
||||
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=624329
|
||||
-->
|
||||
<window title="Mozilla Bug 624329 context menu position"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml"
|
||||
onload="openTestWindow()">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=624329"
|
||||
target="_blank">Mozilla Bug 624329</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
/** Test for Bug 624329 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var win;
|
||||
var timeoutID;
|
||||
var menu;
|
||||
|
||||
function openTestWindow() {
|
||||
win = open("bug624329_window.xul", "_blank", "width=300,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 listenOnce(event, callback) {
|
||||
win.addEventListener(event, function listener() {
|
||||
win.removeEventListener(event, listener, false);
|
||||
callback();
|
||||
}, false);
|
||||
}
|
||||
|
||||
function childFocused() {
|
||||
// maximizing the window is a simple way to ensure that the menu is near
|
||||
// the right edge of the screen.
|
||||
|
||||
listenOnce("resize", childResized);
|
||||
win.maximize();
|
||||
}
|
||||
|
||||
function childResized() {
|
||||
is(win.windowState, win.STATE_MAXIMIZED,
|
||||
"window should be maximized");
|
||||
|
||||
isnot(win.innerWidth, 300,
|
||||
"window inner width should have changed");
|
||||
|
||||
openContextMenu();
|
||||
}
|
||||
|
||||
function openContextMenu() {
|
||||
var mouseX = win.innerWidth - 10;
|
||||
var mouseY = 10;
|
||||
|
||||
menu = win.document.getElementById("menu");
|
||||
var screenX = menu.boxObject.screenX;
|
||||
var screenY = menu.boxObject.screenY;
|
||||
var utils =
|
||||
win.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
utils.sendMouseEvent("contextmenu", mouseX, mouseY, 2, 0, 0);
|
||||
|
||||
var interval = setInterval(checkMoved, 200);
|
||||
function checkMoved() {
|
||||
if (menu.boxObject.screenX != screenX ||
|
||||
menu.boxObject.screenY != screenY) {
|
||||
clearInterval(interval);
|
||||
// Wait further to check that the window does not move again.
|
||||
setTimeout(checkPosition, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function checkPosition() {
|
||||
var menubox = menu.boxObject;
|
||||
var winbox = win.document.documentElement.boxObject
|
||||
|
||||
var x = menubox.screenX - winbox.screenX;
|
||||
var y = menubox.screenY - winbox.screenY;
|
||||
ok(y >= mouseY,
|
||||
"menu top " + y + " should be below click point " + mouseY);
|
||||
ok(y <= mouseY + 20,
|
||||
"menu top " + y + " should not be too far below click point " + mouseY);
|
||||
|
||||
ok(x < mouseX,
|
||||
"menu left " + x + " should be left of click point " + mouseX);
|
||||
var right = x + menubox.width;
|
||||
ok(right > mouseX,
|
||||
"menu right " + right + " should be right of click point " + mouseX);
|
||||
|
||||
clearTimeout(timeoutID);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function finish() {
|
||||
if (menu && navigator.platform.indexOf("Win") >= 0) {
|
||||
todo(false, "Should not have to hide popup before closing its window");
|
||||
// This avoids mochitest "Unable to restore focus" errors (bug 670053).
|
||||
menu.hidePopup();
|
||||
}
|
||||
win.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
Загрузка…
Ссылка в новой задаче