Bug 1916961: Right clicking in the vertical tabs sidebar should show the tabs context menu. r=sidebar-reviewers,kcochrane
Differential Revision: https://phabricator.services.mozilla.com/D221129
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<hbox flex="1" id="browser">
|
||||
<box context="sidebar-context-menu" id="sidebar-main" hidden="true">
|
||||
<html:sidebar-main flex="1">
|
||||
<html:div id="vertical-tabs" slot="tabstrip" customizable="true"></html:div>
|
||||
<box id="vertical-tabs" slot="tabstrip" customizable="true" contextmenu="toolbar-context-menu"></box>
|
||||
</html:sidebar-main>
|
||||
</box>
|
||||
<vbox id="sidebar-box" hidden="true" class="chromeclass-extrachrome">
|
||||
|
||||
@@ -110,7 +110,8 @@ export var ToolbarContextMenu = {
|
||||
parent.classList.contains("customization-target") ||
|
||||
parent.getAttribute("overflowfortoolbar") || // Needs to work in the overflow list as well.
|
||||
parent.localName == "toolbarpaletteitem" ||
|
||||
parent.localName == "toolbar"
|
||||
parent.localName == "toolbar" ||
|
||||
parent.id == "vertical-tabs"
|
||||
) {
|
||||
break;
|
||||
}
|
||||
@@ -126,36 +127,48 @@ export var ToolbarContextMenu = {
|
||||
}
|
||||
}
|
||||
|
||||
MozXULElement.insertFTLIfNeeded("browser/toolbarContextMenu.ftl");
|
||||
let firstMenuItem = aInsertPoint || popup.firstElementChild;
|
||||
let toolbarNodes = gNavToolbox.querySelectorAll("toolbar");
|
||||
for (let toolbar of toolbarNodes) {
|
||||
if (!toolbar.hasAttribute("toolbarname")) {
|
||||
continue;
|
||||
}
|
||||
let showTabStripItems = toolbarItem?.id == "tabbrowser-tabs";
|
||||
let isVerticalTabStripMenu =
|
||||
showTabStripItems && toolbarItem.parentElement.id == "vertical-tabs";
|
||||
|
||||
if (toolbar.id == "PersonalToolbar") {
|
||||
let menu = BookmarkingUI.buildBookmarksToolbarSubmenu(toolbar);
|
||||
popup.insertBefore(menu, firstMenuItem);
|
||||
} else {
|
||||
let menuItem = document.createXULElement("menuitem");
|
||||
menuItem.setAttribute("id", "toggle_" + toolbar.id);
|
||||
menuItem.setAttribute("toolbarId", toolbar.id);
|
||||
menuItem.setAttribute("type", "checkbox");
|
||||
menuItem.setAttribute("label", toolbar.getAttribute("toolbarname"));
|
||||
let hidingAttribute =
|
||||
toolbar.getAttribute("type") == "menubar" ? "autohide" : "collapsed";
|
||||
menuItem.setAttribute(
|
||||
"checked",
|
||||
toolbar.getAttribute(hidingAttribute) != "true"
|
||||
);
|
||||
menuItem.setAttribute("accesskey", toolbar.getAttribute("accesskey"));
|
||||
if (popup.id != "toolbar-context-menu") {
|
||||
menuItem.setAttribute("key", toolbar.getAttribute("key"));
|
||||
aInsertPoint.hidden = isVerticalTabStripMenu;
|
||||
document.getElementById("toolbar-context-customize").hidden =
|
||||
isVerticalTabStripMenu;
|
||||
|
||||
if (!isVerticalTabStripMenu) {
|
||||
MozXULElement.insertFTLIfNeeded("browser/toolbarContextMenu.ftl");
|
||||
let firstMenuItem = aInsertPoint || popup.firstElementChild;
|
||||
let toolbarNodes = gNavToolbox.querySelectorAll("toolbar");
|
||||
for (let toolbar of toolbarNodes) {
|
||||
if (!toolbar.hasAttribute("toolbarname")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
popup.insertBefore(menuItem, firstMenuItem);
|
||||
menuItem.addEventListener("command", onViewToolbarCommand);
|
||||
if (toolbar.id == "PersonalToolbar") {
|
||||
let menu = BookmarkingUI.buildBookmarksToolbarSubmenu(toolbar);
|
||||
popup.insertBefore(menu, firstMenuItem);
|
||||
} else {
|
||||
let menuItem = document.createXULElement("menuitem");
|
||||
menuItem.setAttribute("id", "toggle_" + toolbar.id);
|
||||
menuItem.setAttribute("toolbarId", toolbar.id);
|
||||
menuItem.setAttribute("type", "checkbox");
|
||||
menuItem.setAttribute("label", toolbar.getAttribute("toolbarname"));
|
||||
let hidingAttribute =
|
||||
toolbar.getAttribute("type") == "menubar"
|
||||
? "autohide"
|
||||
: "collapsed";
|
||||
menuItem.setAttribute(
|
||||
"checked",
|
||||
toolbar.getAttribute(hidingAttribute) != "true"
|
||||
);
|
||||
menuItem.setAttribute("accesskey", toolbar.getAttribute("accesskey"));
|
||||
if (popup.id != "toolbar-context-menu") {
|
||||
menuItem.setAttribute("key", toolbar.getAttribute("key"));
|
||||
}
|
||||
|
||||
popup.insertBefore(menuItem, firstMenuItem);
|
||||
menuItem.addEventListener("command", onViewToolbarCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +184,6 @@ export var ToolbarContextMenu = {
|
||||
return;
|
||||
}
|
||||
|
||||
let showTabStripItems = toolbarItem?.id == "tabbrowser-tabs";
|
||||
for (let node of popup.querySelectorAll(
|
||||
'menuitem[contexttype="toolbaritem"]'
|
||||
)) {
|
||||
|
||||
@@ -93,7 +93,10 @@ export default class SidebarMain extends MozLitElement {
|
||||
event.explicitOriginalTarget.flattenedTreeParentNode;
|
||||
if (
|
||||
this.contextMenuTarget.getAttribute("extensionId") ||
|
||||
this.contextMenuTarget.className.includes("tab")
|
||||
this.contextMenuTarget.className.includes("tab") ||
|
||||
document
|
||||
.getElementById("vertical-tabs")
|
||||
.contains(this.contextMenuTarget.flattenedTreeParentNode)
|
||||
) {
|
||||
this.updateExtensionContextMenuItems();
|
||||
return;
|
||||
|
||||
@@ -103,6 +103,40 @@ add_task(async function test_toggle_vertical_tabs() {
|
||||
|
||||
is(win.gBrowser.tabs.length, 4, "Tabstrip now has four tabs");
|
||||
|
||||
const toolbarContextMenu = document.getElementById("toolbar-context-menu");
|
||||
EventUtils.synthesizeMouseAtPoint(
|
||||
containerRect.left + containerRect.width / 2,
|
||||
tabRect.bottom + 100,
|
||||
{
|
||||
type: "contextmenu",
|
||||
button: 2,
|
||||
},
|
||||
win
|
||||
);
|
||||
|
||||
await openAndWaitForContextMenu(
|
||||
toolbarContextMenu,
|
||||
win.gBrowser.selectedTab,
|
||||
() => {
|
||||
ok(
|
||||
document.getElementById("toolbar-context-customize").hidden,
|
||||
"Customize menu item should be hidden"
|
||||
);
|
||||
ok(
|
||||
!document.getElementById("toggle_PersonalToolbar"),
|
||||
"Bookmarks menu item should not be present"
|
||||
);
|
||||
ok(
|
||||
!document.getElementById("toolbar-context-reloadSelectedTab").hidden,
|
||||
"Reload tab item should be visible"
|
||||
);
|
||||
ok(
|
||||
!document.getElementById("toolbar-context-undoCloseTab").hidden,
|
||||
"Undo close tab item should be visible"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// flip the pref to move the tabstrip horizontally
|
||||
await SpecialPowers.pushPrefEnv({ set: [["sidebar.verticalTabs", false]] });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user