зеркало из https://github.com/mozilla/gecko-dev.git
Bug 388112, oversize menu no longer has scrolling mechanism, r+sr=bz
This commit is contained in:
Родитель
1960a851fb
Коммит
2126046c35
|
@ -981,9 +981,6 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame)
|
|||
parentViewWidgetOffset.x - parentPos.x;
|
||||
ypos = screenViewLocY - presContext->DevPixelsToAppUnits(screenParentWidgetRect.y) -
|
||||
parentViewWidgetOffset.y - parentPos.y;
|
||||
|
||||
// once the popup is positioned on screen, it doesn't need to be positioned again
|
||||
mShouldAutoPosition = PR_FALSE;
|
||||
}
|
||||
|
||||
// Compute info about the screen dimensions. Because of multiple monitor systems,
|
||||
|
|
|
@ -56,6 +56,8 @@ _TEST_FILES = bug288254_window.xul \
|
|||
test_bug331215.xul \
|
||||
test_popup_preventdefault_chrome.xul \
|
||||
window_popup_preventdefault_chrome.xul \
|
||||
test_largemenu.xul \
|
||||
window_largemenu.xul \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
|
||||
<window title="Large Menu Tests"
|
||||
onload="setTimeout(runTest, 0);"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<title>Large Menu Tests</title>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
||||
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function runTest()
|
||||
{
|
||||
window.open("window_largemenu.xul", "_new", "chrome,width=200,height=200");
|
||||
}
|
||||
</script>
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<p id="display">
|
||||
</p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
</window>
|
|
@ -0,0 +1,140 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
|
||||
<window title="Large Menu Tests"
|
||||
onfocus="setTimeout(runTests, 0);"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<title>Large Menu Tests</title>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
|
||||
|
||||
<!--
|
||||
This test checks that a large menu is displayed with arrow buttons
|
||||
and is on the screen.
|
||||
-->
|
||||
|
||||
<script>
|
||||
<![CDATA[
|
||||
|
||||
var gOverflowed = false, gUnderflowed = false;
|
||||
var gScreenY = -1;
|
||||
var gTestIndex = 0;
|
||||
var gTests = ["open normal", "open flipped position", "open with scrolling", "open small again"];
|
||||
|
||||
function runTests()
|
||||
{
|
||||
var mouseFn = function(event) { gScreenY = event.screenY; }
|
||||
|
||||
// a hacky way to get the screen position of the document
|
||||
window.addEventListener("mousedown", mouseFn, false);
|
||||
synthesizeMouse(document.documentElement, 0, 0, { });
|
||||
window.removeEventListener("mousedown", mouseFn, false);
|
||||
|
||||
nextTest();
|
||||
}
|
||||
|
||||
function nextTest()
|
||||
{
|
||||
gOverflowed = false, gUnderflowed = false;
|
||||
|
||||
var y = screen.height;
|
||||
if (gTestIndex == 1) // open flipped position test:
|
||||
y -= 100;
|
||||
else
|
||||
y /= 2;
|
||||
|
||||
var popup = document.getElementById("popup");
|
||||
if (gTestIndex == 2) {
|
||||
// add some more menuitems so that scrolling will be necessary
|
||||
for (var t = 1; t <= 30; t++) {
|
||||
var menu = document.createElement("menuitem");
|
||||
menu.setAttribute("label", "More" + t);
|
||||
popup.appendChild(menu);
|
||||
}
|
||||
}
|
||||
else if (gTestIndex == 3) {
|
||||
for (var t = 1; t <= 30; t++)
|
||||
popup.removeChild(popup.lastChild);
|
||||
}
|
||||
|
||||
popup.openPopupAtScreen(100, y, false);
|
||||
}
|
||||
|
||||
function popupShown()
|
||||
{
|
||||
var popup = document.getElementById("popup");
|
||||
var rect = popup.getBoundingClientRect();
|
||||
if (gTestIndex == 0) {
|
||||
// the popup should be in the center of the screen
|
||||
is(Math.round(rect.top) + gScreenY, screen.height / 2,
|
||||
gTests[gTestIndex] + " top");
|
||||
ok(Math.round(rect.bottom) + gScreenY < screen.height,
|
||||
gTests[gTestIndex] + " bottom");
|
||||
ok(!gOverflowed && !gUnderflowed, gTests[gTestIndex] + " overflow")
|
||||
}
|
||||
else if (gTestIndex == 1) {
|
||||
// the popup was supposed to open 100 pixels from the bottom, but that
|
||||
// would put it off screen so it should be flipped to have it's bottom
|
||||
// edge 100 pixels from the bottom
|
||||
ok(Math.round(rect.top) > screen.top, gTests[gTestIndex] + " top");
|
||||
is(Math.round(rect.bottom) + gScreenY, screen.height - 100,
|
||||
gTests[gTestIndex] + " bottom");
|
||||
ok(!gOverflowed && !gUnderflowed, gTests[gTestIndex] + " overflow")
|
||||
}
|
||||
else if (gTestIndex == 2) {
|
||||
// the popup is too large so ensure that it is on screen
|
||||
ok(Math.round(rect.top) > screen.top, gTests[gTestIndex] + " top");
|
||||
ok(Math.round(rect.bottom) < screen.height, gTests[gTestIndex] + " bottom");
|
||||
ok(gOverflowed && !gUnderflowed, gTests[gTestIndex] + " overflow")
|
||||
}
|
||||
else if (gTestIndex == 3) {
|
||||
is(Math.round(rect.top) + gScreenY, screen.height / 2,
|
||||
gTests[gTestIndex] + " top");
|
||||
ok(Math.round(rect.bottom) + gScreenY < screen.height,
|
||||
gTests[gTestIndex] + " bottom");
|
||||
ok(!gOverflowed && gUnderflowed, gTests[gTestIndex] + " overflow")
|
||||
}
|
||||
|
||||
popup.hidePopup();
|
||||
}
|
||||
|
||||
function is(l, r, n) { window.opener.wrappedJSObject.SimpleTest.is(l,r,n); }
|
||||
function ok(v, n) { window.opener.wrappedJSObject.SimpleTest.ok(v,n); }
|
||||
|
||||
function popupHidden()
|
||||
{
|
||||
gTestIndex++;
|
||||
if (gTestIndex == gTests.length) {
|
||||
window.opener.wrappedJSObject.SimpleTest.finish();
|
||||
window.close();
|
||||
}
|
||||
else {
|
||||
nextTest();
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<label value="OK" popup="popup"/>
|
||||
<menupopup id="popup" onpopupshown="popupShown();" onpopuphidden="popupHidden();"
|
||||
onoverflow="gOverflowed = true" onunderflow="gUnderflowed = true;">
|
||||
<menuitem label="1"/>
|
||||
<menuitem label="2"/>
|
||||
<menuitem label="3"/>
|
||||
<menuitem label="4"/>
|
||||
<menuitem label="5"/>
|
||||
<menuitem label="6"/>
|
||||
<menuitem label="7"/>
|
||||
<menuitem label="8"/>
|
||||
<menuitem label="9"/>
|
||||
<menuitem label="10"/>
|
||||
<menuitem label="11"/>
|
||||
<menuitem label="12"/>
|
||||
<menuitem label="13"/>
|
||||
<menuitem label="14"/>
|
||||
<menuitem label="15"/>
|
||||
</menupopup>
|
||||
|
||||
</window>
|
Загрузка…
Ссылка в новой задаче