browser_html_tooltip_consecutive-show.js (2057B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 /* import-globals-from helper_html_tooltip.js */ 4 5 "use strict"; 6 7 /** 8 * Test the HTMLTooltip show can be called several times. It should move according to the 9 * new anchor/options and should not leak event listeners. 10 */ 11 12 const HTML_NS = "http://www.w3.org/1999/xhtml"; 13 const TEST_URI = CHROME_URL_ROOT + "doc_html_tooltip.xhtml"; 14 15 const { 16 HTMLTooltip, 17 } = require("resource://devtools/client/shared/widgets/tooltip/HTMLTooltip.js"); 18 loadHelperScript("helper_html_tooltip.js"); 19 20 function getTooltipContent(doc) { 21 const div = doc.createElementNS(HTML_NS, "div"); 22 div.style.height = "50px"; 23 div.textContent = "tooltip"; 24 return div; 25 } 26 27 add_task(async function () { 28 const { doc } = await createHost("bottom", TEST_URI); 29 30 // Creating a host is not correctly waiting when DevTools run in content frame 31 // See Bug 1571421. 32 await wait(1000); 33 34 const box1 = doc.getElementById("box1"); 35 const box2 = doc.getElementById("box2"); 36 const box3 = doc.getElementById("box3"); 37 const box4 = doc.getElementById("box4"); 38 39 const width = 100, 40 height = 50; 41 42 const tooltip = new HTMLTooltip(doc, { useXulWrapper: false }); 43 tooltip.panel.appendChild(getTooltipContent(doc)); 44 tooltip.setContentSize({ width, height }); 45 46 info( 47 "Show the tooltip on each of the 4 hbox, without calling hide in between" 48 ); 49 50 info("Show tooltip on box1"); 51 tooltip.show(box1); 52 checkTooltipGeometry(tooltip, box1, { position: "bottom", width, height }); 53 54 info("Show tooltip on box2"); 55 tooltip.show(box2); 56 checkTooltipGeometry(tooltip, box2, { position: "bottom", width, height }); 57 58 info("Show tooltip on box3"); 59 tooltip.show(box3); 60 checkTooltipGeometry(tooltip, box3, { position: "top", width, height }); 61 62 info("Show tooltip on box4"); 63 tooltip.show(box4); 64 checkTooltipGeometry(tooltip, box4, { position: "top", width, height }); 65 66 info("Hide tooltip before leaving test"); 67 await hideTooltip(tooltip); 68 69 tooltip.destroy(); 70 });