Bug 1383458 - disable pin to overflow / move to panel for flexible spacers (and other special items), r?jaws
MozReview-Commit-ID: 4eeKLsjPi6I
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5478,18 +5478,23 @@ function onViewToolbarsPopupShowing(aEve
return;
}
// In some cases, we will exit the above loop with toolbarItem being the
// xul:document. That has no parentNode, and we should disable the items in
// this case.
let movable = toolbarItem && toolbarItem.parentNode &&
CustomizableUI.isWidgetRemovable(toolbarItem);
+ let isSpecial = toolbarItem && CustomizableUI.isSpecialWidget(toolbarItem.id);
if (movable) {
- moveToPanel.removeAttribute("disabled");
+ if (isSpecial) {
+ moveToPanel.setAttribute("disabled", true);
+ } else {
+ moveToPanel.removeAttribute("disabled");
+ }
removeFromToolbar.removeAttribute("disabled");
} else {
moveToPanel.setAttribute("disabled", true);
removeFromToolbar.setAttribute("disabled", true);
}
}
function onViewToolbarCommand(aEvent) {
--- a/browser/components/customizableui/test/browser_photon_customization_context_menus.js
+++ b/browser/components/customizableui/test/browser_photon_customization_context_menus.js
@@ -424,8 +424,37 @@ add_task(async function custom_context_m
is(widget.getAttribute("wrapped-context"), expectedContext, "Should keep own context menu wrapped now that we're back in the toolbar.");
await endCustomizing();
is(widget.getAttribute("context"), expectedContext, "Should have context menu again now that we're out of customize mode.");
CustomizableUI.removeWidgetFromArea(widgetId);
widget.remove();
ok(CustomizableUI.inDefaultState, "Should be in default state after removing button.");
});
+
+// Bug 1383458 - shouldn't enable 'pin to overflow menu' for flexible spaces
+add_task(async function flexible_space_context_menu() {
+ CustomizableUI.addWidgetToArea("spring", "nav-bar");
+ let springs = document.querySelectorAll("#nav-bar toolbarspring");
+ let lastSpring = springs[springs.length - 1];
+ ok(lastSpring, "we added a spring");
+ let contextMenu = document.getElementById("toolbar-context-menu");
+ let shownPromise = popupShown(contextMenu);
+ EventUtils.synthesizeMouse(lastSpring, 2, 2, {type: "contextmenu", button: 2});
+ await shownPromise;
+ let expectedEntries = [
+ [".customize-context-moveToPanel", false],
+ [".customize-context-removeFromToolbar", true],
+ ["---"]
+ ];
+ if (!isOSX) {
+ expectedEntries.push(["#toggle_toolbar-menubar", true]);
+ }
+ expectedEntries.push(
+ ["#toggle_PersonalToolbar", true],
+ ["---"],
+ [".viewCustomizeToolbar", true]
+ );
+ checkContextMenu(contextMenu, expectedEntries);
+ contextMenu.hidePopup();
+ gCustomizeMode.removeFromArea(lastSpring);
+ ok(!lastSpring.parentNode, "Spring should have been removed successfully.");
+});