Backed out changeset 05fd6a9c8ff7 (bug 487631) on suspicion of causing Windows unit test orange in CLOSED TREE.

This commit is contained in:
Boris Zbarsky 2009-04-13 17:45:54 -04:00
Родитель 0d83c0693b
Коммит 03b7bba2dd
5 изменённых файлов: 52 добавлений и 66 удалений

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

@ -84,8 +84,6 @@ _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,25 +28,19 @@ var gTests = ["open normal", "open flipped position", "open with scrolling",
"context menu too big either side",
"context menu larger than screen"];
function getScreenXY(element)
function setDocumentScreenY()
{
var screenX, screenY;
var mouseFn = function(event) {
screenX = event.screenX - 1;
screenY = event.screenY - 1;
}
var mouseFn = function(event) { gScreenY = event.screenY; }
// a hacky way to get the screen position of an element without using the box object
// a hacky way to get the screen position of the document
window.addEventListener("mousedown", mouseFn, false);
synthesizeMouse(element, 1, 1, { });
synthesizeMouse(document.documentElement, 0, 0, { });
window.removeEventListener("mousedown", mouseFn, false);
return [screenX, screenY];
}
function runTests()
{
[, gScreenY] = getScreenXY(document.documentElement);
setDocumentScreenY();
nextTest();
}
@ -171,7 +165,8 @@ function contextMenuPopupShown()
var rect = popup.getBoundingClientRect();
var labelrect = document.getElementById("label").getBoundingClientRect();
is(rect.left, labelrect.left + 6, gTests[gTestIndex] + " left");
// XXXndeakin disable test on Linux for now
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");
@ -180,7 +175,7 @@ function contextMenuPopupShown()
is(rect.top, labelrect.top - rect.height + 2, gTests[gTestIndex] + " top");
break;
case "context menu too big either side":
[, gScreenY] = getScreenXY(document.documentElement);
setDocumentScreenY();
// 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
@ -234,54 +229,42 @@ 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);
[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");
// 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");
popup.moveTo(100, 8000);
var expectedy = (overlapOSChrome ? screen.height + screen.top : screen.availHeight + screen.availTop) -
Math.round(rect.height) - 3;
[screenX, screenY] = getScreenXY(popup);
is(screenX, 100, gTests[gTestIndex] + " (100, 8000) x");
is(screenY, expectedy, gTests[gTestIndex] + " (100, 8000) y");
is(popup.boxObject.screenX, 100, gTests[gTestIndex] + " (100, 8000) x");
is(popup.boxObject.screenY, expectedy, gTests[gTestIndex] + " (100, 8000) y");
popup.moveTo(6000, 100);
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");
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");
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");
[screenX, screenY] = getScreenXY(popup);
is(screenX, 80, gTests[gTestIndex] + " set left and top x");
is(screenY, 82, gTests[gTestIndex] + " set left and top y");
is(popup.boxObject.screenX, 80, gTests[gTestIndex] + " set left and top x");
is(popup.boxObject.screenY, 82, gTests[gTestIndex] + " set left and top y");
popup.moveTo(95, 98);
[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.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");
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);
[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");
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");
popup.hidePopup();
}
@ -309,7 +292,7 @@ function testPopupMovement()
<menuitem label="15"/>
</menupopup>
<panel id="panel" onpopupshown="testPopupMovement();" onpopuphidden="popupHidden();" style="margin: 0">
<panel id="panel" onpopupshown="testPopupMovement();" onpopuphidden="popupHidden();">
<button label="OK"/>
</panel>

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

@ -107,7 +107,6 @@ _TEST_FILES = test_bug360220.xul \
test_mousescroll.xul \
test_scrollbar.xul \
test_sorttemplate.xul \
test_contextmenu_list.xul \
test_videocontrols.html \
video.ogg \
$(NULL)
@ -117,5 +116,9 @@ _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" style="padding: 0;" oncontextmenu="checkContextMenu(event)">
<richlistitem id="item1" style="padding-top: 3px; margin: 0;"><button label="One"/></richlistitem>
<richlistbox id="list" context="themenu" oncontextmenu="checkContextMenu(event)">
<richlistitem id="item1" style="padding-top: 3px;"><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, 4, { type : "contextmenu", button: 2 });
synthesizeMouse(element, 7, 2, { type : "contextmenu", button: 2 });
gSelectionStep++;
synthesizeMouse(element.getItemAtIndex(1), 7, 1, { type : "mousedown", button: 2, ctrlKey: true, shiftKey: true });
synthesizeMouse(element, 7, 4, { type : "contextmenu", button: 2 });
synthesizeMouse(element, 7, 2, { type : "contextmenu", button: 2 });
gSelectionStep++;
synthesizeMouse(element.getItemAtIndex(1), 7, 1, { type : "mousedown", button: 2 });
synthesizeMouse(element, 7, 4, { type : "contextmenu", button: 2 });
synthesizeMouse(element, 7, 2, { 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, 4, { type : "contextmenu", button: 2 });
synthesizeMouse(element, 7, 2, { 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 + 4 : rect.bottom;
top = frombase ? rect.top + 2 : rect.bottom;
is(event.clientX, left, gTestElement + " clientX " + gSelectionStep + " " + gTestId + "," + frombase);
is(event.clientY, top, gTestElement + " clientY " + gSelectionStep + " " + gTestId);
@ -177,7 +177,9 @@ function checkContextMenu(event)
is(event.originalTarget, $("treechildren"), "tree selection target");
break;
case 1:
is(event.originalTarget.id, $("item1").id, "list mouse selection target");
// XXXndeakin disable test on Windows for now
if (navigator.platform.indexOf("Win") == -1)
is(event.originalTarget.id, $("item1").id, "list mouse selection target");
break;
case 2:
is(event.originalTarget, $("list"), "list no selection target");
@ -227,7 +229,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) + 6,
is(Math.round(menurect.top), Math.round(elementrect.top) + 4,
gTestElement + " mouse top");
}
else {

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

@ -21,6 +21,8 @@
<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>
@ -36,11 +38,10 @@ var originalHeight = -1;
function nextTest()
{
// there are five tests here:
// there are four 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
@ -69,13 +70,13 @@ function nextTest()
step = "large menu";
popup.removeAttribute("left");
popup.removeAttribute("top");
for (var i = 0; i < 80; i++)
for (var i = 0; i < 40; i++)
menu.appendItem("Test", "");
synthesizeMouse(menu, 2, 2, { });
break;
case "large menu":
step = "shorter menu again";
for (var i = 0; i < 80; i++)
for (var i = 0; i < 40; i++)
menu.removeItemAt(menu.itemCount - 1);
synthesizeMouse(menu, 2, 2, { });
break;
@ -94,24 +95,23 @@ 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;
}
else if (step == "open near bottom") {
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");
}
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");
if (step == "largemenu") {
ok(popuprect.top == windowrect.top, step + " top");
ok(popuprect.bottom - 1 == windowrect.bottom, step + " bottom");
}
else {
ok(popuprect.top >= windowrect.top, step + " top");
ok(popuprect.bottom - 1 <= windowrect.bottom, step + " bottom");
if (step == "shorter menu again")
is(popuprect.bottom - popuprect.top, originalHeight, step + " height shortened");
// XXXndeakin disable this test for now: bug 407937
// is(popuprect.bottom - popuprect.top, originalHeight, step + " height shortened");
}
$("menu").open = false;