2016-08-15 14:03:16 +00:00
|
|
|
/* 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 TooltipToggle helper class for HTMLTooltip
|
|
|
|
*/
|
|
|
|
|
|
|
|
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
2017-07-10 06:46:23 +00:00
|
|
|
const TEST_URI = CHROME_URL_ROOT + "doc_html_tooltip_hover.xul";
|
2016-08-15 14:03:16 +00:00
|
|
|
|
2016-10-05 02:48:49 +00:00
|
|
|
const {HTMLTooltip} = require("devtools/client/shared/widgets/tooltip/HTMLTooltip");
|
2016-08-15 14:03:16 +00:00
|
|
|
loadHelperScript("helper_html_tooltip.js");
|
|
|
|
|
|
|
|
add_task(function* () {
|
|
|
|
let [,, doc] = yield createHost("bottom", TEST_URI);
|
2017-02-03 11:52:28 +00:00
|
|
|
// Wait for full page load before synthesizing events on the page.
|
|
|
|
yield waitUntil(() => doc.readyState === "complete");
|
2016-08-15 14:03:16 +00:00
|
|
|
|
|
|
|
let width = 100, height = 50;
|
|
|
|
let tooltipContent = doc.createElementNS(HTML_NS, "div");
|
|
|
|
tooltipContent.textContent = "tooltip";
|
2016-10-08 13:49:07 +00:00
|
|
|
let tooltip = new HTMLTooltip(doc, {useXulWrapper: false});
|
2016-08-15 14:03:16 +00:00
|
|
|
tooltip.setContent(tooltipContent, {width, height});
|
|
|
|
|
|
|
|
let container = doc.getElementById("container");
|
|
|
|
tooltip.startTogglingOnHover(container, () => true);
|
|
|
|
|
|
|
|
info("Hover on each of the 4 boxes, expect the tooltip to appear");
|
|
|
|
function* showAndCheck(boxId, position) {
|
|
|
|
info(`Show tooltip on ${boxId}`);
|
|
|
|
let box = doc.getElementById(boxId);
|
|
|
|
let shown = tooltip.once("shown");
|
|
|
|
EventUtils.synthesizeMouseAtCenter(box, { type: "mousemove" }, doc.defaultView);
|
|
|
|
yield shown;
|
|
|
|
checkTooltipGeometry(tooltip, box, {position, width, height});
|
|
|
|
}
|
|
|
|
|
|
|
|
yield showAndCheck("box1", "bottom");
|
|
|
|
yield showAndCheck("box2", "bottom");
|
|
|
|
yield showAndCheck("box3", "top");
|
|
|
|
yield showAndCheck("box4", "top");
|
|
|
|
|
|
|
|
info("Move out of the container");
|
|
|
|
let hidden = tooltip.once("hidden");
|
2016-12-08 06:41:49 +00:00
|
|
|
EventUtils.synthesizeMouseAtCenter(container, { type: "mousemove" }, doc.defaultView);
|
2016-08-15 14:03:16 +00:00
|
|
|
yield hidden;
|
|
|
|
|
|
|
|
info("Destroy the tooltip and finish");
|
|
|
|
tooltip.destroy();
|
|
|
|
});
|