Bug 945191 - Australis' combined buttons show wrong context menu options when they are in the toolbar. r=Gijs, DONTBUILD
☠☠ backed out by 29ddc08281ff ☠ ☠
authorJared Wein <jwein@mozilla.com>
Tue, 03 Dec 2013 18:27:10 -0500
changeset 173405 7476bb2b8e9cbaafe538a763fdea90b490a1ea16
parent 173404 e55e2e773ae677155175e56e8765eae2086f9e80
child 173406 b2b20bc6576a270077783c3155405c70090e9b76
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, DONTBUILD
bugs945191
milestone28.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 945191 - Australis' combined buttons show wrong context menu options when they are in the toolbar. r=Gijs, DONTBUILD
browser/components/customizableui/src/CustomizeMode.jsm
browser/components/customizableui/test/browser_880164_customization_context_menus.js
--- a/browser/components/customizableui/src/CustomizeMode.jsm
+++ b/browser/components/customizableui/src/CustomizeMode.jsm
@@ -553,20 +553,24 @@ CustomizeMode.prototype = {
                                 aNode.getAttribute("contextmenu") ? "contextmenu" : "";
     let currentContextMenu = aNode.getAttribute(contextMenuAttrName);
     let contextMenuForPlace = aPlace == "panel" ?
                                 kPanelItemContextMenu :
                                 kPaletteItemContextMenu;
     if (aPlace != "toolbar") {
       wrapper.setAttribute("context", contextMenuForPlace);
     }
-    if (currentContextMenu) {
+    // Only keep track of the menu if it is non-default.
+    if (currentContextMenu &&
+        currentContextMenu != contextMenuForPlace) {
       aNode.setAttribute("wrapped-context", currentContextMenu);
       aNode.setAttribute("wrapped-contextAttrName", contextMenuAttrName)
       aNode.removeAttribute(contextMenuAttrName);
+    } else if (currentContextMenu == contextMenuForPlace) {
+      aNode.removeAttribute(contextMenuAttrName);
     }
 
     wrapper.addEventListener("mousedown", this);
     wrapper.addEventListener("mouseup", this);
 
     return wrapper;
   },
 
--- a/browser/components/customizableui/test/browser_880164_customization_context_menus.js
+++ b/browser/components/customizableui/test/browser_880164_customization_context_menus.js
@@ -236,16 +236,61 @@ let gTests = [
       yield hiddenContextPromise;
     },
     teardown: function() {
       yield endCustomizing(this.otherWin);
       this.otherWin.close();
       this.otherWin = null;
     }
   },
+  {
+    desc: "Bug 945191 - Combined buttons show wrong context menu options when they are in the toolbar.",
+    setup: startCustomizing,
+    run: function () {
+      let contextMenu = document.getElementById("customizationPanelItemContextMenu");
+      let shownPromise = contextMenuShown(contextMenu);
+      let zoomControls = document.getElementById("wrapper-zoom-controls");
+      EventUtils.synthesizeMouse(zoomControls, 2, 2, {type: "contextmenu", button: 2});
+      yield shownPromise;
+      // Execute the command to move the item from the panel to the toolbar.
+      contextMenu.childNodes[0].doCommand();
+      let hiddenPromise = contextMenuHidden(contextMenu);
+      contextMenu.hidePopup();
+      yield hiddenPromise;
+      yield endCustomizing();
+
+      zoomControls = document.getElementById("zoom-controls");
+      is(zoomControls.parentNode.id, "nav-bar-customization-target", "Zoom-controls should be on the nav-bar");
+
+      contextMenu = document.getElementById("toolbar-context-menu");
+      shownPromise = contextMenuShown(contextMenu);
+      EventUtils.synthesizeMouse(zoomControls, 2, 2, {type: "contextmenu", button: 2});
+      yield shownPromise;
+
+      let expectedEntries = [
+        [".customize-context-addToPanel", true],
+        [".customize-context-removeFromToolbar", true],
+        ["---"]
+      ];
+      if (!isOSX) {
+        expectedEntries.push(["#toggle_toolbar-menubar", true]);
+      }
+      expectedEntries.push(
+        ["#toggle_PersonalToolbar", true],
+        ["---"],
+        [".viewCustomizeToolbar", true]
+      );
+      checkContextMenu(contextMenu, expectedEntries);
+
+      hiddenPromise = contextMenuHidden(contextMenu);
+      contextMenu.hidePopup();
+      yield hiddenPromise;
+    },
+    teardown: resetCustomization,
+  }
 ];
 
 function test() {
   waitForExplicitFinish();
   runTests(gTests);
 }
 
 function contextMenuShown(aContextMenu) {