Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Bug 829651 - middle-click on widget shows erroneously the attached panel
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkaPola authored and ochameau committed Jan 21, 2013
1 parent 203f880 commit 74a16ee
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/sdk/widget.js
Expand Up @@ -841,8 +841,8 @@ WidgetChrome.prototype.addEventHandlers = function WC_addEventHandlers() {
return;

// The widget only supports left-click for now,
// so ignore right-clicks.
if (e.type == "click" && e.button == 2)
// so ignore all clicks (i.e. middle or right) except left ones.
if (e.type == "click" && e.button != 0)
return;

// Proxy event to the widget
Expand Down
31 changes: 28 additions & 3 deletions test/test-widget.js
Expand Up @@ -640,7 +640,7 @@ exports.testConstructor = function(test) {
}));

// test click handler not respond to right-click
let clickCount = 0;
let rightClickCount = 0;
tests.push(function testNoRightClick() testSingleWidget({
id: "click-content",
label: "click test widget - content",
Expand All @@ -656,9 +656,34 @@ exports.testConstructor = function(test) {
"evt.initEvent('mouseover', true, true ); " +
"document.getElementById('me').dispatchEvent(evt);",
contentScriptWhen: "end",
onClick: function() clickCount++,
onClick: function() rightClickCount++,
onMouseover: function() {
test.assertEqual(clickCount, 1, "right click wasn't sent to click handler");
test.assertEqual(rightClickCount, 1, "right click wasn't sent to click handler");
this.destroy();
doneTest();
}
}));

// test click handler not respond to middle-click
let middleClickCount = 0;
tests.push(function testNoMiddleClick() testSingleWidget({
id: "click-content",
label: "click test widget - content",
content: "<div id='me'>foo</div>",
contentScript: "var evt = document.createEvent('MouseEvents'); " +
"evt.initMouseEvent('click', true, true, window, " +
" 0, 0, 0, 0, 0, false, false, false, false, 1, null); " +
"document.getElementById('me').dispatchEvent(evt); " +
"evt = document.createEvent('HTMLEvents'); " +
"evt.initEvent('click', true, true ); " +
"document.getElementById('me').dispatchEvent(evt); " +
"evt = document.createEvent('HTMLEvents'); " +
"evt.initEvent('mouseover', true, true ); " +
"document.getElementById('me').dispatchEvent(evt);",
contentScriptWhen: "end",
onClick: function() middleClickCount++,
onMouseover: function() {
test.assertEqual(middleClickCount, 1, "middle click wasn't sent to click handler");
this.destroy();
doneTest();
}
Expand Down

0 comments on commit 74a16ee

Please sign in to comment.