Bug 487631, fix a number of xul tests which were disabled in the past due to not working on some platforms, these are tests for bugs 474149, 416390, 212750, 409242, r=gavin

This commit is contained in:
Neil Deakin 2009-04-22 08:55:49 -04:00
Родитель 0acf58deb4
Коммит 6de3035c87
5 изменённых файлов: 66 добавлений и 52 удалений

Просмотреть файл

@ -86,6 +86,8 @@ _TEST_FILES = findbar_window.xul \
window_keys.xul \
$(NULL)
# test_panel_focus.xul won't work if the Full Keyboard Access preference is set to
# textboxes and lists only, so skip this test on Mac
ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
_TEST_FILES += test_panel_focus.xul \
window_panel_focus.xul

Просмотреть файл

@ -28,19 +28,25 @@ var gTests = ["open normal", "open flipped position", "open with scrolling",
"context menu too big either side",
"context menu larger than screen"];
function setDocumentScreenY()
function getScreenXY(element)
{
var mouseFn = function(event) { gScreenY = event.screenY; }
var screenX, screenY;
var mouseFn = function(event) {
screenX = event.screenX - 1;
screenY = event.screenY - 1;
}
// a hacky way to get the screen position of the document
// a hacky way to get the screen position of an element without using the box object
window.addEventListener("mousedown", mouseFn, false);
synthesizeMouse(document.documentElement, 0, 0, { });
synthesizeMouse(element, 1, 1, { });
window.removeEventListener("mousedown", mouseFn, false);
return [screenX, screenY];
}
function runTests()
{
setDocumentScreenY();
[, gScreenY] = getScreenXY(document.documentElement);
nextTest();
}
@ -165,8 +171,7 @@ function contextMenuPopupShown()
var rect = popup.getBoundingClientRect();
var labelrect = document.getElementById("label").getBoundingClientRect();
// XXXndeakin disable test on Linux for now
is(rect.left, labelrect.left + 6, gTests[gTestIndex] + " left");
is(rect.left, labelrect.left + 6, gTests[gTestIndex] + " left");
switch (gTests[gTestIndex]) {
case "context menu enough space below":
is(rect.top, labelrect.top + 6, gTests[gTestIndex] + " top");
@ -175,7 +180,7 @@ function contextMenuPopupShown()
is(rect.top, labelrect.top - rect.height + 2, gTests[gTestIndex] + " top");
break;
case "context menu too big either side":
setDocumentScreenY();
[, gScreenY] = getScreenXY(document.documentElement);
// compare against the available size as well as the total size, as some
// platforms allow the menu to overlap os chrome and others do not
// the - 3 here is to account for 3 pixels that are subtracted from the
@ -229,42 +234,54 @@ function testPopupMovement()
var button = document.getElementById("label");
var popup = document.getElementById((gTests[gTestIndex] == "panel movement") ? "panel" : "popup");
var screenX, screenY, buttonScreenX, buttonScreenY;
var rect = popup.getBoundingClientRect();
var overlapOSChrome = (navigator.platform.indexOf("Mac") == -1);
popup.moveTo(1, 1);
// is(popup.boxObject.screenX, overlapOSChrome ? 1 : screen.availLeft, gTests[gTestIndex] + " (1, 1) x");
// is(popup.boxObject.screenY, overlapOSChrome ? 1 : screen.availTop, gTests[gTestIndex] + " (1, 1) y");
[screenX, screenY] = getScreenXY(popup);
var expectedx = overlapOSChrome ? 1 : (screen.availLeft < 1 ? 1 : screen.availLeft);
var expectedy = overlapOSChrome ? 1 : (screen.availTop < 1 ? 1 : screen.availTop);
is(screenX, expectedx, gTests[gTestIndex] + " (1, 1) x");
is(screenY, expectedy, gTests[gTestIndex] + " (1, 1) y");
popup.moveTo(100, 8000);
var expectedy = (overlapOSChrome ? screen.height + screen.top : screen.availHeight + screen.availTop) -
Math.round(rect.height) - 3;
is(popup.boxObject.screenX, 100, gTests[gTestIndex] + " (100, 8000) x");
is(popup.boxObject.screenY, expectedy, gTests[gTestIndex] + " (100, 8000) y");
[screenX, screenY] = getScreenXY(popup);
is(screenX, 100, gTests[gTestIndex] + " (100, 8000) x");
is(screenY, expectedy, gTests[gTestIndex] + " (100, 8000) y");
popup.moveTo(6000, 100);
var expectedx = (overlapOSChrome ? screen.width + screen.left : screen.availWidth + screen.availLeft) -
Math.round(rect.width) - 3;
// is(popup.boxObject.screenX, expectedx, gTests[gTestIndex] + " (6000, 100) x");
is(popup.boxObject.screenY, 100, gTests[gTestIndex] + " (6000, 100) y");
expectedx = (overlapOSChrome ? screen.width + screen.left : screen.availWidth + screen.availLeft) -
Math.round(rect.width) - 3;
[screenX, screenY] = getScreenXY(popup);
is(screenX, expectedx, gTests[gTestIndex] + " (6000, 100) x");
is(screenY, 100, gTests[gTestIndex] + " (6000, 100) y");
is(popup.left, "", gTests[gTestIndex] + " left is empty after moving");
is(popup.top, "", gTests[gTestIndex] + " top is empty after moving");
popup.setAttribute("left", "80");
popup.setAttribute("top", "82");
is(popup.boxObject.screenX, 80, gTests[gTestIndex] + " set left and top x");
is(popup.boxObject.screenY, 82, gTests[gTestIndex] + " set left and top y");
[screenX, screenY] = getScreenXY(popup);
is(screenX, 80, gTests[gTestIndex] + " set left and top x");
is(screenY, 82, gTests[gTestIndex] + " set left and top y");
popup.moveTo(95, 98);
is(popup.boxObject.screenX, 95, gTests[gTestIndex] + " move after set left and top x");
is(popup.boxObject.screenY, 98, gTests[gTestIndex] + " move after set left and top y");
[screenX, screenY] = getScreenXY(popup);
is(screenX, 95, gTests[gTestIndex] + " move after set left and top x");
is(screenY, 98, gTests[gTestIndex] + " move after set left and top y");
is(popup.left, "95", gTests[gTestIndex] + " left is set after moving");
is(popup.top, "98", gTests[gTestIndex] + " top is set after moving");
popup.removeAttribute("left");
popup.removeAttribute("top");
popup.moveTo(-1, -1);
is(popup.boxObject.screenX, button.boxObject.screenX, gTests[gTestIndex] + " original x");
is(popup.boxObject.screenY, button.boxObject.screenY + button.getBoundingClientRect().height, gTests[gTestIndex] + " original y");
[screenX, screenY] = getScreenXY(popup);
[buttonScreenX, buttonScreenY] = getScreenXY(button);
is(screenX, buttonScreenX, gTests[gTestIndex] + " original x");
is(screenY, buttonScreenY + button.getBoundingClientRect().height, gTests[gTestIndex] + " original y");
popup.hidePopup();
}
@ -292,7 +309,7 @@ function testPopupMovement()
<menuitem label="15"/>
</menupopup>
<panel id="panel" onpopupshown="testPopupMovement();" onpopuphidden="popupHidden();">
<panel id="panel" onpopupshown="testPopupMovement();" onpopuphidden="popupHidden();" style="margin: 0">
<button label="OK"/>
</panel>

Просмотреть файл

@ -107,6 +107,7 @@ _TEST_FILES = test_bug360220.xul \
test_mousescroll.xul \
test_scrollbar.xul \
test_sorttemplate.xul \
test_contextmenu_list.xul \
test_videocontrols.html \
video.ogg \
$(NULL)
@ -116,9 +117,5 @@ _TEST_FILES += test_menubar.xul \
window_menubar.xul
endif
ifeq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
_TEST_FILES += test_contextmenu_list.xul
endif
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)

Просмотреть файл

@ -14,8 +14,8 @@
<hbox style="padding-left: 10px;">
<spacer width="5"/>
<richlistbox id="list" context="themenu" oncontextmenu="checkContextMenu(event)">
<richlistitem id="item1" style="padding-top: 3px;"><button label="One"/></richlistitem>
<richlistbox id="list" context="themenu" style="padding: 0;" oncontextmenu="checkContextMenu(event)">
<richlistitem id="item1" style="padding-top: 3px; margin: 0;"><button label="One"/></richlistitem>
<richlistitem id="item2" height="22"><checkbox label="Checkbox"/></richlistitem>
<richlistitem id="item3"><button label="Three"/></richlistitem>
<richlistitem id="item4"><checkbox label="Four"/></richlistitem>
@ -86,15 +86,15 @@ function startTest()
// first, check if the richlistbox selection changes on a contextmenu mouse event
var element = $("list");
synthesizeMouse(element.getItemAtIndex(3), 7, 1, { type : "mousedown", button: 2, ctrlKey: true });
synthesizeMouse(element, 7, 2, { type : "contextmenu", button: 2 });
synthesizeMouse(element, 7, 4, { type : "contextmenu", button: 2 });
gSelectionStep++;
synthesizeMouse(element.getItemAtIndex(1), 7, 1, { type : "mousedown", button: 2, ctrlKey: true, shiftKey: true });
synthesizeMouse(element, 7, 2, { type : "contextmenu", button: 2 });
synthesizeMouse(element, 7, 4, { type : "contextmenu", button: 2 });
gSelectionStep++;
synthesizeMouse(element.getItemAtIndex(1), 7, 1, { type : "mousedown", button: 2 });
synthesizeMouse(element, 7, 2, { type : "contextmenu", button: 2 });
synthesizeMouse(element, 7, 4, { type : "contextmenu", button: 2 });
$("menu").open = true;
}
@ -140,7 +140,7 @@ function nextTest()
synthesizeMouse(element, 0, 0, { type : "contextmenu", button: 0 });
}
else if (gTestId == 1) {
synthesizeMouse(element, 7, 2, { type : "contextmenu", button: 2 });
synthesizeMouse(element, 7, 4, { type : "contextmenu", button: 2 });
}
else {
element.currentIndex = -1;
@ -157,7 +157,7 @@ function checkContextMenu(event)
if (!frombase)
rect = event.originalTarget.getBoundingClientRect();
left = frombase ? rect.left + 7 : rect.left;
top = frombase ? rect.top + 2 : rect.bottom;
top = frombase ? rect.top + 4 : rect.bottom;
is(event.clientX, left, gTestElement + " clientX " + gSelectionStep + " " + gTestId + "," + frombase);
is(event.clientY, top, gTestElement + " clientY " + gSelectionStep + " " + gTestId);
@ -177,9 +177,7 @@ function checkContextMenu(event)
is(event.originalTarget, $("treechildren"), "tree selection target");
break;
case 1:
// XXXndeakin disable test on Windows for now
if (navigator.platform.indexOf("Win") == -1)
is(event.originalTarget.id, $("item1").id, "list mouse selection target");
is(event.originalTarget.id, $("item1").id, "list mouse selection target");
break;
case 2:
is(event.originalTarget, $("list"), "list no selection target");
@ -229,7 +227,7 @@ function checkPopup()
var elementrect = $(gTestElement).getBoundingClientRect();
is(Math.round(menurect.left), Math.round(elementrect.left) + 9,
gTestElement + " mouse left");
is(Math.round(menurect.top), Math.round(elementrect.top) + 4,
is(Math.round(menurect.top), Math.round(elementrect.top) + 6,
gTestElement + " mouse top");
}
else {

Просмотреть файл

@ -21,8 +21,6 @@
<menuitem label="One"/>
<menuitem label="Two"/>
<menuitem label="Three"/>
<menuitem label="Four"/>
<menuitem label="Five"/>
<menuitem label="A final longer label that is actually quite long. Very long indeed."/>
</menupopup>
</menu>
@ -38,10 +36,11 @@ var originalHeight = -1;
function nextTest()
{
// there are four tests here:
// there are five tests here:
// openPopupAtScreen - checks that opening a popup using openPopupAtScreen
// constrains the popup to the content area
// left and top - check with the left and top attributes set
// open near bottom - open the menu near the bottom of the window
// large menu - try with a menu that is very large and should be scaled
// shorter menu again - try with a menu that is shorter again. It should have
// the same height as the 'left and top' test
@ -70,13 +69,13 @@ function nextTest()
step = "large menu";
popup.removeAttribute("left");
popup.removeAttribute("top");
for (var i = 0; i < 40; i++)
for (var i = 0; i < 80; i++)
menu.appendItem("Test", "");
synthesizeMouse(menu, 2, 2, { });
break;
case "large menu":
step = "shorter menu again";
for (var i = 0; i < 40; i++)
for (var i = 0; i < 80; i++)
menu.removeItemAt(menu.itemCount - 1);
synthesizeMouse(menu, 2, 2, { });
break;
@ -95,23 +94,24 @@ function popupShown()
ok(popuprect.left >= windowrect.left, step + " left");
ok(popuprect.right - 1 <= windowrect.right, step + " right");
if (step == "left and top")
if (step == "left and top") {
originalHeight = popuprect.bottom - popuprect.top;
if (step == "open near bottom") {
}
else if (step == "open near bottom") {
// check that the menu flipped up so it's above our requested point
ok(popuprect.bottom - 1 <= windowrect.bottom - 5, step + " bottom");
}
if (step == "largemenu") {
ok(popuprect.top == windowrect.top, step + " top");
ok(popuprect.bottom - 1 == windowrect.bottom, step + " bottom");
else if (step == "large menu") {
// add 10 to account for the margin
is(popuprect.top, $("menu").getBoundingClientRect().bottom + 10, step + " top");
ok(popuprect.bottom == windowrect.bottom ||
popuprect.bottom - 1 == windowrect.bottom, step + " bottom");
}
else {
ok(popuprect.top >= windowrect.top, step + " top");
ok(popuprect.bottom - 1 <= windowrect.bottom, step + " bottom");
// XXXndeakin disable this test for now: bug 407937
// is(popuprect.bottom - popuprect.top, originalHeight, step + " height shortened");
if (step == "shorter menu again")
is(popuprect.bottom - popuprect.top, originalHeight, step + " height shortened");
}
$("menu").open = false;