Bug 1677334 - Part 2: Remove Mac-specific check for click event on xul frame; r=NeilDeakin

Now we won't dispatch click event at all when ctrl key is pressed on Mac, so we
don't need those Mac-specific checks.

This patch reverts part of https://hg.mozilla.org/mozilla-central/rev/d8726d18021e
and revise the tests accordingly.

Differential Revision: https://phabricator.services.mozilla.com/D110608
This commit is contained in:
Edgar Chen 2021-04-07 11:23:45 +00:00
Родитель 20e4184d91
Коммит 142488d3c4
8 изменённых файлов: 6 добавлений и 50 удалений

Просмотреть файл

@ -4,15 +4,6 @@
"use strict";
add_task(async function test_character_encoding_menu() {
// On macOS, ctrl-click shouldn't open the panel because this normally opens
// the context menu. This happens via the `contextmenu` event which is created
// by widget code, so our simulated clicks do not do so, so we can't test
// anything on macOS.
if (AppConstants.platform == "macosx") {
ok(true, "The test is ignored on Mac");
return;
}
CustomizableUI.addWidgetToArea(
"characterencoding-button",
CustomizableUI.AREA_NAVBAR,

Просмотреть файл

@ -59,16 +59,6 @@ add_task(async function test_clickData() {
for (let modifier of Object.keys(map)) {
for (let i = 0; i < 2; i++) {
// On Mac, ctrl-click will send a context menu event from the widget,
// we won't send xul command event and won't have onClick message, either.
if (
AppConstants.platform == "macosx" &&
i == 0 &&
modifier == "ctrlKey"
) {
continue;
}
let clickEventData = { button: i };
clickEventData[modifier] = true;
await clickBrowserAction(extension, window, clickEventData);

Просмотреть файл

@ -155,15 +155,7 @@ nsresult nsButtonBoxFrame::HandleEvent(nsPresContext* aPresContext,
case eMouseClick: {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->IsLeftClickEvent()
#ifdef XP_MACOSX
// On Mac, ctrl-click will send a context menu event from the widget,
// so we don't want to dispatch widget command if it is redispatched
// from the mouse event with ctrl key is pressed.
&& !mouseEvent->IsControl()
#endif
) {
if (mouseEvent->IsLeftClickEvent()) {
MouseClicked(mouseEvent);
}
break;

Просмотреть файл

@ -286,14 +286,7 @@ nsresult nsResizerFrame::HandleEvent(nsPresContext* aPresContext,
case eMouseClick: {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->IsLeftClickEvent()
#ifdef XP_MACOSX
// On Mac, ctrl-click will send a context menu event from the widget,
// so we don't want to dispatch widget command if it is redispatched
// from the mouse event with ctrl key is pressed.
&& !mouseEvent->IsControl()
#endif
) {
if (mouseEvent->IsLeftClickEvent()) {
MouseClicked(mouseEvent);
}
break;

Просмотреть файл

@ -134,14 +134,7 @@ nsresult nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
case eMouseClick: {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->IsLeftClickEvent()
#ifdef XP_MACOSX
// On Mac, ctrl-click will send a context menu event from the widget,
// so we don't want to dispatch widget command if it is redispatched
// from the mouse event with ctrl key is pressed.
&& !mouseEvent->IsControl()
#endif
) {
if (mouseEvent->IsLeftClickEvent()) {
MouseClicked(mouseEvent);
}
break;

Просмотреть файл

@ -27,8 +27,7 @@ function test_resizer_ctrl_click()
resizer.addEventListener("click", function(aEvent) {
// Delay check for command event, because it is fired after click event.
setTimeout(() => {
is(isCommandFired, AppConstants.platform != "macosx",
"Check if command event is fired");
ok(isCommandFired, "Check if command event is fired");
SimpleTest.finish();
}, 0);
});

Просмотреть файл

@ -29,8 +29,7 @@ function test_titlebar_ctrl_click()
titlebar.addEventListener("click", function(aEvent) {
// Delay check for command event, because it is fired after click event.
setTimeout(() => {
is(isCommandFired, AppConstants.platform != "macosx",
"Check if command event is fired");
ok(isCommandFired, "Check if command event is fired");
SimpleTest.finish();
}, 0);
});

Просмотреть файл

@ -27,8 +27,7 @@ function test_resizer_ctrl_click()
toolbarbutton.addEventListener("click", function(aEvent) {
// Delay check for command event, because it is fired after click event.
setTimeout(() => {
is(isCommandFired, AppConstants.platform != "macosx",
"Check if command event is fired");
ok(isCommandFired, "Check if command event is fired");
SimpleTest.finish();
}, 0);
});