Bug 1383458 - disable pin to overflow / move to panel for flexible spacers (and other special items), r?jaws draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 26 Jul 2017 17:28:47 +0100
changeset 616008 bf658ef066f27c605abca8c1aa084546df522982
parent 615779 e8400551c2e39f24c75a009ebed496c7acd7bf47
child 639339 3a6a811f08356e5dcecb0db99c7ddca137d4037d
push id70545
push usergijskruitbosch@gmail.com
push dateWed, 26 Jul 2017 16:49:22 +0000
reviewersjaws
bugs1383458
milestone56.0a1
Bug 1383458 - disable pin to overflow / move to panel for flexible spacers (and other special items), r?jaws MozReview-Commit-ID: 4eeKLsjPi6I
browser/base/content/browser.js
browser/components/customizableui/test/browser_photon_customization_context_menus.js
--- 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.");
+});