Bug 1602620, fix margins and add some debugging to see why these tests fail on ubuntu18.04
Differential Diff: PHID-DIFF-6ocgfwdbwvbghtumtnui
--- a/toolkit/content/tests/chrome/test_panel.xhtml
+++ b/toolkit/content/tests/chrome/test_panel.xhtml
@@ -6,16 +6,17 @@
onload="runTest()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script>
SimpleTest.waitForExplicitFinish();
+SimpleTest.requestCompleteLog();
function runTest()
{
window.openDialog("window_panel.xhtml", "_blank", "chrome,left=200,top=200,width=200,height=200,noopener", window);
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display">
--- a/toolkit/content/tests/chrome/test_popup_attribute.xhtml
+++ b/toolkit/content/tests/chrome/test_popup_attribute.xhtml
@@ -5,16 +5,17 @@
<window title="Popup Attribute Tests"
onload="setTimeout(runTest, 0);"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
SimpleTest.waitForExplicitFinish();
+SimpleTest.requestCompleteLog();
function runTest()
{
window.open("window_popup_attribute.xhtml", "_blank", "width=600,height=700");
}
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display">
--- a/toolkit/content/tests/chrome/test_popup_moveToAnchor.xhtml
+++ b/toolkit/content/tests/chrome/test_popup_moveToAnchor.xhtml
@@ -3,51 +3,64 @@
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<vbox align="start">
- <button id="button1" label="Button 1" style="margin-top: 50px;"/>
- <button id="button2" label="Button 2" style="margin-top: 60px;"/>
+ <button id="button1" label="Button 1" style="margin-top: 60px;"/>
+ <button id="button2" label="Button 2" style="margin-top: 70px;"/>
+ <button id="button3" label="Button 3" style="margin-top: 50px;"/>
</vbox>
<menupopup id="popup" onpopupshown="popupshown()" onpopuphidden="SimpleTest.finish()">
<menuitem label="One"/>
<menuitem label="Two"/>
</menupopup>
<script>
SimpleTest.waitForExplicitFinish();
+SimpleTest.requestCompleteLog();
function runTest(id)
{
$("popup").openPopup($("button1"), "after_start");
}
function popupshown()
{
var popup = $("popup");
var popupheight = popup.getBoundingClientRect().height;
var button1rect = $("button1").getBoundingClientRect();
var button2rect = $("button2").getBoundingClientRect();
+ var button3rect = $("button3").getBoundingClientRect();
checkCoords(popup, button1rect.left, button1rect.bottom, "initial");
popup.moveToAnchor($("button1"), "after_start", 0, 8);
checkCoords(popup, button1rect.left, button1rect.bottom + 8, "move anchor top + 8");
popup.moveToAnchor($("button1"), "after_start", 6, -10);
checkCoords(popup, button1rect.left + 6, button1rect.bottom - 10, "move anchor left + 6, top - 10");
popup.moveToAnchor($("button1"), "before_start", -2, 0);
checkCoords(popup, button1rect.left - 2, button1rect.top - popupheight, "move anchor before_start");
+ popup.moveToAnchor($("button3"), "before_start", -2, 0);
+ checkCoords(popup, button3rect.left - 2, button3rect.top - popupheight, "move anchor before_start button3");
+
+dump("Panel ComputedStyle [margin: " + getComputedStyle(popup).marginLeft +
+ "," + getComputedStyle(popup).marginTop + "] " +
+ "[padding: " + getComputedStyle(popup).marginLeft +
+ "," + getComputedStyle(popup).marginTop + "] " +
+ "[border: " + getComputedStyle(popup).borderLeftWidth +
+ "," + getComputedStyle(popup).borderTopWidth + "]\n");
+
popup.moveToAnchor($("button2"), "before_start");
checkCoords(popup, button2rect.left, button2rect.top - popupheight, "move button2");
popup.moveToAnchor($("button1"), "end_before");
checkCoords(popup, button1rect.right, button1rect.top, "move anchor end_before");
popup.moveToAnchor($("button2"), "after_start", 5, 4);
checkCoords(popup, button2rect.left + 5, button2rect.bottom + 4, "move button2 left + 5, top + 4");
@@ -61,16 +74,17 @@ function popupshown()
popup.hidePopup();
}
function checkCoords(popup, expectedx, expectedy, testid)
{
var rect = popup.getBoundingClientRect();
is(Math.round(rect.left), Math.round(expectedx), testid + " left");
is(Math.round(rect.top), Math.round(expectedy), testid + " top");
+dump(testid + " -- " + rect.left + "," + rect.top + "\n");
}
SimpleTest.waitForFocus(runTest);
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display">
--- a/toolkit/content/tests/chrome/window_panel.xhtml
+++ b/toolkit/content/tests/chrome/window_panel.xhtml
@@ -27,16 +27,17 @@
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml" style="height: 300px; overflow: auto;"/>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
+SimpleTest.requestCompleteLog();
var currentTest = null;
function ok(condition, message) {
window.arguments[0].SimpleTest.ok(condition, message);
}
function is(left, right, message) {
@@ -155,18 +156,18 @@ var tests = [
var screenRect = panel.getOuterScreenRect();
is(screenRect.left, 0, this.testname + " screen left before open");
is(screenRect.top, 0, this.testname + " screen top before open");
is(screenRect.width, 0, this.testname + " screen width before open");
is(screenRect.height, 0, this.testname + " screen height before open");
panel.openPopupAtScreen(200, 210);
},
- result: function(testname, panel) {
- var panelrect = panel.getBoundingClientRect();
+ result: function(testname, panel) {
+ var panelrect = panel.getBoundingClientRect();
is(panelrect.left, 200 - mozInnerScreenX, testname + "left");
is(panelrect.top, 210 - mozInnerScreenY, testname + "top");
is(panelrect.width, 120, testname + "width");
is(panelrect.height, 40, testname + "height");
var screenRect = panel.getOuterScreenRect();
is(screenRect.left, 200, testname + " screen left");
is(screenRect.top, 210, testname + " screen top");
@@ -184,17 +185,25 @@ var tests = [
is(screenRect.left, 0, this.testname + " screen left before open");
is(screenRect.top, 0, this.testname + " screen top before open");
is(screenRect.width, 0, this.testname + " screen width before open");
is(screenRect.height, 0, this.testname + " screen height before open");
panel.openPopupAtScreen(200, 210);
},
result: function(testname, panel) {
+dump("Panel ComputedStyle [margin: " + getComputedStyle(panel).marginLeft +
+ "," + getComputedStyle(panel).marginTop + "] " +
+ "[padding: " + getComputedStyle(panel).marginLeft +
+ "," + getComputedStyle(panel).marginTop + "] " +
+ "[border: " + getComputedStyle(panel).borderLeftWidth +
+ "," + getComputedStyle(panel).borderTopWidth + "]\n");
+
var panelrect = panel.getBoundingClientRect();
+dump("***" + panelrect.top + "," + mozInnerScreenY + "\n");
ok(panelrect.left >= 200 - mozInnerScreenX, testname + "left");
if (!navigator.platform.includes("Linux")) {
ok(panelrect.top >= 210 - mozInnerScreenY + 10, testname + "top greater");
}
ok(panelrect.top <= 210 - mozInnerScreenY + 32, testname + "top less");
is(panelrect.width, 120, testname + "width");
is(panelrect.height, 40, testname + "height");
--- a/toolkit/content/tests/widgets/popup_shared.js
+++ b/toolkit/content/tests/widgets/popup_shared.js
@@ -507,16 +507,19 @@ function compareEdge(anchor, popup, edge
is(
Math.round(popuprect.top),
Math.round(anchorrect.top) + offsetY + 21,
testname + " y position"
);
return;
}
+is(true, true, "Anchor Coords: " + anchorrect.top + "," + anchorrect.top + "," + anchorrect.width + "," + anchorrect.height + "\n");
+is(true, true, "Popup Coords: " + popuprect.top + "," + popuprect.top + "," + popuprect.width + "," + popuprect.height + "\n");
+
if (edge == "overlap") {
ok(
Math.round(anchorrect.left) + offsetY == Math.round(popuprect.left) &&
Math.round(anchorrect.top) + offsetY == Math.round(popuprect.top),
testname + " position"
);
return;
}