Bug 1923041 - Listen for click events on the sidebar to handle new-tab middle clicks. r=Gijs,sidebar-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D224765
This commit is contained in:
Tom Schuster 2024-10-18 09:28:09 +00:00
parent cee5571f91
commit 5c98e5e245
2 changed files with 13 additions and 6 deletions

View File

@ -274,6 +274,7 @@ document.addEventListener(
}
navigatorToolbox.addEventListener("click", onClick);
widgetOverflow.addEventListener("click", onClick);
document.getElementById("sidebar-main").addEventListener("click", onClick);
function onKeyPress(event) {
const isLikeLeftClick = event.key === "Enter" || event.key === " ";

View File

@ -284,11 +284,17 @@ add_task(async function test_toggle_vertical_tabs() {
}
);
let newTabButton = document.getElementById("tabs-newtab-button");
info("Open a new tab using the new tab button.");
EventUtils.synthesizeMouseAtCenter(
document.getElementById("tabs-newtab-button"),
{}
);
EventUtils.synthesizeMouseAtCenter(newTabButton, {});
is(gBrowser.tabs.length, 5, "Tabstrip now has six tabs");
// Middle click on new tab button should also open a new tab.
info("Open a new tab middle clicking the new tab button.");
// Make sure there is something in the clipboard that can be opened.
SpecialPowers.clipboardCopyString("about:blank");
EventUtils.synthesizeMouseAtCenter(newTabButton, { button: 1 });
is(gBrowser.tabs.length, 6, "Tabstrip now has five tabs");
keyedScalars = TelemetryTestUtils.getProcessScalars("parent", true);
TelemetryTestUtils.assertKeyedScalar(
@ -300,7 +306,7 @@ add_task(async function test_toggle_vertical_tabs() {
await checkTelemetryScalar(
"browser.engagement.max_concurrent_vertical_tab_count",
5
6
);
// flip the pref to move the tabstrip horizontally
@ -328,7 +334,7 @@ add_task(async function test_toggle_vertical_tabs() {
TelemetryTestUtils.assertScalar(
scalars,
"browser.engagement.max_concurrent_tab_count",
5
6
);
TelemetryTestUtils.assertScalar(
scalars,