Bug 1753414 - stop switching tabs with the context menu open, r=NeilDeakin

Differential Revision: https://phabricator.services.mozilla.com/D138972
This commit is contained in:
Gijs Kruitbosch 2022-02-22 10:06:37 +00:00
Родитель 75f3f492e2
Коммит 814f569cac
4 изменённых файлов: 61 добавлений и 0 удалений

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

@ -5346,6 +5346,11 @@
return;
}
// Skip if chrome code has cancelled this:
if (aEvent.defaultPreventedByChrome) {
return;
}
// Don't check if the event was already consumed because tab
// navigation should always work for better user experience.
@ -5438,6 +5443,11 @@
return;
}
// Skip if chrome code has cancelled this:
if (aEvent.defaultPreventedByChrome) {
return;
}
switch (ShortcutUtils.getSystemActionForEvent(aEvent, { rtl: RTL_UI })) {
case ShortcutUtils.TOGGLE_CARET_BROWSING:
if (

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

@ -130,6 +130,7 @@ skip-if =
[browser_tabSpinnerProbe.js]
skip-if = !e10s # Tab spinner is e10s only.
[browser_tabSuccessors.js]
[browser_tabswitch_contextmenu.js]
[browser_tabswitch_updatecommands.js]
[browser_undo_close_tabs.js]
skip-if = true #bug 1642084

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

@ -0,0 +1,45 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Don't switch tabs via the keyboard while the contextmenu is open.
*/
add_task(async function cant_tabswitch_mid_contextmenu() {
let tab1 = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"https://example.com/idontexist"
);
let tab2 = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"https://example.org/idontexist"
);
const contextMenu = document.getElementById("contentAreaContextMenu");
let promisePopupShown = BrowserTestUtils.waitForPopupEvent(
contextMenu,
"shown"
);
await BrowserTestUtils.synthesizeMouse(
"body",
0,
0,
{
type: "contextmenu",
button: 2,
},
tab2.linkedBrowser
);
await promisePopupShown;
EventUtils.synthesizeKey("VK_TAB", { accelKey: true });
ok(tab2.selected, "tab2 should stay selected");
BrowserTestUtils.removeTab(tab1);
BrowserTestUtils.removeTab(tab2);
let promisePopupHidden = BrowserTestUtils.waitForPopupEvent(
contextMenu,
"hidden"
);
contextMenu.hidePopup();
await promisePopupHidden;
});

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

@ -117,6 +117,11 @@
return;
}
// Skip if chrome code has cancelled this:
if (event.defaultPreventedByChrome) {
return;
}
// Don't check if the event was already consumed because tab
// navigation should always work for better user experience.