Bug 991111 - Middle clicks on tiles are not counted [r=adw]

Move the click listener to the xul window to correctly get the click event to filter for site-related clicks.

--HG--
extra : rebase_source : 3fd8b2c658a695fbc9aa79d09f461acaeef2078f
This commit is contained in:
Ed Lee 2014-04-15 12:14:08 -07:00
parent 4bffb6f53a
commit ac847ef39e
3 changed files with 29 additions and 2 deletions

View File

@ -169,7 +169,10 @@ Site.prototype = {
this._node.addEventListener("dragstart", this, false); this._node.addEventListener("dragstart", this, false);
this._node.addEventListener("dragend", this, false); this._node.addEventListener("dragend", this, false);
this._node.addEventListener("mouseover", this, false); this._node.addEventListener("mouseover", this, false);
this._node.addEventListener("click", this, false);
// XXX bug 991111 - Not all click events are correctly triggered when
// listening from the xhtml node, so listen from the xul window and filter
addEventListener("click", this, false);
// Specially treat the sponsored icon to prevent regular hover effects // Specially treat the sponsored icon to prevent regular hover effects
let sponsored = this._querySelector(".newtab-control-sponsored"); let sponsored = this._querySelector(".newtab-control-sponsored");
@ -240,7 +243,11 @@ Site.prototype = {
handleEvent: function Site_handleEvent(aEvent) { handleEvent: function Site_handleEvent(aEvent) {
switch (aEvent.type) { switch (aEvent.type) {
case "click": case "click":
this._onClick(aEvent); // Check the bitmask if the click event is for the site's descendants
if (this._node.compareDocumentPosition(aEvent.target) &
this._node.DOCUMENT_POSITION_CONTAINED_BY) {
this._onClick(aEvent);
}
break; break;
case "mouseover": case "mouseover":
this._node.removeEventListener("mouseover", this, false); this._node.removeEventListener("mouseover", this, false);

View File

@ -15,6 +15,7 @@ skip-if = os == "mac" # Intermittent failures, bug 898317
[browser_newtab_bug752841.js] [browser_newtab_bug752841.js]
[browser_newtab_bug765628.js] [browser_newtab_bug765628.js]
[browser_newtab_bug876313.js] [browser_newtab_bug876313.js]
[browser_newtab_bug991111.js]
[browser_newtab_disable.js] [browser_newtab_disable.js]
[browser_newtab_drag_drop.js] [browser_newtab_drag_drop.js]
[browser_newtab_drag_drop_ext.js] [browser_newtab_drag_drop_ext.js]

View File

@ -0,0 +1,19 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function runTests() {
yield setLinks("0");
yield addNewTabPageTab();
// Remember if the click handler was triggered
let cell = getCell(0);
let clicked = false;
cell.site._onClick = e => {
clicked = true;
executeSoon(TestRunner.next);
};
// Send a middle-click and make sure it happened
yield EventUtils.synthesizeMouseAtCenter(cell.node, {button: 1}, getContentWindow());
ok(clicked, "middle click triggered click listener");
}