Bug 1615732 - Don't show download 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/D66414

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Edgar Chen 2020-03-17 01:03:00 +00:00
Родитель 9e5dc0120e
Коммит 7e26f04dd1
3 изменённых файлов: 41 добавлений и 1 удалений

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

@ -568,7 +568,11 @@ const DownloadsIndicatorView = {
onCommand(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.
(aEvent.type == "mousedown" &&
(aEvent.button != 0 ||
(AppConstants.platform == "macosx" && aEvent.ctrlKey))) ||
(aEvent.type == "keypress" && aEvent.key != " " && aEvent.key != "Enter")
) {
return;

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

@ -15,6 +15,7 @@ skip-if = (os == 'win' && os_version == '10.0' && ccov) # Bug 1306510
[browser_library_clearall.js]
[browser_downloads_panel_block.js]
skip-if = true # Bug 1352792
[browser_downloads_panel_ctrl_click.js]
[browser_downloads_panel_height.js]
[browser_downloads_autohide.js]
[browser_go_to_download_page.js]

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

@ -0,0 +1,35 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function test_downloads_panel() {
// 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;
}
await SpecialPowers.pushPrefEnv({
set: [["browser.download.autohideButton", false]],
});
await promiseButtonShown("downloads-button");
const button = document.getElementById("downloads-button");
let shownPromise = promisePanelOpened();
// Should still open the panel when Ctrl key is pressed.
EventUtils.synthesizeMouseAtCenter(button, { ctrlKey: true });
await shownPromise;
is(DownloadsPanel.panel.state, "open", "Check that panel state is 'open'");
// Close download panel
DownloadsPanel.hidePanel();
is(
DownloadsPanel.panel.state,
"closed",
"Check that panel state is 'closed'"
);
});