fune/devtools/client/shared/test/browser_html_tooltip-05.js
Yoshi Huang 7363e22f81 Bug 1377523 - Part 4: fix devtools/client/shared/test. r=pbro
Move data: URIs in devtools/client/shared/test to seperate files.


--HG--
rename : devtools/client/shared/test/browser_layoutHelpers-getBoxQuads.html => devtools/client/shared/test/doc_layoutHelpers-getBoxQuads.html
rename : devtools/client/shared/test/browser_layoutHelpers.html => devtools/client/shared/test/doc_layoutHelpers.html
rename : devtools/client/shared/test/html-mdn-css-basic-testing.html => devtools/client/shared/test/doc_mdn-css-basic-testing.html
rename : devtools/client/shared/test/html-mdn-css-no-summary-or-syntax.html => devtools/client/shared/test/doc_mdn-css-no-summary-or-syntax.html
rename : devtools/client/shared/test/html-mdn-css-no-summary.html => devtools/client/shared/test/doc_mdn-css-no-summary.html
rename : devtools/client/shared/test/html-mdn-css-no-syntax.html => devtools/client/shared/test/doc_mdn-css-no-syntax.html
rename : devtools/client/shared/test/html-mdn-css-syntax-old-style.html => devtools/client/shared/test/doc_mdn-css-syntax-old-style.html
rename : devtools/client/shared/test/browser_templater_basic.html => devtools/client/shared/test/doc_templater_basic.html
rename : devtools/client/shared/test/browser_toolbar_basic.html => devtools/client/shared/test/doc_toolbar_basic.html
2017-07-13 12:27:52 +08:00

98 lines
3.7 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* import-globals-from helper_html_tooltip.js */
"use strict";
/**
* Test the HTMLTooltip positioning for a huge tooltip element (can not fit in
* the viewport).
*/
const HTML_NS = "http://www.w3.org/1999/xhtml";
const TEST_URI = CHROME_URL_ROOT + "doc_html_tooltip-05.xul";
const {HTMLTooltip} = require("devtools/client/shared/widgets/tooltip/HTMLTooltip");
loadHelperScript("helper_html_tooltip.js");
const TOOLTIP_HEIGHT = 200;
const TOOLTIP_WIDTH = 200;
add_task(function* () {
// Force the toolbox to be 200px high;
yield pushPref("devtools.toolbox.footer.height", 200);
yield addTab("about:blank");
let [,, doc] = yield createHost("bottom", TEST_URI);
info("Create HTML tooltip");
let tooltip = new HTMLTooltip(doc, {useXulWrapper: false});
let div = doc.createElementNS(HTML_NS, "div");
div.style.height = "100%";
tooltip.setContent(div, {width: TOOLTIP_WIDTH, height: TOOLTIP_HEIGHT});
let box1 = doc.getElementById("box1");
let box2 = doc.getElementById("box2");
let box3 = doc.getElementById("box3");
let box4 = doc.getElementById("box4");
let width = TOOLTIP_WIDTH;
// box1: Can not fit above or below box1, default to bottom with a reduced
// height of 150px.
info("Display the tooltip on box1.");
yield showTooltip(tooltip, box1);
let expectedTooltipGeometry = {position: "bottom", height: 150, width};
checkTooltipGeometry(tooltip, box1, expectedTooltipGeometry);
yield hideTooltip(tooltip);
info("Try to display the tooltip on top of box1.");
yield showTooltip(tooltip, box1, {position: "top"});
expectedTooltipGeometry = {position: "bottom", height: 150, width};
checkTooltipGeometry(tooltip, box1, expectedTooltipGeometry);
yield hideTooltip(tooltip);
// box2: Can not fit above or below box2, default to bottom with a reduced
// height of 100px.
info("Try to display the tooltip on box2.");
yield showTooltip(tooltip, box2);
expectedTooltipGeometry = {position: "bottom", height: 100, width};
checkTooltipGeometry(tooltip, box2, expectedTooltipGeometry);
yield hideTooltip(tooltip);
info("Try to display the tooltip on top of box2.");
yield showTooltip(tooltip, box2, {position: "top"});
expectedTooltipGeometry = {position: "bottom", height: 100, width};
checkTooltipGeometry(tooltip, box2, expectedTooltipGeometry);
yield hideTooltip(tooltip);
// box3: Can not fit above or below box3, default to top with a reduced height
// of 100px.
info("Try to display the tooltip on box3.");
yield showTooltip(tooltip, box3);
expectedTooltipGeometry = {position: "top", height: 100, width};
checkTooltipGeometry(tooltip, box3, expectedTooltipGeometry);
yield hideTooltip(tooltip);
info("Try to display the tooltip on bottom of box3.");
yield showTooltip(tooltip, box3, {position: "bottom"});
expectedTooltipGeometry = {position: "top", height: 100, width};
checkTooltipGeometry(tooltip, box3, expectedTooltipGeometry);
yield hideTooltip(tooltip);
// box4: Can not fit above or below box4, default to top with a reduced height
// of 150px.
info("Display the tooltip on box4.");
yield showTooltip(tooltip, box4);
expectedTooltipGeometry = {position: "top", height: 150, width};
checkTooltipGeometry(tooltip, box4, expectedTooltipGeometry);
yield hideTooltip(tooltip);
info("Try to display the tooltip on bottom of box4.");
yield showTooltip(tooltip, box4, {position: "bottom"});
expectedTooltipGeometry = {position: "top", height: 150, width};
checkTooltipGeometry(tooltip, box4, expectedTooltipGeometry);
yield hideTooltip(tooltip);
is(tooltip.isVisible(), false, "Tooltip is not visible");
tooltip.destroy();
});