Bug 968447 - [Australis] The Bookmarks Toolbar Items doesn't appear as a normal menu panel button in new windows. r=Gijs, a=sledru.
authorJared Wein <jwein@mozilla.com>
Tue, 11 Mar 2014 19:28:18 -0400
changeset 183261 d2cc1445178189eb075456f38620c437204f1c40
parent 183260 2eb6678ad228995cb9a925dc6b40088834c36b89
child 183262 d40e9c054bc318f86353affab41d9eefd51f9b78
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, sledru
bugs968447
milestone29.0a2
Bug 968447 - [Australis] The Bookmarks Toolbar Items doesn't appear as a normal menu panel button in new windows. r=Gijs, a=sledru.
browser/components/customizableui/content/panelUI.js
browser/components/customizableui/test/browser.ini
browser/components/customizableui/test/browser_968447_bookmarks_toolbar_items_in_panel.js
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -116,28 +116,35 @@ const PanelUI = {
    * Opens the menu panel. If the event target has a child with the
    * toolbarbutton-icon attribute, the panel will be anchored on that child.
    * Otherwise, the panel is anchored on the event target itself.
    *
    * @param aEvent the event (if any) that triggers showing the menu.
    */
   show: function(aEvent) {
     let deferred = Promise.defer();
-    if (this.panel.state == "open" ||
-        document.documentElement.hasAttribute("customizing")) {
-      deferred.resolve();
-      return deferred.promise;
-    }
 
     this.ensureReady().then(() => {
+      if (this.panel.state == "open" ||
+          document.documentElement.hasAttribute("customizing")) {
+        deferred.resolve();
+        return;
+      }
+
       let editControlPlacement = CustomizableUI.getPlacementOfWidget("edit-controls");
       if (editControlPlacement && editControlPlacement.area == CustomizableUI.AREA_PANEL) {
         updateEditUIVisibility();
       }
 
+      let personalBookmarksPlacement = CustomizableUI.getPlacementOfWidget("personal-bookmarks");
+      if (personalBookmarksPlacement &&
+          personalBookmarksPlacement.area == CustomizableUI.AREA_PANEL) {
+        PlacesToolbarHelper.customizeChange();
+      }
+
       let anchor;
       if (!aEvent ||
           aEvent.type == "command") {
         anchor = this.menuButton;
       } else {
         anchor = aEvent.target;
       }
       let iconAnchor =
--- a/browser/components/customizableui/test/browser.ini
+++ b/browser/components/customizableui/test/browser.ini
@@ -60,15 +60,16 @@ skip-if = os == "linux"
 [browser_942581_unregisterArea_keeps_placements.js]
 [browser_943683_migration_test.js]
 [browser_944887_destroyWidget_should_destroy_in_palette.js]
 [browser_945739_showInPrivateBrowsing_customize_mode.js]
 [browser_947987_removable_default.js]
 [browser_948985_non_removable_defaultArea.js]
 [browser_952963_areaType_getter_no_area.js]
 [browser_956602_remove_special_widget.js]
+[browser_968447_bookmarks_toolbar_items_in_panel.js]
 [browser_969427_recreate_destroyed_widget_after_reset.js]
 [browser_969661_character_encoding_navbar_disabled.js]
 [browser_970511_undo_restore_default.js]
 [browser_972267_customizationchange_events.js]
 [browser_973932_addonbar_currentset.js]
 [browser_975719_customtoolbars_behaviour.js]
 [browser_panel_toggle.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/customizableui/test/browser_968447_bookmarks_toolbar_items_in_panel.js
@@ -0,0 +1,32 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+// Bug 968447 - The Bookmarks Toolbar Items doesn't appear as a
+// normal menu panel button in new windows.
+add_task(function() {
+  const buttonId = "bookmarks-toolbar-placeholder";
+  yield startCustomizing();
+  CustomizableUI.addWidgetToArea("personal-bookmarks", CustomizableUI.AREA_PANEL);
+  yield endCustomizing();
+  yield PanelUI.show();
+  let bookmarksToolbarPlaceholder = document.getElementById(buttonId);
+  ok(bookmarksToolbarPlaceholder.classList.contains("toolbarbutton-1"),
+     "Button should have toolbarbutton-1 class");
+  is(bookmarksToolbarPlaceholder.getAttribute("wrap"), "true",
+     "Button should have the 'wrap' attribute");
+  yield PanelUI.hide();
+
+  let newWin = yield openAndLoadWindow();
+  yield newWin.PanelUI.show();
+  let newWinBookmarksToolbarPlaceholder = newWin.document.getElementById(buttonId);
+  ok(newWinBookmarksToolbarPlaceholder.classList.contains("toolbarbutton-1"),
+     "Button in new window should have toolbarbutton-1 class");
+  is(newWinBookmarksToolbarPlaceholder.getAttribute("wrap"), "true",
+     "Button in new window should have 'wrap' attribute");
+  yield newWin.PanelUI.hide();
+  newWin.close();
+  CustomizableUI.reset();
+});