зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1266450 - part3: fix helper to check if click occurred in tooltip;r=bgrins
The existing helper checking if a click occurred inside or outside a HTMLTooltip container was failing if the click occurred in an iframe. MozReview-Commit-ID: 9AIACOukYUF --HG-- extra : rebase_source : e10ce05610e9a630ed1d9ba8a3f70b3344dffe9e extra : source : 978c01749bdc4012f010db5fe09b0f8a402a9c0e
This commit is contained in:
Родитель
b46591f37c
Коммит
14ed6c99b4
|
@ -12,13 +12,16 @@ const HTML_NS = "http://www.w3.org/1999/xhtml";
|
|||
const TEST_URI = `data:text/xml;charset=UTF-8,<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css"?>
|
||||
<?xml-stylesheet href="chrome://devtools/skin/tooltips.css"?>
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="Tooltip test">
|
||||
<window
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
htmlns="http://www.w3.org/1999/xhtml"
|
||||
title="Tooltip test">
|
||||
<vbox flex="1">
|
||||
<hbox id="box1" flex="1">test1</hbox>
|
||||
<hbox id="box2" flex="1">test2</hbox>
|
||||
<hbox id="box3" flex="1">test3</hbox>
|
||||
<hbox id="box4" flex="1">test4</hbox>
|
||||
<iframe id="frame" width="200"></iframe>
|
||||
</vbox>
|
||||
</window>`;
|
||||
|
||||
|
@ -32,6 +35,7 @@ add_task(function* () {
|
|||
yield testTooltipNotClosingOnInsideClick(doc);
|
||||
yield testConsumeOutsideClicksFalse(doc);
|
||||
yield testConsumeOutsideClicksTrue(doc);
|
||||
yield testClickInsideIframe(doc);
|
||||
});
|
||||
|
||||
function* testTooltipNotClosingOnInsideClick(doc) {
|
||||
|
@ -90,6 +94,22 @@ function* testConsumeOutsideClicksTrue(doc) {
|
|||
tooltip.destroy();
|
||||
}
|
||||
|
||||
function* testClickInsideIframe(doc) {
|
||||
info("Test closing a tooltip via click inside an iframe");
|
||||
let frame = doc.getElementById("frame");
|
||||
|
||||
let tooltip = new HTMLTooltip({doc});
|
||||
yield 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();
|
||||
}
|
||||
|
||||
function getTooltipContent(doc) {
|
||||
let div = doc.createElementNS(HTML_NS, "div");
|
||||
div.style.height = "50px";
|
||||
|
|
|
@ -229,22 +229,27 @@ HTMLTooltip.prototype = {
|
|||
},
|
||||
|
||||
_isInTooltipContainer: function (node) {
|
||||
let contentWindow = this.panel.ownerDocument.defaultView;
|
||||
let tooltipWindow = this.panel.ownerDocument.defaultView;
|
||||
let win = node.ownerDocument.defaultView;
|
||||
|
||||
if (win === contentWindow) {
|
||||
// If node is in the same window as the tooltip, check if the tooltip
|
||||
// parent contains node.
|
||||
if (this.arrow && this.arrow === node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (win === tooltipWindow) {
|
||||
// If node is in the same window as the tooltip, check if the tooltip panel
|
||||
// contains node.
|
||||
return this.panel.contains(node);
|
||||
}
|
||||
|
||||
// Otherwise check if the node window is in the tooltip window.
|
||||
// Otherwise check if the node window is in the tooltip container.
|
||||
while (win.parent && win.parent != win) {
|
||||
win = win.parent;
|
||||
if (win === contentWindow) {
|
||||
return true;
|
||||
if (win === tooltipWindow) {
|
||||
return this.panel.contains(win.frameElement);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче