Bug 1266456 - part1: HTMLTooltip cleanup test & jsdoc for synchronous setContent;r=jsnajdr
MozReview-Commit-ID: Ia3aRmwFawP
--- a/devtools/client/shared/test/browser_html_tooltip-01.js
+++ b/devtools/client/shared/test/browser_html_tooltip-01.js
@@ -35,17 +35,17 @@ function getTooltipContent(doc) {
add_task(function* () {
yield addTab("about:blank");
let [,, doc] = yield createHost("bottom", TEST_URI);
let tooltip = new HTMLTooltip({doc}, {});
info("Set tooltip content");
- yield tooltip.setContent(getTooltipContent(doc), 100, 50);
+ tooltip.setContent(getTooltipContent(doc), 100, 50);
is(tooltip.isVisible(), false, "Tooltip is not visible");
info("Show the tooltip and check the expected events are fired.");
let shown = 0;
tooltip.on("shown", () => shown++);
--- a/devtools/client/shared/test/browser_html_tooltip-02.js
+++ b/devtools/client/shared/test/browser_html_tooltip-02.js
@@ -37,33 +37,33 @@ add_task(function* () {
yield testClickInOuterIframe(doc);
yield testClickInInnerIframe(doc);
});
function* testClickInTooltipContent(doc) {
info("Test a tooltip is not closed when clicking inside itself");
let tooltip = new HTMLTooltip({doc}, {});
- yield tooltip.setContent(getTooltipContent(doc), 100, 50);
+ tooltip.setContent(getTooltipContent(doc), 100, 50);
yield showTooltip(tooltip, doc.getElementById("box1"));
let onTooltipContainerClick = once(tooltip.container, "click");
EventUtils.synthesizeMouseAtCenter(tooltip.container, {}, doc.defaultView);
yield onTooltipContainerClick;
is(tooltip.isVisible(), true, "Tooltip is still visible");
tooltip.destroy();
}
function* testConsumeOutsideClicksFalse(doc) {
info("Test closing a tooltip via click with consumeOutsideClicks: false");
let box4 = doc.getElementById("box4");
let tooltip = new HTMLTooltip({doc}, {consumeOutsideClicks: false});
- yield tooltip.setContent(getTooltipContent(doc), 100, 50);
+ tooltip.setContent(getTooltipContent(doc), 100, 50);
yield showTooltip(tooltip, doc.getElementById("box1"));
let onBox4Clicked = once(box4, "click");
let onHidden = once(tooltip, "hidden");
EventUtils.synthesizeMouseAtCenter(box4, {}, doc.defaultView);
yield onHidden;
yield onBox4Clicked;
@@ -76,17 +76,17 @@ function* testConsumeOutsideClicksTrue(d
info("Test closing a tooltip via click with consumeOutsideClicks: true");
let box4 = doc.getElementById("box4");
// Count clicks on box4
let box4clicks = 0;
box4.addEventListener("click", () => box4clicks++);
let tooltip = new HTMLTooltip({doc}, {consumeOutsideClicks: true});
- yield tooltip.setContent(getTooltipContent(doc), 100, 50);
+ tooltip.setContent(getTooltipContent(doc), 100, 50);
yield showTooltip(tooltip, doc.getElementById("box1"));
let onHidden = once(tooltip, "hidden");
EventUtils.synthesizeMouseAtCenter(box4, {}, doc.defaultView);
yield onHidden;
is(box4clicks, 0, "box4 catched no click event");
is(tooltip.isVisible(), false, "Tooltip is hidden");
@@ -94,17 +94,17 @@ function* testConsumeOutsideClicksTrue(d
tooltip.destroy();
}
function* testClickInOuterIframe(doc) {
info("Test clicking an iframe outside of the tooltip closes the tooltip");
let frame = doc.getElementById("frame");
let tooltip = new HTMLTooltip({doc});
- yield tooltip.setContent(getTooltipContent(doc), 100, 50);
+ tooltip.setContent(getTooltipContent(doc), 100, 50);
yield showTooltip(tooltip, doc.getElementById("box1"));
let onHidden = once(tooltip, "hidden");
EventUtils.synthesizeMouseAtCenter(frame, {}, doc.defaultView);
yield onHidden;
is(tooltip.isVisible(), false, "Tooltip is hidden");
tooltip.destroy();
@@ -113,17 +113,17 @@ function* testClickInOuterIframe(doc) {
function* testClickInInnerIframe(doc) {
info("Test clicking an iframe inside the tooltip content does not close the tooltip");
let tooltip = new HTMLTooltip({doc}, {consumeOutsideClicks: false});
let iframe = doc.createElementNS(HTML_NS, "iframe");
iframe.style.width = "100px";
iframe.style.height = "50px";
- yield tooltip.setContent(iframe, 100, 50);
+ tooltip.setContent(iframe, 100, 50);
yield showTooltip(tooltip, doc.getElementById("box1"));
let onTooltipContainerClick = once(tooltip.container, "click");
EventUtils.synthesizeMouseAtCenter(tooltip.container, {}, doc.defaultView);
yield onTooltipContainerClick;
is(tooltip.isVisible(), true, "Tooltip is still visible");
--- a/devtools/client/shared/test/browser_html_tooltip-03.js
+++ b/devtools/client/shared/test/browser_html_tooltip-03.js
@@ -127,11 +127,11 @@ function blurNode(doc, selector) {
*/
function* createTooltip(doc, autofocus) {
let tooltip = new HTMLTooltip({doc}, {autofocus});
let div = doc.createElementNS(HTML_NS, "div");
div.classList.add("tooltip-content");
div.style.height = "50px";
div.innerHTML = '<input type="text"></input>';
- yield tooltip.setContent(div, 150, 50);
+ tooltip.setContent(div, 150, 50);
return tooltip;
}
--- a/devtools/client/shared/test/browser_html_tooltip-04.js
+++ b/devtools/client/shared/test/browser_html_tooltip-04.js
@@ -38,17 +38,17 @@ add_task(function* () {
yield addTab("about:blank");
let [,, doc] = yield createHost("bottom", TEST_URI);
info("Create HTML tooltip");
let tooltip = new HTMLTooltip({doc}, {});
let div = doc.createElementNS(HTML_NS, "div");
div.style.height = "100%";
- yield tooltip.setContent(div, TOOLTIP_WIDTH, TOOLTIP_HEIGHT);
+ tooltip.setContent(div, TOOLTIP_WIDTH, TOOLTIP_HEIGHT);
let box1 = doc.getElementById("box1");
let box2 = doc.getElementById("box2");
let box3 = doc.getElementById("box3");
let box4 = doc.getElementById("box4");
let height = TOOLTIP_HEIGHT, width = TOOLTIP_WIDTH;
// box1: Can only fit below box1
--- a/devtools/client/shared/test/browser_html_tooltip-05.js
+++ b/devtools/client/shared/test/browser_html_tooltip-05.js
@@ -35,17 +35,17 @@ add_task(function* () {
yield addTab("about:blank");
let [,, doc] = yield createHost("bottom", TEST_URI);
info("Create HTML tooltip");
let tooltip = new HTMLTooltip({doc}, {});
let div = doc.createElementNS(HTML_NS, "div");
div.style.height = "100%";
- yield tooltip.setContent(div, TOOLTIP_WIDTH, TOOLTIP_HEIGHT);
+ tooltip.setContent(div, TOOLTIP_WIDTH, 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
--- a/devtools/client/shared/test/browser_html_tooltip_arrow-01.js
+++ b/devtools/client/shared/test/browser_html_tooltip_arrow-01.js
@@ -55,17 +55,17 @@ add_task(function* () {
yield addTab("about:blank");
let [,, doc] = yield createHost("bottom", TEST_URI);
info("Create HTML tooltip");
let tooltip = new HTMLTooltip({doc}, {type: "arrow"});
let div = doc.createElementNS(HTML_NS, "div");
div.style.height = "35px";
- yield tooltip.setContent(div, 200, 35);
+ tooltip.setContent(div, 200, 35);
let {right: docRight} = doc.documentElement.getBoundingClientRect();
let elements = [...doc.querySelectorAll(".anchor")];
for (let el of elements) {
info("Display the tooltip on an anchor.");
yield showTooltip(tooltip, el);
--- a/devtools/client/shared/test/browser_html_tooltip_arrow-02.js
+++ b/devtools/client/shared/test/browser_html_tooltip_arrow-02.js
@@ -49,17 +49,17 @@ add_task(function* () {
yield addTab("about:blank");
let [,, doc] = yield createHost("bottom", TEST_URI);
info("Create HTML tooltip");
let tooltip = new HTMLTooltip({doc}, {type: "arrow"});
let div = doc.createElementNS(HTML_NS, "div");
div.style.height = "35px";
- yield tooltip.setContent(div, 200, 35);
+ tooltip.setContent(div, 200, 35);
let {right: docRight} = doc.documentElement.getBoundingClientRect();
let elements = [...doc.querySelectorAll(".anchor")];
for (let el of elements) {
info("Display the tooltip on an anchor.");
yield showTooltip(tooltip, el);
--- a/devtools/client/shared/widgets/HTMLTooltip.js
+++ b/devtools/client/shared/widgets/HTMLTooltip.js
@@ -110,18 +110,16 @@ HTMLTooltip.prototype = {
* The tooltip content, should be a HTML element.
* @param {Number} width
* Preferred width for the tooltip container
* @param {Number} height (optional)
* Preferred height for the tooltip container. If the content height is
* smaller than the container's height, the tooltip will automatically
* shrink around the content. If not specified, will use all the height
* available.
- * @return {Promise} a promise that will resolve when the content has been
- * added in the tooltip container.
*/
setContent: function (content, width, height = Infinity) {
let themeHeight = EXTRA_HEIGHT[this.type] + 2 * EXTRA_BORDER[this.type];
let themeWidth = 2 * EXTRA_BORDER[this.type];
this.preferredWidth = width + themeWidth;
this.preferredHeight = height + themeHeight;