зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1615732 - Don't show menu panel on Mac when ctrl key is pressed; r=Gijs
On Mac, ctrl-click will send a context menu event from the widget, so we don't want to bring up the panel when ctrl key is pressed. Differential Revision: https://phabricator.services.mozilla.com/D66397 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
feb7fe3776
Коммит
9e5dc0120e
|
@ -302,7 +302,12 @@ const PanelUI = {
|
|||
}
|
||||
break;
|
||||
case "mousedown":
|
||||
if (aEvent.button == 0) {
|
||||
// On Mac, ctrl-click will send a context menu event from the widget, so
|
||||
// we don't want to bring up the panel when ctrl key is pressed.
|
||||
if (
|
||||
aEvent.button == 0 &&
|
||||
(AppConstants.platform != "macosx" || !aEvent.ctrlKey)
|
||||
) {
|
||||
this.toggle(aEvent);
|
||||
}
|
||||
break;
|
||||
|
@ -380,7 +385,13 @@ const PanelUI = {
|
|||
async showSubView(aViewId, aAnchor, aEvent) {
|
||||
let domEvent = null;
|
||||
if (aEvent) {
|
||||
if (aEvent.type == "mousedown" && aEvent.button != 0) {
|
||||
// On Mac, ctrl-click will send a context menu event from the widget, so
|
||||
// we don't want to bring up the panel when ctrl key is pressed.
|
||||
if (
|
||||
aEvent.type == "mousedown" &&
|
||||
(aEvent.button != 0 ||
|
||||
(AppConstants.platform == "macosx" && aEvent.ctrlKey))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
|
|
|
@ -137,6 +137,7 @@ skip-if = verify
|
|||
[browser_1484275_PanelMultiView_toggle_with_other_popup.js]
|
||||
[browser_allow_dragging_removable_false.js]
|
||||
[browser_bootstrapped_custom_toolbar.js]
|
||||
[browser_ctrl_click_panel_opening.js]
|
||||
[browser_currentset_post_reset.js]
|
||||
[browser_customizemode_contextmenu_menubuttonstate.js]
|
||||
skip-if = os == "win" && bits == 64 # 1526429
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_appMenu_mainView() {
|
||||
// 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;
|
||||
}
|
||||
|
||||
const mainView = document.getElementById("appMenu-mainView");
|
||||
|
||||
let shownPromise = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
|
||||
// Should still open the panel when Ctrl key is pressed.
|
||||
EventUtils.synthesizeMouseAtCenter(PanelUI.menuButton, { ctrlKey: true });
|
||||
await shownPromise;
|
||||
ok(true, "Main menu shown after button pressed");
|
||||
|
||||
// Close the main panel.
|
||||
let hiddenPromise = BrowserTestUtils.waitForEvent(document, "popuphidden");
|
||||
mainView.closest("panel").hidePopup();
|
||||
await hiddenPromise;
|
||||
});
|
||||
|
||||
add_task(async function test_appMenu_libraryView() {
|
||||
// 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;
|
||||
}
|
||||
|
||||
const libraryView = document.getElementById("appMenu-libraryView");
|
||||
const button = document.getElementById("library-button");
|
||||
|
||||
let shownPromise = BrowserTestUtils.waitForEvent(libraryView, "ViewShown");
|
||||
// Should still open the panel when Ctrl key is pressed.
|
||||
EventUtils.synthesizeMouseAtCenter(button, { ctrlKey: true });
|
||||
await shownPromise;
|
||||
ok(true, "Library menu shown after button pressed");
|
||||
|
||||
// Close the Library panel.
|
||||
let hiddenPromise = BrowserTestUtils.waitForEvent(document, "popuphidden");
|
||||
libraryView.closest("panel").hidePopup();
|
||||
await hiddenPromise;
|
||||
});
|
Загрузка…
Ссылка в новой задаче