summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/chrome/window_tooltip.xhtml
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/content/tests/chrome/window_tooltip.xhtml')
-rw-r--r--toolkit/content/tests/chrome/window_tooltip.xhtml55
1 files changed, 50 insertions, 5 deletions
diff --git a/toolkit/content/tests/chrome/window_tooltip.xhtml b/toolkit/content/tests/chrome/window_tooltip.xhtml
index b78075de45..e6ee5c6b42 100644
--- a/toolkit/content/tests/chrome/window_tooltip.xhtml
+++ b/toolkit/content/tests/chrome/window_tooltip.xhtml
@@ -30,6 +30,8 @@ var gOriginalWidth = -1;
var gOriginalHeight = -1;
var gButton = null;
+const kTooltipOffsetVertical = 10;
+
function runTest()
{
startPopupTests(popupTests);
@@ -112,7 +114,7 @@ var popupTests = [
Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6),
testname + " left position of tooltip");
is(Math.round(rect.top),
- Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6),
+ Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6 + kTooltipOffsetVertical),
testname + " top position of tooltip");
var labelrect = document.getElementById("label").getBoundingClientRect();
@@ -159,7 +161,7 @@ var popupTests = [
Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 4),
testname + " left position of tooltip");
is(Math.round(rect.top),
- Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 4),
+ Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 4 + kTooltipOffsetVertical),
testname + " top position of tooltip");
var labelrect = document.getElementById("label").getBoundingClientRect();
@@ -204,7 +206,7 @@ var popupTests = [
Math.round(buttonrect.left + parseFloat(popupstyle.marginLeft) + 6),
testname + " left position of tooltip");
is(Math.round(rect.top),
- Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6),
+ Math.round(buttonrect.top + parseFloat(popupstyle.marginTop) + 6 + kTooltipOffsetVertical),
testname + " top position of tooltip");
var labelrect = document.getElementById("label").getBoundingClientRect();
@@ -327,7 +329,43 @@ var popupTests = [
// that the original height has increased by at least 10 pixels
ok(gOriginalHeight + 10 < rect.bottom - rect.top, testname + " tooltip is wrapped");
}
-}
+},
+{
+ testname: "anchored tooltip with no offset",
+ events: ["popupshowing thetooltip", "popupshown thetooltip"],
+ autohide: "thetooltip",
+ test() {
+ gButton = document.getElementById("withtooltip");
+ document
+ .getElementById("thetooltip")
+ .setAttribute(
+ "onpopupshowing",
+ "this.moveToAnchor(this.triggerNode, 'after_start');"
+ );
+ disableNonTestMouse(true);
+ synthesizeMouse(gButton, 2, 2, { type: "mouseover" });
+ synthesizeMouse(gButton, 4, 4, { type: "mousemove" });
+ synthesizeMouse(gButton, 6, 6, { type: "mousemove" });
+ disableNonTestMouse(false);
+ },
+ result(testname) {
+ var buttonrect = document
+ .getElementById("withtooltip")
+ .getBoundingClientRect();
+ var tooltip = document.getElementById("thetooltip");
+ var rect = tooltip.getBoundingClientRect();
+ var popupstyle = window.getComputedStyle(tooltip);
+
+ // Offset does not apply to anchored tooltips
+ is(
+ Math.round(rect.top),
+ Math.round(buttonrect.bottom + parseFloat(popupstyle.marginTop)),
+ testname + " top position of tooltip"
+ );
+
+ tooltip.removeAttribute("onpopupshowing");
+ },
+},
];
var waitSteps = 0;
@@ -359,7 +397,14 @@ function moveWindowTo(x, y, callback, arg)
}
}
-window.arguments[0].SimpleTest.waitForFocus(runTest, window);
+(async function() {
+ let parent = window.arguments[0];
+ await Promise.all([
+ parent.SimpleTest.promiseFocus(window),
+ parent.SpecialPowers.pushPrefEnv({set: [["ui.tooltipOffsetVertical", kTooltipOffsetVertical]]}),
+ ]);
+ runTest();
+})();
]]>
</script>