Bug 1383458 - disable pin to overflow / move to panel for flexible spacers (and other special items), r=jaws
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 26 Jul 2017 17:28:47 +0100
changeset 419822 b6da3839bc2acc8cfc038a5b6813aad899a4c67c
parent 419821 93d48f1320f774e6bd2f96d6405f25b67f8f8850
child 419823 4eef98771d0374f192245455c22a8cc97d8af9ab
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1383458
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.");
+});