// Hiding the tooltip is async so we need to wait for "hidden" to be emitted // timing out after 3 seconds. If hidden is emitted we need to fail, // otherwise the test passes. const shown = await Promise.race([
onHidden,
wait(PROMISE_TIMEOUT).then(() => true),
]);
ok(shown, "Tooltip is still visible");
tooltip.destroy();
}
async function testConsumeOutsideClicksFalse(doc) {
info("Test closing a tooltip via click with consumeOutsideClicks: false"); const box4 = doc.getElementById("box4");
is(tooltip.isVisible(), false, "Tooltip is hidden");
tooltip.destroy();
}
async function testConsumeOutsideClicksTrue(doc) {
info("Test closing a tooltip via click with consumeOutsideClicks: true"); const box4 = doc.getElementById("box4");
// Count clicks on box4
let box4clicks = 0;
box4.addEventListener("click", () => box4clicks++);
is(box4clicks, 0, "box4 catched no click event");
is(tooltip.isVisible(), false, "Tooltip is hidden");
tooltip.destroy();
}
async function testConsumeWithRightClick(doc) {
info( "Test closing a tooltip with a right-click, with consumeOutsideClicks: true"
); const box4 = doc.getElementById("box4");
// Only left-click events should be consumed, so we expect to catch a click when using // {button: 2}, which simulates a right-click.
info( "Right click on box4, expect tooltip to be hidden, event should not be consumed"
); const onBox4Clicked = once(box4, "click"); const onHidden = once(tooltip, "hidden");
EventUtils.synthesizeMouseAtCenter(box4, { button: 2 }, doc.defaultView);
await onHidden;
await onBox4Clicked;
is(tooltip.isVisible(), false, "Tooltip is hidden");
tooltip.destroy();
}
async function testClickInOuterIframe(doc) {
info("Test clicking an iframe outside of the tooltip closes the tooltip"); const frame = doc.getElementById("frame");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.