mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 00:05:36 +00:00
Bug 1286553 - HTMLTooltip: consume only left click events;r=bgrins
MozReview-Commit-ID: Hr0Lwv8Zx5C --HG-- extra : rebase_source : 5464c3881db5ad0413cb3ca3a8103c88d970d851
This commit is contained in:
parent
bd810d4350
commit
50dbb87670
@ -46,6 +46,7 @@ function* runTests(doc) {
|
||||
yield testClickInTooltipContent(doc);
|
||||
yield testConsumeOutsideClicksFalse(doc);
|
||||
yield testConsumeOutsideClicksTrue(doc);
|
||||
yield testConsumeWithRightClick(doc);
|
||||
yield testClickInOuterIframe(doc);
|
||||
yield testClickInInnerIframe(doc);
|
||||
}
|
||||
@ -106,6 +107,28 @@ function* testConsumeOutsideClicksTrue(doc) {
|
||||
tooltip.destroy();
|
||||
}
|
||||
|
||||
function* testConsumeWithRightClick(doc) {
|
||||
info("Test closing a tooltip with a right-click, with consumeOutsideClicks: true");
|
||||
let box4 = doc.getElementById("box4");
|
||||
|
||||
let tooltip = new HTMLTooltip({doc}, {consumeOutsideClicks: true, useXulWrapper});
|
||||
tooltip.setContent(getTooltipContent(doc), {width: 100, height: 50});
|
||||
yield showTooltip(tooltip, doc.getElementById("box1"));
|
||||
|
||||
// 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");
|
||||
let onBox4Clicked = once(box4, "click");
|
||||
let onHidden = once(tooltip, "hidden");
|
||||
EventUtils.synthesizeMouseAtCenter(box4, {button: 2}, doc.defaultView);
|
||||
yield onHidden;
|
||||
yield onBox4Clicked;
|
||||
|
||||
is(tooltip.isVisible(), false, "Tooltip is hidden");
|
||||
|
||||
tooltip.destroy();
|
||||
}
|
||||
|
||||
function* testClickInOuterIframe(doc) {
|
||||
info("Test clicking an iframe outside of the tooltip closes the tooltip");
|
||||
let frame = doc.getElementById("frame");
|
||||
|
@ -491,7 +491,8 @@ HTMLTooltip.prototype = {
|
||||
}
|
||||
|
||||
this.hide();
|
||||
if (this.consumeOutsideClicks) {
|
||||
if (this.consumeOutsideClicks && e.button === 0) {
|
||||
// Consume only left click events (button === 0).
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user