Merge mozilla-central into holly
authorMike Conley <mconley@mozilla.com>
Fri, 06 Dec 2013 17:08:39 -0500
changeset 174637 8882f647856901a4c4b24a0d4b1256738859d277
parent 174636 453372e8d361f9c3ef4e4d676011c9e3e36cd501 (current diff)
parent 174577 9e7f91032d7dbf79ea3ea1891473f7a5db96ae03 (diff)
child 174668 83d94bb9a5f58416ca3214d59efa8361bbb87700
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone28.0a1
Merge mozilla-central into holly
CLOBBER
browser/base/content/browser-customization.js
browser/base/content/tab-shape.inc.svg
browser/base/content/tabbrowser.xml
browser/base/content/test/general/browser_tabbar_big_widgets.js
browser/base/content/test/general/browser_windowopen_reflows.js
browser/base/content/urlbarBindings.xml
browser/components/customizableui/content/aboutCustomizing.xhtml
browser/components/customizableui/content/customizeMode.inc.xul
browser/components/customizableui/content/jar.mn
browser/components/customizableui/content/moz.build
browser/components/customizableui/content/panelUI.css
browser/components/customizableui/content/panelUI.inc.xul
browser/components/customizableui/content/panelUI.js
browser/components/customizableui/content/panelUI.xml
browser/components/customizableui/content/toolbar.xml
browser/components/customizableui/moz.build
browser/components/customizableui/src/CustomizableUI.jsm
browser/components/customizableui/src/CustomizableWidgets.jsm
browser/components/customizableui/src/CustomizeMode.jsm
browser/components/customizableui/src/DragPositionManager.jsm
browser/components/customizableui/src/PanelWideWidgetTracker.jsm
browser/components/customizableui/src/ScrollbarSampler.jsm
browser/components/customizableui/src/logging.js
browser/components/customizableui/src/moz.build
browser/components/customizableui/test/browser.ini
browser/components/customizableui/test/browser_873501_handle_specials.js
browser/components/customizableui/test/browser_876926_customize_mode_wrapping.js
browser/components/customizableui/test/browser_876944_customize_mode_create_destroy.js
browser/components/customizableui/test/browser_877006_missing_view.js
browser/components/customizableui/test/browser_877178_unregisterArea.js
browser/components/customizableui/test/browser_877447_skip_missing_ids.js
browser/components/customizableui/test/browser_878452_drag_to_panel.js
browser/components/customizableui/test/browser_880164_customization_context_menus.js
browser/components/customizableui/test/browser_880382_drag_wide_widgets_in_panel.js
browser/components/customizableui/test/browser_885530_showInPrivateBrowsing.js
browser/components/customizableui/test/browser_886323_buildArea_removable_nodes.js
browser/components/customizableui/test/browser_887438_currentset_shim.js
browser/components/customizableui/test/browser_888817_currentset_updating.js
browser/components/customizableui/test/browser_890140_orphaned_placeholders.js
browser/components/customizableui/test/browser_890262_destroyWidget_after_add_to_panel.js
browser/components/customizableui/test/browser_892955_isWidgetRemovable_for_removed_widgets.js
browser/components/customizableui/test/browser_892956_destroyWidget_defaultPlacements.js
browser/components/customizableui/test/browser_909779_overflow_toolbars_new_window.js
browser/components/customizableui/test/browser_913972_currentset_overflow.js
browser/components/customizableui/test/browser_914138_widget_API_overflowable_toolbar.js
browser/components/customizableui/test/browser_914863_disabled_help_quit_buttons.js
browser/components/customizableui/test/browser_918049_skipintoolbarset_dnd.js
browser/components/customizableui/test/browser_923857_customize_mode_event_wrapping_during_reset.js
browser/components/customizableui/test/browser_927717_customize_drag_empty_toolbar.js
browser/components/customizableui/test/browser_934113_menubar_removable.js
browser/components/customizableui/test/browser_938980_navbar_collapsed.js
browser/components/customizableui/test/browser_938995_indefaultstate_nonremovable.js
browser/components/customizableui/test/browser_940013_registerToolbarNode_calls_registerArea.js
browser/components/customizableui/test/browser_940946_removable_from_navbar_customizemode.js
browser/components/customizableui/test/browser_941083_invalidate_wrapper_cache_createWidget.js
browser/components/customizableui/test/browser_942581_unregisterArea_keeps_placements.js
browser/components/customizableui/test/browser_943683_migration_test.js
browser/components/customizableui/test/browser_944887_destroyWidget_should_destroy_in_palette.js
browser/components/customizableui/test/browser_panel_toggle.js
browser/components/customizableui/test/head.js
browser/components/downloads/test/browser/browser_overflow_anchor.js
browser/locales/en-US/chrome/browser/customizableui/customizableWidgets.properties
browser/themes/linux/Toolbar-inverted.png
browser/themes/linux/browser-lightweightTheme.css
browser/themes/linux/customizableui/background-noise-toolbar.png
browser/themes/linux/customizableui/customizeMode-gridTexture.png
browser/themes/linux/customizableui/customizeMode-separatorHorizontal.png
browser/themes/linux/customizableui/customizeMode-separatorVertical.png
browser/themes/linux/customizableui/panelUIOverlay.css
browser/themes/linux/linuxShared.inc
browser/themes/linux/menuPanel-customize.png
browser/themes/linux/menuPanel-exit.png
browser/themes/linux/menuPanel-help.png
browser/themes/linux/menuPanel-small.png
browser/themes/linux/menuPanel.png
browser/themes/linux/reload-stop-go.png
browser/themes/linux/tabbrowser/tab-active-middle.png
browser/themes/linux/tabbrowser/tab-background-end.png
browser/themes/linux/tabbrowser/tab-background-middle.png
browser/themes/linux/tabbrowser/tab-background-start.png
browser/themes/linux/tabbrowser/tab-separator.png
browser/themes/linux/tabbrowser/tab-stroke-end.png
browser/themes/linux/tabbrowser/tab-stroke-start.png
browser/themes/osx/Toolbar-background-noise.png
browser/themes/osx/Toolbar-inverted.png
browser/themes/osx/Toolbar-inverted@2x.png
browser/themes/osx/Toolbar@2x.png
browser/themes/osx/browser-lightweightTheme.css
browser/themes/osx/customizableui/background-noise-toolbar.png
browser/themes/osx/customizableui/customizeMode-gridTexture.png
browser/themes/osx/customizableui/customizeMode-separatorHorizontal.png
browser/themes/osx/customizableui/customizeMode-separatorVertical.png
browser/themes/osx/customizableui/panelUIOverlay.css
browser/themes/osx/menuPanel-customize.png
browser/themes/osx/menuPanel-customize@2x.png
browser/themes/osx/menuPanel-exit.png
browser/themes/osx/menuPanel-exit@2x.png
browser/themes/osx/menuPanel-help.png
browser/themes/osx/menuPanel-help@2x.png
browser/themes/osx/menuPanel-small.png
browser/themes/osx/menuPanel-small@2x.png
browser/themes/osx/menuPanel.png
browser/themes/osx/menuPanel@2x.png
browser/themes/osx/tabbrowser/alltabs-box-bkgnd-icon-inverted.png
browser/themes/osx/tabbrowser/alltabs-box-bkgnd-icon-inverted@2x.png
browser/themes/osx/tabbrowser/newtab-inverted.png
browser/themes/osx/tabbrowser/newtab-inverted@2x.png
browser/themes/osx/tabbrowser/tab-active-middle.png
browser/themes/osx/tabbrowser/tab-active-middle@2x.png
browser/themes/osx/tabbrowser/tab-arrow-left-inverted.png
browser/themes/osx/tabbrowser/tab-arrow-left-inverted@2x.png
browser/themes/osx/tabbrowser/tab-arrow-right-inverted.png
browser/themes/osx/tabbrowser/tab-arrow-right-inverted@2x.png
browser/themes/osx/tabbrowser/tab-background-end.png
browser/themes/osx/tabbrowser/tab-background-end@2x.png
browser/themes/osx/tabbrowser/tab-background-middle.png
browser/themes/osx/tabbrowser/tab-background-middle@2x.png
browser/themes/osx/tabbrowser/tab-background-start.png
browser/themes/osx/tabbrowser/tab-background-start@2x.png
browser/themes/osx/tabbrowser/tab-separator.png
browser/themes/osx/tabbrowser/tab-separator@2x.png
browser/themes/osx/tabbrowser/tab-stroke-end.png
browser/themes/osx/tabbrowser/tab-stroke-end@2x.png
browser/themes/osx/tabbrowser/tab-stroke-start.png
browser/themes/osx/tabbrowser/tab-stroke-start@2x.png
browser/themes/shared/customizableui/customizeMode.inc.css
browser/themes/shared/customizableui/panelUIOverlay.inc.css
browser/themes/shared/menupanel.inc.css
browser/themes/shared/tab-selected.svg
browser/themes/shared/tabs.inc.css
browser/themes/shared/toolbarbuttons.inc.css
browser/themes/windows/Toolbar-aero.png
browser/themes/windows/Toolbar-inverted-aero.png
browser/themes/windows/Toolbar-lunaSilver.png
browser/themes/windows/browser-lightweightTheme.css
browser/themes/windows/customizableui/background-noise-toolbar.png
browser/themes/windows/customizableui/customizeMode-gridTexture.png
browser/themes/windows/customizableui/customizeMode-separatorHorizontal.png
browser/themes/windows/customizableui/customizeMode-separatorVertical.png
browser/themes/windows/customizableui/panelUIOverlay.css
browser/themes/windows/menuPanel-aero.png
browser/themes/windows/menuPanel-customize.png
browser/themes/windows/menuPanel-exit.png
browser/themes/windows/menuPanel-help.png
browser/themes/windows/menuPanel-small-aero.png
browser/themes/windows/menuPanel-small.png
browser/themes/windows/menuPanel.png
browser/themes/windows/privatebrowsing-indicator.png
browser/themes/windows/tabbrowser/tab-active-middle.png
browser/themes/windows/tabbrowser/tab-background-end.png
browser/themes/windows/tabbrowser/tab-background-middle.png
browser/themes/windows/tabbrowser/tab-background-start.png
browser/themes/windows/tabbrowser/tab-separator-aero.png
browser/themes/windows/tabbrowser/tab-separator-luna-blue.png
browser/themes/windows/tabbrowser/tab-separator.png
browser/themes/windows/tabbrowser/tab-stroke-end.png
browser/themes/windows/tabbrowser/tab-stroke-start.png
browser/themes/windows/windowsShared.inc
gfx/cairo/cairo/src/pixman-rename.h
toolkit/themes/windows/global/icons/close-lunaBlue.png
toolkit/themes/windows/global/icons/close-lunaOlive.png
toolkit/themes/windows/global/icons/close-lunaSilver.png
toolkit/themes/windows/global/icons/close-win8.png
uriloader/exthandler/Makefile.in
widget/cocoa/nsNativeThemeCocoa.mm
--- a/accessible/tests/mochitest/events/test_focus_general.html
+++ b/accessible/tests/mochitest/events/test_focus_general.html
@@ -91,17 +91,17 @@
       gQueue = new eventQueue();
 
       gQueue.push(new synthFocus("editablearea"));
       gQueue.push(new synthFocus("navarea"));
       gQueue.push(new synthTab("navarea", new focusChecker(frameDoc)));
       gQueue.push(new focusElmWhileSubdocIsFocused("link"));
 
       gQueue.push(new synthTab(editableDoc, new focusChecker(editableDoc)));
-      if (WIN || LINUX) {
+      if (WIN) {
         // Alt key is used to active menubar and focus menu item on Windows,
         // other platforms requires setting a ui.key.menuAccessKeyFocuses
         // preference.
         gQueue.push(new toggleTopMenu(editableDoc, new topMenuChecker()));
         gQueue.push(new toggleTopMenu(editableDoc, new focusChecker(editableDoc)));
       }
       gQueue.push(new synthContextMenu(editableDoc, new contextMenuChecker()));
       gQueue.push(new synthDownKey(editableDoc, new focusContextMenuItemChecker()));
--- a/accessible/tests/mochitest/events/test_menu.xul
+++ b/accessible/tests/mochitest/events/test_menu.xul
@@ -151,17 +151,17 @@
 
       gQueue.push(new openFileMenu());
       gQueue.push(new openEditMenu());
       gQueue.push(new closeEditMenu());
 
       // Alt key is used to active menubar and focus menu item on Windows,
       // other platforms requires setting a ui.key.menuAccessKeyFocuses
       // preference.
-      if (WIN || LINUX) {
+      if (WIN) {
         gQueue.push(new focusFileMenu());
         gQueue.push(new focusEditMenu());
         gQueue.push(new leaveMenubar());
       }
 
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
--- a/addon-sdk/source/test/test-ui-button.js
+++ b/addon-sdk/source/test/test-ui-button.js
@@ -6,17 +6,17 @@
 module.metadata = {
   'engines': {
     'Firefox': '> 24'
   }
 };
 
 const { Cu } = require('chrome');
 const { Loader } = require('sdk/test/loader');
-const { data } = require('sdk/self');
+const data = require('./fixtures');
 const { open, focus, close } = require('sdk/window/helpers');
 const { setTimeout } = require('sdk/timers');
 const { getMostRecentBrowserWindow } = require('sdk/window/utils');
 
 function getWidget(buttonId, window = getMostRecentBrowserWindow()) {
   const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
   const { AREA_NAVBAR } = CustomizableUI;
 
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -238,17 +238,17 @@ pref("extensions.{972ce4c6-7e08-4474-a28
 pref("extensions.{972ce4c6-7e08-4474-a285-3208198ce6fd}.description", "chrome://browser/locale/browser.properties");
 
 pref("xpinstall.whitelist.add", "addons.mozilla.org");
 pref("xpinstall.whitelist.add.180", "marketplace.firefox.com");
 
 pref("lightweightThemes.update.enabled", true);
 
 // UI tour experience.
-pref("browser.uitour.enabled", true);
+pref("browser.uitour.enabled", false);
 pref("browser.uitour.requireSecure", true);
 pref("browser.uitour.themeOrigin", "https://addons.mozilla.org/%LOCALE%/firefox/themes/");
 pref("browser.uitour.pinnedTabUrl", "https://support.mozilla.org/%LOCALE%/kb/pinned-tabs-keep-favorite-websites-open");
 pref("browser.uitour.whitelist.add.260", "www.mozilla.org,support.mozilla.org");
 
 pref("keyword.enabled", true);
 
 pref("general.useragent.locale", "@AB_CD@");
@@ -439,20 +439,21 @@ pref("browser.tabs.warnOnCloseOtherTabs"
 pref("browser.tabs.warnOnOpen", true);
 pref("browser.tabs.maxOpenBeforeWarn", 15);
 pref("browser.tabs.loadInBackground", true);
 pref("browser.tabs.opentabfor.middleclick", true);
 pref("browser.tabs.loadDivertedInBackground", false);
 pref("browser.tabs.loadBookmarksInBackground", false);
 pref("browser.tabs.tabClipWidth", 140);
 pref("browser.tabs.animate", true);
-#ifdef UNIX_BUT_NOT_MAC
+pref("browser.tabs.onTop", true);
+#ifdef XP_WIN
+pref("browser.tabs.drawInTitlebar", true);
+#else
 pref("browser.tabs.drawInTitlebar", false);
-#else
-pref("browser.tabs.drawInTitlebar", true);
 #endif
 
 // Where to show tab close buttons:
 // 0  on active tab only
 // 1  on all tabs until tabClipWidth is reached, then active tab only
 // 2  no close buttons at all
 // 3  at the end of the tabstrip
 pref("browser.tabs.closeButtons", 1);
@@ -1328,13 +1329,10 @@ pref("dom.debug.propagate_gesture_events
 
 // The request URL of the GeoLocation backend.
 pref("geo.wifi.uri", "https://www.googleapis.com/geolocation/v1/geolocate?key=%GOOGLE_API_KEY%");
 
 // Necko IPC security checks only needed for app isolation for cookies/cache/etc:
 // currently irrelevant for desktop e10s
 pref("network.disable.ipc.security", true);
 
-// CustomizableUI debug logging.
-pref("browser.uiCustomization.debug", false);
-
 // The URL of the Firefox Accounts auth server backend
 pref("identity.fxaccounts.auth.uri", "https://api-accounts.dev.lcip.org/v1");
--- a/browser/base/content/browser-addons.js
+++ b/browser/base/content/browser-addons.js
@@ -173,16 +173,60 @@ const gXPInstallObserver = {
 
       PopupNotifications.show(browser, notificationID, messageString, anchorID,
                               action, null, options);
       break;
     }
   }
 };
 
+/*
+ * When addons are installed/uninstalled, check and see if the number of items
+ * on the add-on bar changed:
+ * - If an add-on was installed, incrementing the count, show the bar.
+ * - If an add-on was uninstalled, and no more items are left, hide the bar.
+ */
+let AddonsMgrListener = {
+  get addonBar() document.getElementById("addon-bar"),
+  get statusBar() document.getElementById("status-bar"),
+  getAddonBarItemCount: function() {
+    // Take into account the contents of the status bar shim for the count.
+    var itemCount = this.statusBar.childNodes.length;
+
+    var defaultOrNoninteractive = this.addonBar.getAttribute("defaultset")
+                                      .split(",")
+                                      .concat(["separator", "spacer", "spring"]);
+    for (let item of this.addonBar.currentSet.split(",")) {
+      if (defaultOrNoninteractive.indexOf(item) == -1)
+        itemCount++;
+    }
+
+    return itemCount;
+  },
+  onInstalling: function(aAddon) {
+    this.lastAddonBarCount = this.getAddonBarItemCount();
+  },
+  onInstalled: function(aAddon) {
+    if (this.getAddonBarItemCount() > this.lastAddonBarCount)
+      setToolbarVisibility(this.addonBar, true);
+  },
+  onUninstalling: function(aAddon) {
+    this.lastAddonBarCount = this.getAddonBarItemCount();
+  },
+  onUninstalled: function(aAddon) {
+    if (this.getAddonBarItemCount() == 0)
+      setToolbarVisibility(this.addonBar, false);
+  },
+  onEnabling: function(aAddon) this.onInstalling(),
+  onEnabled: function(aAddon) this.onInstalled(),
+  onDisabling: function(aAddon) this.onUninstalling(),
+  onDisabled: function(aAddon) this.onUninstalled(),
+};
+
+
 var LightWeightThemeWebInstaller = {
   handleEvent: function (event) {
     switch (event.type) {
       case "InstallBrowserTheme":
       case "PreviewBrowserTheme":
       case "ResetBrowserThemePreview":
         // ignore requests from background tabs
         if (event.target.ownerDocument.defaultView.top != content)
@@ -366,65 +410,8 @@ var LightWeightThemeWebInstaller = {
     return pm.testPermission(uri, "install") == pm.ALLOW_ACTION;
   },
 
   _getThemeFromNode: function (node) {
     return this._manager.parseTheme(node.getAttribute("data-browsertheme"),
                                     node.baseURI);
   }
 }
-
-/*
- * Listen for Lightweight Theme styling changes and update the browser's theme accordingly.
- */
-let LightweightThemeListener = {
-  _modifiedStyles: [],
-
-  init: function () {
-    XPCOMUtils.defineLazyGetter(this, "styleSheet", function() {
-      for (let i = document.styleSheets.length - 1; i >= 0; i--) {
-        let sheet = document.styleSheets[i];
-        if (sheet.href == "chrome://browser/skin/browser-lightweightTheme.css")
-          return sheet;
-      }
-    });
-
-    Services.obs.addObserver(this, "lightweight-theme-styling-update", false);
-    if (document.documentElement.hasAttribute("lwtheme"))
-      this.updateStyleSheet(document.documentElement.style.backgroundImage);
-  },
-
-  uninit: function () {
-    Services.obs.removeObserver(this, "lightweight-theme-styling-update");
-  },
-
-  /**
-   * Append the headerImage to the background-image property of all rulesets in
-   * browser-lightweightTheme.css.
-   *
-   * @param headerImage - a string containing a CSS image for the lightweight theme header.
-   */
-  updateStyleSheet: function(headerImage) {
-    if (!this.styleSheet)
-      return;
-    for (let i = 0; i < this.styleSheet.cssRules.length; i++) {
-      let rule = this.styleSheet.cssRules[i];
-      if (!rule.style.backgroundImage)
-        continue;
-
-      if (!this._modifiedStyles[i])
-        this._modifiedStyles[i] = { backgroundImage: rule.style.backgroundImage };
-
-      rule.style.backgroundImage = this._modifiedStyles[i].backgroundImage + ", " + headerImage;
-    }
-  },
-
-  // nsIObserver
-  observe: function (aSubject, aTopic, aData) {
-    if (aTopic != "lightweight-theme-styling-update" || !this.styleSheet)
-      return;
-
-    let themeData = JSON.parse(aData);
-    if (!themeData)
-      return;
-    this.updateStyleSheet("url(" + themeData.headerURL + ")");
-  },
-};
new file mode 100644
--- /dev/null
+++ b/browser/base/content/browser-appmenu.inc
@@ -0,0 +1,411 @@
+# -*- Mode: HTML -*-
+# 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/.
+
+<menupopup id="appmenu-popup"
+           onpopupshowing="if (event.target == this) {
+                             updateEditUIVisibility();
+                             updateSwitchToMetroVisibility();
+#ifdef MOZ_SERVICES_SYNC
+                             gSyncUI.updateUI();
+#endif
+                             return;
+                           }
+                           updateCharacterEncodingMenuState();
+                           if (event.target.parentNode.parentNode.parentNode.parentNode == this)
+                             this._currentPopup = event.target;">
+  <hbox>
+    <vbox id="appmenuPrimaryPane">
+      <splitmenu id="appmenu_newTab"
+                 label="&tabCmd.label;"
+                 command="cmd_newNavigatorTab">
+          <menupopup>
+            <menuitem id="appmenu_newTab_popup"
+                      label="&tabCmd.label;"
+                      command="cmd_newNavigatorTab"
+                      key="key_newNavigatorTab"/>
+            <menuitem id="appmenu_newNavigator"
+                      label="&newNavigatorCmd.label;"
+                      command="cmd_newNavigator"
+                      key="key_newNavigator"/>
+            <menuseparator/>
+            <menuitem id="appmenu_openFile"
+                      label="&openFileCmd.label;"
+                      command="Browser:OpenFile"
+                      key="openFileKb"/>
+          </menupopup>
+      </splitmenu>
+      <menuitem id="appmenu_newPrivateWindow"
+                class="menuitem-iconic menuitem-iconic-tooltip"
+                label="&newPrivateWindow.label;"
+                command="Tools:PrivateBrowsing"
+                key="key_privatebrowsing"/>
+      <menuitem label="&goOfflineCmd.label;"
+                id="appmenu_offlineModeRecovery"
+                type="checkbox"
+                observes="workOfflineMenuitemState"
+                oncommand="BrowserOffline.toggleOfflineStatus();"/>
+      <menuseparator class="appmenu-menuseparator"/>
+      <hbox>
+        <menuitem id="appmenu-edit-label"
+                  label="&appMenuEdit.label;"
+                  disabled="true"/>
+        <toolbarbutton id="appmenu-cut"
+                       class="appmenu-edit-button"
+                       command="cmd_cut"
+                       onclick="if (!this.disabled) hidePopup();"
+                       tooltiptext="&cutButton.tooltip;"/>
+        <toolbarbutton id="appmenu-copy"
+                       class="appmenu-edit-button"
+                       command="cmd_copy"
+                       onclick="if (!this.disabled) hidePopup();"
+                       tooltiptext="&copyButton.tooltip;"/>
+        <toolbarbutton id="appmenu-paste"
+                       class="appmenu-edit-button"
+                       command="cmd_paste"
+                       onclick="if (!this.disabled) hidePopup();"
+                       tooltiptext="&pasteButton.tooltip;"/>
+        <spacer flex="1"/>
+        <menu id="appmenu-editmenu">
+          <menupopup id="appmenu-editmenu-menupopup">
+            <menuitem id="appmenu-editmenu-cut"
+                      class="menuitem-iconic"
+                      label="&cutCmd.label;"
+                      key="key_cut"
+                      command="cmd_cut"/>
+            <menuitem id="appmenu-editmenu-copy"
+                      class="menuitem-iconic"
+                      label="&copyCmd.label;"
+                      key="key_copy"
+                      command="cmd_copy"/>
+            <menuitem id="appmenu-editmenu-paste"
+                      class="menuitem-iconic"
+                      label="&pasteCmd.label;"
+                      key="key_paste"
+                      command="cmd_paste"/>
+            <menuseparator/>
+            <menuitem id="appmenu-editmenu-undo"
+                      label="&undoCmd.label;"
+                      key="key_undo"
+                      command="cmd_undo"/>
+            <menuitem id="appmenu-editmenu-redo"
+                      label="&redoCmd.label;"
+                      key="key_redo"
+                      command="cmd_redo"/>
+            <menuseparator/>
+            <menuitem id="appmenu-editmenu-selectAll"
+                      label="&selectAllCmd.label;"
+                      key="key_selectAll"
+                      command="cmd_selectAll"/>
+            <menuseparator/>
+            <menuitem id="appmenu-editmenu-delete"
+                      label="&deleteCmd.label;"
+                      key="key_delete"
+                      command="cmd_delete"/>
+          </menupopup>
+        </menu>
+      </hbox>
+      <menuitem id="appmenu_find"
+                class="menuitem-tooltip"
+                label="&appMenuFind.label;"
+                command="cmd_find"
+                key="key_find"/>
+      <menuseparator class="appmenu-menuseparator"/>
+      <menuitem id="appmenu_savePage"
+                class="menuitem-tooltip"
+                label="&savePageCmd.label;"
+                command="Browser:SavePage"
+                key="key_savePage"/>
+      <menuitem id="appmenu_sendLink"
+                label="&emailPageCmd.label;"
+                command="Browser:SendLink"/>
+      <splitmenu id="appmenu_print"
+                 iconic="true"
+                 label="&printCmd.label;"
+                 command="cmd_print">
+          <menupopup>
+            <menuitem id="appmenu_print_popup"
+                      class="menuitem-iconic"
+                      label="&printCmd.label;"
+                      command="cmd_print"
+                      key="printKb"/>
+            <menuitem id="appmenu_printPreview"
+                      label="&printPreviewCmd.label;"
+                      command="cmd_printPreview"/>
+            <menuitem id="appmenu_printSetup"
+                      label="&printSetupCmd.label;"
+                      command="cmd_pageSetup"/>
+          </menupopup>
+      </splitmenu>
+      <menuseparator class="appmenu-menuseparator"/>
+      <splitmenu id="appmenu_webDeveloper"
+                 command="Tools:DevToolbox"
+                 label="&appMenuWebDeveloper.label;">
+        <menupopup id="appmenu_webDeveloper_popup">
+          <menuitem id="appmenu_devToolbox"
+                    observes="devtoolsMenuBroadcaster_DevToolbox"/>
+          <menuseparator id="appmenu_devtools_separator"/>
+          <menuitem id="appmenu_devToolbar"
+                    observes="devtoolsMenuBroadcaster_DevToolbar"/>
+          <menuitem id="appmenu_devAppMgr"
+                    observes="devtoolsMenuBroadcaster_DevAppMgr"/>
+          <menuitem id="appmenu_chromeDebugger"
+                    observes="devtoolsMenuBroadcaster_ChromeDebugger"/>
+          <menuitem id="appmenu_browserConsole"
+                    observes="devtoolsMenuBroadcaster_BrowserConsole"/>
+          <menuitem id="appmenu_responsiveUI"
+                    observes="devtoolsMenuBroadcaster_ResponsiveUI"/>
+          <menuitem id="appmenu_scratchpad"
+                    observes="devtoolsMenuBroadcaster_Scratchpad"/>
+          <menuitem id="appmenu_pageSource"
+                    observes="devtoolsMenuBroadcaster_PageSource"/>
+          <menuitem id="appmenu_errorConsole"
+                    observes="devtoolsMenuBroadcaster_ErrorConsole"/>
+          <menuitem id="appmenu_devtools_connect"
+                    observes="devtoolsMenuBroadcaster_connect"/>
+          <menuseparator id="appmenu_devToolsEndSeparator"/>
+          <menuitem id="appmenu_getMoreDevtools"
+                    observes="devtoolsMenuBroadcaster_GetMoreTools"/>
+          <menuseparator/>
+#define ID_PREFIX appmenu_developer_
+#define OMIT_ACCESSKEYS
+#include browser-charsetmenu.inc
+#undef ID_PREFIX
+#undef OMIT_ACCESSKEYS
+          <menuitem id="appmenu_offlineMode"
+                    label="&goOfflineCmd.label;"
+                    type="checkbox"
+                    observes="workOfflineMenuitemState"
+                    oncommand="BrowserOffline.toggleOfflineStatus();"/>
+        </menupopup>
+      </splitmenu>
+      <menuseparator class="appmenu-menuseparator"/>
+#define ID_PREFIX appmenu_
+#define OMIT_ACCESSKEYS
+#include browser-charsetmenu.inc
+#undef ID_PREFIX
+#undef OMIT_ACCESSKEYS
+      <menuitem id="appmenu_fullScreen"
+                class="menuitem-tooltip"
+                label="&fullScreenCmd.label;"
+                type="checkbox"
+                observes="View:FullScreen"
+                key="key_fullScreen"/>
+#ifdef MOZ_SERVICES_SYNC
+      <!-- only one of sync-setup or sync-syncnow will be showing at once -->
+      <menuitem id="sync-setup-appmenu"
+                label="&syncSetup.label;"
+                observes="sync-setup-state"
+                oncommand="gSyncUI.openSetup()"/>
+      <menuitem id="sync-syncnowitem-appmenu"
+                label="&syncSyncNowItem.label;"
+                observes="sync-syncnow-state"
+                oncommand="gSyncUI.doSync(event);"/>
+#endif
+      <menuitem id="switch-to-metro"
+                label="&switchToMetroCmd.label;"
+                oncommand="SwitchToMetro()"/>
+      <menuitem id="appmenu-quit"
+                class="menuitem-iconic"
+#ifdef XP_WIN
+                label="&quitApplicationCmdWin.label;"
+#else
+                label="&quitApplicationCmd.label;"
+#endif
+                command="cmd_quitApplication"/>
+    </vbox>
+    <vbox id="appmenuSecondaryPane">
+      <splitmenu id="appmenu_bookmarks"
+                 iconic="true"
+                 label="&bookmarksMenu.label;"
+                 command="Browser:ShowAllBookmarks">
+          <menupopup id="appmenu_bookmarksPopup"
+                     placespopup="true"
+                     context="placesContext"
+                     openInTabs="children"
+                     oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);"
+                     onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
+                     onpopupshowing="BookmarkingUI.onPopupShowing(event);
+                                     if (!this.parentNode._placesView)
+                                       new PlacesMenu(event, 'place:folder=BOOKMARKS_MENU');"
+                     tooltip="bhTooltip"
+                     popupsinherittooltip="true">
+            <menuitem id="appmenu_showAllBookmarks"
+                      label="&showAllBookmarks2.label;"
+                      command="Browser:ShowAllBookmarks"
+                      context=""
+                      key="manBookmarkKb"/>
+            <menuseparator/>
+            <menuitem id="appmenu_bookmarkThisPage"
+                      class="menuitem-iconic"
+                      label="&bookmarkThisPageCmd.label;"
+                      command="Browser:AddBookmarkAs"
+                      key="addBookmarkAsKb"/>
+            <menuitem id="appmenu_subscribeToPage"
+                      class="menuitem-iconic"
+                      label="&subscribeToPageMenuitem.label;"
+                      oncommand="return FeedHandler.subscribeToFeed(null, event);"
+                      onclick="checkForMiddleClick(this, event);"
+                      observes="singleFeedMenuitemState"/>
+            <menu id="appmenu_subscribeToPageMenu"
+                  class="menu-iconic"
+                  label="&subscribeToPageMenupopup.label;"
+                  observes="multipleFeedsMenuState">
+              <menupopup id="appmenu_subscribeToPageMenupopup"
+                         onpopupshowing="return FeedHandler.buildFeedList(event.target);"
+                         oncommand="return FeedHandler.subscribeToFeed(null, event);"
+                         onclick="checkForMiddleClick(this, event);"/>
+            </menu>
+            <menuseparator/>
+            <menu id="appmenu_bookmarksToolbar"
+                  placesanonid="toolbar-autohide"
+                  class="menu-iconic bookmark-item"
+                  label="&personalbarCmd.label;"
+                  container="true">
+              <menupopup id="appmenu_bookmarksToolbarPopup"
+                         placespopup="true"
+                         context="placesContext"
+                         onpopupshowing="if (!this.parentNode._placesView)
+                                           new PlacesMenu(event, 'place:folder=TOOLBAR');"/>
+            </menu>
+            <menuseparator/>
+            <!-- Bookmarks menu items -->
+            <menuseparator builder="end"
+                           class="hide-if-empty-places-result"/>
+            <menuitem id="appmenu_unsortedBookmarks"
+                      label="&appMenuUnsorted.label;"
+                      oncommand="PlacesCommandHook.showPlacesOrganizer('UnfiledBookmarks');"
+                      class="menuitem-iconic"/>
+          </menupopup>
+      </splitmenu>
+      <splitmenu id="appmenu_history"
+                 iconic="true"
+                 label="&historyMenu.label;"
+                 command="Browser:ShowAllHistory">
+          <menupopup id="appmenu_historyMenupopup"
+                     placespopup="true"
+                     oncommand="this.parentNode._placesView._onCommand(event);"
+                     onclick="checkForMiddleClick(this, event);"
+                     onpopupshowing="if (!this.parentNode._placesView)
+                                       new HistoryMenu(event);"
+                     tooltip="bhTooltip"
+                     popupsinherittooltip="true">
+            <menuitem id="appmenu_showAllHistory"
+                      label="&showAllHistoryCmd2.label;"
+                      command="Browser:ShowAllHistory"
+                      key="showAllHistoryKb"/>
+            <menuseparator/>
+            <menuitem id="appmenu_sanitizeHistory"
+                      label="&clearRecentHistory.label;"
+                      key="key_sanitize"
+                      command="Tools:Sanitize"/>
+            <menuseparator class="hide-if-empty-places-result"/>
+#ifdef MOZ_SERVICES_SYNC
+            <menuitem id="appmenu_sync-tabs"
+                      class="syncTabsMenuItem"
+                      label="&syncTabsMenu2.label;"
+                      oncommand="BrowserOpenSyncTabs();"
+                      disabled="true"/>
+#endif
+            <menuitem id="appmenu_restoreLastSession"
+                      label="&historyRestoreLastSession.label;"
+                      command="Browser:RestoreLastSession"/>
+            <menu id="appmenu_recentlyClosedTabsMenu"
+                  class="recentlyClosedTabsMenu"
+                  label="&historyUndoMenu.label;"
+                  disabled="true">
+              <menupopup id="appmenu_recentlyClosedTabsMenupopup"
+                         onpopupshowing="document.getElementById('appmenu_history')._placesView.populateUndoSubmenu();"/>
+            </menu>
+            <menu id="appmenu_recentlyClosedWindowsMenu"
+                  class="recentlyClosedWindowsMenu"
+                  label="&historyUndoWindowMenu.label;"
+                  disabled="true">
+              <menupopup id="appmenu_recentlyClosedWindowsMenupopup"
+                         onpopupshowing="document.getElementById('appmenu_history')._placesView.populateUndoWindowSubmenu();"/>
+            </menu>
+            <menuseparator/>
+          </menupopup>
+      </splitmenu>
+      <menuitem id="appmenu_downloads"
+                class="menuitem-tooltip"
+                label="&downloads.label;"
+                command="Tools:Downloads"
+                key="key_openDownloads"/>
+      <spacer id="appmenuSecondaryPane-spacer"/>
+      <menuitem id="appmenu_addons"
+                class="menuitem-iconic menuitem-iconic-tooltip"
+                label="&addons.label;"
+                command="Tools:Addons"
+                key="key_openAddons"/>
+      <splitmenu id="appmenu_customize"
+#ifdef XP_UNIX
+                 label="&preferencesCmdUnix.label;"
+#else
+                 label="&preferencesCmd2.label;"
+#endif
+                 oncommand="openPreferences();">
+          <menupopup id="appmenu_customizeMenu"
+                     onpopupshowing="onViewToolbarsPopupShowing(event, document.getElementById('appmenu_toggleToolbarsSeparator'));">
+            <menuitem id="appmenu_preferences"
+#ifdef XP_UNIX
+                      label="&preferencesCmdUnix.label;"
+#else
+                      label="&preferencesCmd2.label;"
+#endif
+                      oncommand="openPreferences();"/>
+            <menuseparator/>
+            <menuseparator id="appmenu_toggleToolbarsSeparator"/>
+            <menuitem id="appmenu_toggleTabsOnTop"
+                      label="&viewTabsOnTop.label;"
+                      type="checkbox"
+                      command="cmd_ToggleTabsOnTop"/>
+            <menuitem id="appmenu_toolbarLayout"
+                      label="&appMenuToolbarLayout.label;"
+                      command="cmd_CustomizeToolbars"/>
+          </menupopup>
+      </splitmenu>
+      <splitmenu id="appmenu_help"
+                 label="&helpMenu.label;"
+                 oncommand="openHelpLink('firefox-help')">
+          <menupopup id="appmenu_helpMenupopup">
+            <menuitem id="appmenu_openHelp"
+                      label="&helpMenu.label;"
+                      oncommand="openHelpLink('firefox-help')"
+                      onclick="checkForMiddleClick(this, event);"/>
+            <menuitem id="appmenu_gettingStarted"
+                      label="&appMenuGettingStarted.label;"
+                      oncommand="gBrowser.loadOneTab('https://www.mozilla.org/firefox/central/', {inBackground: false});"
+                      onclick="checkForMiddleClick(this, event);"/>
+            <menuitem id="appmenu_keyboardShortcuts"
+                      label="&helpKeyboardShortcuts.label;"
+                      oncommand="openHelpLink('keyboard-shortcuts')"
+                      onclick="checkForMiddleClick(this, event);"/>
+#ifdef MOZ_SERVICES_HEALTHREPORT
+            <menuitem id="appmenu_healthReport"
+                      label="&healthReport.label;"
+                      oncommand="openHealthReport()"
+                      onclick="checkForMiddleClick(this, event);"/>
+#endif
+            <menuitem id="appmenu_troubleshootingInfo"
+                      label="&helpTroubleshootingInfo.label;"
+                      oncommand="openTroubleshootingPage()"
+                      onclick="checkForMiddleClick(this,event);"/>
+            <menuitem id="appmenu_feedbackPage"
+                      label="&helpFeedbackPage.label;"
+                      oncommand="openFeedbackPage()"
+                      onclick="checkForMiddleClick(this, event);"/>
+            <menuseparator/>
+            <menuitem id="appmenu_safeMode"
+                      label="&appMenuSafeMode.label;"
+                      oncommand="safeModeRestart();"/>
+            <menuseparator/>
+            <menuitem id="appmenu_about"
+                      label="&aboutProduct.label;"
+                      oncommand="openAboutDialog();"/>
+          </menupopup>
+      </splitmenu>
+    </vbox>
+  </hbox>
+</menupopup>
deleted file mode 100644
--- a/browser/base/content/browser-customization.js
+++ /dev/null
@@ -1,97 +0,0 @@
-# -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-# 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/.
-
-/**
- * Customization handler prepares this browser window for entering and exiting
- * customization mode by handling customizationstarting and customizationending
- * events.
- */
-let CustomizationHandler = {
-  handleEvent: function(aEvent) {
-    switch(aEvent.type) {
-      case "customizationstarting":
-        this._customizationStarting();
-        break;
-      case "customizationending":
-        this._customizationEnding(aEvent.detail);
-        break;
-    }
-  },
-
-  isCustomizing: function() {
-    return document.documentElement.hasAttribute("customizing") ||
-           document.documentElement.hasAttribute("customize-exiting");
-  },
-
-  _customizationStarting: function() {
-    // Disable the toolbar context menu items
-    let menubar = document.getElementById("main-menubar");
-    for (let childNode of menubar.childNodes)
-      childNode.setAttribute("disabled", true);
-
-    let cmd = document.getElementById("cmd_CustomizeToolbars");
-    cmd.setAttribute("disabled", "true");
-
-    let splitter = document.getElementById("urlbar-search-splitter");
-    if (splitter) {
-      splitter.parentNode.removeChild(splitter);
-    }
-
-    CombinedStopReload.uninit();
-    PlacesToolbarHelper.customizeStart();
-    BookmarkingUI.customizeStart();
-    DownloadsButton.customizeStart();
-  },
-
-  _customizationEnding: function(aDetails) {
-    // Update global UI elements that may have been added or removed
-    if (aDetails.changed) {
-      gURLBar = document.getElementById("urlbar");
-
-      gProxyFavIcon = document.getElementById("page-proxy-favicon");
-      gHomeButton.updateTooltip();
-      gIdentityHandler._cacheElements();
-      XULBrowserWindow.init();
-
-#ifndef XP_MACOSX
-      updateEditUIVisibility();
-#endif
-
-      // Hacky: update the PopupNotifications' object's reference to the iconBox,
-      // if it already exists, since it may have changed if the URL bar was
-      // added/removed.
-      if (!window.__lookupGetter__("PopupNotifications")) {
-        PopupNotifications.iconBox =
-          document.getElementById("notification-popup-box");
-      }
-
-    }
-
-    PlacesToolbarHelper.customizeDone();
-    BookmarkingUI.customizeDone();
-    DownloadsButton.customizeDone();
-
-    // The url bar splitter state is dependent on whether stop/reload
-    // and the location bar are combined, so we need this ordering
-    CombinedStopReload.init();
-    UpdateUrlbarSearchSplitterState();
-
-    // Update the urlbar
-    if (gURLBar) {
-      URLBarSetURI();
-      XULBrowserWindow.asyncUpdateUI();
-      BookmarkingUI.updateStarState();
-    }
-
-    // Re-enable parts of the UI we disabled during the dialog
-    let menubar = document.getElementById("main-menubar");
-    for (let childNode of menubar.childNodes)
-      childNode.setAttribute("disabled", false);
-    let cmd = document.getElementById("cmd_CustomizeToolbars");
-    cmd.removeAttribute("disabled");
-
-    gBrowser.selectedBrowser.focus();
-  }
-}
--- a/browser/base/content/browser-feeds.js
+++ b/browser/base/content/browser-feeds.js
@@ -3,72 +3,85 @@
 # 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/.
 
 /**
  * The Feed Handler object manages discovery of RSS/ATOM feeds in web pages
  * and shows UI when they are discovered.
  */
 var FeedHandler = {
-  /** Called when the user clicks on the Subscribe to This Page... menu item,
-   * or when the user clicks the feed button when the page contains multiple
-   * feeds.
+  /**
+   * The click handler for the Feed icon in the toolbar. Opens the
+   * subscription page if user is not given a choice of feeds.
+   * (Otherwise the list of available feeds will be presented to the
+   * user in a popup menu.)
+   */
+  onFeedButtonClick: function(event) {
+    event.stopPropagation();
+
+    let feeds = gBrowser.selectedBrowser.feeds || [];
+    // If there are multiple feeds, the menu will open, so no need to do
+    // anything. If there are no feeds, nothing to do either.
+    if (feeds.length != 1)
+      return;
+
+    if (event.eventPhase == Event.AT_TARGET &&
+        (event.button == 0 || event.button == 1)) {
+      this.subscribeToFeed(feeds[0].href, event);
+    }
+  },
+
+ /** Called when the user clicks on the Subscribe to This Page... menu item.
    * Builds a menu of unique feeds associated with the page, and if there
    * is only one, shows the feed inline in the browser window.
-   * @param   container
-   *          The feed list container (menupopup or subview) to be populated.
-   * @param   isSubview
-   *          Whether we're creating a subview (true) or menu (false/undefined)
-   * @returns true if the menu/subview should be shown, false if there was only
+   * @param   menuPopup
+   *          The feed list menupopup to be populated.
+   * @returns true if the menu should be shown, false if there was only
    *          one feed and the feed should be shown inline in the browser
-   *          window (do not show the menupopup/subview).
+   *          window (do not show the menupopup).
    */
-  buildFeedList: function(container, isSubview) {
+  buildFeedList: function(menuPopup) {
     var feeds = gBrowser.selectedBrowser.feeds;
-    if (!isSubview && feeds == null) {
+    if (feeds == null) {
       // XXX hack -- menu opening depends on setting of an "open"
       // attribute, and the menu refuses to open if that attribute is
       // set (because it thinks it's already open).  onpopupshowing gets
       // called after the attribute is unset, and it doesn't get unset
       // if we return false.  so we unset it here; otherwise, the menu
       // refuses to work past this point.
-      container.parentNode.removeAttribute("open");
+      menuPopup.parentNode.removeAttribute("open");
       return false;
     }
 
-    while (container.firstChild)
-      container.removeChild(container.firstChild);
+    while (menuPopup.firstChild)
+      menuPopup.removeChild(menuPopup.firstChild);
 
-    if (!feeds || feeds.length <= 1)
+    if (feeds.length <= 1)
       return false;
 
     // Build the menu showing the available feed choices for viewing.
-    var itemNodeType = isSubview ? "toolbarbutton" : "menuitem";
     for (let feedInfo of feeds) {
-      var item = document.createElement(itemNodeType);
+      var menuItem = document.createElement("menuitem");
       var baseTitle = feedInfo.title || feedInfo.href;
       var labelStr = gNavigatorBundle.getFormattedString("feedShowFeedNew", [baseTitle]);
-      item.setAttribute("class", "feed-" + itemNodeType);
-      item.setAttribute("label", labelStr);
-      item.setAttribute("feed", feedInfo.href);
-      item.setAttribute("tooltiptext", feedInfo.href);
-      item.setAttribute("crop", "center");
-      if (isSubview) {
-        item.setAttribute("tabindex", "0");
-      }
-      container.appendChild(item);
+      menuItem.setAttribute("class", "feed-menuitem");
+      menuItem.setAttribute("label", labelStr);
+      menuItem.setAttribute("feed", feedInfo.href);
+      menuItem.setAttribute("tooltiptext", feedInfo.href);
+      menuItem.setAttribute("crop", "center");
+      menuPopup.appendChild(menuItem);
     }
     return true;
   },
 
   /**
    * Subscribe to a given feed.  Called when
    *   1. Page has a single feed and user clicks feed icon in location bar
    *   2. Page has a single feed and user selects Subscribe menu item
-   *   3. Page has multiple feeds and user selects from feed icon popup (or subview)
+   *   3. Page has multiple feeds and user selects from feed icon popup
    *   4. Page has multiple feeds and user selects from Subscribe submenu
    * @param   href
    *          The feed to subscribe to. May be null, in which case the
    *          event target's feed attribute is examined.
    * @param   event
    *          The event this method is handling. Used to decide where
    *          to open the preview UI. (Optional, unless href is null)
    */
@@ -116,23 +129,18 @@ var FeedHandler = {
   updateFeeds: function() {
     if (this._updateFeedTimeout)
       clearTimeout(this._updateFeedTimeout);
 
     var feeds = gBrowser.selectedBrowser.feeds;
     var haveFeeds = feeds && feeds.length > 0;
 
     var feedButton = document.getElementById("feed-button");
-    if (feedButton) {
-      if (haveFeeds) {
-        feedButton.removeAttribute("disabled");
-      } else {
-        feedButton.setAttribute("disabled", "true");
-      }
-    }
+    if (feedButton)
+      feedButton.disabled = !haveFeeds;
 
     if (!haveFeeds) {
       this._feedMenuitem.setAttribute("disabled", "true");
       this._feedMenuitem.removeAttribute("hidden");
       this._feedMenupopup.setAttribute("hidden", "true");
       return;
     }
 
--- a/browser/base/content/browser-fullScreen.js
+++ b/browser/base/content/browser-fullScreen.js
@@ -12,17 +12,17 @@ var FullScreen = {
   toggle: function (event) {
     var enterFS = window.fullScreen;
 
     // We get the fullscreen event _before_ the window transitions into or out of FS mode.
     if (event && event.type == "fullscreen")
       enterFS = !enterFS;
 
     // Toggle the View:FullScreen command, which controls elements like the
-    // fullscreen menuitem, and menubars.
+    // fullscreen menuitem, menubars, and the appmenu.
     let fullscreenCommand = document.getElementById("View:FullScreen");
     if (enterFS) {
       fullscreenCommand.setAttribute("checked", enterFS);
     } else {
       fullscreenCommand.removeAttribute("checked");
     }
 
 #ifdef XP_MACOSX
@@ -512,33 +512,50 @@ var FullScreen = {
   showXULChrome: function(aTag, aShow)
   {
     var els = document.getElementsByTagNameNS(this._XULNS, aTag);
 
     for (let el of els) {
       // XXX don't interfere with previously collapsed toolbars
       if (el.getAttribute("fullscreentoolbar") == "true") {
         if (!aShow) {
+
+          var toolbarMode = el.getAttribute("mode");
+          if (toolbarMode != "text") {
+            el.setAttribute("saved-mode", toolbarMode);
+            el.setAttribute("saved-iconsize", el.getAttribute("iconsize"));
+            el.setAttribute("mode", "icons");
+            el.setAttribute("iconsize", "small");
+          }
+
           // Give the main nav bar and the tab bar the fullscreen context menu,
           // otherwise remove context menu to prevent breakage
           el.setAttribute("saved-context", el.getAttribute("context"));
           if (el.id == "nav-bar" || el.id == "TabsToolbar")
             el.setAttribute("context", "autohide-context");
           else
             el.removeAttribute("context");
 
           // Set the inFullscreen attribute to allow specific styling
           // in fullscreen mode
           el.setAttribute("inFullscreen", true);
         }
         else {
-          if (el.hasAttribute("saved-context")) {
-            el.setAttribute("context", el.getAttribute("saved-context"));
-            el.removeAttribute("saved-context");
+          var restoreAttr = function restoreAttr(attrName) {
+            var savedAttr = "saved-" + attrName;
+            if (el.hasAttribute(savedAttr)) {
+              el.setAttribute(attrName, el.getAttribute(savedAttr));
+              el.removeAttribute(savedAttr);
+            }
           }
+
+          restoreAttr("mode");
+          restoreAttr("iconsize");
+          restoreAttr("context");
+
           el.removeAttribute("inFullscreen");
         }
       } else {
         // use moz-collapsed so it doesn't persist hidden/collapsed,
         // so that new windows don't have missing toolbars
         if (aShow)
           el.removeAttribute("moz-collapsed");
         else
@@ -549,19 +566,21 @@ var FullScreen = {
     if (aShow) {
       gNavToolbox.removeAttribute("inFullscreen");
       document.documentElement.removeAttribute("inFullscreen");
     } else {
       gNavToolbox.setAttribute("inFullscreen", true);
       document.documentElement.setAttribute("inFullscreen", true);
     }
 
+    // In tabs-on-top mode, move window controls to the tab bar,
+    // and in tabs-on-bottom mode, move them back to the navigation toolbar.
     var fullscreenctls = document.getElementById("window-controls");
     var navbar = document.getElementById("nav-bar");
-    var ctlsOnTabbar = window.toolbar.visible;
+    var ctlsOnTabbar = window.toolbar.visible && (navbar.collapsed || TabsOnTop.enabled);
     if (fullscreenctls.parentNode == navbar && ctlsOnTabbar) {
       fullscreenctls.removeAttribute("flex");
       document.getElementById("TabsToolbar").appendChild(fullscreenctls);
     }
     else if (fullscreenctls.parentNode.id == "TabsToolbar" && !ctlsOnTabbar) {
       fullscreenctls.setAttribute("flex", "1");
       navbar.appendChild(fullscreenctls);
     }
--- a/browser/base/content/browser-fullZoom.js
+++ b/browser/base/content/browser-fullZoom.js
@@ -392,17 +392,16 @@ var FullZoom = {
 
   /**
    * Saves the zoom level of the page in the given browser to the content
    * prefs store.
    *
    * @param browser  The zoom of this browser will be saved.  Required.
    */
   _applyZoomToPref: function FullZoom__applyZoomToPref(browser) {
-    Services.obs.notifyObservers(null, "browser-fullZoom:zoomChange", "");
     if (!this.siteSpecific ||
         gInPrintPreviewMode ||
         browser.contentDocument.mozSyntheticDocument)
       return;
 
     this._cps2.set(browser.currentURI.spec, this.name,
                    ZoomManager.getZoomForBrowser(browser),
                    this._loadContextFromWindow(browser.contentWindow), {
@@ -413,17 +412,16 @@ var FullZoom = {
   },
 
   /**
    * Removes from the content prefs store the zoom level of the given browser.
    *
    * @param browser  The zoom of this browser will be removed.  Required.
    */
   _removePref: function FullZoom__removePref(browser) {
-    Services.obs.notifyObservers(null, "browser-fullZoom:zoomReset", "");
     if (browser.contentDocument.mozSyntheticDocument)
       return;
     let ctxt = this._loadContextFromWindow(browser.contentWindow);
     this._cps2.removeByDomainAndName(browser.currentURI.spec, this.name, ctxt, {
       handleCompletion: function () {
         this._isNextContentPrefChangeInternal = true;
       }.bind(this),
     });
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -180,16 +180,21 @@
                   accesskey="&viewMenu.accesskey;">
               <menupopup id="menu_viewPopup"
                          onpopupshowing="updateCharacterEncodingMenuState();">
                 <menu id="viewToolbarsMenu"
                       label="&viewToolbarsMenu.label;"
                       accesskey="&viewToolbarsMenu.accesskey;">
                   <menupopup onpopupshowing="onViewToolbarsPopupShowing(event);">
                     <menuseparator/>
+                    <menuitem id="menu_tabsOnTop"
+                              command="cmd_ToggleTabsOnTop"
+                              type="checkbox"
+                              label="&viewTabsOnTop.label;"
+                              accesskey="&viewTabsOnTop.accesskey;"/>
                     <menuitem id="menu_customizeToolbars"
                               label="&viewCustomizeToolbar.label;"
                               accesskey="&viewCustomizeToolbar.accesskey;"
                               command="cmd_CustomizeToolbars"/>
                   </menupopup>
                 </menu>
                 <menu id="viewSidebarMenuMenu"
                       label="&viewSidebarMenu.label;"
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -129,16 +129,19 @@ var StarUI = {
       this._doShowEditBookmarkPanel(aItemId, aAnchorElement, aPosition);
       return;
     }
 
     this._overlayLoading = true;
     document.loadOverlay(
       "chrome://browser/content/places/editBookmarkOverlay.xul",
       (function (aSubject, aTopic, aData) {
+        //XXX We just caused localstore.rdf to be re-applied (bug 640158)
+        retrieveToolbarIconsizesFromTheme();
+
         // Move the header (star, title, button) into the grid,
         // so that it aligns nicely with the other items (bug 484022).
         let header = this._element("editBookmarkPanelHeader");
         let rows = this._element("editBookmarkPanelGrid").lastChild;
         rows.insertBefore(header, rows.firstChild);
         header.hidden = false;
 
         this._overlayLoading = false;
@@ -737,20 +740,19 @@ var BookmarksEventHandler = {
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 //// PlacesMenuDNDHandler
 
 // Handles special drag and drop functionality for Places menus that are not
 // part of a Places view (e.g. the bookmarks menu in the menubar).
 var PlacesMenuDNDHandler = {
-  _springLoadDelayMs: 350,
-  _closeDelayMs: 500,
+  _springLoadDelay: 350, // milliseconds
   _loadTimer: null,
-  _closeTimer: null,
+  _closerTimer: null,
 
   /**
    * Called when the user enters the <menu> element during a drag.
    * @param   event
    *          The DragEnter event that spawned the opening. 
    */
   onDragEnter: function PMDH_onDragEnter(event) {
     // Opening menus in a Places popup is handled by the view itself.
@@ -761,31 +763,30 @@ var PlacesMenuDNDHandler = {
     if (this._loadTimer || popup.state === "showing" || popup.state === "open")
       return;
 
     this._loadTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
     this._loadTimer.initWithCallback(() => {
       this._loadTimer = null;
       popup.setAttribute("autoopened", "true");
       popup.showPopup(popup);
-    }, this._springLoadDelayMs, Ci.nsITimer.TYPE_ONE_SHOT);
+    }, this._springLoadDelay, Ci.nsITimer.TYPE_ONE_SHOT);
     event.preventDefault();
     event.stopPropagation();
   },
 
   /**
    * Handles dragleave on the <menu> element.
    * @returns true if the element is a container element (menu or 
    *          menu-toolbarbutton), false otherwise.
    */
   onDragLeave: function PMDH_onDragLeave(event) {
     // Handle menu-button separate targets.
     if (event.relatedTarget === event.currentTarget ||
-        (event.relatedTarget &&
-         event.relatedTarget.parentNode === event.currentTarget))
+        event.relatedTarget.parentNode === event.currentTarget)
       return;
 
     // Closing menus in a Places popup is handled by the view itself.
     if (!this._isStaticContainer(event.target))
       return;
 
     let popup = event.target.lastChild;
 
@@ -801,17 +802,17 @@ var PlacesMenuDNDHandler = {
       while (node && !inHierarchy) {
         inHierarchy = node == event.target;
         node = node.parentNode;
       }
       if (!inHierarchy && popup && popup.hasAttribute("autoopened")) {
         popup.removeAttribute("autoopened");
         popup.hidePopup();
       }
-    }, this._closeDelayMs, Ci.nsITimer.TYPE_ONE_SHOT);
+    }, this._springLoadDelay, Ci.nsITimer.TYPE_ONE_SHOT);
   },
 
   /**
    * Determines if a XUL element represents a static container.
    * @returns true if the element is a container element (menu or 
    *`         menu-toolbarbutton), false otherwise.
    */
   _isStaticContainer: function PMDH__isContainer(node) {
@@ -869,107 +870,83 @@ let PlacesToolbarHelper = {
     return document.getElementById("PlacesToolbar");
   },
 
   init: function PTH_init() {
     let viewElt = this._viewElt;
     if (!viewElt || viewElt._placesView)
       return;
 
-    // If the bookmarks toolbar item is:
-    // - not in a toolbar, or;
-    // - the toolbar is collapsed, or;
-    // - the toolbar is hidden some other way:
-    // don't initialize.  Also, there is no need to initialize the toolbar if
-    // customizing, because that will happen when the customization is done.
-    let toolbar = this._getParentToolbar(viewElt);
-    if (!toolbar || toolbar.collapsed || this._isCustomizing ||
-        getComputedStyle(toolbar, "").display == "none")
+    // If the bookmarks toolbar item is hidden because the parent toolbar is
+    // collapsed or hidden (i.e. in a popup), spare the initialization.  Also,
+    // there is no need to initialize the toolbar if customizing because
+    // init() will be called when the customization is done.
+    let toolbar = viewElt.parentNode.parentNode;
+    if (toolbar.collapsed ||
+        getComputedStyle(toolbar, "").display == "none" ||
+        this._isCustomizing)
       return;
 
     new PlacesToolbar(this._place);
   },
 
   customizeStart: function PTH_customizeStart() {
-    try {
-      let viewElt = this._viewElt;
-      if (viewElt && viewElt._placesView)
-        viewElt._placesView.uninit();
-    } finally {
-      this._isCustomizing = true;
-    }
+    let viewElt = this._viewElt;
+    if (viewElt && viewElt._placesView)
+      viewElt._placesView.uninit();
+
+    this._isCustomizing = true;
   },
 
   customizeDone: function PTH_customizeDone() {
     this._isCustomizing = false;
     this.init();
-  },
-
-  onPlaceholderCommand: function () {
-    let widgetGroup = CustomizableUI.getWidget("personal-bookmarks");
-    let widget = widgetGroup.forWindow(window);
-    if (widget.overflowed ||
-        widgetGroup.areaType == CustomizableUI.TYPE_MENU_PANEL) {
-      PlacesCommandHook.showPlacesOrganizer("BookmarksToolbar");
-    }
-  },
-
-  _getParentToolbar: function(element) {
-    while (element) {
-      if (element.localName == "toolbar") {
-        return element;
-      }
-      element = element.parentNode;
-    }
-    return null;
   }
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 //// BookmarkingUI
 
 /**
- * Handles the bookmarks menu-button in the toolbar.
+ * Handles the bookmarks star button in the URL bar, as well as the bookmark
+ * menu button.
  */
 
 let BookmarkingUI = {
   get button() {
-    let widgetGroup = CustomizableUI.getWidget("bookmarks-menu-button");
-    if (widgetGroup.areaType == CustomizableUI.TYPE_TOOLBAR) {
-      return widgetGroup.forWindow(window).node;
+    if (!this._button) {
+      this._button = document.getElementById("bookmarks-menu-button");
     }
-    return null;
+    return this._button;
   },
 
   get star() {
-    let button = this.button;
-    return button && document.getAnonymousElementByAttribute(button, "anonid",
-                                                             "button");
+    if (!this._star) {
+      this._star = document.getElementById("star-button");
+    }
+    return this._star;
   },
 
   get anchor() {
-    let widget = CustomizableUI.getWidget("bookmarks-menu-button")
-                               .forWindow(window);
-    if (widget.overflowed)
-      return widget.anchor;
-
-    let star = this.star;
-    return star && document.getAnonymousElementByAttribute(star, "class",
-                                                           "toolbarbutton-icon");
+    if (this.star && isElementVisible(this.star)) {
+      // Anchor to the icon, so the panel looks more natural.
+      return this.star;
+    }
+    return null;
   },
 
   STATUS_UPDATING: -1,
   STATUS_UNSTARRED: 0,
   STATUS_STARRED: 1,
   get status() {
     if (this._pendingStmt)
       return this.STATUS_UPDATING;
-    let button = this.button;
-    return button && button.hasAttribute("starred") ? this.STATUS_STARRED
-                                                    : this.STATUS_UNSTARRED;
+    return this.star &&
+           this.star.hasAttribute("starred") ? this.STATUS_STARRED
+                                             : this.STATUS_UNSTARRED;
   },
 
   get _starredTooltip()
   {
     delete this._starredTooltip;
     return this._starredTooltip =
       gNavigatorBundle.getString("starButtonOn.tooltip");
   },
@@ -992,100 +969,97 @@ let BookmarkingUI = {
     this._popupNeedsUpdate = true;
   },
 
   onPopupShowing: function BUI_onPopupShowing(event) {
     // Don't handle events for submenus.
     if (event.target != event.currentTarget)
       return;
 
-    let widget = CustomizableUI.getWidget("bookmarks-menu-button")
-                               .forWindow(window);
-    if (widget.overflowed) {
-      // Don't open a popup in the overflow popup, rather just open the Library.
-      event.preventDefault();
-      widget.node.removeAttribute("noautoclose");
-      PlacesCommandHook.showPlacesOrganizer("BookmarksMenu");
-      return;
-    }
-
     if (!this._popupNeedsUpdate)
       return;
     this._popupNeedsUpdate = false;
 
     let popup = event.target;
     let getPlacesAnonymousElement =
       aAnonId => document.getAnonymousElementByAttribute(popup.parentNode,
                                                          "placesanonid",
                                                          aAnonId);
 
     let viewToolbarMenuitem = getPlacesAnonymousElement("view-toolbar");
     if (viewToolbarMenuitem) {
       // Update View bookmarks toolbar checkbox menuitem.
       let personalToolbar = document.getElementById("PersonalToolbar");
       viewToolbarMenuitem.setAttribute("checked", !personalToolbar.collapsed);
     }
+
+    let toolbarMenuitem = getPlacesAnonymousElement("toolbar-autohide");
+    if (toolbarMenuitem) {
+      // If bookmarks items are visible, hide Bookmarks Toolbar menu and the
+      // separator after it.
+      toolbarMenuitem.collapsed = toolbarMenuitem.nextSibling.collapsed =
+        isElementVisible(document.getElementById("personal-bookmarks"));
+    }
   },
 
   /**
    * Handles star styling based on page proxy state changes.
    */
   onPageProxyStateChanged: function BUI_onPageProxyStateChanged(aState) {
     if (!this.star) {
       return;
     }
 
     if (aState == "invalid") {
       this.star.setAttribute("disabled", "true");
-      this.button.removeAttribute("starred");
-      this.button.setAttribute("buttontooltiptext", "");
+      this.star.removeAttribute("starred");
     }
     else {
       this.star.removeAttribute("disabled");
     }
-    this._updateToolbarStyle();
   },
 
   _updateToolbarStyle: function BUI__updateToolbarStyle() {
-    let button = this.button;
-    if (!button)
+    if (!this.button) {
       return;
+    }
 
     let personalToolbar = document.getElementById("PersonalToolbar");
-    let onPersonalToolbar = button.parentNode == personalToolbar ||
-                            button.parentNode.parentNode == personalToolbar;
+    let onPersonalToolbar = this.button.parentNode == personalToolbar ||
+                            this.button.parentNode.parentNode == personalToolbar;
 
     if (onPersonalToolbar) {
-      button.classList.add("bookmark-item");
-      button.classList.remove("toolbarbutton-1");
+      this.button.classList.add("bookmark-item");
+      this.button.classList.remove("toolbarbutton-1");
     }
     else {
-      button.classList.remove("bookmark-item");
-      button.classList.add("toolbarbutton-1");
+      this.button.classList.remove("bookmark-item");
+      this.button.classList.add("toolbarbutton-1");
     }
   },
 
   _uninitView: function BUI__uninitView() {
     // When an element with a placesView attached is removed and re-inserted,
     // XBL reapplies the binding causing any kind of issues and possible leaks,
     // so kill current view and let popupshowing generate a new one.
-    let button = this.button;
-    if (button && button._placesView)
-      button._placesView.uninit();
+    if (this.button && this.button._placesView) {
+      this.button._placesView.uninit();
+    }
   },
 
   customizeStart: function BUI_customizeStart() {
     this._uninitView();
   },
 
   customizeChange: function BUI_customizeChange() {
     this._updateToolbarStyle();
   },
 
   customizeDone: function BUI_customizeDone() {
+    delete this._button;
     this.onToolbarVisibilityChange();
     this._updateToolbarStyle();
   },
 
   _hasBookmarksObserver: false,
   uninit: function BUI_uninit() {
     this._uninitView();
 
@@ -1095,17 +1069,17 @@ let BookmarkingUI = {
 
     if (this._pendingStmt) {
       this._pendingStmt.cancel();
       delete this._pendingStmt;
     }
   },
 
   updateStarState: function BUI_updateStarState() {
-    if (!this.button || (this._uri && gBrowser.currentURI.equals(this._uri))) {
+    if (!this.star || (this._uri && gBrowser.currentURI.equals(this._uri))) {
       return;
     }
 
     // Reset tracked values.
     this._uri = gBrowser.currentURI;
     this._itemIds = [];
 
     if (this._pendingStmt) {
@@ -1144,127 +1118,63 @@ let BookmarkingUI = {
         }
       }
 
       delete this._pendingStmt;
     }, this);
   },
 
   _updateStar: function BUI__updateStar() {
-    let button = this.button;
-    if (!button)
+    if (!this.star) {
       return;
+    }
 
     if (this._itemIds.length > 0) {
-      button.setAttribute("starred", "true");
-      button.setAttribute("buttontooltiptext", this._starredTooltip);
+      this.star.setAttribute("starred", "true");
+      this.star.setAttribute("tooltiptext", this._starredTooltip);
     }
     else {
-      button.removeAttribute("starred");
-      button.setAttribute("buttontooltiptext", this._unstarredTooltip);
+      this.star.removeAttribute("starred");
+      this.star.setAttribute("tooltiptext", this._unstarredTooltip);
     }
   },
 
   onCommand: function BUI_onCommand(aEvent) {
     if (aEvent.target != aEvent.currentTarget) {
       return;
     }
-
-    // Handle special case when the button is in the panel.
-    let widgetGroup = CustomizableUI.getWidget("bookmarks-menu-button");
-    let widget = widgetGroup.forWindow(window);
-    if (widgetGroup.areaType == CustomizableUI.TYPE_MENU_PANEL) {
-      let view = document.getElementById("PanelUI-bookmarks");
-      view.addEventListener("ViewShowing", this.onPanelMenuViewShowing);
-      view.addEventListener("ViewHiding", this.onPanelMenuViewHiding);
-      widget.node.setAttribute("noautoclose", "true");
-      PanelUI.showSubView("PanelUI-bookmarks", widget.node,
-                          CustomizableUI.AREA_PANEL);
-      return;
-    }
-    else if (widget.overflowed) {
-      // Allow to close the panel if the page is already bookmarked, cause
-      // we are going to open the edit bookmark panel.
-      if (this._itemIds.length > 0)
-        widget.node.removeAttribute("noautoclose");
-      else
-        widget.node.setAttribute("noautoclose", "true");
-    }
-
     // Ignore clicks on the star if we are updating its state.
     if (!this._pendingStmt) {
       PlacesCommandHook.bookmarkCurrentPage(this._itemIds.length > 0);
     }
   },
 
-  onPanelMenuViewShowing: function BUI_onViewShowing(aEvent) {
-    // Update checked status of the toolbar toggle.
-    let viewToolbar = document.getElementById("panelMenu_viewBookmarksToolbar");
-    let personalToolbar = document.getElementById("PersonalToolbar");
-    if (personalToolbar.collapsed)
-      viewToolbar.removeAttribute("checked");
-    else
-      viewToolbar.setAttribute("checked", "true");
-    // Setup the Places view.
-    this._panelMenuView = new PlacesPanelMenuView("place:folder=BOOKMARKS_MENU",
-                                                  "panelMenu_bookmarksMenu",
-                                                  "panelMenu_bookmarksMenu");
-  },
-
-  onPanelMenuViewHiding: function BUI_onViewHiding(aEvent) {
-    this._panelMenuView.uninit();
-    delete this._panelMenuView;
-  },
-
-  onPanelMenuViewCommand: function BUI_onPanelMenuViewCommand(aEvent, aView) {
-    let target = aEvent.originalTarget;
-    if (!target._placesNode)
-      return;
-    if (PlacesUtils.nodeIsContainer(target._placesNode))
-      PlacesCommandHook.showPlacesOrganizer([ "BookmarksMenu", target._placesNode.itemId ]);
-    else
-      PlacesUIUtils.openNodeWithEvent(target._placesNode, aEvent, aView);
-    PanelUI.hide();
-  },
-
   // nsINavBookmarkObserver
   onItemAdded: function BUI_onItemAdded(aItemId, aParentId, aIndex, aItemType,
                                         aURI) {
-    if (!this.button) {
-      return;
-    }
-
     if (aURI && aURI.equals(this._uri)) {
       // If a new bookmark has been added to the tracked uri, register it.
       if (this._itemIds.indexOf(aItemId) == -1) {
         this._itemIds.push(aItemId);
         this._updateStar();
       }
     }
   },
 
   onItemRemoved: function BUI_onItemRemoved(aItemId) {
-    if (!this.button) {
-      return;
-    }
-
     let index = this._itemIds.indexOf(aItemId);
     // If one of the tracked bookmarks has been removed, unregister it.
     if (index != -1) {
       this._itemIds.splice(index, 1);
       this._updateStar();
     }
   },
 
   onItemChanged: function BUI_onItemChanged(aItemId, aProperty,
                                             aIsAnnotationProperty, aNewValue) {
-    if (!this.button) {
-      return;
-    }
-
     if (aProperty == "uri") {
       let index = this._itemIds.indexOf(aItemId);
       // If the changed bookmark was tracked, check if it is now pointing to
       // a different uri and unregister it.
       if (index != -1 && aNewValue != this._uri.spec) {
         this._itemIds.splice(index, 1);
         this._updateStar();
       }
--- a/browser/base/content/browser-sets.inc
+++ b/browser/base/content/browser-sets.inc
@@ -27,16 +27,17 @@
     <command id="Browser:SendLink"
              oncommand="MailIntegration.sendLinkForWindow(window.content);"/>
 
     <command id="cmd_pageSetup" oncommand="PrintUtils.showPageSetup();"/>
     <command id="cmd_print" oncommand="PrintUtils.print();"/>
     <command id="cmd_printPreview" oncommand="PrintUtils.printPreview(PrintPreviewListener);"/>
     <command id="cmd_close" oncommand="BrowserCloseTabOrWindow()"/>
     <command id="cmd_closeWindow" oncommand="BrowserTryToCloseWindow()"/>
+    <command id="cmd_ToggleTabsOnTop" oncommand="TabsOnTop.toggle()"/>
     <command id="cmd_CustomizeToolbars" oncommand="BrowserCustomizeToolbar()"/>
     <command id="cmd_quitApplication" oncommand="goQuitApplication()"/>
 
 
     <commandset id="editMenuCommands"/>
 
     <command id="View:PageSource" oncommand="BrowserViewSourceOfDocument(content.document);" observes="isImage"/>
     <command id="View:PageInfo" oncommand="BrowserPageInfo();"/>
@@ -103,23 +104,23 @@
     <command id="Tools:ErrorConsole" oncommand="toJavaScriptConsole()" disabled="true" hidden="true"/>
     <command id="Tools:DevToolsConnect" oncommand="gDevToolsBrowser.openConnectScreen(gBrowser)" disabled="true" hidden="true"/>
     <command id="Tools:Sanitize"
      oncommand="Cc['@mozilla.org/browser/browserglue;1'].getService(Ci.nsIBrowserGlue).sanitize(window);"/>
     <command id="Tools:PrivateBrowsing"
       oncommand="OpenBrowserWindow({private: true});"/>
     <command id="History:UndoCloseTab" oncommand="undoCloseTab();"/>
     <command id="History:UndoCloseWindow" oncommand="undoCloseWindow();"/>
+    <command id="Browser:ToggleAddonBar" oncommand="toggleAddonBar();"/>
     <command id="Social:SharePage" oncommand="SocialShare.sharePage();" disabled="true"/>
     <command id="Social:ToggleSidebar" oncommand="Social.toggleSidebar();" hidden="true"/>
     <command id="Social:ToggleNotifications" oncommand="Social.toggleNotifications();" hidden="true"/>
     <command id="Social:FocusChat" oncommand="SocialChatBar.focus();" hidden="true" disabled="true"/>
     <command id="Social:Toggle" oncommand="Social.toggle();" hidden="true"/>
     <command id="Social:Addons" oncommand="BrowserOpenAddonsMgr('addons://list/service');"/>
-    <command id="MenuPanel:Toggle" oncommand="PanelUI.toggle(event);"/>
   </commandset>
 
   <commandset id="placesCommands">
     <command id="Browser:ShowAllBookmarks"
              oncommand="PlacesCommandHook.showPlacesOrganizer('AllBookmarks');"/>
     <command id="Browser:ShowAllHistory"
              oncommand="PlacesCommandHook.showPlacesOrganizer('History');"/>
   </commandset>
@@ -406,38 +407,33 @@
     <key id="key_quitApplication" key="&quitApplicationCmdUnix.key;" command="cmd_quitApplication" modifiers="accel"/>
 #endif
 
 #ifdef FULL_BROWSER_WINDOW
     <key id="key_undoCloseTab" command="History:UndoCloseTab" key="&tabCmd.commandkey;" modifiers="accel,shift"/>
 #endif
     <key id="key_undoCloseWindow" command="History:UndoCloseWindow" key="&newNavigatorCmd.key;" modifiers="accel,shift"/>
 
-    <key id="key_menuButton" command="MenuPanel:Toggle"
-#ifdef XP_MACOSX
-         key="&toggleMenuPanelMac.key;" modifiers="accel,shift"/>
-#else
-         key="&toggleMenuPanel.key;" modifiers="accel"/>
-#endif
-
 #ifdef XP_GNOME
 #define NUM_SELECT_TAB_MODIFIER alt
 #else
 #define NUM_SELECT_TAB_MODIFIER accel
 #endif
 
 #expand    <key id="key_selectTab1" oncommand="gBrowser.selectTabAtIndex(0, event);" key="1" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
 #expand    <key id="key_selectTab2" oncommand="gBrowser.selectTabAtIndex(1, event);" key="2" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
 #expand    <key id="key_selectTab3" oncommand="gBrowser.selectTabAtIndex(2, event);" key="3" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
 #expand    <key id="key_selectTab4" oncommand="gBrowser.selectTabAtIndex(3, event);" key="4" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
 #expand    <key id="key_selectTab5" oncommand="gBrowser.selectTabAtIndex(4, event);" key="5" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
 #expand    <key id="key_selectTab6" oncommand="gBrowser.selectTabAtIndex(5, event);" key="6" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
 #expand    <key id="key_selectTab7" oncommand="gBrowser.selectTabAtIndex(6, event);" key="7" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
 #expand    <key id="key_selectTab8" oncommand="gBrowser.selectTabAtIndex(7, event);" key="8" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
 #expand    <key id="key_selectLastTab" oncommand="gBrowser.selectTabAtIndex(-1, event);" key="9" modifiers="__NUM_SELECT_TAB_MODIFIER__"/>
 
+    <key id="key_toggleAddonBar" command="Browser:ToggleAddonBar" key="&toggleAddonBarCmd.key;" modifiers="accel"/>
+
   </keyset>
 
 # Used by baseMenuOverlay
 #ifdef XP_MACOSX
   <commandset id="baseMenuCommandSet" />
 #endif
   <keyset id="baseMenuKeyset" />
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -44,23 +44,29 @@ SocialUI = {
   // Called on delayed startup to initialize the UI
   init: function SocialUI_init() {
     Services.obs.addObserver(this, "social:ambient-notification-changed", false);
     Services.obs.addObserver(this, "social:profile-changed", false);
     Services.obs.addObserver(this, "social:frameworker-error", false);
     Services.obs.addObserver(this, "social:provider-set", false);
     Services.obs.addObserver(this, "social:providers-changed", false);
     Services.obs.addObserver(this, "social:provider-reload", false);
+    Services.obs.addObserver(this, "social:provider-installed", false);
+    Services.obs.addObserver(this, "social:provider-uninstalled", false);
     Services.obs.addObserver(this, "social:provider-enabled", false);
     Services.obs.addObserver(this, "social:provider-disabled", false);
 
     Services.prefs.addObserver("social.sidebar.open", this, false);
     Services.prefs.addObserver("social.toast-notifications.enabled", this, false);
 
     gBrowser.addEventListener("ActivateSocialFeature", this._activationEventHandler.bind(this), true, true);
+    window.addEventListener("aftercustomization", function() {
+      if (SocialUI.enabled)
+        SocialMarks.populateContextMenu(SocialMarks);
+    }, false);
 
     if (!Social.initialized) {
       Social.init();
     } else if (Social.providers.length > 0) {
       // Social was initialized during startup in a previous window. If we have
       // providers enabled initialize the UI for this window.
       this.observe(null, "social:providers-changed", null);
       this.observe(null, "social:provider-set", Social.provider ? Social.provider.origin : null);
@@ -70,32 +76,42 @@ SocialUI = {
   // Called on window unload
   uninit: function SocialUI_uninit() {
     Services.obs.removeObserver(this, "social:ambient-notification-changed");
     Services.obs.removeObserver(this, "social:profile-changed");
     Services.obs.removeObserver(this, "social:frameworker-error");
     Services.obs.removeObserver(this, "social:provider-set");
     Services.obs.removeObserver(this, "social:providers-changed");
     Services.obs.removeObserver(this, "social:provider-reload");
+    Services.obs.removeObserver(this, "social:provider-installed");
+    Services.obs.removeObserver(this, "social:provider-uninstalled");
     Services.obs.removeObserver(this, "social:provider-enabled");
     Services.obs.removeObserver(this, "social:provider-disabled");
 
     Services.prefs.removeObserver("social.sidebar.open", this);
     Services.prefs.removeObserver("social.toast-notifications.enabled", this);
   },
 
   _matchesCurrentProvider: function (origin) {
     return Social.provider && Social.provider.origin == origin;
   },
 
   observe: function SocialUI_observe(subject, topic, data) {
     // Exceptions here sometimes don't get reported properly, report them
     // manually :(
     try {
       switch (topic) {
+        case "social:provider-installed":
+          SocialMarks.setPosition(data);
+          SocialStatus.setPosition(data);
+          break;
+        case "social:provider-uninstalled":
+          SocialMarks.removePosition(data);
+          SocialStatus.removePosition(data);
+          break;
         case "social:provider-enabled":
           SocialMarks.populateToolbarPalette();
           SocialStatus.populateToolbarPalette();
           break;
         case "social:provider-disabled":
           SocialMarks.removeProvider(data);
           SocialStatus.removeProvider(data);
           break;
@@ -777,17 +793,19 @@ SocialShare = {
       }, true);
     }
     // always ensure that origin belongs to the endpoint
     let uri = Services.io.newURI(shareEndpoint, null, null);
     iframe.setAttribute("origin", provider.origin);
     iframe.setAttribute("src", shareEndpoint);
 
     let navBar = document.getElementById("nav-bar");
-    let anchor = document.getAnonymousElementByAttribute(this.shareButton, "class", "toolbarbutton-icon");
+    let anchor = navBar.getAttribute("mode") == "text" ?
+                   document.getAnonymousElementByAttribute(this.shareButton, "class", "toolbarbutton-text") :
+                   document.getAnonymousElementByAttribute(this.shareButton, "class", "toolbarbutton-icon");
     this.panel.openPopup(anchor, "bottomcenter topright", 0, 0, false, false);
     Social.setErrorListener(iframe, this.setErrorMessage.bind(this));
   }
 };
 
 SocialMenu = {
   populate: function SocialMenu_populate() {
     let submenu = document.getElementById("menu_social-statusarea-popup");
@@ -1115,17 +1133,19 @@ SocialToolbar = {
           setTimeout(function() {
             dispatchPanelEvent("socialFrameShow");
           }, 0);
         }, true);
       }
     });
 
     let navBar = document.getElementById("nav-bar");
-    let anchor = document.getAnonymousElementByAttribute(aToolbarButton, "class", "toolbarbutton-badge-container");
+    let anchor = navBar.getAttribute("mode") == "text" ?
+                   document.getAnonymousElementByAttribute(aToolbarButton, "class", "toolbarbutton-text") :
+                   document.getAnonymousElementByAttribute(aToolbarButton, "class", "toolbarbutton-badge-container");
     // Bug 849216 - open the popup in a setTimeout so we avoid the auto-rollup
     // handling from preventing it being opened in some cases.
     setTimeout(function() {
       panel.openPopup(anchor, "bottomcenter topright", 0, 0, false, false);
     }, 0);
   },
 
   setPanelErrorMessage: function SocialToolbar_setPanelErrorMessage(aNotificationFrame) {
@@ -1284,73 +1304,169 @@ SocialSidebar = {
     } else {
       let url = encodeURIComponent(Social.provider.sidebarURL);
       sbrowser.loadURI("about:socialerror?mode=tryAgain&url=" + url, null, null);
     }
   }
 }
 
 // this helper class is used by removable/customizable buttons to handle
-// widget creation/destruction
+// location persistence and insertion into palette and/or toolbars
 
 // When a provider is installed we show all their UI so the user will see the
 // functionality of what they installed. The user can later customize the UI,
 // moving buttons around or off the toolbar.
 //
-// On startup, we create the button widgets of any enabled provider.
-// CustomizableUI handles placement and persistence of placement.
+// To make this happen, on install we add a button id to the navbar currentset.
+// On enabling the provider (happens just after install) we insert the button
+// into the toolbar as well. The button is then persisted on restart (assuming
+// it was not removed).
+//
+// When a provider is disabled, we do not remove the buttons from currentset.
+// That way, if the provider is re-enabled during the same session, the buttons
+// will reappear where they were before. When a provider is uninstalled, we make
+// sure that the id is removed from currentset.
+//
+// On startup, we insert the buttons of any enabled provider into either the
+// apropriate toolbar or the palette.
 function ToolbarHelper(type, createButtonFn) {
   this._createButton = createButtonFn;
   this._type = type;
 }
 
 ToolbarHelper.prototype = {
-  idFromOrigin: function(origin) {
-    // this id needs to pass the checks in CustomizableUI, so remove characters
-    // that wont pass.
-    return this._type + "-" + Services.io.newURI(origin, null, null).hostPort.replace(/[\.:]/g,'-');
+  idFromOrgin: function(origin) {
+    return this._type + "-" + origin;
+  },
+
+  // find a button either in the document or the palette
+  _getExistingButton: function(id) {
+    let button = document.getElementById(id);
+    if (button)
+      return button;
+    let palette = document.getElementById("navigator-toolbox").palette;
+    let paletteItem = palette.firstChild;
+    while (paletteItem) {
+      if (paletteItem.id == id)
+        return paletteItem;
+      paletteItem = paletteItem.nextSibling;
+    }
+    return null;
   },
 
-  // should be called on disable of a provider
-  removeProviderButton: function(origin) {
-    CustomizableUI.destroyWidget(this.idFromOrigin(origin));
+  setPersistentPosition: function(id) {
+    // called when a provider is installed.  add provider buttons to nav-bar
+    let toolbar = document.getElementById("nav-bar");
+    // first startups will not have a currentset attribute, always rely on
+    // currentSet since it will be derived from the defaultset in that case.
+    let currentset = toolbar.currentSet;
+    if (currentset == "__empty")
+      currentset = []
+    else
+      currentset = currentset.split(",");
+    if (currentset.indexOf(id) >= 0)
+      return;
+    // we do not set toolbar.currentSet since that will try to add the button,
+    // and we have not added it yet (happens on provider being enabled)
+    currentset.push(id);
+    toolbar.setAttribute("currentset", currentset.join(","));
+    document.persist(toolbar.id, "currentset");
   },
 
+  removeProviderButton: function(origin) {
+    // this will remove the button from the palette or the toolbar
+    let button = this._getExistingButton(this.idFromOrgin(origin));
+    if (button)
+      button.parentNode.removeChild(button);
+  },
+
+  removePersistence: function(id) {
+    let persisted = document.querySelectorAll("*[currentset]");
+    for (let pent of persisted) {
+      // the button will have been removed, but left in the currentset attribute
+      // in case the user re-enables (e.g. undo in addon manager). So we only
+      // check the attribute here.
+      let currentset = pent.getAttribute("currentset").split(",");
+
+      let pos = currentset.indexOf(id);
+      if (pos >= 0) {
+        currentset.splice(pos, 1);
+        pent.setAttribute("currentset", currentset.join(","));
+        document.persist(pent.id, "currentset");
+        return;
+      }
+    }
+  },
+
+  // if social is entirely disabled, we need to clear the palette, but leave
+  // the persisted id's in place
   clearPalette: function() {
     [this.removeProviderButton(p.origin) for (p of Social.providers)];
   },
 
-  // should be called on enable of a provider
+  // should be called on startup of each window, otherwise the addon manager
+  // listener will handle new activations, or enable/disabling of a provider
+  // XXX we currently call more regularly, will fix during refactoring
   populatePalette: function() {
     if (!Social.enabled) {
       this.clearPalette();
       return;
     }
+    let persisted = document.querySelectorAll("*[currentset]");
+    let persistedById = {};
+    for (let pent of persisted) {
+      let pset = pent.getAttribute("currentset").split(',');
+      for (let id of pset)
+        persistedById[id] = pent;
+    }
 
     // create any buttons that do not exist yet if they have been persisted
     // as a part of the UI (otherwise they belong in the palette).
     for (let provider of Social.providers) {
-      let id = this.idFromOrigin(provider.origin);
-      let widget = CustomizableUI.getWidget(id);
-      // The widget is only null if we've created then destroyed the widget.
-      // Once we've actually called createWidget the provider will be set to
-      // PROVIDER_API.
-      if (!widget || widget.provider != CustomizableUI.PROVIDER_API)
-        this._createButton(provider);
+      let id = this.idFromOrgin(provider.origin);
+      if (this._getExistingButton(id))
+        continue;
+      let button = this._createButton(provider);
+      if (button && persistedById.hasOwnProperty(id)) {
+        let parent = persistedById[id];
+        let pset = persistedById[id].getAttribute("currentset").split(',');
+        let pi = pset.indexOf(id) + 1;
+        let next = document.getElementById(pset[pi]);
+        parent.insertItem(id, next, null, false);
+      }
     }
   }
 }
 
 SocialStatus = {
   populateToolbarPalette: function() {
     if (!Social.allowMultipleWorkers)
       return;
     this._toolbarHelper.populatePalette();
   },
 
+  setPosition: function(origin) {
+    if (!Social.allowMultipleWorkers)
+      return;
+    // this is called during install, before the provider is enabled so we have
+    // to use the manifest rather than the provider instance as we do elsewhere.
+    let manifest = Social.getManifestByOrigin(origin);
+    if (!manifest.statusURL)
+      return;
+    let tbh = this._toolbarHelper;
+    tbh.setPersistentPosition(tbh.idFromOrgin(origin));
+  },
+
+  removePosition: function(origin) {
+    if (!Social.allowMultipleWorkers)
+      return;
+    let tbh = this._toolbarHelper;
+    tbh.removePersistence(tbh.idFromOrgin(origin));
+  },
+
   removeProvider: function(origin) {
     if (!Social.allowMultipleWorkers)
       return;
     this._removeFrame(origin);
     this._toolbarHelper.removeProviderButton(origin);
   },
 
   _removeFrame: function(origin) {
@@ -1371,40 +1487,30 @@ SocialStatus = {
   get _dynamicResizer() {
     delete this._dynamicResizer;
     this._dynamicResizer = new DynamicResizeWatcher();
     return this._dynamicResizer;
   },
 
   _createButton: function(provider) {
     if (!provider.statusURL)
-      return;
-    let aId = this._toolbarHelper.idFromOrigin(provider.origin);
-    CustomizableUI.createWidget({
-      id: aId,
-      type: 'custom',
-      removable: true,
-      defaultArea: CustomizableUI.AREA_NAVBAR,
-      onBuild: function(document) {
-        let window = document.defaultView;
-
-        let node = document.createElement('toolbarbutton');
-
-        node.id = this.id;
-        node.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional social-status-button');
-        node.setAttribute('type', "badged");
-        node.style.listStyleImage = "url(" + provider.iconURL + ")";
-        node.setAttribute("origin", provider.origin);
-
-        node.setAttribute("label", provider.name);
-        node.setAttribute("tooltiptext", provider.name);
-        node.setAttribute("oncommand", "SocialStatus.showPopup(this);");
-        return node;
-      }
-    });
+      return null;
+    let palette = document.getElementById("navigator-toolbox").palette;
+    let button = document.createElement("toolbarbutton");
+    button.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional social-status-button");
+    button.setAttribute("type", "badged");
+    button.setAttribute("removable", "true");
+    button.setAttribute("image", provider.iconURL);
+    button.setAttribute("label", provider.name);
+    button.setAttribute("tooltiptext", provider.name);
+    button.setAttribute("origin", provider.origin);
+    button.setAttribute("oncommand", "SocialStatus.showPopup(this);");
+    button.setAttribute("id", this._toolbarHelper.idFromOrgin(provider.origin));
+    palette.appendChild(button);
+    return button;
   },
 
   // status panels are one-per button per-process, we swap the docshells between
   // windows when necessary
   _attachNotificatonPanel: function(aButton, provider) {
     let panel = document.getElementById("social-notification-panel");
     panel.hidden = !SocialUI.enabled;
     let notificationFrameId = "social-status-" + provider.origin;
@@ -1443,17 +1549,17 @@ SocialStatus = {
     }
     aButton.setAttribute("notificationFrameId", notificationFrameId);
   },
 
   updateButton: function(origin) {
     if (!Social.allowMultipleWorkers)
       return;
     let provider = Social._getProviderFromOrigin(origin);
-    let button = document.getElementById(this._toolbarHelper.idFromOrigin(provider.origin));
+    let button = document.getElementById(this._toolbarHelper.idFromOrgin(provider.origin));
     if (button) {
       // we only grab the first notification, ignore all others
       let icons = provider.ambientNotificationIcons;
       let iconNames = Object.keys(icons);
       let notif = icons[iconNames[0]];
 
       // The image and tooltip need to be updated for both
       // ambient notification and profile changes.
@@ -1585,17 +1691,17 @@ SocialMarks = {
 
   getProviders: function() {
     // only rely on providers that the user has placed in the UI somewhere. This
     // also means that populateToolbarPalette must be called prior to using this
     // method, otherwise you get a big fat zero. For our use case with context
     // menu's, this is ok.
     let tbh = this._toolbarHelper;
     return [p for (p of Social.providers) if (p.markURL &&
-                                              document.getElementById(tbh.idFromOrigin(p.origin)))];
+                                              document.getElementById(tbh.idFromOrgin(p.origin)))];
   },
 
   populateContextMenu: function() {
     // only show a selection if enabled and there is more than one
     let providers = this.getProviders();
 
     // remove all previous entries by class
     let menus = [m for (m of document.getElementsByClassName("context-socialmarks"))];
@@ -1644,51 +1750,55 @@ SocialMarks = {
     }
   },
 
   populateToolbarPalette: function() {
     this._toolbarHelper.populatePalette();
     this.populateContextMenu();
   },
 
+  setPosition: function(origin) {
+    // this is called during install, before the provider is enabled so we have
+    // to use the manifest rather than the provider instance as we do elsewhere.
+    let manifest = Social.getManifestByOrigin(origin);
+    if (!manifest.markURL)
+      return;
+    let tbh = this._toolbarHelper;
+    tbh.setPersistentPosition(tbh.idFromOrgin(origin));
+  },
+
+  removePosition: function(origin) {
+    let tbh = this._toolbarHelper;
+    tbh.removePersistence(tbh.idFromOrgin(origin));
+  },
+
   removeProvider: function(origin) {
     this._toolbarHelper.removeProviderButton(origin);
   },
 
   get _toolbarHelper() {
     delete this._toolbarHelper;
     this._toolbarHelper = new ToolbarHelper("social-mark-button", this._createButton.bind(this));
     return this._toolbarHelper;
   },
 
   _createButton: function(provider) {
     if (!provider.markURL)
-      return;
-    let aId = this._toolbarHelper.idFromOrigin(provider.origin);
-    CustomizableUI.createWidget({
-      id: aId,
-      type: 'custom',
-      removable: true,
-      defaultArea: CustomizableUI.AREA_NAVBAR,
-      onBuild: function(document) {
-        let window = document.defaultView;
-
-        let node = document.createElement('toolbarbutton');
-
-        node.id = this.id;
-        node.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional social-mark-button');
-        node.setAttribute('type', "socialmark");
-        node.style.listStyleImage = "url(" + provider.iconURL + ")";
-        node.setAttribute("origin", provider.origin);
-
-        return node;
-      }
-    });
+      return null;
+    let palette = document.getElementById("navigator-toolbox").palette;
+    let button = document.createElement("toolbarbutton");
+    button.setAttribute("type", "socialmark");
+    button.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional social-mark-button");
+    button.style.listStyleImage = "url(" + provider.iconURL + ")";
+    button.setAttribute("origin", provider.origin);
+    button.setAttribute("id", this._toolbarHelper.idFromOrgin(provider.origin));
+    palette.appendChild(button);
+    return button
   },
 
   markLink: function(aOrigin, aUrl) {
     // find the button for this provider, and open it
-    let id = this._toolbarHelper.idFromOrigin(aOrigin);
+    let id = this._toolbarHelper.idFromOrgin(aOrigin);
     document.getElementById(id).markLink(aUrl);
   }
 };
 
 })();
--- a/browser/base/content/browser-tabview.js
+++ b/browser/base/content/browser-tabview.js
@@ -421,23 +421,26 @@ let TabView = {
   _addToolbarButton: function TabView__addToolbarButton() {
     let buttonId = "tabview-button";
 
     if (document.getElementById(buttonId))
       return;
 
     let toolbar = document.getElementById("TabsToolbar");
     let currentSet = toolbar.currentSet.split(",");
+
     let alltabsPos = currentSet.indexOf("alltabs-button");
     if (-1 == alltabsPos)
       return;
 
-    let allTabsBtn = document.getElementById("alltabs-button");
-    let nextItem = allTabsBtn.nextSibling;
-    toolbar.insertItem(buttonId, nextItem);
+    currentSet[alltabsPos] += "," + buttonId;
+    currentSet = currentSet.join(",");
+    toolbar.currentSet = currentSet;
+    toolbar.setAttribute("currentset", currentSet);
+    document.persist(toolbar.id, "currentset");
   },
 
   // ----------
   // Function: updateGroupNumberBroadcaster
   // Updates the group number broadcaster.
   updateGroupNumberBroadcaster: function TabView_updateGroupNumberBroadcaster(number) {
     let groupsNumber = document.getElementById("tabviewGroupsNumber");
     groupsNumber.setAttribute("groups", number);
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -16,73 +16,16 @@
 searchbar {
   -moz-binding: url("chrome://browser/content/search/search.xml#searchbar");
 }
 
 .browserStack > browser[remote="true"] {
   -moz-binding: url("chrome://global/content/bindings/remote-browser.xml#remote-browser");
 }
 
-toolbar[customizable="true"] {
-  -moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar");
-}
-
-%ifdef XP_MACOSX
-#toolbar-menubar {
-  -moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar-menubar-stub");
-}
-
-toolbar[customizable="true"]:not([nowindowdrag="true"]) {
-  -moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar-drag");
-}
-%endif
-
-#toolbar-menubar[autohide="true"] {
-  -moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar-menubar-autohide");
-}
-
-#addon-bar {
-  -moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#addonbar-delegating");
-  visibility: visible;
-  margin: 0;
-  height: 0 !important;
-  overflow: hidden;
-  padding: 0;
-  border: 0 none;
-}
-
-#addonbar-closebutton {
-  visibility: visible;
-  height: 0 !important;
-}
-
-#status-bar {
-  height: 0 !important;
-  -moz-binding: none;
-  padding: 0;
-  margin: 0;
-}
-
-panelmultiview {
-  -moz-binding: url("chrome://browser/content/customizableui/panelUI.xml#panelmultiview");
-}
-
-panelview {
-  -moz-binding: url("chrome://browser/content/customizableui/panelUI.xml#panelview");
-  -moz-box-orient: vertical;
-}
-
-.panel-mainview {
-  transition: transform 150ms;
-}
-
-panelview:not([mainview]):not([current]) {
-  display: none;
-}
-
 tabbrowser {
   -moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser");
 }
 
 .tabbrowser-tabs {
   -moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-tabs");
 }
 
@@ -99,43 +42,31 @@ tabbrowser {
 }
 
 .tabbrowser-tab {
   -moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-tab");
 }
 
 .tabbrowser-tab:not([pinned]) {
   -moz-box-flex: 100;
-  max-width: 180px;
+  max-width: 250px;
   min-width: 100px;
   width: 0;
   transition: min-width 200ms ease-out,
-              max-width 230ms ease-out;
+              max-width 250ms ease-out,
+              opacity 50ms ease-out 20ms /* hide the tab for the first 20ms of the max-width transition */;
 }
 
 .tabbrowser-tab:not([pinned]):not([fadein]) {
   max-width: 0.1px;
   min-width: 0.1px;
-  visibility: hidden;
+  opacity: 0 !important;
   transition: min-width 200ms ease-out,
-              max-width 230ms ease-out;
-}
-
-.tab-background {
-  /* Explicitly set the visibility to override the value (collapsed)
-   * we inherit from #TabsToolbar[collapsed] upon opening a browser window. */
-  visibility: visible;
-  /* The transition is only delayed for opening tabs. */
-  transition: visibility 0ms 25ms;
-}
-
-.tab-background:not([fadein]):not([pinned]) {
-  visibility: hidden;
-  /* Closing tabs are hidden without a delay. */
-  transition-delay: 0ms;
+              max-width 250ms ease-out,
+              opacity 50ms ease-out 180ms /* hide the tab for the last 20ms of the max-width transition */;
 }
 
 .tab-throbber:not([fadein]):not([pinned]),
 .tab-label:not([fadein]):not([pinned]),
 .tab-icon-image:not([fadein]):not([pinned]),
 .tab-close-button:not([fadein]):not([pinned]) {
   display: none;
 }
@@ -158,23 +89,30 @@ tabbrowser {
 #alltabs-popup {
   -moz-binding: url("chrome://browser/content/tabbrowser.xml#tabbrowser-alltabs-popup");
 }
 
 toolbar[printpreview="true"] {
   -moz-binding: url("chrome://global/content/printPreviewBindings.xml#printpreviewtoolbar");
 }
 
-toolbar[overflowable] > .customization-target {
-  overflow: hidden;
+#toolbar-menubar {
+  -moz-box-ordinal-group: 5;
 }
 
-toolbar:not([overflowing]) > .overflow-button,
-toolbar[customizing] > .overflow-button {
-  display: none;
+#navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar) {
+  -moz-box-ordinal-group: 50;
+}
+
+#TabsToolbar {
+  -moz-box-ordinal-group: 100;
+}
+
+#TabsToolbar[tabsontop="true"] {
+  -moz-box-ordinal-group: 10;
 }
 
 %ifdef CAN_DRAW_IN_TITLEBAR
 #main-window[inFullscreen] > #titlebar,
 #main-window[inFullscreen] .titlebar-placeholder,
 #main-window:not([tabsintitlebar]) .titlebar-placeholder {
   display: none;
 }
@@ -182,118 +120,53 @@ toolbar[customizing] > .overflow-button 
 #titlebar {
   -moz-binding: url("chrome://global/content/bindings/general.xml#windowdragbox");
 }
 
 #titlebar-spacer {
   pointer-events: none;
 }
 
+#main-window[tabsintitlebar] #appmenu-button-container,
 #main-window[tabsintitlebar] #titlebar-buttonbox {
   position: relative;
 }
-
-#titlebar-buttonbox {
-  -moz-appearance: -moz-window-button-box;
-}
-
-%ifdef XP_MACOSX
-#titlebar-fullscreen-button {
-  -moz-appearance: -moz-mac-fullscreen-button;
-}
-
-/* Because these buttons don't move, they should always be aligned the same,
- * left and right were deprecated, so we have to do work to get it to mean that: */
-#titlebar-buttonbox-container:-moz-locale-dir(ltr) {
-  -moz-box-align: start;
-}
-
-#titlebar-buttonbox-container:-moz-locale-dir(rtl) {
-  -moz-box-align: end;
-}
-
-/* Fullscreen and caption buttons don't move with RTL on OS X so override the automatic ordering. */
-#titlebar-fullscreen-button:-moz-locale-dir(ltr),
-#titlebar-buttonbox-container:-moz-locale-dir(rtl),
-.titlebar-placeholder[type="fullscreen-button"]:-moz-locale-dir(ltr),
-.titlebar-placeholder[type="caption-buttons"]:-moz-locale-dir(rtl) {
-  -moz-box-ordinal-group: 1000;
-}
-
-#titlebar-fullscreen-button:-moz-locale-dir(rtl),
-#titlebar-buttonbox-container:-moz-locale-dir(ltr),
-.titlebar-placeholder[type="caption-buttons"]:-moz-locale-dir(ltr),
-.titlebar-placeholder[type="fullscreen-button"]:-moz-locale-dir(rtl) {
-  -moz-box-ordinal-group: 0;
-}
-%else
-/* On non-OSX, these should be start-aligned */
-#titlebar-buttonbox-container {
-  -moz-box-align: start;
-}
-%endif
-
-%ifdef XP_WIN
-#main-window[sizemode="maximized"] #titlebar-buttonbox {
-  -moz-appearance: -moz-window-button-box-maximized;
-}
 %endif
 
-%endif
-
-/* Rules to help integrate SDK widgets */
-toolbarpaletteitem > toolbaritem[sdkstylewidget="true"] > .toolbarbutton-text {
-  display: -moz-box;
-}
-
-toolbarpaletteitem > toolbaritem[sdkstylewidget="true"] > iframe {
+.bookmarks-toolbar-customize,
+#wrapper-personal-bookmarks > #personal-bookmarks > #PlacesToolbar > hbox > #PlacesToolbarItems {
   display: none;
 }
 
-#bookmarks-toolbar-placeholder,
-toolbarpaletteitem > #personal-bookmarks > #PlacesToolbar,
-#personal-bookmarks[cui-areatype="menu-panel"] > #PlacesToolbar,
-#personal-bookmarks[cui-areatype="toolbar"].overflowedItem > #PlacesToolbar {
-  display: none;
-}
-
-toolbarpaletteitem > #personal-bookmarks > #bookmarks-toolbar-placeholder,
-#personal-bookmarks[cui-areatype="menu-panel"] > #bookmarks-toolbar-placeholder,
-#personal-bookmarks[cui-areatype="toolbar"].overflowedItem > #bookmarks-toolbar-placeholder {
+#wrapper-personal-bookmarks[place="toolbar"] > #personal-bookmarks > #PlacesToolbar > .bookmarks-toolbar-customize {
   display: -moz-box;
 }
 
-#zoom-controls[cui-areatype="toolbar"]:not(.overflowedItem) > #zoom-reset-button > .toolbarbutton-text {
-  display: -moz-box;
-}
-
-#wrapper-urlbar-container > #urlbar-container > #urlbar-wrapper > #urlbar > toolbarbutton,
-#urlbar-reload-button:not([displaystop]) + #urlbar-stop-button,
-#urlbar-reload-button[displaystop] {
+#main-window[disablechrome] #navigator-toolbox[tabsontop="true"] > toolbar:not(#toolbar-menubar):not(#TabsToolbar) {
   visibility: collapse;
 }
 
-#PanelUI-feeds > .feed-toolbarbutton:-moz-locale-dir(rtl) {
-  direction: rtl;
+#wrapper-urlbar-container #urlbar-container > #urlbar > toolbarbutton,
+#urlbar-container:not([combined]) > #urlbar > toolbarbutton,
+#urlbar-container[combined] + #reload-button + #stop-button,
+#urlbar-container[combined] + #reload-button,
+toolbar:not([mode="icons"]) > #urlbar-container > #urlbar > toolbarbutton,
+toolbar[mode="icons"] > #urlbar-container > #urlbar > #urlbar-reload-button:not([displaystop]) + #urlbar-stop-button,
+toolbar[mode="icons"] > #urlbar-container > #urlbar > #urlbar-reload-button[displaystop],
+toolbar[mode="icons"] > #reload-button:not([displaystop]) + #stop-button,
+toolbar[mode="icons"] > #reload-button[displaystop] {
+  visibility: collapse;
 }
 
-#panelMenu_bookmarksMenu {
-  overflow-x: hidden;
-  overflow-y: auto;
-}
-#panelMenu_bookmarksMenu > .bookmark-item {
-  max-width: none;
+#feed-button > .toolbarbutton-menu-dropmarker {
+  display: none;
 }
 
-#urlbar-container {
-  min-width: 50ch;
-}
-
-#search-container {
-  min-width: 25ch;
+#feed-menu > .feed-menuitem:-moz-locale-dir(rtl) {
+  direction: rtl;
 }
 
 #main-window:-moz-lwtheme {
   background-repeat: no-repeat;
   background-position: top right;
 }
 
 %ifdef XP_MACOSX
@@ -302,26 +175,59 @@ toolbarpaletteitem > #personal-bookmarks
 }
 %endif
 
 #browser-bottombox[lwthemefooter="true"] {
   background-repeat: no-repeat;
   background-position: bottom left;
 }
 
+splitmenu {
+  -moz-binding: url("chrome://browser/content/urlbarBindings.xml#splitmenu");
+}
+
+.splitmenu-menuitem {
+  -moz-binding: url("chrome://global/content/bindings/menu.xml#menuitem");
+  list-style-image: inherit;
+  -moz-image-region: inherit;
+}
+
+.splitmenu-menuitem[iconic="true"] {
+  -moz-binding: url("chrome://global/content/bindings/menu.xml#menuitem-iconic");
+}
+
+.splitmenu-menu > .menu-text,
+:-moz-any(.splitmenu-menu, .splitmenu-menuitem) > .menu-accel-container,
+#appmenu-editmenu > .menu-text,
+#appmenu-editmenu > .menu-accel-container {
+  display: none;
+}
+
 .menuitem-tooltip {
   -moz-binding: url("chrome://browser/content/urlbarBindings.xml#menuitem-tooltip");
 }
 
 .menuitem-iconic-tooltip,
 .menuitem-tooltip[type="checkbox"],
 .menuitem-tooltip[type="radio"] {
   -moz-binding: url("chrome://browser/content/urlbarBindings.xml#menuitem-iconic-tooltip");
 }
 
+%ifdef MENUBAR_CAN_AUTOHIDE
+%ifndef CAN_DRAW_IN_TITLEBAR
+#appmenu-toolbar-button > .toolbarbutton-text {
+  display: -moz-box;
+}
+%endif
+
+#appmenu_offlineModeRecovery:not([checked=true]) {
+  display: none;
+}
+%endif
+
 /* Hide menu elements intended for keyboard access support */
 #main-menubar[openedwithkey=false] .show-only-for-keyboard {
   display: none;
 }
 
 /* ::::: location bar ::::: */
 #urlbar {
   -moz-binding: url(chrome://browser/content/urlbarBindings.xml#urlbar);
@@ -346,30 +252,32 @@ panel[noactions] > richlistbox > richlis
 panel[noactions] > richlistbox > richlistitem[type~="action"] > .ac-url-box > .ac-url > .ac-url-text {
   visibility: visible;
 }
 
 #urlbar:not([actiontype]) > #urlbar-display-box {
   display: none;
 }
 
-#wrapper-urlbar-container > #urlbar-container > #urlbar-wrapper > #urlbar {
+#wrapper-urlbar-container > #urlbar-container > #urlbar {
   -moz-user-input: disabled;
   cursor: grab;
 }
 
 #PopupAutoComplete {
   -moz-binding: url("chrome://browser/content/urlbarBindings.xml#browser-autocomplete-result-popup");
 }
 
 #PopupAutoCompleteRichResult {
   -moz-binding: url("chrome://browser/content/urlbarBindings.xml#urlbar-rich-result-popup");
 }
 
-#urlbar[pageproxystate="invalid"] > #urlbar-icons > .urlbar-icon,
+#urlbar-container[combined] > #urlbar > #urlbar-icons > #go-button,
+#urlbar[pageproxystate="invalid"] > #urlbar-icons > .urlbar-icon:not(#go-button),
+#urlbar[pageproxystate="valid"] > #urlbar-icons > #go-button,
 #urlbar[pageproxystate="invalid"][focused="true"] > #urlbar-go-button ~ toolbarbutton,
 #urlbar[pageproxystate="valid"] > #urlbar-go-button,
 #urlbar:not([focused="true"]) > #urlbar-go-button {
   visibility: collapse;
 }
 
 #urlbar[pageproxystate="invalid"] > #identity-box > #identity-icon-labels {
   visibility: collapse;
@@ -403,30 +311,28 @@ panel[noactions] > richlistbox > richlis
 .unified-nav-current {
   font-weight: bold;
 }
 
 toolbarbutton.bookmark-item {
   max-width: 13em;
 }
 
+%ifdef MENUBAR_CAN_AUTOHIDE
+#toolbar-menubar:not([autohide="true"]) ~ toolbar > #bookmarks-menu-button,
+#toolbar-menubar:not([autohide="true"]) > #bookmarks-menu-button {
+  display: none;
+}
+%endif
+
 #editBMPanel_tagsSelector {
   /* override default listbox width from xul.css */
   width: auto;
 }
 
-/* The star doesn't make sense as text */
-toolbar[mode="text"] #bookmarks-menu-button > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
-  display: -moz-box !important;
-}
-toolbar[mode="text"] #bookmarks-menu-button > .toolbarbutton-menubutton-button > .toolbarbutton-text,
-toolbar[mode="full"] #bookmarks-menu-button.bookmark-item > .toolbarbutton-menubutton-button > .toolbarbutton-text {
-  display: none;
-}
-
 menupopup[emptyplacesresult="true"] > .hide-if-empty-places-result {
   display: none;
 }
 
 menuitem.spell-suggestion {
   font-weight: bold;
 }
 
@@ -441,16 +347,17 @@ window[sizemode="maximized"] #content .n
 
 /* Hide extension toolbars that neglected to set the proper class */
 window[chromehidden~="location"][chromehidden~="toolbar"] toolbar:not(.chromeclass-menubar),
 window[chromehidden~="toolbar"] toolbar:not(.toolbar-primary):not(.chromeclass-menubar) {
   display: none;
 }
 
 #navigator-toolbox ,
+#status-bar ,
 #mainPopupSet {
   min-width: 1px;
 }
 
 %ifdef MOZ_SERVICES_SYNC
 /* Sync notification UI */
 #sync-notifications {
   -moz-binding: url("chrome://browser/content/sync/notification.xml#notificationbox");
@@ -539,16 +446,24 @@ window[chromehidden~="toolbar"] toolbar:
 
 #full-screen-domain-text,
 #full-screen-remember-decision > .checkbox-label-box > .checkbox-label {
   word-wrap: break-word;
   /* We must specify a min-width, otherwise word-wrap:break-word doesn't work. Bug 630864. */
   min-width: 1px;
 }
 
+#nav-bar[mode="text"] > #window-controls > toolbarbutton > .toolbarbutton-icon {
+  display: -moz-box;
+}
+
+#nav-bar[mode="text"] > #window-controls > toolbarbutton > .toolbarbutton-text {
+  display: none;
+}
+
 /* ::::: Ctrl-Tab Panel ::::: */
 
 .ctrlTab-preview > html|img,
 .ctrlTab-preview > html|canvas {
   min-width: inherit;
   max-width: inherit;
   min-height: inherit;
   max-height: inherit;
@@ -603,16 +518,27 @@ window[chromehidden~="toolbar"] toolbar:
 #click-to-play-plugins-notification {
   -moz-binding: url("chrome://browser/content/urlbarBindings.xml#click-to-play-plugins-notification");
 }
 
 .plugin-popupnotification-centeritem {
   -moz-binding: url("chrome://browser/content/urlbarBindings.xml#plugin-popupnotification-center-item");
 }
 
+/* override hidden="true" for the status bar compatibility shim
+   in case it was persisted for the real status bar */
+#status-bar {
+  display: -moz-box;
+}
+
+/* Remove the resizer from the statusbar compatibility shim */
+#status-bar[hideresizer] > .statusbar-resizerpanel {
+  display: none;
+}
+
 browser[tabmodalPromptShowing] {
   -moz-user-focus: none !important;
 }
 
 /* Status panel */
 
 statuspanel {
   -moz-binding: url("chrome://browser/content/tabbrowser.xml#statuspanel");
@@ -845,105 +771,16 @@ chatbox:-moz-full-screen-ancestor > .cha
   /* color: menutext used to overwrite the disabled color */
   color: menutext;
 }
 
 .contentSelectDropdown-ingroup {
   -moz-margin-start: 2em;
 }
 
-/* Give this menupopup an arrow panel styling */
-#BMB_bookmarksPopup {
-  -moz-appearance: none;
-  -moz-binding: url("chrome://browser/content/places/menu.xml#places-popup-arrow");
-  background: transparent;
-  border: none;
-  transition: opacity 300ms;
-  /* The popup inherits -moz-image-region from the button, must reset it */
-  -moz-image-region: auto;
-}
-
-/* Customize mode */
-#tab-view-deck {
-  transition-property: padding;
-  transition-duration: 150ms;
-  transition-timing-function: ease-out;
-}
-
-#tab-view-deck[fastcustomizeanimation] {
-  transition-duration: 1ms;
-  transition-timing-function: linear;
-}
-
-#PanelUI-contents > .panel-customization-placeholder > .panel-customization-placeholder-child {
-  list-style-image: none;
-}
-
-#customization-panelHolder {
-  overflow-y: hidden;
-}
-
-#customization-panelWrapper,
-#customization-panelWrapper > .panel-arrowcontent {
-  -moz-box-flex: 1;
-}
-
-#customization-panelWrapper > .panel-arrowcontent {
-  padding: 0 !important;
-}
-
-#customization-panelHolder > #PanelUI-mainView {
-  display: flex;
-  flex-direction: column;
-  /* Hack alert - by manually setting the preferred height to 0, we convince
-     #PanelUI-mainView to shrink when the window gets smaller in customization
-     mode. Not sure why that is - might have to do with our intermingling of
-     XUL flex, and CSS3 Flexbox. */
-  height: 0;
-}
-
-#customization-panelHolder > #PanelUI-mainView > #PanelUI-contents-scroller {
-  display: flex;
-  flex: auto;
-  flex-direction: column;
-}
-
-#customization-panel-container {
-  overflow-y: auto;
-}
-
-toolbarpaletteitem[dragover] {
-  border-left-color: transparent;
-  border-right-color: transparent;
-}
-
-#customization-palette:not([hidden]) {
-  display: block;
-  overflow: auto;
-  min-height: 3em;
-}
-
-toolbarpaletteitem[place="palette"] {
-  width: 110px;
-  height: 94px;
-  overflow: hidden;
-  display: inline-block;
-}
-
-toolbarpaletteitem[place="palette"][hidden] {
-  display: none;
-}
-
-#customization-palette .toolbarpaletteitem-box {
-  -moz-box-pack: center;
-  -moz-box-flex: 1;
-  width: 110px;
-  max-width: 110px;
-}
-
 /* UI Tour */
 
 @keyframes uitour-wobble {
   from {
     transform: rotate(0deg) translateX(2px) rotate(0deg);
   }
   to {
     transform: rotate(360deg) translateX(2px) rotate(-360deg);
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -82,22 +82,16 @@ this.__defineGetter__("PluralForm", func
 this.__defineSetter__("PluralForm", function (val) {
   delete this.PluralForm;
   return this.PluralForm = val;
 });
 
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch",
   "resource://gre/modules/TelemetryStopwatch.jsm");
 
-XPCOMUtils.defineLazyGetter(this, "gCustomizeMode", function() {
-  let scope = {};
-  Cu.import("resource:///modules/CustomizeMode.jsm", scope);
-  return new scope.CustomizeMode(window);
-});
-
 #ifdef MOZ_SERVICES_SYNC
 XPCOMUtils.defineLazyModuleGetter(this, "Weave",
   "resource://services-sync/main.js");
 #endif
 
 XPCOMUtils.defineLazyGetter(this, "PopupNotifications", function () {
   let tmp = {};
   Cu.import("resource://gre/modules/PopupNotifications.jsm", tmp);
@@ -146,27 +140,29 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 XPCOMUtils.defineLazyModuleGetter(this, "SessionStore",
   "resource:///modules/sessionstore/SessionStore.jsm");
 
 #ifdef MOZ_CRASHREPORTER
 XPCOMUtils.defineLazyModuleGetter(this, "TabCrashReporter",
   "resource:///modules/TabCrashReporter.jsm");
 #endif
 
+XPCOMUtils.defineLazyModuleGetter(this, "BrowserUITelemetry",
+  "resource:///modules/BrowserUITelemetry.jsm");
+
 let gInitialPages = [
   "about:blank",
   "about:newtab",
   "about:home",
   "about:privatebrowsing",
   "about:welcomeback",
   "about:sessionrestore"
 ];
 
 #include browser-addons.js
-#include browser-customization.js
 #include browser-feeds.js
 #include browser-fullScreen.js
 #include browser-fullZoom.js
 #include browser-places.js
 #include browser-plugins.js
 #include browser-safebrowsing.js
 #include browser-social.js
 #include browser-tabPreviews.js
@@ -319,32 +315,39 @@ function SetClickAndHoldHandlers() {
     }
   }
 
   function _addClickAndHoldListenersOnElement(aElm) {
     aElm.addEventListener("mousedown", mousedownHandler, true);
     aElm.addEventListener("click", clickHandler, true);
   }
 
-  // Bug 414797: Clone the back/forward buttons' context menu into both buttons.
-  let popup = document.getElementById("backForwardMenu").cloneNode(true);
-  popup.removeAttribute("id");
-  // Prevent the back/forward buttons' context attributes from being inherited.
-  popup.setAttribute("context", "");
-
-  let backButton = document.getElementById("back-button");
-  backButton.setAttribute("type", "menu");
-  backButton.appendChild(popup);
-  _addClickAndHoldListenersOnElement(backButton);
-
-  let forwardButton = document.getElementById("forward-button");
-  popup = popup.cloneNode(true);
-  forwardButton.setAttribute("type", "menu");
-  forwardButton.appendChild(popup);
-  _addClickAndHoldListenersOnElement(forwardButton);
+  // Bug 414797: Clone unified-back-forward-button's context menu into both the
+  // back and the forward buttons.
+  var unifiedButton = document.getElementById("unified-back-forward-button");
+  if (unifiedButton && !unifiedButton._clickHandlersAttached) {
+    unifiedButton._clickHandlersAttached = true;
+
+    let popup = document.getElementById("backForwardMenu").cloneNode(true);
+    popup.removeAttribute("id");
+    // Prevent the context attribute on unified-back-forward-button from being
+    // inherited.
+    popup.setAttribute("context", "");
+
+    let backButton = document.getElementById("back-button");
+    backButton.setAttribute("type", "menu");
+    backButton.appendChild(popup);
+    _addClickAndHoldListenersOnElement(backButton);
+
+    let forwardButton = document.getElementById("forward-button");
+    popup = popup.cloneNode(true);
+    forwardButton.setAttribute("type", "menu");
+    forwardButton.appendChild(popup);
+    _addClickAndHoldListenersOnElement(forwardButton);
+  }
 }
 
 const gSessionHistoryObserver = {
   observe: function(subject, topic, data)
   {
     if (topic != "browser:purge-session-history")
       return;
 
@@ -734,18 +737,16 @@ const gFormSubmitObserver = {
       position = "after_start";
     }
 
     this.panel.openPopup(element, position, offset, 0);
   }
 };
 
 var gBrowserInit = {
-  delayedStartupFinished: false,
-
   onLoad: function() {
     gMultiProcessBrowser = gPrefService.getBoolPref("browser.tabs.remote");
 
     var mustLoadSidebar = false;
 
     if (!gMultiProcessBrowser) {
       // There is a Content:Click message manually sent from content.
       Cc["@mozilla.org/eventlistenerservice;1"]
@@ -888,29 +889,38 @@ var gBrowserInit = {
         // border.  Use 28px as a guess (titlebar + bottom window border)
         defaultHeight -= 28;
 #endif
       }
       document.documentElement.setAttribute("width", defaultWidth);
       document.documentElement.setAttribute("height", defaultHeight);
     }
 
+    if (!gShowPageResizers)
+      document.getElementById("status-bar").setAttribute("hideresizer", "true");
+
     if (!window.toolbar.visible) {
       // adjust browser UI for popups
       if (gURLBar) {
         gURLBar.setAttribute("readonly", "true");
         gURLBar.setAttribute("enablehistory", "false");
       }
       goSetCommandEnabled("cmd_newNavigatorTab", false);
     }
 
+#ifdef MENUBAR_CAN_AUTOHIDE
+    updateAppButtonDisplay();
+#endif
+
     // Misc. inits.
     CombinedStopReload.init();
+    TabsOnTop.init();
     gPrivateBrowsingUI.init();
     TabsInTitlebar.init();
+    retrieveToolbarIconsizesFromTheme();
 
     // Wait until chrome is painted before executing code not critical to making the window visible
     this._boundDelayedStartup = this._delayedStartup.bind(this, mustLoadSidebar);
     window.addEventListener("MozAfterPaint", this._boundDelayedStartup);
 
     this._loadHandled = true;
   },
 
@@ -1002,23 +1012,17 @@ var gBrowserInit = {
     Services.obs.addObserver(gXPInstallObserver, "addon-install-complete", false);
     Services.obs.addObserver(gFormSubmitObserver, "invalidformsubmit", false);
 
     BrowserOffline.init();
     OfflineApps.init();
     IndexedDBPromptHelper.init();
     gFormSubmitObserver.init();
     SocialUI.init();
-
-    // Initialize the full zoom setting.
-    // We do this before the session restore service gets initialized so we can
-    // apply full zoom settings to tabs restored by the session restore service.
-    FullZoom.init();
-    PanelUI.init();
-    LightweightThemeListener.init();
+    AddonManager.addAddonListener(AddonsMgrListener);
     WebrtcIndicator.init();
 
     // Ensure login manager is up and running.
     Services.logins;
 
 #ifdef MOZ_CRASHREPORTER
     if (gMultiProcessBrowser)
       TabCrashReporter.init();
@@ -1059,16 +1063,21 @@ var gBrowserInit = {
       document.getElementById("textfieldDirection-swap").hidden = false;
     }
 
     // Setup click-and-hold gestures access to the session history
     // menus if global click-and-hold isn't turned on
     if (!getBoolPref("ui.click_hold_context_menus", false))
       SetClickAndHoldHandlers();
 
+    // Initialize the full zoom setting.
+    // We do this before the session restore service gets initialized so we can
+    // apply full zoom settings to tabs restored by the session restore service.
+    FullZoom.init();
+
     // Bug 666804 - NetworkPrioritizer support for e10s
     if (!gMultiProcessBrowser) {
       let NP = {};
       Cu.import("resource:///modules/NetworkPrioritizer.jsm", NP);
       NP.trackBrowserWindow(window);
     }
 
     PlacesToolbarHelper.init();
@@ -1129,25 +1138,54 @@ var gBrowserInit = {
 #endif
 
 #ifdef MOZ_DATA_REPORTING
     gDataNotificationInfoBar.init();
 #endif
 
     gBrowserThumbnails.init();
 
+    setUrlAndSearchBarWidthForConditionalForwardButton();
+    window.addEventListener("resize", function resizeHandler(event) {
+      if (event.target == window)
+        setUrlAndSearchBarWidthForConditionalForwardButton();
+    });
+
+#ifdef MENUBAR_CAN_AUTOHIDE
+    // If the user (or the locale) hasn't enabled the top-level "Character
+    // Encoding" menu via the "browser.menu.showCharacterEncoding" preference,
+    // hide it.
+    if ("true" != gPrefService.getComplexValue("browser.menu.showCharacterEncoding",
+                                               Ci.nsIPrefLocalizedString).data)
+      document.getElementById("appmenu_charsetMenu").hidden = true;
+#endif
+
     // Add Devtools menuitems and listeners
     gDevToolsBrowser.registerBrowserWindow(window);
 
+    let appMenuButton = document.getElementById("appmenu-button");
+    let appMenuPopup = document.getElementById("appmenu-popup");
+    if (appMenuButton && appMenuPopup) {
+      let appMenuOpening = null;
+      appMenuButton.addEventListener("mousedown", function(event) {
+        if (event.button == 0)
+          appMenuOpening = new Date();
+      }, false);
+      appMenuPopup.addEventListener("popupshown", function(event) {
+        if (event.target != appMenuPopup || !appMenuOpening)
+          return;
+        let duration = new Date() - appMenuOpening;
+        appMenuOpening = null;
+        Services.telemetry.getHistogramById("FX_APP_MENU_OPEN_MS").add(duration);
+      }, false);
+    }
+
     window.addEventListener("mousemove", MousePosTracker, false);
     window.addEventListener("dragover", MousePosTracker, false);
 
-    gNavToolbox.addEventListener("customizationstarting", CustomizationHandler);
-    gNavToolbox.addEventListener("customizationending", CustomizationHandler);
-
     // End startup crash tracking after a delay to catch crashes while restoring
     // tabs and to postpone saving the pref to disk.
     try {
       const startupCrashEndDelay = 30 * 1000;
       setTimeout(Services.startup.trackStartupCrashEnd, startupCrashEndDelay);
     } catch (ex) {
       Cu.reportError("Could not end startup crash tracking: " + ex);
     }
@@ -1167,17 +1205,16 @@ var gBrowserInit = {
     SessionStore.promiseInitialized.then(() => {
       // Enable the Restore Last Session command if needed
       RestoreLastSessionObserver.init();
 
       TabView.init();
 
       setTimeout(function () { BrowserChromeTest.markAsReady(); }, 0);
     });
-    this.delayedStartupFinished = true;
 
     Services.obs.notifyObservers(window, "browser-delayed-startup-finished", "");
     TelemetryTimestamps.add("delayedStartupFinished");
   },
 
   // Returns the URI(s) to load at startup.
   _getUriToLoad: function () {
     // window.arguments[0]: URI to load (string), or an nsISupportsArray of
@@ -1233,16 +1270,18 @@ var gBrowserInit = {
     try {
       gBrowser.removeProgressListener(window.XULBrowserWindow);
       gBrowser.removeTabsProgressListener(window.TabsProgressListener);
     } catch (ex) {
     }
 
     BookmarkingUI.uninit();
 
+    TabsOnTop.uninit();
+
     TabsInTitlebar.uninit();
 
     var enumerator = Services.wm.getEnumerator(null);
     enumerator.getNext();
     if (!enumerator.hasMoreElements()) {
       document.persist("sidebar-box", "sidebarcommand");
       document.persist("sidebar-box", "width");
       document.persist("sidebar-box", "src");
@@ -1279,19 +1318,18 @@ var gBrowserInit = {
 
       if (typeof WindowsPrefSync !== 'undefined') {
         WindowsPrefSync.uninit();
       }
 
       BrowserOffline.uninit();
       OfflineApps.uninit();
       IndexedDBPromptHelper.uninit();
+      AddonManager.removeAddonListener(AddonsMgrListener);
       SocialUI.uninit();
-      LightweightThemeListener.uninit();
-      PanelUI.uninit();
     }
 
     // Final window teardown, do this last.
     window.XULBrowserWindow = null;
     window.QueryInterface(Ci.nsIInterfaceRequestor)
           .getInterface(Ci.nsIWebNavigation)
           .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
           .QueryInterface(Ci.nsIInterfaceRequestor)
@@ -1306,17 +1344,17 @@ var gBrowserInit = {
   // macBrowserOverlay
   nonBrowserWindowStartup: function() {
     // Disable inappropriate commands / submenus
     var disabledItems = ['Browser:SavePage',
                          'Browser:SendLink', 'cmd_pageSetup', 'cmd_print', 'cmd_find', 'cmd_findAgain',
                          'viewToolbarsMenu', 'viewSidebarMenuMenu', 'Browser:Reload',
                          'viewFullZoomMenu', 'pageStyleMenu', 'charsetMenu', 'View:PageSource', 'View:FullScreen',
                          'viewHistorySidebar', 'Browser:AddBookmarkAs', 'Browser:BookmarkAllTabs',
-                         'View:PageInfo', 'Browser:ToggleTabView'];
+                         'View:PageInfo', 'Browser:ToggleTabView', 'Browser:ToggleAddonBar'];
     var element;
 
     for (let disabledItem of disabledItems) {
       element = document.getElementById(disabledItem);
       if (element)
         element.setAttribute("disabled", "true");
     }
 
@@ -2105,47 +2143,60 @@ function losslessDecodeURI(aURI) {
   return value;
 }
 
 function UpdateUrlbarSearchSplitterState()
 {
   var splitter = document.getElementById("urlbar-search-splitter");
   var urlbar = document.getElementById("urlbar-container");
   var searchbar = document.getElementById("search-container");
-
-  // If the splitter is already in the right place, we don't need to do anything:
-  if (splitter &&
-      ((splitter.nextSibling == searchbar && splitter.previousSibling == urlbar) ||
-       (splitter.nextSibling == urlbar && splitter.previousSibling == searchbar))) {
-    return;
-  }
+  var stop = document.getElementById("stop-button");
 
   var ibefore = null;
   if (urlbar && searchbar) {
-    if (urlbar.nextSibling == searchbar)
+    if (urlbar.nextSibling == searchbar ||
+        urlbar.getAttribute("combined") &&
+        stop && stop.nextSibling == searchbar)
       ibefore = searchbar;
     else if (searchbar.nextSibling == urlbar)
       ibefore = urlbar;
   }
 
   if (ibefore) {
     if (!splitter) {
       splitter = document.createElement("splitter");
       splitter.id = "urlbar-search-splitter";
       splitter.setAttribute("resizebefore", "flex");
       splitter.setAttribute("resizeafter", "flex");
       splitter.setAttribute("skipintoolbarset", "true");
-      splitter.setAttribute("overflows", "false");
       splitter.className = "chromeclass-toolbar-additional";
     }
     urlbar.parentNode.insertBefore(splitter, ibefore);
   } else if (splitter)
     splitter.parentNode.removeChild(splitter);
 }
 
+function setUrlAndSearchBarWidthForConditionalForwardButton() {
+  // Workaround for bug 694084: Showing/hiding the conditional forward button resizes
+  // the search bar when the url/search bar splitter hasn't been used.
+  var urlbarContainer = document.getElementById("urlbar-container");
+  var searchbarContainer = document.getElementById("search-container");
+  if (!urlbarContainer ||
+      !searchbarContainer ||
+      urlbarContainer.hasAttribute("width") ||
+      searchbarContainer.hasAttribute("width") ||
+      urlbarContainer.parentNode != searchbarContainer.parentNode)
+    return;
+  urlbarContainer.style.width = searchbarContainer.style.width = "";
+  var urlbarWidth = urlbarContainer.clientWidth;
+  var searchbarWidth = searchbarContainer.clientWidth;
+  urlbarContainer.style.width = urlbarWidth + "px";
+  searchbarContainer.style.width = searchbarWidth + "px";
+}
+
 function UpdatePageProxyState()
 {
   if (gURLBar && gURLBar.value != gLastValidURLStr)
     SetPageProxyState("invalid");
 }
 
 function SetPageProxyState(aState)
 {
@@ -2458,19 +2509,19 @@ function _checkDefaultAndSwitchToMetro()
 #ifdef XP_WIN
 #ifdef MOZ_METRO
   let shell = Components.classes["@mozilla.org/browser/shell-service;1"].
     getService(Components.interfaces.nsIShellService);
   let isDefault = shell.isDefaultBrowser(false, false);
 
   if (isDefault) {
     let appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"].
-    getService(Components.interfaces.nsIAppStartup);
-
-    Services.prefs.setBoolPref('browser.sessionstore.resume_session_once', true);
+      getService(Components.interfaces.nsIAppStartup);
+
+    Services.prefs.setBoolPref("browser.sessionstore.resume_session_once", true);
     appStartup.quit(Components.interfaces.nsIAppStartup.eAttemptQuit |
                     Components.interfaces.nsIAppStartup.eRestartTouchEnvironment);
     return true;
   }
   return false;
 #endif
 #endif
 #endif
@@ -2491,16 +2542,31 @@ function SwitchToMetro() {
 
   let intervalID = window.setInterval(this._checkDefaultAndSwitchToMetro, 1000);
   window.setTimeout(function() { window.clearInterval(intervalID); }, 10000);
 #endif
 #endif
 #endif
 }
 
+function isInWin8() {
+  let sysInfo = Services.sysinfo;
+  let osName = sysInfo.getProperty("name");
+  let version = sysInfo.getProperty("version");
+
+  // Windows 8 is version >= 6.2
+  return osName == "Windows_NT" && version >= 6.2;
+}
+
+function updateSwitchToMetroVisibility() {
+  if (PrivateBrowsingUtils.isWindowPrivate(window) || !isInWin8()) {
+    document.getElementById("switch-to-metro").hidden = true;
+  }
+}
+
 function onFullScreen(event) {
   FullScreen.toggle(event);
 }
 
 function onMozEnteredDomFullscreen(event) {
   FullScreen.enterDomFullscreen(event);
 }
 
@@ -2578,30 +2644,35 @@ var PrintPreviewListener = {
     if (gInPrintPreviewMode)
       this._hideChrome();
     else
       this._showChrome();
 
     if (this._chromeState.sidebarOpen)
       toggleSidebar(this._sidebarCommand);
 
-    TabsInTitlebar.allowedBy("print-preview", !gInPrintPreviewMode);
+#ifdef MENUBAR_CAN_AUTOHIDE
+    updateAppButtonDisplay();
+#endif
   },
   _hideChrome: function () {
     this._chromeState = {};
 
     var sidebar = document.getElementById("sidebar-box");
     this._chromeState.sidebarOpen = !sidebar.hidden;
     this._sidebarCommand = sidebar.getAttribute("sidebarcommand");
 
     var notificationBox = gBrowser.getNotificationBox();
     this._chromeState.notificationsOpen = !notificationBox.notificationsHidden;
     notificationBox.notificationsHidden = true;
 
     document.getElementById("sidebar").setAttribute("src", "about:blank");
+    var addonBar = document.getElementById("addon-bar");
+    this._chromeState.addonBarOpen = !addonBar.collapsed;
+    addonBar.collapsed = true;
     gBrowser.updateWindowResizers();
 
     this._chromeState.findOpen = gFindBarInitialized && !gFindBar.hidden;
     if (gFindBarInitialized)
       gFindBar.close();
 
     var globalNotificationBox = document.getElementById("global-notificationbox");
     this._chromeState.globalNotificationsOpen = !globalNotificationBox.notificationsHidden;
@@ -2613,16 +2684,21 @@ var PrintPreviewListener = {
       this._chromeState.syncNotificationsOpen = !syncNotifications.notificationsHidden;
       syncNotifications.notificationsHidden = true;
     }
   },
   _showChrome: function () {
     if (this._chromeState.notificationsOpen)
       gBrowser.getNotificationBox().notificationsHidden = false;
 
+    if (this._chromeState.addonBarOpen) {
+      document.getElementById("addon-bar").collapsed = false;
+      gBrowser.updateWindowResizers();
+    }
+
     if (this._chromeState.findOpen)
       gFindBar.open();
 
     if (this._chromeState.globalNotificationsOpen)
       document.getElementById("global-notificationbox").notificationsHidden = false;
 
     if (this._chromeState.syncNotificationsOpen)
       document.getElementById("sync-notifications").notificationsHidden = false;
@@ -2689,16 +2765,45 @@ function openHomeDialog(aURL)
       gPrefService.setComplexValue("browser.startup.homepage",
                                    Components.interfaces.nsISupportsString, str);
     } catch (ex) {
       dump("Failed to set the home page.\n"+ex+"\n");
     }
   }
 }
 
+var bookmarksButtonObserver = {
+  onDrop: function (aEvent)
+  {
+    let name = { };
+    let url = browserDragAndDrop.drop(aEvent, name);
+    try {
+      PlacesUIUtils.showBookmarkDialog({ action: "add"
+                                       , type: "bookmark"
+                                       , uri: makeURI(url)
+                                       , title: name
+                                       , hiddenRows: [ "description"
+                                                     , "location"
+                                                     , "loadInSidebar"
+                                                     , "keyword" ]
+                                       }, window);
+    } catch(ex) { }
+  },
+
+  onDragOver: function (aEvent)
+  {
+    browserDragAndDrop.dragOver(aEvent);
+    aEvent.dropEffect = "link";
+  },
+
+  onDragExit: function (aEvent)
+  {
+  }
+}
+
 var newTabButtonObserver = {
   onDragOver: function (aEvent)
   {
     browserDragAndDrop.dragOver(aEvent);
   },
 
   onDragExit: function (aEvent)
   {
@@ -3231,28 +3336,166 @@ function OpenBrowserWindow(options)
   else // forget about the charset information.
   {
     win = window.openDialog("chrome://browser/content/", "_blank", "chrome,all,dialog=no" + extraFeatures, defaultArgs);
   }
 
   return win;
 }
 
-//XXXunf Are these still useful to keep around?
+var gCustomizeSheet = false;
 function BrowserCustomizeToolbar() {
-  gCustomizeMode.enter();
+  // Disable the toolbar context menu items
+  var menubar = document.getElementById("main-menubar");
+  for (let childNode of menubar.childNodes)
+    childNode.setAttribute("disabled", true);
+
+  var cmd = document.getElementById("cmd_CustomizeToolbars");
+  cmd.setAttribute("disabled", "true");
+
+  var splitter = document.getElementById("urlbar-search-splitter");
+  if (splitter)
+    splitter.parentNode.removeChild(splitter);
+
+  CombinedStopReload.uninit();
+
+  PlacesToolbarHelper.customizeStart();
+  BookmarkingUI.customizeStart();
+  DownloadsButton.customizeStart();
+
+  TabsInTitlebar.allowedBy("customizing-toolbars", false);
+
+  var customizeURL = "chrome://global/content/customizeToolbar.xul";
+  gCustomizeSheet = getBoolPref("toolbar.customization.usesheet", false);
+
+  BrowserUITelemetry.countCustomizationEvent("start");
+
+  if (gCustomizeSheet) {
+    let sheetFrame = document.createElement("iframe");
+    let panel = document.getElementById("customizeToolbarSheetPopup");
+    sheetFrame.id = "customizeToolbarSheetIFrame";
+    sheetFrame.toolbox = gNavToolbox;
+    sheetFrame.panel = panel;
+    sheetFrame.setAttribute("style", panel.getAttribute("sheetstyle"));
+    panel.appendChild(sheetFrame);
+
+    // Open the panel, but make it invisible until the iframe has loaded so
+    // that the user doesn't see a white flash.
+    panel.style.visibility = "hidden";
+    gNavToolbox.addEventListener("beforecustomization", function onBeforeCustomization() {
+      gNavToolbox.removeEventListener("beforecustomization", onBeforeCustomization, false);
+      panel.style.removeProperty("visibility");
+    }, false);
+
+    sheetFrame.setAttribute("src", customizeURL);
+
+    panel.openPopup(gNavToolbox, "after_start", 0, 0);
+  } else {
+    window.openDialog(customizeURL,
+                      "CustomizeToolbar",
+                      "chrome,titlebar,toolbar,location,resizable,dependent",
+                      gNavToolbox);
+  }
 }
 
 function BrowserToolboxCustomizeDone(aToolboxChanged) {
-  gCustomizeMode.exit(aToolboxChanged);
+  if (gCustomizeSheet) {
+    document.getElementById("customizeToolbarSheetPopup").hidePopup();
+    let iframe = document.getElementById("customizeToolbarSheetIFrame");
+    iframe.parentNode.removeChild(iframe);
+  }
+
+  // Update global UI elements that may have been added or removed
+  if (aToolboxChanged) {
+    gURLBar = document.getElementById("urlbar");
+
+    gProxyFavIcon = document.getElementById("page-proxy-favicon");
+    gHomeButton.updateTooltip();
+    gIdentityHandler._cacheElements();
+    window.XULBrowserWindow.init();
+
+#ifndef XP_MACOSX
+    updateEditUIVisibility();
+#endif
+
+    // Hacky: update the PopupNotifications' object's reference to the iconBox,
+    // if it already exists, since it may have changed if the URL bar was
+    // added/removed.
+    if (!window.__lookupGetter__("PopupNotifications"))
+      PopupNotifications.iconBox = document.getElementById("notification-popup-box");
+  }
+
+  PlacesToolbarHelper.customizeDone();
+  BookmarkingUI.customizeDone();
+  DownloadsButton.customizeDone();
+
+  // The url bar splitter state is dependent on whether stop/reload
+  // and the location bar are combined, so we need this ordering
+  CombinedStopReload.init();
+  UpdateUrlbarSearchSplitterState();
+  setUrlAndSearchBarWidthForConditionalForwardButton();
+
+  // Update the urlbar
+  if (gURLBar) {
+    URLBarSetURI();
+    XULBrowserWindow.asyncUpdateUI();
+    BookmarkingUI.updateStarState();
+    SocialUI.updateState();
+  }
+
+  TabsInTitlebar.allowedBy("customizing-toolbars", true);
+
+  // Re-enable parts of the UI we disabled during the dialog
+  var menubar = document.getElementById("main-menubar");
+  for (let childNode of menubar.childNodes)
+    childNode.setAttribute("disabled", false);
+  var cmd = document.getElementById("cmd_CustomizeToolbars");
+  cmd.removeAttribute("disabled");
+
+  // make sure to re-enable click-and-hold
+  if (!getBoolPref("ui.click_hold_context_menus", false))
+    SetClickAndHoldHandlers();
+
+  gBrowser.selectedBrowser.focus();
 }
 
 function BrowserToolboxCustomizeChange(aType) {
-  gHomeButton.updatePersonalToolbarStyle();
-  BookmarksMenuButton.customizeChange();
+  switch (aType) {
+    case "iconsize":
+    case "mode":
+      retrieveToolbarIconsizesFromTheme();
+      break;
+    default:
+      gHomeButton.updatePersonalToolbarStyle();
+      BookmarkingUI.customizeChange();
+      BrowserUITelemetry.countCustomizationEvent(aType);
+  }
+}
+
+/**
+ * Allows themes to override the "iconsize" attribute on toolbars.
+ */
+function retrieveToolbarIconsizesFromTheme() {
+  function retrieveToolbarIconsize(aToolbar) {
+    if (aToolbar.localName != "toolbar")
+      return;
+
+    // The theme indicates that it wants to override the "iconsize" attribute
+    // by specifying a special value for the "counter-reset" property on the
+    // toolbar. A custom property cannot be used because getComputedStyle can
+    // only return the values of standard CSS properties.
+    let counterReset = getComputedStyle(aToolbar).counterReset;
+    if (counterReset == "smallicons 0")
+      aToolbar.setAttribute("iconsize", "small");
+    else if (counterReset == "largeicons 0")
+      aToolbar.setAttribute("iconsize", "large");
+  }
+
+  Array.forEach(gNavToolbox.childNodes, retrieveToolbarIconsize);
+  gNavToolbox.externalToolbars.forEach(retrieveToolbarIconsize);
 }
 
 /**
  * Update the global flag that tracks whether or not any edit UI (the Edit menu,
  * edit-related items in the context menu, and edit-related toolbar buttons
  * is visible, then update the edit commands' enabled state accordingly.  We use
  * this flag to skip updating the edit commands on focus or selection changes
  * when no UI is visible to improve performance (including pageload performance,
@@ -3271,27 +3514,36 @@ function BrowserToolboxCustomizeChange(a
  * is a no op.
  */
 function updateEditUIVisibility()
 {
 #ifndef XP_MACOSX
   let editMenuPopupState = document.getElementById("menu_EditPopup").state;
   let contextMenuPopupState = document.getElementById("contentAreaContextMenu").state;
   let placesContextMenuPopupState = document.getElementById("placesContext").state;
+#ifdef MENUBAR_CAN_AUTOHIDE
+  let appMenuPopupState = document.getElementById("appmenu-popup").state;
+#endif
 
   // The UI is visible if the Edit menu is opening or open, if the context menu
   // is open, or if the toolbar has been customized to include the Cut, Copy,
   // or Paste toolbar buttons.
   gEditUIVisible = editMenuPopupState == "showing" ||
                    editMenuPopupState == "open" ||
                    contextMenuPopupState == "showing" ||
                    contextMenuPopupState == "open" ||
                    placesContextMenuPopupState == "showing" ||
                    placesContextMenuPopupState == "open" ||
-                   document.getElementById("edit-controls") ? true : false;
+#ifdef MENUBAR_CAN_AUTOHIDE
+                   appMenuPopupState == "showing" ||
+                   appMenuPopupState == "open" ||
+#endif
+                   document.getElementById("cut-button") ||
+                   document.getElementById("copy-button") ||
+                   document.getElementById("paste-button") ? true : false;
 
   // If UI is visible, update the edit commands' enabled state to reflect
   // whether or not they are actually enabled for the current focus/selection.
   if (gEditUIVisible)
     goUpdateGlobalEditMenuItems();
 
   // Otherwise, enable all commands, so that keyboard shortcuts still work,
   // then lazily determine their actual enabled state when the user presses
@@ -3311,29 +3563,44 @@ function updateEditUIVisibility()
 
 /**
  * Makes the Character Encoding menu enabled or disabled as appropriate.
  * To be called when the View menu or the app menu is opened.
  */
 function updateCharacterEncodingMenuState()
 {
   let charsetMenu = document.getElementById("charsetMenu");
+  let appCharsetMenu = document.getElementById("appmenu_charsetMenu");
+  let appDevCharsetMenu =
+    document.getElementById("appmenu_developer_charsetMenu");
   // gBrowser is null on Mac when the menubar shows in the context of
   // non-browser windows. The above elements may be null depending on
   // what parts of the menubar are present. E.g. no app menu on Mac.
   if (gBrowser &&
       gBrowser.docShell &&
       gBrowser.docShell.mayEnableCharacterEncodingMenu) {
     if (charsetMenu) {
       charsetMenu.removeAttribute("disabled");
     }
+    if (appCharsetMenu) {
+      appCharsetMenu.removeAttribute("disabled");
+    }
+    if (appDevCharsetMenu) {
+      appDevCharsetMenu.removeAttribute("disabled");
+    }
   } else {
     if (charsetMenu) {
       charsetMenu.setAttribute("disabled", "true");
     }
+    if (appCharsetMenu) {
+      appCharsetMenu.setAttribute("disabled", "true");
+    }
+    if (appDevCharsetMenu) {
+      appDevCharsetMenu.setAttribute("disabled", "true");
+    }
   }
 }
 
 /**
  * Returns true if |aMimeType| is text-based, false otherwise.
  *
  * @param aMimeType
  *        The MIME type to check.
@@ -3355,18 +3622,18 @@ function mimeTypeIsTextBased(aMimeType)
 var XULBrowserWindow = {
   // Stored Status, Link and Loading values
   status: "",
   defaultStatus: "",
   overLink: "",
   startTime: 0,
   statusText: "",
   isBusy: false,
-  // Left here for add-on compatibility, see bug 752434
-  inContentWhitelist: [],
+  inContentWhitelist: ["about:addons", "about:downloads", "about:permissions",
+                       "about:sync-progress", "about:preferences"],
 
   QueryInterface: function (aIID) {
     if (aIID.equals(Ci.nsIWebProgressListener) ||
         aIID.equals(Ci.nsIWebProgressListener2) ||
         aIID.equals(Ci.nsISupportsWeakReference) ||
         aIID.equals(Ci.nsIXULBrowserWindow) ||
         aIID.equals(Ci.nsISupports))
       return this;
@@ -3385,16 +3652,18 @@ var XULBrowserWindow = {
     return gBrowser.getStatusPanel();
   },
   get isImage () {
     delete this.isImage;
     return this.isImage = document.getElementById("isImage");
   },
 
   init: function () {
+    this.throbberElement = document.getElementById("navigator-throbber");
+
     // Initialize the security button's state and tooltip text.
     var securityUI = gBrowser.securityUI;
     this.onSecurityChange(null, null, securityUI.state);
   },
 
   setJSStatus: function () {
     // unsupported
   },
@@ -3508,16 +3777,20 @@ var XULBrowserWindow = {
         gBrowser.selectedBrowser.engines = null;
       }
 
       this.isBusy = true;
 
       if (!(aStateFlags & nsIWebProgressListener.STATE_RESTORING)) {
         this._busyUI = true;
 
+        // Turn the throbber on.
+        if (this.throbberElement)
+          this.throbberElement.setAttribute("busy", "true");
+
         // XXX: This needs to be based on window activity...
         this.stopCommand.removeAttribute("disabled");
         CombinedStopReload.switchToStop();
       }
     }
     else if (aStateFlags & nsIWebProgressListener.STATE_STOP) {
       // This (thanks to the filter) is a network stop or the last
       // request stop outside of loading the document, stop throbbers
@@ -3552,16 +3825,20 @@ var XULBrowserWindow = {
           this.isImage.setAttribute('disabled', 'true');
       }
 
       this.isBusy = false;
 
       if (this._busyUI) {
         this._busyUI = false;
 
+        // Turn the throbber off.
+        if (this.throbberElement)
+          this.throbberElement.removeAttribute("busy");
+
         this.stopCommand.setAttribute("disabled", "true");
         CombinedStopReload.switchToReload(aRequest instanceof Ci.nsIRequest);
       }
     }
   },
 
   onLocationChange: function (aWebProgress, aRequest, aLocationURI, aFlags) {
     var location = aLocationURI ? aLocationURI.spec : "";
@@ -3618,16 +3895,26 @@ var XULBrowserWindow = {
       if (gURLBar) {
         URLBarSetURI(aLocationURI);
 
         // Update starring UI
         BookmarkingUI.updateStarState();
         SocialUI.updateState();
       }
 
+      // Show or hide browser chrome based on the whitelist
+      if (this.hideChromeForLocation(location)) {
+        document.documentElement.setAttribute("disablechrome", "true");
+      } else {
+        if (SessionStore.getTabValue(gBrowser.selectedTab, "appOrigin"))
+          document.documentElement.setAttribute("disablechrome", "true");
+        else
+          document.documentElement.removeAttribute("disablechrome");
+      }
+
       // Utility functions for disabling find
       var shouldDisableFind = function shouldDisableFind(aDocument) {
         let docElt = aDocument.documentElement;
         return docElt && docElt.getAttribute("disablefastfind") == "true";
       }
 
       var disableFindCommands = function disableFindCommands(aDisable) {
         let findCommands = [document.getElementById("cmd_find"),
@@ -3658,27 +3945,16 @@ var XULBrowserWindow = {
           if (content.document.readyState == "interactive" || content.document.readyState == "complete")
             disableFindCommands(shouldDisableFind(content.document));
           else {
             content.document.addEventListener("readystatechange", onContentRSChange);
           }
         }
       } else
         disableFindCommands(false);
-
-      // Try not to instantiate gCustomizeMode as much as possible,
-      // so don't use CustomizeMode.jsm to check for URI or customizing.
-      let customizingURI = "about:customizing";
-      if (location == customizingURI &&
-          !CustomizationHandler.isCustomizing()) {
-        gCustomizeMode.enter();
-      } else if (location != customizingURI &&
-                 CustomizationHandler.isCustomizing()) {
-        gCustomizeMode.exit();
-      }
     }
     UpdateBackForwardCommands(gBrowser.webNavigation);
 
     gGestureSupport.restoreRotationState();
 
     // See bug 358202, when tabs are switched during a drag operation,
     // timers don't fire on windows (bug 203573)
     if (aRequest)
@@ -3686,18 +3962,22 @@ var XULBrowserWindow = {
     else
       this.asyncUpdateUI();
   },
 
   asyncUpdateUI: function () {
     FeedHandler.updateFeeds();
   },
 
-  // Left here for add-on compatibility, see bug 752434
-  hideChromeForLocation: function() {},
+  hideChromeForLocation: function(aLocation) {
+    aLocation = aLocation.toLowerCase();
+    return this.inContentWhitelist.some(function(aSpec) {
+      return aSpec == aLocation;
+    });
+  },
 
   onStatusChange: function (aWebProgress, aRequest, aStatus, aMessage) {
     this.status = aMessage;
     this.updateStatusField();
   },
 
   // Properties used to cache security state used to update the UI
   _state: null,
@@ -3825,18 +4105,31 @@ var LinkTargetDisplay = {
   }
 };
 
 var CombinedStopReload = {
   init: function () {
     if (this._initialized)
       return;
 
-    let reload = document.getElementById("urlbar-reload-button");
-    let stop = document.getElementById("urlbar-stop-button");
+    var urlbar = document.getElementById("urlbar-container");
+    var reload = document.getElementById("reload-button");
+    var stop = document.getElementById("stop-button");
+
+    if (urlbar) {
+      if (urlbar.parentNode.getAttribute("mode") != "icons" ||
+          !reload || urlbar.nextSibling != reload ||
+          !stop || reload.nextSibling != stop)
+        urlbar.removeAttribute("combined");
+      else {
+        urlbar.setAttribute("combined", "true");
+        reload = document.getElementById("urlbar-reload-button");
+        stop = document.getElementById("urlbar-stop-button");
+      }
+    }
     if (!stop || !reload || reload.nextSibling != stop)
       return;
 
     this._initialized = true;
     if (XULBrowserWindow.stopCommand.getAttribute("disabled") != "true")
       reload.setAttribute("displaystop", "true");
     stop.addEventListener("click", this, false);
     this.reload = reload;
@@ -4158,398 +4451,248 @@ function onViewToolbarsPopupShowing(aEve
     var deadItem = popup.childNodes[i];
     if (deadItem.hasAttribute("toolbarId"))
       popup.removeChild(deadItem);
   }
 
   var firstMenuItem = aInsertPoint || popup.firstChild;
 
   let toolbarNodes = Array.slice(gNavToolbox.childNodes);
-  toolbarNodes = toolbarNodes.concat(gNavToolbox.externalToolbars);
+  toolbarNodes.push(document.getElementById("addon-bar"));
 
   for (let toolbar of toolbarNodes) {
     let toolbarName = toolbar.getAttribute("toolbarname");
     if (toolbarName) {
       let menuItem = document.createElement("menuitem");
       let hidingAttribute = toolbar.getAttribute("type") == "menubar" ?
                             "autohide" : "collapsed";
       menuItem.setAttribute("id", "toggle_" + toolbar.id);
       menuItem.setAttribute("toolbarId", toolbar.id);
       menuItem.setAttribute("type", "checkbox");
       menuItem.setAttribute("label", toolbarName);
       menuItem.setAttribute("checked", toolbar.getAttribute(hidingAttribute) != "true");
-      menuItem.setAttribute("accesskey", toolbar.getAttribute("accesskey"));
+      if (popup.id != "appmenu_customizeMenu")
+        menuItem.setAttribute("accesskey", toolbar.getAttribute("accesskey"));
       if (popup.id != "toolbar-context-menu")
         menuItem.setAttribute("key", toolbar.getAttribute("key"));
 
       popup.insertBefore(menuItem, firstMenuItem);
 
       menuItem.addEventListener("command", onViewToolbarCommand, false);
     }
   }
-
-
-  let addToPanel = popup.querySelector(".customize-context-addToPanel");
-  let removeFromToolbar = popup.querySelector(".customize-context-removeFromToolbar");
-  // View -> Toolbars menu doesn't have the addToPanel or removeFromToolbar items.
-  if (!addToPanel || !removeFromToolbar) {
-    return;
-  }
-
-  // The explicitOriginalTarget can be a nested child element of a toolbaritem.
-  let toolbarItem = aEvent.explicitOriginalTarget;
-
-  if (toolbarItem && toolbarItem.localName == "toolbarpaletteitem") {
-    toolbarItem = toolbarItem.firstChild;
-  } else {
-    while (toolbarItem && toolbarItem.parentNode) {
-      let parent = toolbarItem.parentNode;
-      if ((parent.classList && parent.classList.contains("customization-target")) ||
-          parent.localName == "toolbarpaletteitem" ||
-          parent.localName == "toolbar")
-        break;
-      toolbarItem = parent;
-    }
-  }
-
-  // Right-clicking on an empty part of the tabstrip 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);
-  if (movable) {
-    addToPanel.removeAttribute("disabled");
-    removeFromToolbar.removeAttribute("disabled");
-  } else {
-    addToPanel.setAttribute("disabled", true);
-    removeFromToolbar.setAttribute("disabled", true);
-  }
 }
 
 function onViewToolbarCommand(aEvent) {
   var toolbarId = aEvent.originalTarget.getAttribute("toolbarId");
   var toolbar = document.getElementById(toolbarId);
   var isVisible = aEvent.originalTarget.getAttribute("checked") == "true";
   setToolbarVisibility(toolbar, isVisible);
 }
 
 function setToolbarVisibility(toolbar, isVisible) {
   var hidingAttribute = toolbar.getAttribute("type") == "menubar" ?
                         "autohide" : "collapsed";
 
   toolbar.setAttribute(hidingAttribute, !isVisible);
   document.persist(toolbar.id, hidingAttribute);
-  let eventParams = {
-    detail: {
-      visible: isVisible
-    },
-    bubbles: true
-  };
-  let event = new CustomEvent("toolbarvisibilitychange", eventParams);
-  toolbar.dispatchEvent(event);
 
   PlacesToolbarHelper.init();
   BookmarkingUI.onToolbarVisibilityChange();
   gBrowser.updateWindowResizers();
+
+#ifdef MENUBAR_CAN_AUTOHIDE
+  updateAppButtonDisplay();
+#endif
+}
+
+var TabsOnTop = {
+  init: function TabsOnTop_init() {
+    Services.prefs.addObserver(this._prefName, this, false);
+
+    // Only show the toggle UI if the user disabled tabs on top.
+    if (Services.prefs.getBoolPref(this._prefName)) {
+      for (let item of document.querySelectorAll("menuitem[command=cmd_ToggleTabsOnTop]"))
+        item.parentNode.removeChild(item);
+    }
+  },
+
+  uninit: function TabsOnTop_uninit() {
+    Services.prefs.removeObserver(this._prefName, this);
+  },
+
+  toggle: function () {
+    this.enabled = !Services.prefs.getBoolPref(this._prefName);
+  },
+
+  syncUI: function () {
+    let userEnabled = Services.prefs.getBoolPref(this._prefName);
+    let enabled = userEnabled && gBrowser.tabContainer.visible;
+
+    document.getElementById("cmd_ToggleTabsOnTop")
+            .setAttribute("checked", userEnabled);
+
+    document.documentElement.setAttribute("tabsontop", enabled);
+    document.getElementById("navigator-toolbox").setAttribute("tabsontop", enabled);
+    document.getElementById("TabsToolbar").setAttribute("tabsontop", enabled);
+    document.getElementById("nav-bar").setAttribute("tabsontop", enabled);
+    gBrowser.tabContainer.setAttribute("tabsontop", enabled);
+    TabsInTitlebar.allowedBy("tabs-on-top", enabled);
+  },
+
+  get enabled () {
+    return gNavToolbox.getAttribute("tabsontop") == "true";
+  },
+
+  set enabled (val) {
+    Services.prefs.setBoolPref(this._prefName, !!val);
+    return val;
+  },
+
+  observe: function (subject, topic, data) {
+    if (topic == "nsPref:changed")
+      this.syncUI();
+  },
+
+  _prefName: "browser.tabs.onTop"
 }
 
 var TabsInTitlebar = {
   init: function () {
 #ifdef CAN_DRAW_IN_TITLEBAR
     this._readPref();
     Services.prefs.addObserver(this._prefName, this, false);
 
-    // We need to update the appearance of the titlebar when the menu changes
-    // from the active to the inactive state. We can't, however, rely on
-    // DOMMenuBarInactive, because the menu fires this event and then removes
-    // the inactive attribute after an event-loop spin.
-    //
-    // Because updating the appearance involves sampling the heights and margins
-    // of various elements, it's important that the layout be more or less
-    // settled before updating the titlebar. So instead of listening to
-    // DOMMenuBarActive and DOMMenuBarInactive, we use a MutationObserver to
-    // watch the "invalid" attribute directly.
-    let menu = document.getElementById("toolbar-menubar");
-    this._menuObserver = new MutationObserver(this._onMenuMutate);
-    this._menuObserver.observe(menu, {attributes: true});
-
-    gNavToolbox.addEventListener("customization-transitionend", this);
-
-    this.onAreaReset = function(aArea) {
-      if (aArea == CustomizableUI.AREA_TABSTRIP || aArea == CustomizableUI.AREA_MENUBAR)
-        this._update(true);
-    };
-    this.onWidgetAdded = this.onWidgetRemoved = function(aWidgetId, aArea) {
-      if (aArea == CustomizableUI.AREA_TABSTRIP || aArea == CustomizableUI.AREA_MENUBAR)
-        this._update(true);
-    };
-    CustomizableUI.addListener(this);
+    // Don't trust the initial value of the sizemode attribute; wait for
+    // the resize event (handled in tabbrowser.xml).
+    this.allowedBy("sizemode", false);
 
     this._initialized = true;
 #endif
   },
 
   allowedBy: function (condition, allow) {
 #ifdef CAN_DRAW_IN_TITLEBAR
     if (allow) {
       if (condition in this._disallowed) {
         delete this._disallowed[condition];
-        this._update(true);
+        this._update();
       }
     } else {
       if (!(condition in this._disallowed)) {
         this._disallowed[condition] = null;
-        this._update(true);
+        this._update();
       }
     }
 #endif
   },
 
-  updateAppearance: function updateAppearance(aForce) {
-#ifdef CAN_DRAW_IN_TITLEBAR
-    this._update(aForce);
-#endif
-  },
-
   get enabled() {
     return document.documentElement.getAttribute("tabsintitlebar") == "true";
   },
 
 #ifdef CAN_DRAW_IN_TITLEBAR
   observe: function (subject, topic, data) {
     if (topic == "nsPref:changed")
       this._readPref();
   },
 
-  handleEvent: function(ev) {
-    if (ev.type == "customization-transitionend") {
-      this._update(true);
-    }
-  },
-
-  _onMenuMutate: function (aMutations) {
-    for (let mutation of aMutations) {
-      if (mutation.attributeName == "inactive" ||
-          mutation.attributeName == "autohide") {
-        TabsInTitlebar._update(true);
-        return;
-      }
-    }
-  },
-
   _initialized: false,
   _disallowed: {},
   _prefName: "browser.tabs.drawInTitlebar",
-  _lastSizeMode: null,
 
   _readPref: function () {
     this.allowedBy("pref",
                    Services.prefs.getBoolPref(this._prefName));
   },
 
-  _update: function (aForce=false) {
+  _update: function () {
     function $(id) document.getElementById(id);
     function rect(ele) ele.getBoundingClientRect();
-    function verticalMargins(cstyle) parseFloat(cstyle.marginBottom) + parseFloat(cstyle.marginTop);
 
     if (!this._initialized || window.fullScreen)
       return;
 
     let allowed = true;
-
-    if (!aForce) {
-      // _update is called on resize events, because the window is not ready
-      // after sizemode events. However, we only care about the event when the
-      // sizemode is different from the last time we updated the appearance of
-      // the tabs in the titlebar.
-      let sizemode = document.documentElement.getAttribute("sizemode");
-      if (this._lastSizeMode == sizemode) {
-        return;
-      }
-      this._lastSizeMode = sizemode;
-    }
-
     for (let something in this._disallowed) {
       allowed = false;
       break;
     }
 
+    if (allowed == this.enabled)
+      return;
+
     let titlebar = $("titlebar");
-    let titlebarContent = $("titlebar-content");
-    let menubar = $("toolbar-menubar");
 
     if (allowed) {
-      // We set the tabsintitlebar attribute first so that our CSS for
-      // tabsintitlebar manifests before we do our measurements.
-      document.documentElement.setAttribute("tabsintitlebar", "true");
-      updateTitlebarDisplay();
-
-      // Try to avoid reflows in this code by calculating dimensions first and
-      // then later set the properties affecting layout together in a batch.
-
-      // Buttons first:
-      let captionButtonsBoxWidth = rect($("titlebar-buttonbox")).width;
-#ifdef XP_MACOSX
-      let fullscreenButtonWidth = rect($("titlebar-fullscreen-button")).width;
-      // No need to look up the menubar stuff on OS X:
-      let menuHeight = 0;
-      let fullMenuHeight = 0;
-      // Instead, look up the titlebar padding:
-      let titlebarPadding = parseInt(window.getComputedStyle(titlebar).paddingTop, 10);
-#else
-      // Otherwise, get the height and margins separately for the menubar
-      let menuHeight = rect(menubar).height;
-      let menuStyles = window.getComputedStyle(menubar);
-      let fullMenuHeight = verticalMargins(menuStyles) + menuHeight;
+      let tabsToolbar       = $("TabsToolbar");
+
+#ifdef MENUBAR_CAN_AUTOHIDE
+      let appmenuButtonBox  = $("appmenu-button-container");
+      this._sizePlaceholder("appmenu-button", rect(appmenuButtonBox).width);
 #endif
-      // Get the full height of the tabs toolbar:
-      let tabsToolbar = $("TabsToolbar");
-      let tabsStyles = window.getComputedStyle(tabsToolbar);
-      let fullTabsHeight = rect(tabsToolbar).height + verticalMargins(tabsStyles);
-
-      // If the navbar overlaps the tabbar using negative margins, we need to take those into
-      // account so we don't overlap it
-      let navbarMarginTop = parseFloat(window.getComputedStyle($("nav-bar")).marginTop);
-      navbarMarginTop = Math.min(navbarMarginTop, 0);
-
-      // And get the height of what's in the titlebar:
-      let titlebarContentHeight = rect(titlebarContent).height;
-
-      // Padding surrounds the tab-view-deck when we are in customization mode,
-      // so take that into account:
-      let areCustomizing = document.documentElement.hasAttribute("customizing") ||
-                           document.documentElement.hasAttribute("customize-exiting");
-      let customizePadding = 0;
-      if (areCustomizing) {
-        let deckStyle = window.getComputedStyle($("tab-view-deck"));
-        customizePadding = parseFloat(deckStyle.paddingTop);
-      }
-
-      // Begin setting CSS properties which will cause a reflow
-
-      // If the menubar is around (menuHeight is non-zero), try to adjust
-      // its full height (i.e. including margins) to match the titlebar,
-      // by changing the menubar's bottom padding
-      if (menuHeight) {
-        // Calculate the difference between the titlebar's height and that of the menubar
-        let menuTitlebarDelta = titlebarContentHeight - fullMenuHeight;
-        let paddingBottom;
-        // The titlebar is bigger:
-        if (menuTitlebarDelta > 0) {
-          fullMenuHeight += menuTitlebarDelta;
-          // If there is already padding on the menubar, we need to add that
-          // to the difference so the total padding is correct:
-          if ((paddingBottom = menuStyles.paddingBottom)) {
-            menuTitlebarDelta += parseFloat(paddingBottom);
-          }
-          menubar.style.paddingBottom = menuTitlebarDelta + "px";
-        // The menubar is bigger, but has bottom padding we can remove:
-        } else if (menuTitlebarDelta < 0 && (paddingBottom = menuStyles.paddingBottom)) {
-          let existingPadding = parseFloat(paddingBottom);
-          // menuTitlebarDelta is negative; work out what's left, but don't set negative padding:
-          let desiredPadding = Math.max(0, existingPadding + menuTitlebarDelta);
-          menubar.style.paddingBottom = desiredPadding + "px";
-          // We've changed the menu height now:
-          fullMenuHeight += desiredPadding - existingPadding;
-        }
-      }
-
-      // Next, we calculate how much we need to stretch the titlebar down to
-      // go all the way to the bottom of the tab strip, if necessary.
-      let tabAndMenuHeight = fullTabsHeight + fullMenuHeight;
-      // Oh, and don't forget customization mode:
-      if (areCustomizing) {
-        tabAndMenuHeight += customizePadding;
-      }
-
-      if (tabAndMenuHeight > titlebarContentHeight) {
-        // We need to increase the titlebar content's outer height (ie including margins)
-        // to match the tab and menu height:
-        let extraMargin = tabAndMenuHeight - titlebarContentHeight;
-        // We need to reduce the height by the amount of navbar overlap
-        // (this value is 0 or negative):
-        extraMargin += navbarMarginTop;
-        // On non-OSX, we can just use bottom margin:
-#ifndef XP_MACOSX
-        titlebarContent.style.marginBottom = extraMargin + "px";
-#else
-        // Otherwise, center the content. This means taking the titlebar's
-        // padding into account:
-        let halfMargin = (extraMargin - titlebarPadding) / 2;
-        titlebarContent.style.marginTop =  halfMargin + "px";
-        titlebarContent.style.marginBottom =  (titlebarPadding + halfMargin) + "px";
-#endif
-        titlebarContentHeight += extraMargin;
-      }
-
-      // Then we bring up the titlebar by the same amount, but we add any negative margin:
-      titlebar.style.marginBottom = "-" + titlebarContentHeight + "px";
-
-
-      // Finally, size the placeholders:
-#ifdef XP_MACOSX
-      this._sizePlaceholder("fullscreen-button", fullscreenButtonWidth);
-#endif
-      this._sizePlaceholder("caption-buttons", captionButtonsBoxWidth);
-
-      if (!this._draghandles) {
-        this._draghandles = {};
+      let captionButtonsBox = $("titlebar-buttonbox");
+      this._sizePlaceholder("caption-buttons", rect(captionButtonsBox).width);
+
+      let tabsToolbarRect = rect(tabsToolbar);
+      let titlebarTop = rect($("titlebar-content")).top;
+      titlebar.style.marginBottom = - Math.min(tabsToolbarRect.top - titlebarTop,
+                                               tabsToolbarRect.height) + "px";
+
+      document.documentElement.setAttribute("tabsintitlebar", "true");
+
+      if (!this._draghandle) {
         let tmp = {};
         Components.utils.import("resource://gre/modules/WindowDraggingUtils.jsm", tmp);
-
-        let mouseDownCheck = function () {
+        this._draghandle = new tmp.WindowDraggingElement(tabsToolbar);
+        this._draghandle.mouseDownCheck = function () {
           return !this._dragBindingAlive && TabsInTitlebar.enabled;
         };
-
-        this._draghandles.tabsToolbar = new tmp.WindowDraggingElement(tabsToolbar);
-        this._draghandles.tabsToolbar.mouseDownCheck = mouseDownCheck;
-
-        this._draghandles.navToolbox = new tmp.WindowDraggingElement(gNavToolbox);
-        this._draghandles.navToolbox.mouseDownCheck = mouseDownCheck;
       }
     } else {
       document.documentElement.removeAttribute("tabsintitlebar");
-      updateTitlebarDisplay();
-
-      // Reset the margins and padding that might have been modified:
-      titlebarContent.style.marginBottom = "";
+
       titlebar.style.marginBottom = "";
-      menubar.style.paddingBottom = "";
     }
   },
 
   _sizePlaceholder: function (type, width) {
     Array.forEach(document.querySelectorAll(".titlebar-placeholder[type='"+ type +"']"),
                   function (node) { node.width = width; });
   },
 #endif
 
   uninit: function () {
 #ifdef CAN_DRAW_IN_TITLEBAR
     this._initialized = false;
     Services.prefs.removeObserver(this._prefName, this);
-    this._menuObserver.disconnect();
-    CustomizableUI.removeListener(this);
 #endif
   }
 };
 
+#ifdef MENUBAR_CAN_AUTOHIDE
+function updateAppButtonDisplay() {
+  var displayAppButton =
+    !gInPrintPreviewMode &&
+    window.menubar.visible &&
+    document.getElementById("toolbar-menubar").getAttribute("autohide") == "true";
+
 #ifdef CAN_DRAW_IN_TITLEBAR
-function updateTitlebarDisplay() {
-  document.getElementById("titlebar").hidden = !TabsInTitlebar.enabled;
-
-  if (TabsInTitlebar.enabled)
-#ifdef XP_WIN
+  document.getElementById("titlebar").hidden = !displayAppButton;
+
+  if (displayAppButton)
     document.documentElement.setAttribute("chromemargin", "0,2,2,2");
-#else
-    document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1");
-#endif
   else
     document.documentElement.removeAttribute("chromemargin");
+
+  TabsInTitlebar.allowedBy("drawing-in-titlebar", displayAppButton);
+#else
+  document.getElementById("appmenu-toolbar-button").hidden =
+    !displayAppButton;
+#endif
 }
 #endif
 
 #ifdef CAN_DRAW_IN_TITLEBAR
 function onTitlebarMaxClick() {
   if (window.windowState == window.STATE_MAXIMIZED)
     window.restore();
   else
@@ -6767,32 +6910,39 @@ let gPrivateBrowsingUI = {
       return;
     }
 
     // Disable the Clear Recent History... menu item when in PB mode
     // temporary fix until bug 463607 is fixed
     document.getElementById("Tools:Sanitize").setAttribute("disabled", "true");
 
     if (window.location.href == getBrowserURL()) {
+#ifdef XP_MACOSX
+      if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
+        document.documentElement.setAttribute("drawintitlebar", true);
+      }
+#endif
+
       // Adjust the window's title
       let docElement = document.documentElement;
       if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
         docElement.setAttribute("title",
           docElement.getAttribute("title_privatebrowsing"));
         docElement.setAttribute("titlemodifier",
           docElement.getAttribute("titlemodifier_privatebrowsing"));
       }
       docElement.setAttribute("privatebrowsingmode",
         PrivateBrowsingUtils.permanentPrivateBrowsing ? "permanent" : "temporary");
       gBrowser.updateTitlebar();
 
       if (PrivateBrowsingUtils.permanentPrivateBrowsing) {
         // Adjust the New Window menu entries
         [
           { normal: "menu_newNavigator", private: "menu_newPrivateWindow" },
+          { normal: "appmenu_newNavigator", private: "appmenu_newPrivateWindow" },
         ].forEach(function(menu) {
           let newWindow = document.getElementById(menu.normal);
           let newPrivateWindow = document.getElementById(menu.private);
           if (newWindow && newPrivateWindow) {
             newPrivateWindow.hidden = true;
             newWindow.label = newPrivateWindow.label;
             newWindow.accessKey = newPrivateWindow.accessKey;
             newWindow.command = newPrivateWindow.command;
@@ -7027,16 +7177,21 @@ function duplicateTabIn(aTab, where, del
       // A background tab has been opened, nothing else to do here.
       break;
     case "tab":
       gBrowser.selectedTab = newTab;
       break;
   }
 }
 
+function toggleAddonBar() {
+  let addonBar = document.getElementById("addon-bar");
+  setToolbarVisibility(addonBar, addonBar.collapsed);
+}
+
 var Scratchpad = {
   openScratchpad: function SP_openScratchpad() {
     return this.ScratchpadManager.openScratchpad();
   }
 };
 
 XPCOMUtils.defineLazyGetter(Scratchpad, "ScratchpadManager", function() {
   let tmp = {};
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -4,19 +4,17 @@
 #
 # 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/.
 
 <?xml-stylesheet href="chrome://browser/content/browser.css" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/content/places/places.css" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/skin/devtools/common.css" type="text/css"?>
-<?xml-stylesheet href="chrome://browser/skin/customizableui/panelUIOverlay.css" type="text/css"?>
 <?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
-<?xml-stylesheet href="chrome://browser/skin/browser-lightweightTheme.css" type="text/css"?>
 
 <?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
 <?xul-overlay href="chrome://browser/content/baseMenuOverlay.xul"?>
 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
 
 # All DTD information is stored in a separate file so that it can be shared by
 # hiddenWindow.xul.
 #include browser-doctype.inc
@@ -36,32 +34,23 @@
         titlemodifier_normal=""
         titlemodifier_privatebrowsing="&mainWindow.titlePrivateBrowsingSuffix;"
 #else
         title_privatebrowsing="&mainWindow.titlemodifier; &mainWindow.titlePrivateBrowsingSuffix;"
         titlemodifier="&mainWindow.titlemodifier;"
         titlemodifier_normal="&mainWindow.titlemodifier;"
         titlemodifier_privatebrowsing="&mainWindow.titlemodifier; &mainWindow.titlePrivateBrowsingSuffix;"
 #endif
-#ifdef CAN_DRAW_IN_TITLEBAR
-#ifdef XP_WIN
-        chromemargin="0,2,2,2"
-#else
-        chromemargin="0,-1,-1,-1"
-#endif
-        tabsintitlebar="true"
-#endif
         titlemenuseparator="&mainWindow.titlemodifiermenuseparator;"
         lightweightthemes="true"
         lightweightthemesfooter="browser-bottombox"
         windowtype="navigator:browser"
         macanimationtype="document"
         screenX="4" screenY="4"
         fullscreenbutton="true"
-        sizemode="normal"
         persist="screenX screenY width height sizemode">
 
 # All JS files which are not content (only) dependent that browser.xul
 # wishes to include *must* go into the global-scripts.inc file
 # so that they can be shared by macBrowserOverlay.xul.
 #include global-scripts.inc
 <script type="application/javascript" src="chrome://browser/content/nsContextMenu.js"/>
 
@@ -261,29 +250,23 @@
            type="arrow"
            hidden="true"
            flip="slide"
            rolluponmousewheel="true"
            noautofocus="true"
            position="topcenter topright"/>
 
     <menupopup id="toolbar-context-menu"
-               onpopupshowing="onViewToolbarsPopupShowing(event, document.getElementById('viewToolbarsMenuSeparator'));">
-      <menuitem oncommand="gCustomizeMode.addToPanel(document.popupNode)"
-                accesskey="&customizeMenu.addToPanel.accesskey;"
-                label="&customizeMenu.addToPanel.label;"
-                class="customize-context-addToPanel"/>
-      <menuitem oncommand="gCustomizeMode.removeFromArea(document.popupNode)"
-                accesskey="&customizeMenu.removeFromToolbar.accesskey;"
-                label="&customizeMenu.removeFromToolbar.label;"
-                class="customize-context-removeFromToolbar"/>
+               onpopupshowing="onViewToolbarsPopupShowing(event);">
       <menuseparator/>
-      <menuseparator id="viewToolbarsMenuSeparator"/>
+      <menuitem command="cmd_ToggleTabsOnTop"
+                type="checkbox"
+                label="&viewTabsOnTop.label;"
+                accesskey="&viewTabsOnTop.accesskey;"/>
       <menuitem command="cmd_CustomizeToolbars"
-                class="viewCustomizeToolbar"
                 label="&viewCustomizeToolbar.label;"
                 accesskey="&viewCustomizeToolbar.accesskey;"/>
     </menupopup>
 
     <menupopup id="blockedPopupOptions"
                onpopupshowing="gPopupBlockerObserver.fillPopupList(event);"
                onpopuphiding="gPopupBlockerObserver.onPopupHiding(event);">
       <menuitem observes="blockedPopupAllowSite"/>
@@ -393,16 +376,20 @@
       <hbox pack="center">
         <button id="ctrlTab-showAll" class="ctrlTab-preview" noicon="true"/>
       </hbox>
     </panel>
 
     <!-- Bookmarks and history tooltip -->
     <tooltip id="bhTooltip"/>
 
+    <panel id="customizeToolbarSheetPopup"
+           noautohide="true"
+           sheetstyle="&dialog.dimensions;"/>
+
     <tooltip id="tabbrowser-tab-tooltip" onpopupshowing="gBrowser.createTooltip(event);"/>
 
     <tooltip id="back-button-tooltip">
       <label class="tooltip-label" value="&backButton.tooltip;"/>
 #ifdef XP_MACOSX
       <label class="tooltip-label" value="&backForwardButtonMenuMac.tooltip;"/>
 #else
       <label class="tooltip-label" value="&backForwardButtonMenu.tooltip;"/>
@@ -415,491 +402,374 @@
       <label class="tooltip-label" value="&backForwardButtonMenuMac.tooltip;"/>
 #else
       <label class="tooltip-label" value="&backForwardButtonMenu.tooltip;"/>
 #endif
     </tooltip>
 
 #include popup-notifications.inc
 
-#include ../../components/customizableui/content/panelUI.inc.xul
-
     <hbox id="downloads-animation-container" mousethrough="always">
       <vbox id="downloads-notification-anchor">
         <vbox id="downloads-indicator-notification"/>
       </vbox>
     </hbox>
   </popupset>
 
 #ifdef CAN_DRAW_IN_TITLEBAR
 <vbox id="titlebar">
   <hbox id="titlebar-content">
+#ifdef MENUBAR_CAN_AUTOHIDE
+    <hbox id="appmenu-button-container">
+      <button id="appmenu-button"
+              type="menu"
+              label="&brandShortName;"
+              style="-moz-user-focus: ignore;">
+#include browser-appmenu.inc
+      </button>
+    </hbox>
+#endif
     <spacer id="titlebar-spacer" flex="1"/>
-    <hbox id="titlebar-buttonbox-container">
+    <hbox id="titlebar-buttonbox-container" align="start">
       <hbox id="titlebar-buttonbox">
         <toolbarbutton class="titlebar-button" id="titlebar-min" oncommand="window.minimize();"/>
         <toolbarbutton class="titlebar-button" id="titlebar-max" oncommand="onTitlebarMaxClick();"/>
         <toolbarbutton class="titlebar-button" id="titlebar-close" command="cmd_closeWindow"/>
       </hbox>
     </hbox>
-#ifdef XP_MACOSX
-    <hbox id="titlebar-fullscreen-button"/>
-#endif
   </hbox>
 </vbox>
 #endif
 
 <deck flex="1" id="tab-view-deck">
 <vbox flex="1" id="browser-panel">
 
-  <toolbox id="navigator-toolbox">
+  <toolbox id="navigator-toolbox"
+           defaultmode="icons" mode="icons"
+           iconsize="large">
     <!-- Menu -->
     <toolbar type="menubar" id="toolbar-menubar" class="chromeclass-menubar" customizable="true"
              defaultset="menubar-items"
-             mode="icons" iconsize="small"
+             mode="icons" iconsize="small" defaulticonsize="small"
+             lockiconsize="true"
 #ifdef MENUBAR_CAN_AUTOHIDE
              toolbarname="&menubarCmd.label;"
              accesskey="&menubarCmd.accesskey;"
-#ifdef XP_LINUX
-             autohide="true"
-#endif
 #endif
              context="toolbar-context-menu">
-      <toolbaritem id="menubar-items" align="center"
-                   cui-areatype="toolbar">
+      <toolbaritem id="menubar-items" align="center">
 # The entire main menubar is placed into browser-menubar.inc, so that it can be shared by
 # hiddenWindow.xul.
 #include browser-menubar.inc
       </toolbaritem>
 
 #ifdef CAN_DRAW_IN_TITLEBAR
-#ifndef XP_MACOSX
-      <hbox class="titlebar-placeholder" type="caption-buttons" ordinal="1000"
-            id="titlebar-placeholder-on-menubar-for-caption-buttons" persist="width"
-            skipintoolbarset="true"/>
-#endif
-#endif
-    </toolbar>
-
-    <toolbar id="TabsToolbar"
-             class="toolbar-primary"
-             fullscreentoolbar="true"
-             customizable="true"
-             mode="icons"
-             iconsize="small"
-             aria-label="&tabsToolbar.label;"
-             context="toolbar-context-menu"
-             defaultset="tabbrowser-tabs,new-tab-button,alltabs-button,tabs-closebutton"
-             collapsed="true">
-
-      <tabs id="tabbrowser-tabs"
-            class="tabbrowser-tabs"
-            tabbrowser="content"
-            flex="1"
-            setfocus="false"
-            tooltip="tabbrowser-tab-tooltip"
-            cui-areatype="toolbar"
-            stopwatchid="FX_TAB_CLICK_MS">
-        <tab class="tabbrowser-tab" selected="true" fadein="true"/>
-      </tabs>
-
-      <toolbarbutton id="new-tab-button"
-                     class="toolbarbutton-1 chromeclass-toolbar-additional"
-                     label="&tabCmd.label;"
-                     command="cmd_newNavigatorTab"
-                     onclick="checkForMiddleClick(this, event);"
-                     tooltiptext="&newTabButton.tooltip;"
-                     ondrop="newTabButtonObserver.onDrop(event)"
-                     ondragover="newTabButtonObserver.onDragOver(event)"
-                     ondragenter="newTabButtonObserver.onDragOver(event)"
-                     ondragexit="newTabButtonObserver.onDragExit(event)"
-                     cui-areatype="toolbar"
-                     removable="true"/>
-
-      <toolbarbutton id="alltabs-button"
-                     class="toolbarbutton-1 chromeclass-toolbar-additional tabs-alltabs-button"
-                     type="menu"
-                     label="&listAllTabs.label;"
-                     tooltiptext="&listAllTabs.label;"
-                     removable="false">
-        <menupopup id="alltabs-popup"
-                   position="after_end">
-          <menuitem id="menu_tabview"
-                    class="menuitem-iconic"
-                    key="key_tabview"
-                    label="&viewTabGroups.label;"
-                    command="Browser:ToggleTabView"
-                    cui-areatype="toolbar"
-                    observes="tabviewGroupsNumber"/>
-          <menuseparator id="alltabs-popup-separator"/>
-        </menupopup>
-      </toolbarbutton>
-
-      <toolbarbutton id="tabs-closebutton"
-                     class="close-button tabs-closebutton close-icon"
-                     command="cmd_close"
-                     label="&closeTab.label;"
-                     cui-areatype="toolbar"
-                     tooltiptext="&closeTab.label;"/>
-
-#ifdef CAN_DRAW_IN_TITLEBAR
-      <hbox class="titlebar-placeholder" type="caption-buttons"
-            id="titlebar-placeholder-on-TabsToolbar-for-captions-buttons" persist="width"
-#ifndef XP_MACOSX
-            ordinal="1000"
-#endif
-            skipintoolbarset="true"/>
-
-#ifdef XP_MACOSX
-      <hbox class="titlebar-placeholder" type="fullscreen-button"
-            id="titlebar-placeholder-on-TabsToolbar-for-fullscreen-button" persist="width"
-            skipintoolbarset="true"/>
-#endif
+      <hbox class="titlebar-placeholder" type="appmenu-button" ordinal="0"/>
+      <hbox class="titlebar-placeholder" type="caption-buttons" ordinal="1000"/>
 #endif
     </toolbar>
 
-    <!--
-           CAVEAT EMPTOR
-           Should you need to add items to the toolbar here, make sure to also add them
-           to the default placements of buttons in CustomizableUI.jsm, so the
-           customization code doesn't get confused.
-      -->
     <toolbar id="nav-bar" class="toolbar-primary chromeclass-toolbar"
-             aria-label="&navbarCmd.label;"
+             toolbarname="&navbarCmd.label;" accesskey="&navbarCmd.accesskey;"
              fullscreentoolbar="true" mode="icons" customizable="true"
-             iconsize="small"
-             defaultset="urlbar-container,search-container,webrtc-status-button,bookmarks-menu-button,downloads-button,home-button,social-share-button,social-toolbar-item"
-             customizationtarget="nav-bar-customization-target"
-             overflowable="true"
-             overflowbutton="nav-bar-overflow-button"
-             overflowtarget="widget-overflow-list"
+             iconsize="large"
+             defaultset="unified-back-forward-button,urlbar-container,reload-button,stop-button,search-container,webrtc-status-button,bookmarks-menu-button,downloads-button,home-button,window-controls"
              context="toolbar-context-menu">
 
-      <hbox id="nav-bar-customization-target" class="customization-target" flex="1">
-        <toolbaritem id="urlbar-container" flex="400" persist="width"
-                     forwarddisabled="true" title="&locationItem.title;" removable="false"
-                     cui-areatype="toolbar"
-                     class="chromeclass-location" overflows="false">
-          <toolbarbutton id="back-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
-                         label="&backCmd.label;"
-                         command="Browser:BackOrBackDuplicate"
-                         onclick="checkForMiddleClick(this, event);"
-                         tooltip="back-button-tooltip"
-                         context="backForwardMenu"/>
-          <toolbarbutton id="forward-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
-                         label="&forwardCmd.label;"
-                         command="Browser:ForwardOrForwardDuplicate"
+      <toolbaritem id="unified-back-forward-button" class="chromeclass-toolbar-additional"
+                   context="backForwardMenu" removable="true"
+                   forwarddisabled="true"
+                   title="&backForwardItem.title;">
+        <toolbarbutton id="back-button" class="toolbarbutton-1"
+                       label="&backCmd.label;"
+                       command="Browser:BackOrBackDuplicate"
+                       onclick="checkForMiddleClick(this, event);"
+                       tooltip="back-button-tooltip"/>
+        <toolbarbutton id="forward-button" class="toolbarbutton-1"
+                       label="&forwardCmd.label;"
+                       command="Browser:ForwardOrForwardDuplicate"
+                       onclick="checkForMiddleClick(this, event);"
+                       tooltip="forward-button-tooltip"/>
+        <dummyobservertarget hidden="true"
+                             onbroadcast="if (this.getAttribute('disabled') == 'true')
+                                            this.parentNode.setAttribute('forwarddisabled', 'true');
+                                          else
+                                            this.parentNode.removeAttribute('forwarddisabled');">
+          <observes element="Browser:ForwardOrForwardDuplicate" attribute="disabled"/>
+        </dummyobservertarget>
+      </toolbaritem>
+
+      <toolbaritem id="urlbar-container" align="center" flex="400" persist="width" combined="true"
+                   title="&locationItem.title;" class="chromeclass-location" removable="true">
+        <textbox id="urlbar" flex="1"
+                 placeholder="&urlbar.placeholder2;"
+                 type="autocomplete"
+                 autocompletesearch="urlinline history"
+                 autocompletesearchparam="enable-actions"
+                 autocompletepopup="PopupAutoCompleteRichResult"
+                 completeselectedindex="true"
+                 tabscrolling="true"
+                 showcommentcolumn="true"
+                 showimagecolumn="true"
+                 enablehistory="true"
+                 maxrows="6"
+                 newlines="stripsurroundingwhitespace"
+                 oninput="gBrowser.userTypedValue = this.value;"
+                 ontextentered="this.handleCommand(param);"
+                 ontextreverted="return this.handleRevert();"
+                 pageproxystate="invalid"
+                 onfocus="document.getElementById('identity-box').style.MozUserFocus= 'normal'"
+                 onblur="setTimeout(function() document.getElementById('identity-box').style.MozUserFocus = '', 0);">
+          <box id="notification-popup-box" hidden="true" align="center">
+            <image id="default-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="identity-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="geo-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="addons-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="indexedDB-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="password-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="webapps-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="plugins-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="web-notifications-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="plugin-install-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="mixed-content-blocked-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="webRTC-shareDevices-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="webRTC-sharingDevices-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="pointerLock-notification-icon" class="notification-anchor-icon" role="button"/>
+            <image id="servicesInstall-notification-icon" class="notification-anchor-icon" role="button"/>
+          </box>
+          <!-- Use onclick instead of normal popup= syntax since the popup
+               code fires onmousedown, and hence eats our favicon drag events.
+               We only add the identity-box button to the tab order when the location bar
+               has focus, otherwise pressing F6 focuses it instead of the location bar -->
+          <box id="identity-box" role="button"
+               align="center"
+               onclick="gIdentityHandler.handleIdentityButtonEvent(event);"
+               onkeypress="gIdentityHandler.handleIdentityButtonEvent(event);"
+               ondragstart="gIdentityHandler.onDragStart(event);">
+            <image id="page-proxy-favicon"
+                   onclick="PageProxyClickHandler(event);"
+                   pageproxystate="invalid"/>
+            <hbox id="identity-icon-labels">
+              <label id="identity-icon-label" class="plain" flex="1"/>
+              <label id="identity-icon-country-label" class="plain"/>
+            </hbox>
+          </box>
+          <box id="urlbar-display-box" align="center">
+            <label id="urlbar-display" value="&urlbar.switchToTab.label;"/>
+          </box>
+          <hbox id="urlbar-icons">
+            <image id="page-report-button"
+                   class="urlbar-icon"
+                   hidden="true"
+                   tooltiptext="&pageReportIcon.tooltip;"
+                   onclick="gPopupBlockerObserver.onReportButtonClick(event);"/>
+            <image id="star-button"
+                   class="urlbar-icon"
+                   onclick="if (event.button === 0) BookmarkingUI.onCommand(event);"/>
+            <image id="go-button"
+                   class="urlbar-icon"
+                   tooltiptext="&goEndCap.tooltip;"
+                   onclick="gURLBar.handleCommand(event);"/>
+          </hbox>
+          <toolbarbutton id="urlbar-go-button"
+                         class="chromeclass-toolbar-additional"
+                         onclick="gURLBar.handleCommand(event);"
+                         tooltiptext="&goEndCap.tooltip;"/>
+          <toolbarbutton id="urlbar-reload-button"
+                         class="chromeclass-toolbar-additional"
+                         command="Browser:ReloadOrDuplicate"
                          onclick="checkForMiddleClick(this, event);"
-                         tooltip="forward-button-tooltip"
-                         context="backForwardMenu"/>
-          <dummyobservertarget hidden="true"
-                               onbroadcast="if (this.getAttribute('disabled') == 'true')
-                                              this.parentNode.setAttribute('forwarddisabled', 'true');
-                                            else
-                                              this.parentNode.removeAttribute('forwarddisabled');">
-            <observes element="Browser:ForwardOrForwardDuplicate" attribute="disabled"/>
-          </dummyobservertarget>
-          <hbox id="urlbar-wrapper" flex="1" align="center">
-            <textbox id="urlbar" flex="1"
-                     placeholder="&urlbar.placeholder2;"
-                     type="autocomplete"
-                     autocompletesearch="urlinline history"
-                     autocompletesearchparam="enable-actions"
-                     autocompletepopup="PopupAutoCompleteRichResult"
-                     completeselectedindex="true"
-                     tabscrolling="true"
-                     showcommentcolumn="true"
-                     showimagecolumn="true"
-                     enablehistory="true"
-                     maxrows="6"
-                     newlines="stripsurroundingwhitespace"
-                     oninput="gBrowser.userTypedValue = this.value;"
-                     ontextentered="this.handleCommand(param);"
-                     ontextreverted="return this.handleRevert();"
-                     pageproxystate="invalid"
-                     onfocus="document.getElementById('identity-box').style.MozUserFocus= 'normal'"
-                     onblur="setTimeout(function() document.getElementById('identity-box').style.MozUserFocus = '', 0);">
-              <box id="notification-popup-box" hidden="true" align="center">
-                <image id="default-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="identity-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="geo-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="addons-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="indexedDB-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="password-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="webapps-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="plugins-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="web-notifications-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="plugin-install-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="mixed-content-blocked-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="webRTC-shareDevices-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="webRTC-sharingDevices-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="pointerLock-notification-icon" class="notification-anchor-icon" role="button"/>
-                <image id="servicesInstall-notification-icon" class="notification-anchor-icon" role="button"/>
-              </box>
-              <!-- Use onclick instead of normal popup= syntax since the popup
-                   code fires onmousedown, and hence eats our favicon drag events.
-                   We only add the identity-box button to the tab order when the location bar
-                   has focus, otherwise pressing F6 focuses it instead of the location bar -->
-              <box id="identity-box" role="button"
-                   align="center"
-                   onclick="gIdentityHandler.handleIdentityButtonEvent(event);"
-                   onkeypress="gIdentityHandler.handleIdentityButtonEvent(event);"
-                   ondragstart="gIdentityHandler.onDragStart(event);">
-                <image id="page-proxy-favicon"
-                       onclick="PageProxyClickHandler(event);"
-                       pageproxystate="invalid"/>
-                <hbox id="identity-icon-labels">
-                  <label id="identity-icon-label" class="plain" flex="1"/>
-                  <label id="identity-icon-country-label" class="plain"/>
-                </hbox>
-              </box>
-              <box id="urlbar-display-box" align="center">
-                <label id="urlbar-display" value="&urlbar.switchToTab.label;"/>
-              </box>
-              <hbox id="urlbar-icons">
-                <image id="page-report-button"
-                       class="urlbar-icon"
-                       hidden="true"
-                       tooltiptext="&pageReportIcon.tooltip;"
-                       onclick="gPopupBlockerObserver.onReportButtonClick(event);"/>
-                <image id="star-button"
-                       class="urlbar-icon"
-                       onclick="if (event.button === 0) BookmarkingUI.onCommand(event);"/>
-              </hbox>
-              <toolbarbutton id="urlbar-go-button"
-                             class="chromeclass-toolbar-additional"
-                             onclick="gURLBar.handleCommand(event);"
-                             tooltiptext="&goEndCap.tooltip;"/>
-              <toolbarbutton id="urlbar-reload-button"
-                             class="chromeclass-toolbar-additional"
-                             command="Browser:ReloadOrDuplicate"
-                             onclick="checkForMiddleClick(this, event);"
-                             tooltiptext="&reloadButton.tooltip;"/>
-              <toolbarbutton id="urlbar-stop-button"
-                             class="chromeclass-toolbar-additional"
-                             command="Browser:Stop"
-                             tooltiptext="&stopButton.tooltip;"/>
-            </textbox>
-          </hbox>
-        </toolbaritem>
+                         tooltiptext="&reloadButton.tooltip;"/>
+          <toolbarbutton id="urlbar-stop-button"
+                         class="chromeclass-toolbar-additional"
+                         command="Browser:Stop"
+                         tooltiptext="&stopButton.tooltip;"/>
+        </textbox>
+      </toolbaritem>
 
-        <toolbaritem id="search-container" title="&searchItem.title;"
-                     align="center" class="chromeclass-toolbar-additional panel-wide-item"
-                     cui-areatype="toolbar"
-                     flex="100" persist="width" removable="true">
-          <searchbar id="searchbar" flex="1"/>
-        </toolbaritem>
+      <toolbarbutton id="reload-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     label="&reloadCmd.label;" removable="true"
+                     command="Browser:ReloadOrDuplicate"
+                     onclick="checkForMiddleClick(this, event);"
+                     tooltiptext="&reloadButton.tooltip;"/>
 
-        <toolbarbutton id="webrtc-status-button"
-                       class="toolbarbutton-1 chromeclass-toolbar-additional"
-                       type="menu"
-                       hidden="true"
-                       orient="horizontal"
-                       label="&webrtcIndicatorButton.label;"
-                       tooltiptext="&webrtcIndicatorButton.tooltip;"
-                       cui-areatype="toolbar"
-                       overflows="false">
-          <menupopup onpopupshowing="WebrtcIndicator.fillPopup(this);"
-                     onpopuphiding="WebrtcIndicator.clearPopup(this);"
-                     oncommand="WebrtcIndicator.menuCommand(event.target);"/>
-        </toolbarbutton>
+      <toolbarbutton id="stop-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     label="&stopCmd.label;" removable="true"
+                     command="Browser:Stop"
+                     tooltiptext="&stopButton.tooltip;"/>
 
-        <toolbarbutton id="bookmarks-menu-button"
-                       class="toolbarbutton-1 chromeclass-toolbar-additional"
-                       persist="class"
-                       removable="true"
-                       type="menu-button"
-                       label="&bookmarksMenuButton.label;"
-                       tooltiptext="&bookmarksMenuButton.tooltip;"
-                       ondragenter="PlacesMenuDNDHandler.onDragEnter(event);"
-                       ondragover="PlacesMenuDNDHandler.onDragOver(event);"
-                       ondragleave="PlacesMenuDNDHandler.onDragLeave(event);"
-                       ondrop="PlacesMenuDNDHandler.onDrop(event);"
-                       cui-areatype="toolbar"
-                       oncommand="BookmarkingUI.onCommand(event);">
-          <menupopup id="BMB_bookmarksPopup"
-                     placespopup="true"
-                     context="placesContext"
-                     openInTabs="children"
-                     anonanchorclass="toolbarbutton-menubutton-dropmarker"
-                     oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);"
-                     onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
-                     onpopupshowing="BookmarkingUI.onPopupShowing(event);
-                                     if (!this.parentNode._placesView)
-                                       new PlacesMenu(event, 'place:folder=BOOKMARKS_MENU');"
-                     tooltip="bhTooltip" popupsinherittooltip="true">
-            <menuitem id="BMB_bookmarksShowAll"
-                      label="&showAllBookmarks2.label;"
-                      command="Browser:ShowAllBookmarks"
-                      key="manBookmarkKb"/>
-            <menuitem id="BMB_viewBookmarksSidebar"
-                      label="&viewBookmarksSidebar2.label;"
-                      type="checkbox"
-                      oncommand="toggleSidebar('viewBookmarksSidebar');">
-              <observes element="viewBookmarksSidebar" attribute="checked"/>
-            </menuitem>
-            <menuseparator/>
-            <menuitem id="BMB_subscribeToPageMenuitem"
+      <toolbaritem id="search-container" title="&searchItem.title;"
+                   align="center" class="chromeclass-toolbar-additional"
+                   flex="100" persist="width" removable="true">
+        <searchbar id="searchbar" flex="1"/>
+      </toolbaritem>
+
+      <toolbarbutton id="webrtc-status-button"
+                     class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     type="menu"
+                     hidden="true"
+                     orient="horizontal"
+                     label="&webrtcIndicatorButton.label;"
+                     tooltiptext="&webrtcIndicatorButton.tooltip;">
+        <menupopup onpopupshowing="WebrtcIndicator.fillPopup(this);"
+                   onpopuphiding="WebrtcIndicator.clearPopup(this);"
+                   oncommand="WebrtcIndicator.menuCommand(event.target);"/>
+      </toolbarbutton>
+
+      <toolbarbutton id="bookmarks-menu-button"
+                     class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     persist="class"
+                     removable="true"
+                     type="menu"
+                     label="&bookmarksMenuButton.label;"
+                     tooltiptext="&bookmarksMenuButton.tooltip;"
+                     ondragenter="PlacesMenuDNDHandler.onDragEnter(event);"
+                     ondragover="PlacesMenuDNDHandler.onDragOver(event);"
+                     ondragleave="PlacesMenuDNDHandler.onDragLeave(event);"
+                     ondrop="PlacesMenuDNDHandler.onDrop(event);">
+        <menupopup id="BMB_bookmarksPopup"
+                   placespopup="true"
+                   context="placesContext"
+                   openInTabs="children"
+                   oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);"
+                   onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
+                   onpopupshowing="BookmarkingUI.onPopupShowing(event);
+                                   if (!this.parentNode._placesView)
+                                     new PlacesMenu(event, 'place:folder=BOOKMARKS_MENU');"
+                   tooltip="bhTooltip" popupsinherittooltip="true">
+          <menuitem id="BMB_viewBookmarksToolbar"
+                    placesanonid="view-toolbar"
+                    toolbarId="PersonalToolbar"
+                    type="checkbox"
+                    oncommand="onViewToolbarCommand(event)"
+                    label="&viewBookmarksToolbar.label;"/>
+          <menuseparator/>
+          <menuitem id="BMB_bookmarksShowAll"
+                    label="&showAllBookmarks2.label;"
+                    command="Browser:ShowAllBookmarks"
+                    key="manBookmarkKb"/>
+          <menuseparator/>
+          <menuitem id="BMB_bookmarkThisPage"
 #ifndef XP_MACOSX
-                      class="menuitem-iconic"
+                    class="menuitem-iconic"
 #endif
-                      label="&subscribeToPageMenuitem.label;"
-                      oncommand="return FeedHandler.subscribeToFeed(null, event);"
-                      onclick="checkForMiddleClick(this, event);"
-                      observes="singleFeedMenuitemState"/>
-            <menu id="BMB_subscribeToPageMenupopup"
+                    label="&bookmarkThisPageCmd.label;"
+                    command="Browser:AddBookmarkAs"
+                    key="addBookmarkAsKb"/>
+          <menuitem id="BMB_subscribeToPageMenuitem"
 #ifndef XP_MACOSX
-                  class="menu-iconic"
+                    class="menuitem-iconic"
 #endif
-                  label="&subscribeToPageMenupopup.label;"
-                  observes="multipleFeedsMenuState">
-              <menupopup id="BMB_subscribeToPageSubmenuMenupopup"
-                         onpopupshowing="return FeedHandler.buildFeedList(event.target);"
-                         oncommand="return FeedHandler.subscribeToFeed(null, event);"
-                         onclick="checkForMiddleClick(this, event);"/>
-            </menu>
-            <menuseparator/>
-            <menu id="BMB_bookmarksToolbar"
-                  class="menu-iconic bookmark-item"
-                  label="&personalbarCmd.label;"
-                  container="true">
-              <menupopup id="BMB_bookmarksToolbarPopup"
-                         placespopup="true"
-                         context="placesContext"
-                         onpopupshowing="if (!this.parentNode._placesView)
-                                           new PlacesMenu(event, 'place:folder=TOOLBAR');">
-                <menuitem id="BMB_viewBookmarksToolbar"
-                          placesanonid="view-toolbar"
-                          toolbarId="PersonalToolbar"
-                          type="checkbox"
-                          oncommand="onViewToolbarCommand(event)"
-                          label="&viewBookmarksToolbar.label;"/>
-                <menuseparator/>
-                <!-- Bookmarks toolbar items -->
-              </menupopup>
-            </menu>
-            <menu id="BMB_unsortedBookmarks"
-                  class="menu-iconic bookmark-item"
-                  label="&bookmarksMenuButton.unsorted.label;"
-                  container="true">
-              <menupopup id="BMB_unsortedBookmarksPopup"
-                         placespopup="true"
-                         context="placesContext"
-                         onpopupshowing="if (!this.parentNode._placesView)
-                                           new PlacesMenu(event, 'place:folder=UNFILED_BOOKMARKS');"/>
-            </menu>
-            <menuseparator/>
-            <!-- Bookmarks menu items -->
-          </menupopup>
-        </toolbarbutton>
+                    label="&subscribeToPageMenuitem.label;"
+                    oncommand="return FeedHandler.subscribeToFeed(null, event);"
+                    onclick="checkForMiddleClick(this, event);"
+                    observes="singleFeedMenuitemState"/>
+          <menu id="BMB_subscribeToPageMenupopup"
+#ifndef XP_MACOSX
+                class="menu-iconic"
+#endif
+                label="&subscribeToPageMenupopup.label;"
+                observes="multipleFeedsMenuState">
+            <menupopup id="BMB_subscribeToPageSubmenuMenupopup"
+                       onpopupshowing="return FeedHandler.buildFeedList(event.target);"
+                       oncommand="return FeedHandler.subscribeToFeed(null, event);"
+                       onclick="checkForMiddleClick(this, event);"/>
+          </menu>
+          <menuseparator/>
+          <menu id="BMB_bookmarksToolbar"
+                placesanonid="toolbar-autohide"
+                class="menu-iconic bookmark-item"
+                label="&personalbarCmd.label;"
+                container="true">
+            <menupopup id="BMB_bookmarksToolbarPopup"
+                       placespopup="true"
+                       context="placesContext"
+                       onpopupshowing="if (!this.parentNode._placesView)
+                                         new PlacesMenu(event, 'place:folder=TOOLBAR');"/>
+          </menu>
+          <menuseparator/>
+          <!-- Bookmarks menu items -->
+          <menuseparator builder="end"
+                         class="hide-if-empty-places-result"/>
+          <menuitem id="BMB_unsortedBookmarks"
+                    label="&bookmarksMenuButton.unsorted.label;"
+                    oncommand="PlacesCommandHook.showPlacesOrganizer('UnfiledBookmarks');"
+                    class="menuitem-iconic"/>
+        </menupopup>
+      </toolbarbutton>
 
-        <!-- This is a placeholder for the Downloads Indicator.  It is visible
-             during the customization of the toolbar, in the palette, and before
-             the Downloads Indicator overlay is loaded. -->
-        <toolbarbutton id="downloads-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
-                       oncommand="DownloadsIndicatorView.onCommand(event);"
-                       ondrop="DownloadsIndicatorView.onDrop(event);"
-                       ondragover="DownloadsIndicatorView.onDragOver(event);"
-                       ondragenter="DownloadsIndicatorView.onDragOver(event);"
-                       label="&downloads.label;"
-                       removable="true"
-                       cui-areatype="toolbar"
-                       tooltiptext="&downloads.tooltip;"/>
+      <toolbarbutton id="home-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     persist="class" removable="true"
+                     label="&homeButton.label;"
+                     ondragover="homeButtonObserver.onDragOver(event)"
+                     ondragenter="homeButtonObserver.onDragOver(event)"
+                     ondrop="homeButtonObserver.onDrop(event)"
+                     ondragexit="homeButtonObserver.onDragExit(event)"
+                     onclick="BrowserGoHome(event);"
+                     aboutHomeOverrideTooltip="&abouthome.pageTitle;"/>
 
-        <toolbarbutton id="home-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
-                       persist="class" removable="true"
-                       label="&homeButton.label;"
-                       ondragover="homeButtonObserver.onDragOver(event)"
-                       ondragenter="homeButtonObserver.onDragOver(event)"
-                       ondrop="homeButtonObserver.onDrop(event)"
-                       ondragexit="homeButtonObserver.onDragExit(event)"
-                       onclick="BrowserGoHome(event);"
-                       cui-areatype="toolbar"
-                       aboutHomeOverrideTooltip="&abouthome.pageTitle;"/>
-
+      <toolbarbutton id="social-share-button"
+                     class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     hidden="true"
+                     label="&sharePageCmd.label;"
+                     tooltiptext="&sharePageCmd.label;"
+                     command="Social:SharePage"/>
 
-        <toolbarbutton id="social-share-button"
-                       class="toolbarbutton-1 chromeclass-toolbar-additional"
-                       hidden="true"
-                       overflows="false"
-                       label="&sharePageCmd.label;"
-                       tooltiptext="&sharePageCmd.label;"
-                       cui-areatype="toolbar"
-                       command="Social:SharePage"/>
-
-        <toolbaritem id="social-toolbar-item"
-                     class="chromeclass-toolbar-additional toolbaritem-with-separator"
-                     removable="false"
-                     title="&socialToolbar.title;"
-                     hidden="true"
-                     overflows="false"
-                     cui-areatype="toolbar"
-                     observes="socialActiveBroadcaster">
+      <toolbaritem id="social-toolbar-item"
+                   class="chromeclass-toolbar-additional"
+                   removable="false"
+                   title="&socialToolbar.title;"
+                   hidden="true"
+                   skipintoolbarset="true"
+                   observes="socialActiveBroadcaster">
         <toolbarbutton id="social-notification-icon" class="default-notification-icon toolbarbutton-1 notification-anchor-icon"
                    oncommand="PopupNotifications._reshowNotifications(this,
                                 document.getElementById('social-sidebar-browser'));"/>
-          <toolbarbutton id="social-provider-button"
-                         class="toolbarbutton-1"
-                         type="menu">
-            <menupopup id="social-statusarea-popup">
-              <menuitem class="social-statusarea-user menuitem-iconic" pack="start" align="center"
-                        observes="socialBroadcaster_userDetails"
-                        oncommand="SocialUI.showProfile(); document.getElementById('social-statusarea-popup').hidePopup();">
-                <image class="social-statusarea-user-portrait"
+        <toolbarbutton id="social-provider-button"
+                       class="toolbarbutton-1"
+                       type="menu">
+          <menupopup id="social-statusarea-popup">
+            <menuitem class="social-statusarea-user menuitem-iconic" pack="start" align="center"
+                      observes="socialBroadcaster_userDetails"
+                      oncommand="SocialUI.showProfile(); document.getElementById('social-statusarea-popup').hidePopup();">
+              <image class="social-statusarea-user-portrait"
+                     observes="socialBroadcaster_userDetails"/>
+              <vbox>
+                <label class="social-statusarea-loggedInStatus"
                        observes="socialBroadcaster_userDetails"/>
-                <vbox>
-                  <label class="social-statusarea-loggedInStatus"
-                         observes="socialBroadcaster_userDetails"/>
-                </vbox>
-              </menuitem>
+              </vbox>
+            </menuitem>
 #ifndef XP_WIN
-              <menuseparator class="social-statusarea-separator"/>
+            <menuseparator class="social-statusarea-separator"/>
 #endif
-              <menuitem class="social-toggle-sidebar-menuitem"
-                        type="checkbox"
-                        autocheck="false"
-                        command="Social:ToggleSidebar"
-                        label="&social.toggleSidebar.label;"
-                        accesskey="&social.toggleSidebar.accesskey;"/>
-              <menuitem class="social-toggle-notifications-menuitem"
-                        type="checkbox"
-                        autocheck="false"
-                        command="Social:ToggleNotifications"
-                        label="&social.toggleNotifications.label;"
-                        accesskey="&social.toggleNotifications.accesskey;"/>
-              <menuitem class="social-toggle-menuitem" command="Social:Toggle"/>
-              <menuseparator/>
-              <menuseparator class="social-provider-menu" hidden="true"/>
-              <menuitem class="social-addons-menuitem" command="Social:Addons"
-                        label="&social.addons.label;"/>
-              <menuitem label="&social.learnMore.label;"
-                        accesskey="&social.learnMore.accesskey;"
-                        oncommand="SocialUI.showLearnMore();"/>
-            </menupopup>
-          </toolbarbutton>
-        </toolbaritem>
-      </hbox>
-
-      <toolbarbutton id="nav-bar-overflow-button"
-                     class="toolbarbutton-1 chromeclass-toolbar-additional overflow-button"
-                     skipintoolbarset="true"
-                     tooltiptext="&navbarOverflow.label;"/>
-
-      <toolbaritem id="PanelUI-button"
-                   class="chromeclass-toolbar-additional"
-                   removable="false"
-                   title="&appmenu.title;">
-        <toolbarbutton id="PanelUI-menu-button"
-                       class="toolbarbutton-1"
-                       label="&brandShortName;"
-                       tooltiptext="&appmenu.title;"/>
+            <menuitem class="social-toggle-sidebar-menuitem"
+                      type="checkbox"
+                      autocheck="false"
+                      command="Social:ToggleSidebar"
+                      label="&social.toggleSidebar.label;"
+                      accesskey="&social.toggleSidebar.accesskey;"/>
+            <menuitem class="social-toggle-notifications-menuitem"
+                      type="checkbox"
+                      autocheck="false"
+                      command="Social:ToggleNotifications"
+                      label="&social.toggleNotifications.label;"
+                      accesskey="&social.toggleNotifications.accesskey;"/>
+            <menuitem class="social-toggle-menuitem" command="Social:Toggle"/>
+            <menuseparator/>
+            <menuseparator class="social-provider-menu" hidden="true"/>
+            <menuitem class="social-addons-menuitem" command="Social:Addons"
+                      label="&social.addons.label;"/>
+            <menuitem label="&social.learnMore.label;"
+                      accesskey="&social.learnMore.accesskey;"
+                      oncommand="SocialUI.showLearnMore();"/>
+          </menupopup>
+        </toolbarbutton>
       </toolbaritem>
 
-      <hbox id="window-controls" hidden="true" pack="end" skipintoolbarset="true"
-            ordinal="1000">
+      <hbox id="window-controls" hidden="true" pack="end">
         <toolbarbutton id="minimize-button"
                        tooltiptext="&fullScreenMinimize.tooltip;"
                        oncommand="window.minimize();"/>
 
         <toolbarbutton id="restore-button"
                        tooltiptext="&fullScreenRestore.tooltip;"
                        oncommand="BrowserFullScreen();"/>
 
@@ -907,40 +777,36 @@
                        tooltiptext="&fullScreenClose.tooltip;"
                        oncommand="BrowserTryToCloseWindow();"/>
       </hbox>
     </toolbar>
 
     <toolbarset id="customToolbars" context="toolbar-context-menu"/>
 
     <toolbar id="PersonalToolbar"
-             mode="icons" iconsize="small"
+             mode="icons" iconsize="small" defaulticonsize="small"
+             lockiconsize="true"
              class="chromeclass-directories"
              context="toolbar-context-menu"
              defaultset="personal-bookmarks"
              toolbarname="&personalbarCmd.label;" accesskey="&personalbarCmd.accesskey;"
              collapsed="true"
              customizable="true">
-      <toolbaritem id="personal-bookmarks"
-                   flex="1"
-                   title="&bookmarksToolbarItem.label;"
-                   cui-areatype="toolbar"
+      <toolbaritem flex="1" id="personal-bookmarks" title="&bookmarksItem.title;"
                    removable="true">
-        <toolbarbutton id="bookmarks-toolbar-placeholder"
-                       type="wrap"
-                       mousethrough="never"
-                       label="&bookmarksToolbarItem.label;"
-                       oncommand="PlacesToolbarHelper.onPlaceholderCommand();"/>
         <hbox flex="1"
               id="PlacesToolbar"
               context="placesContext"
               onclick="BookmarksEventHandler.onClick(event, this._placesView);"
               oncommand="BookmarksEventHandler.onCommand(event, this._placesView);"
               tooltip="bhTooltip"
               popupsinherittooltip="true">
+          <toolbarbutton class="bookmark-item bookmarks-toolbar-customize"
+                         mousethrough="never"
+                         label="&bookmarksToolbarItem.label;"/>
           <hbox flex="1">
             <hbox align="center">
               <image id="PlacesToolbarDropIndicator"
                      mousethrough="always"
                      collapsed="true"/>
             </hbox>
             <scrollbox orient="horizontal"
                        id="PlacesToolbarItems"
@@ -958,112 +824,250 @@
                          tooltip="bhTooltip" popupsinherittooltip="true"
                          context="placesContext"/>
             </toolbarbutton>
           </hbox>
         </hbox>
       </toolbaritem>
     </toolbar>
 
-    <!-- This is a shim which will go away ASAP. See bug 749804 for details -->
-    <toolbar id="addon-bar" toolbar-delegate="nav-bar" mode="icons" iconsize="small">
-      <hbox id="addonbar-closebutton"/>
-      <statusbar id="status-bar"/>
+#ifdef MENUBAR_CAN_AUTOHIDE
+#ifndef CAN_DRAW_IN_TITLEBAR
+#define APPMENU_ON_TABBAR
+#endif
+#endif
+
+
+    <toolbar id="TabsToolbar"
+             class="toolbar-primary"
+             fullscreentoolbar="true"
+             customizable="true"
+             mode="icons" lockmode="true"
+             iconsize="small" defaulticonsize="small" lockiconsize="true"
+             aria-label="&tabsToolbar.label;"
+             context="toolbar-context-menu"
+#ifdef APPMENU_ON_TABBAR
+             defaultset="appmenu-toolbar-button,tabbrowser-tabs,new-tab-button,alltabs-button,tabs-closebutton"
+#else
+             defaultset="tabbrowser-tabs,new-tab-button,alltabs-button,tabs-closebutton"
+#endif
+             collapsed="true">
+
+#ifdef APPMENU_ON_TABBAR
+      <toolbarbutton id="appmenu-toolbar-button"
+                     class="chromeclass-toolbar-additional"
+                     type="menu"
+                     label="&brandShortName;"
+                     tooltiptext="&appMenuButton.tooltip;">
+#include browser-appmenu.inc
+      </toolbarbutton>
+#endif
+
+      <tabs id="tabbrowser-tabs"
+            class="tabbrowser-tabs"
+            tabbrowser="content"
+            flex="1"
+            setfocus="false"
+            tooltip="tabbrowser-tab-tooltip"
+            stopwatchid="FX_TAB_CLICK_MS">
+        <tab class="tabbrowser-tab" selected="true" fadein="true"/>
+      </tabs>
+
+      <toolbarbutton id="new-tab-button"
+                     class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     label="&tabCmd.label;"
+                     command="cmd_newNavigatorTab"
+                     onclick="checkForMiddleClick(this, event);"
+                     tooltiptext="&newTabButton.tooltip;"
+                     ondrop="newTabButtonObserver.onDrop(event)"
+                     ondragover="newTabButtonObserver.onDragOver(event)"
+                     ondragenter="newTabButtonObserver.onDragOver(event)"
+                     ondragexit="newTabButtonObserver.onDragExit(event)"
+                     removable="true"/>
+
+      <toolbarbutton id="alltabs-button"
+                     class="toolbarbutton-1 chromeclass-toolbar-additional tabs-alltabs-button"
+                     type="menu"
+                     label="&listAllTabs.label;"
+                     tooltiptext="&listAllTabs.label;"
+                     removable="true">
+        <menupopup id="alltabs-popup"
+                   position="after_end">
+          <menuitem id="menu_tabview"
+                    class="menuitem-iconic"
+                    key="key_tabview"
+                    label="&viewTabGroups.label;"
+                    command="Browser:ToggleTabView"
+                    observes="tabviewGroupsNumber"/>
+          <menuseparator id="alltabs-popup-separator"/>
+        </menupopup>
+      </toolbarbutton>
+
+      <toolbarbutton id="tabs-closebutton"
+                     class="close-button tabs-closebutton"
+                     command="cmd_close"
+                     label="&closeTab.label;"
+                     tooltiptext="&closeTab.label;"/>
+
+#ifdef CAN_DRAW_IN_TITLEBAR
+      <hbox class="titlebar-placeholder" type="appmenu-button" ordinal="0"/>
+      <hbox class="titlebar-placeholder" type="caption-buttons" ordinal="1000"/>
+#endif
     </toolbar>
 
     <toolbarpalette id="BrowserToolbarPalette">
 
 # Update primaryToolbarButtons in browser/themes/shared/browser.inc when adding
 # or removing default items with the toolbarbutton-1 class.
 
       <toolbarbutton id="print-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
-#ifdef XP_MACOSX
-                     command="cmd_print"
-#else
-                     command="cmd_printPreview"
-#endif
-                     label="&printButton.label;" tooltiptext="&printButton.tooltip;"/>
+                     label="&printButton.label;" command="cmd_print"
+                     tooltiptext="&printButton.tooltip;"/>
 
+      <!-- This is a placeholder for the Downloads Indicator.  It is visible
+           during the customization of the toolbar, in the palette, and before
+           the Downloads Indicator overlay is loaded. -->
+      <toolbarbutton id="downloads-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     oncommand="DownloadsIndicatorView.onCommand(event);"
+                     ondrop="DownloadsIndicatorView.onDrop(event);"
+                     ondragover="DownloadsIndicatorView.onDragOver(event);"
+                     ondragenter="DownloadsIndicatorView.onDragOver(event);"
+                     label="&downloads.label;"
+                     tooltiptext="&downloads.tooltip;"/>
+
+      <toolbarbutton id="history-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     observes="viewHistorySidebar" label="&historyButton.label;"
+                     tooltiptext="&historyButton.tooltip;"/>
+
+      <toolbarbutton id="bookmarks-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     observes="viewBookmarksSidebar"
+                     tooltiptext="&bookmarksButton.tooltip;"
+                     ondrop="bookmarksButtonObserver.onDrop(event)"
+                     ondragover="bookmarksButtonObserver.onDragOver(event)"
+                     ondragenter="bookmarksButtonObserver.onDragOver(event)"
+                     ondragexit="bookmarksButtonObserver.onDragExit(event)"/>
 
       <toolbarbutton id="new-window-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                      label="&newNavigatorCmd.label;"
                      command="key_newNavigator"
                      tooltiptext="&newWindowButton.tooltip;"
                      ondrop="newWindowButtonObserver.onDrop(event)"
                      ondragover="newWindowButtonObserver.onDragOver(event)"
                      ondragenter="newWindowButtonObserver.onDragOver(event)"
                      ondragexit="newWindowButtonObserver.onDragExit(event)"/>
 
       <toolbarbutton id="fullscreen-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                      observes="View:FullScreen"
                      type="checkbox"
                      label="&fullScreenCmd.label;"
                      tooltiptext="&fullScreenButton.tooltip;"/>
 
+      <toolbaritem id="zoom-controls" class="chromeclass-toolbar-additional"
+                   title="&zoomControls.label;">
+        <toolbarbutton id="zoom-out-button" class="toolbarbutton-1"
+                       label="&fullZoomReduceCmd.label;"
+                       command="cmd_fullZoomReduce"
+                       tooltiptext="&zoomOutButton.tooltip;"/>
+        <toolbarbutton id="zoom-in-button" class="toolbarbutton-1"
+                       label="&fullZoomEnlargeCmd.label;"
+                       command="cmd_fullZoomEnlarge"
+                       tooltiptext="&zoomInButton.tooltip;"/>
+      </toolbaritem>
+
+      <toolbarbutton id="feed-button"
+                     type="menu"
+                     class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     disabled="true"
+                     label="&feedButton.label;"
+                     tooltiptext="&feedButton.tooltip;"
+                     onclick="return FeedHandler.onFeedButtonClick(event);">
+        <menupopup position="after_end"
+                   id="feed-menu"
+                   onpopupshowing="return FeedHandler.buildFeedList(this);"
+                   oncommand="return FeedHandler.subscribeToFeed(null, event);"
+                   onclick="checkForMiddleClick(this, event);"/>
+      </toolbarbutton>
+
+      <toolbarbutton id="cut-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     label="&cutCmd.label;"
+                     command="cmd_cut"
+                     tooltiptext="&cutButton.tooltip;"/>
+
+      <toolbarbutton id="copy-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     label="&copyCmd.label;"
+                     command="cmd_copy"
+                     tooltiptext="&copyButton.tooltip;"/>
+
+      <toolbarbutton id="paste-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
+                     label="&pasteCmd.label;"
+                     command="cmd_paste"
+                     tooltiptext="&pasteButton.tooltip;"/>
+
 #ifdef MOZ_SERVICES_SYNC
       <toolbarbutton id="sync-button"
                      class="toolbarbutton-1 chromeclass-toolbar-additional"
                      label="&syncToolbarButton.label;"
                      oncommand="gSyncUI.handleToolbarButton()"/>
 #endif
 
+      <toolbaritem id="navigator-throbber" title="&throbberItem.title;" align="center" pack="center"
+                   mousethrough="always">
+        <image/>
+      </toolbaritem>
+
       <toolbarbutton id="tabview-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
                      label="&tabGroupsButton.label;"
                      command="Browser:ToggleTabView"
                      tooltiptext="&tabGroupsButton.tooltip;"
                      observes="tabviewGroupsNumber"/>
     </toolbarpalette>
   </toolbox>
 
   <hbox id="fullscr-toggler" collapsed="true"/>
 
-  <deck id="content-deck" flex="1">
-    <hbox flex="1" id="browser">
-      <vbox id="browser-border-start" hidden="true" layer="true"/>
-      <vbox id="sidebar-box" hidden="true" class="chromeclass-extrachrome">
-        <sidebarheader id="sidebar-header" align="center">
-          <label id="sidebar-title" persist="value" flex="1" crop="end" control="sidebar"/>
-          <image id="sidebar-throbber"/>
-          <toolbarbutton class="tabs-closebutton close-icon" tooltiptext="&sidebarCloseButton.tooltip;" oncommand="toggleSidebar();"/>
-        </sidebarheader>
-        <browser id="sidebar" flex="1" autoscroll="false" disablehistory="true"
-                  style="min-width: 14em; width: 18em; max-width: 36em;"/>
-      </vbox>
+  <hbox flex="1" id="browser">
+    <vbox id="browser-border-start" hidden="true" layer="true"/>
+    <vbox id="sidebar-box" hidden="true" class="chromeclass-extrachrome">
+      <sidebarheader id="sidebar-header" align="center">
+        <label id="sidebar-title" persist="value" flex="1" crop="end" control="sidebar"/>
+        <image id="sidebar-throbber"/>
+        <toolbarbutton class="tabs-closebutton" tooltiptext="&sidebarCloseButton.tooltip;" oncommand="toggleSidebar();"/>
+      </sidebarheader>
+      <browser id="sidebar" flex="1" autoscroll="false" disablehistory="true"
+                style="min-width: 14em; width: 18em; max-width: 36em;"/>
+    </vbox>
 
-      <splitter id="sidebar-splitter" class="chromeclass-extrachrome sidebar-splitter" hidden="true"/>
-      <vbox id="appcontent" flex="1">
-        <tabbrowser id="content"
-                    flex="1" contenttooltip="aHTMLTooltip"
-                    tabcontainer="tabbrowser-tabs"
-                    contentcontextmenu="contentAreaContextMenu"
-                    autocompletepopup="PopupAutoComplete"
-                    selectpopup="ContentSelectDropdown"
-                    onclick="contentAreaClick(event, false);"/>
-        <chatbar id="pinnedchats" layer="true" mousethrough="always" hidden="true"/>
-      </vbox>
-      <splitter id="social-sidebar-splitter"
-                class="chromeclass-extrachrome sidebar-splitter"
-                observes="socialSidebarBroadcaster"/>
-      <vbox id="social-sidebar-box"
-            class="chromeclass-extrachrome"
-            observes="socialSidebarBroadcaster"
-            persist="width">
-        <browser id="social-sidebar-browser"
-                 type="content"
-                 context="contentAreaContextMenu"
-                 disableglobalhistory="true"
-                 tooltip="aHTMLTooltip"
+    <splitter id="sidebar-splitter" class="chromeclass-extrachrome sidebar-splitter" hidden="true"/>
+    <vbox id="appcontent" flex="1">
+      <tabbrowser id="content"
+                  flex="1" contenttooltip="aHTMLTooltip"
+                  tabcontainer="tabbrowser-tabs"
+                  contentcontextmenu="contentAreaContextMenu"
+                  autocompletepopup="PopupAutoComplete"
+                  selectpopup="ContentSelectDropdown"/>
+      <chatbar id="pinnedchats" layer="true" mousethrough="always" hidden="true"/>
+    </vbox>
+    <splitter id="social-sidebar-splitter"
+              class="chromeclass-extrachrome sidebar-splitter"
+              observes="socialSidebarBroadcaster"/>
+    <vbox id="social-sidebar-box"
+          class="chromeclass-extrachrome"
+          observes="socialSidebarBroadcaster"
+          persist="width">
+      <browser id="social-sidebar-browser"
+               type="content"
+               context="contentAreaContextMenu"
+               disableglobalhistory="true"
+               tooltip="aHTMLTooltip"
                popupnotificationanchor="social-notification-icon"
-                 flex="1"
-                 style="min-width: 14em; width: 18em; max-width: 36em;"/>
-      </vbox>
-      <vbox id="browser-border-end" hidden="true" layer="true"/>
-    </hbox>
-#include ../../components/customizableui/content/customizeMode.inc.xul
-  </deck>
+               flex="1"
+               style="min-width: 14em; width: 18em; max-width: 36em;"/>
+    </vbox>
+    <vbox id="browser-border-end" hidden="true" layer="true"/>
+  </hbox>
 
   <hbox id="full-screen-warning-container" hidden="true" fadeout="true">
     <hbox style="width: 100%;" pack="center"> <!-- Inner hbox needed due to bug 579776. -->
       <vbox id="full-screen-warning-message" align="center">
         <description id="full-screen-domain-text"/>
         <description class="full-screen-description" value="&fullscreenExitHint2.value;"/>
         <vbox id="full-screen-approval-pane" align="center">
           <hbox>
@@ -1110,38 +1114,66 @@
                          tooltiptext="&devToolbarToolsButton.tooltip;"/>
 #ifndef XP_MACOSX
           <toolbarbutton id="developer-toolbar-closebutton"
                          class="devtools-closebutton"
                          oncommand="DeveloperToolbar.hide();"
                          tooltiptext="&devToolbarCloseButton.tooltiptext;"/>
 #endif
    </toolbar>
+
+    <toolbar id="addon-bar"
+             toolbarname="&addonBarCmd.label;" accesskey="&addonBarCmd.accesskey;"
+             collapsed="true"
+             class="toolbar-primary chromeclass-toolbar"
+             context="toolbar-context-menu" toolboxid="navigator-toolbox"
+             mode="icons" iconsize="small" defaulticonsize="small"
+             lockiconsize="true"
+             defaultset="addonbar-closebutton,spring,status-bar"
+             customizable="true"
+             key="key_toggleAddonBar">
+      <toolbarbutton id="addonbar-closebutton"
+                     tooltiptext="&addonBarCloseButton.tooltip;"
+                     oncommand="setToolbarVisibility(this.parentNode, false);"/>
+      <statusbar id="status-bar" ordinal="1000"/>
+    </toolbar>
   </vbox>
 
+#ifndef XP_UNIX
   <svg:svg height="0">
-#include tab-shape.inc.svg
-
-#ifndef XP_UNIX
     <svg:clipPath id="windows-keyhole-forward-clip-path" clipPathUnits="objectBoundingBox">
       <svg:path d="M 0,0 C 0.16,0.11 0.28,0.29 0.28,0.5 0.28,0.71 0.16,0.89 0,1 L 1,1 1,0 0,0 z"/>
     </svg:clipPath>
     <svg:clipPath id="windows-urlbar-back-button-clip-path" clipPathUnits="userSpaceOnUse">
-      <svg:path d="m 0,-5 l 0,7.8 c 2.5,3.2 4,6.2 4,10.2 c 0,4 -1.5,7 -4,10 l 0,22l10000,0 l 0,-50 l -10000,0 z"/>
+      <svg:path d="M 0,0 0,7.8 C 2.5,11 4,14 4,18 4,22 2.5,25 0,28 l 0,22 10000,0 0,-50 L 0,0 z"/>
     </svg:clipPath>
+  </svg:svg>
 #endif
 #ifdef XP_MACOSX
+  <svg:svg height="0">
     <svg:clipPath id="osx-keyhole-forward-clip-path" clipPathUnits="objectBoundingBox">
       <svg:path d="M 0,0 C 0.15,0.12 0.25,0.3 0.25,0.5 0.25,0.7 0.15,0.88 0,1 L 1,1 1,0 0,0 z"/>
     </svg:clipPath>
     <svg:clipPath id="osx-urlbar-back-button-clip-path" clipPathUnits="userSpaceOnUse">
-      <svg:path d="m -3,-10 l -0.1,7.7 c 6.6,1.8 8.8,7.6 8.8,12.5 c 0,5 -1.9,11.5 -8.25,13.25 l 0.05,25.75 l 10000,0 l 0,-55 l -10000,-4.2 z"/>
+      <svg:path d="m 0,-5 0,4.03 C 3.6,1.8 6,6.1 6,11 6,16 3.6,20 0,23 l 0,27 10000,0 0,-55 L 0,-5 z"/>
+    </svg:clipPath>
+    <svg:clipPath id="osx-tab-ontop-left-curve-clip-path" clipPathUnits="userSpaceOnUse">
+      <svg:path d="M 9,0 C 7.3,0 6,1.3 6,3 l 0,14 c 0,3 -2.2,5 -5,5 l -1,0 0,1 12,0 0,-1 0,-19 0,-3 -3,0 z"/>
+    </svg:clipPath>
+    <svg:clipPath id="osx-tab-ontop-right-curve-clip-path" clipPathUnits="userSpaceOnUse">
+      <svg:path d="m 0,0 0,3 0,19 0,1 12,0 0,-1 -1,0 C 8.2,22 6,20 6,17 L 6,3 C 6,1.3 4.7,0 3,0 L 0,0 z"/>
     </svg:clipPath>
+    <svg:clipPath id="osx-tab-onbottom-left-curve-clip-path" clipPathUnits="userSpaceOnUse">
+      <svg:path d="m 0,0 0,1 1,0 c 2.8,0 5,2.2 5,5 l 0,14 c 0,2 1.3,3 3,3 l 3,0 0,-3 L 12,1 12,0 0,0 z"/>
+    </svg:clipPath>
+    <svg:clipPath id="osx-tab-onbottom-right-curve-clip-path" clipPathUnits="userSpaceOnUse">
+      <svg:path d="m 0,0 0,1 0,19 0,3 3,0 c 1.7,0 3,-1 3,-3 L 6,6 C 6,3.2 8.2,1 11,1 L 12,1 12,0 0,0 z"/>
+    </svg:clipPath>
+  </svg:svg>
 #endif
-  </svg:svg>
 
 </vbox>
 # <iframe id="tab-view"> is dynamically appended as the 2nd child of #tab-view-deck.
 #     Introducing the iframe dynamically, as needed, was found to be better than
 #     starting with an empty iframe here in browser.xul from a Ts standpoint.
 </deck>
 
 </window>
--- a/browser/base/content/global-scripts.inc
+++ b/browser/base/content/global-scripts.inc
@@ -4,11 +4,10 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 <script type="application/javascript" src="chrome://global/content/printUtils.js"/>
 <script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/>
 <script type="application/javascript" src="chrome://browser/content/places/browserPlacesViews.js"/>
 <script type="application/javascript" src="chrome://browser/content/browser.js"/>
 <script type="application/javascript" src="chrome://browser/content/downloads/downloads.js"/>
 <script type="application/javascript" src="chrome://browser/content/downloads/indicator.js"/>
-<script type="application/javascript" src="chrome://browser/content/customizableui/panelUI.js"/>
 <script type="application/javascript" src="chrome://global/content/inlineSpellCheckUI.js"/>
 <script type="application/javascript" src="chrome://global/content/viewSourceUtils.js"/>
--- a/browser/base/content/newtab/newTab.xul
+++ b/browser/base/content/newtab/newTab.xul
@@ -26,17 +26,16 @@
                      value="&newtab.undo.removedLabel;" />
           <xul:button id="newtab-undo-button" tabindex="-1"
                       label="&newtab.undo.undoButton;"
                       class="newtab-undo-button" />
           <xul:button id="newtab-undo-restore-button" tabindex="-1"
                       label="&newtab.undo.restoreButton;"
                       class="newtab-undo-button" />
           <xul:toolbarbutton id="newtab-undo-close-button" tabindex="-1"
-                             class="close-icon"
                              tooltiptext="&newtab.undo.closeTooltip;" />
         </div>
       </div>
 
       <div id="newtab-horizontal-margin">
         <div class="newtab-side-margin"/>
 
         <div id="newtab-grid">
--- a/browser/base/content/sync/notification.xml
+++ b/browser/base/content/sync/notification.xml
@@ -78,17 +78,17 @@
 
     </implementation>
   </binding>
 
   <binding id="notification" extends="chrome://global/content/bindings/notification.xml#notification">
     <content>
       <xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type">
         <xul:toolbarbutton ondblclick="event.stopPropagation();"
-                           class="messageCloseButton close-icon tabbable"
+                           class="messageCloseButton tabbable"
                            xbl:inherits="hidden=hideclose"
                            tooltiptext="&closeNotification.tooltip;"
                            oncommand="document.getBindingParent(this).close()"/>
         <xul:hbox anonid="details" align="center" flex="1">
           <xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image"/>
           <xul:description anonid="messageText" class="messageText" xbl:inherits="xbl:text=label"/>
 
           <!-- The children are the buttons defined by the notification. -->
deleted file mode 100644
--- a/browser/base/content/tab-shape.inc.svg
+++ /dev/null
@@ -1,11 +0,0 @@
-<!-- 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/. -->
-
-<svg:clipPath id="tab-curve-clip-path-start" clipPathUnits="objectBoundingBox">
-  <svg:path d="m 1,0.0625 0.05,0 0,0.938 -1,0 0,-0.028 C 0.32082458,0.95840561 0.4353096,0.81970962 0.48499998,0.5625 0.51819998,0.3905 0.535,0.0659 1,0.0625 z"/>
-</svg:clipPath>
-
-<svg:clipPath id="tab-curve-clip-path-end" clipPathUnits="objectBoundingBox">
-  <svg:path d="m 0,0.0625 -0.05,0 0,0.938 1,0 0,-0.028 C 0.67917542,0.95840561 0.56569036,0.81970962 0.51599998,0.5625 0.48279998,0.3905 0.465,0.0659 0,0.0625 z"/>
-</svg:clipPath>
--- a/browser/base/content/tabbrowser.css
+++ b/browser/base/content/tabbrowser.css
@@ -36,17 +36,16 @@ tabpanels {
   background-color: transparent;
 }
 
 .tab-drop-indicator {
   position: relative;
   z-index: 2;
 }
 
-.tab-icon-image:not([src]):not([pinned]),
 .tab-throbber:not([busy]),
 .tab-throbber[busy] + .tab-icon-image {
   display: none;
 }
 
 .closing-tabs-spacer {
   pointer-events: none;
 }
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -203,17 +203,18 @@
         ]]></body>
       </method>
 
       <method name="updateWindowResizers">
         <body><![CDATA[
           if (!window.gShowPageResizers)
             return;
 
-          var show = window.windowState == window.STATE_NORMAL;
+          var show = document.getElementById("addon-bar").collapsed &&
+                     window.windowState == window.STATE_NORMAL;
           for (let i = 0; i < this.browsers.length; i++) {
             this.browsers[i].showWindowResizer = show;
           }
         ]]></body>
       </method>
 
       <method name="_setCloseKeyState">
         <parameter name="aEnabled"/>
@@ -1000,17 +1001,17 @@
 
             newBrowser.setAttribute("type", "content-primary");
             newBrowser.docShellIsActive =
               (window.windowState != window.STATE_MINIMIZED);
             this.mCurrentBrowser = newBrowser;
             this.mCurrentTab = this.tabContainer.selectedItem;
             this.showTab(this.mCurrentTab);
 
-            var backForwardContainer = document.getElementById("urlbar-container");
+            var backForwardContainer = document.getElementById("unified-back-forward-button");
             if (backForwardContainer) {
               backForwardContainer.setAttribute("switchingtabs", "true");
               window.addEventListener("MozAfterPaint", function removeSwitchingtabsAttr() {
                 window.removeEventListener("MozAfterPaint", removeSwitchingtabsAttr);
                 backForwardContainer.removeAttribute("switchingtabs");
               });
             }
 
@@ -1491,17 +1492,18 @@
             b.setAttribute("type", "content-targetable");
             b.setAttribute("message", "true");
             b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu"));
             b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
 
             if (remote)
               b.setAttribute("remote", "true");
 
-            if (window.gShowPageResizers && window.windowState == window.STATE_NORMAL) {
+            if (window.gShowPageResizers && document.getElementById("addon-bar").collapsed &&
+                window.windowState == window.STATE_NORMAL) {
               b.setAttribute("showresizer", "true");
             }
 
             if (this.hasAttribute("autocompletepopup"))
               b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
 
             if (this.hasAttribute("selectpopup"))
               b.setAttribute("selectpopup", this.getAttribute("selectpopup"));
@@ -1923,21 +1925,16 @@
                 return null;
 
               newTab = true;
             }
 
             aTab.closing = true;
             this._removingTabs.push(aTab);
             this._visibleTabs = null; // invalidate cache
-
-            // Invalidate hovered tab state tracking for this closing tab.
-            if (this.tabContainer._hoveredTab == aTab)
-              aTab._mouseleave();
-
             if (newTab)
               this.addTab(BROWSER_NEW_TAB_URL, {skipAnimation: true});
             else
               this.tabContainer.updateVisibility();
 
             // We're committed to closing the tab now.
             // Dispatch a notification.
             // We dispatch it before any teardown so that event listeners can
@@ -3246,38 +3243,16 @@
         ]]></body>
       </method>
       <method name="_canScrollToElement">
         <parameter name="tab"/>
         <body><![CDATA[
           return !tab.pinned && !tab.hidden;
         ]]></body>
       </method>
-      <field name="_tabMarginLeft">null</field>
-      <field name="_tabMarginRight">null</field>
-      <method name="_adjustElementStartAndEnd">
-        <parameter name="aTab"/>
-        <parameter name="tabStart"/>
-        <parameter name="tabEnd"/>
-        <body><![CDATA[
-          if (this._tabMarginLeft === null || this._tabMarginRight === null) {
-            let tabMiddle = document.getAnonymousElementByAttribute(aTab, "class", "tab-background-middle");
-            let tabMiddleStyle = window.getComputedStyle(tabMiddle, null);
-            this._tabMarginLeft = parseFloat(tabMiddleStyle.marginLeft);
-            this._tabMarginRight = parseFloat(tabMiddleStyle.marginRight);
-          }
-          if (this._tabMarginLeft < 0) {
-            tabStart = tabStart + this._tabMarginLeft;
-          }
-          if (this._tabMarginRight < 0) {
-            tabEnd = tabEnd - this._tabMarginRight;
-          }
-          return [tabStart, tabEnd];
-        ]]></body>
-      </method>
     </implementation>
 
     <handlers>
       <handler event="underflow" phase="capturing"><![CDATA[
         if (event.detail == 0)
           return; // Ignore vertical events
 
         var tabs = document.getBindingParent(this);
@@ -3289,21 +3264,18 @@
         tabs.tabbrowser._removingTabs.forEach(tabs.tabbrowser.removeTab,
                                               tabs.tabbrowser);
 
         tabs._positionPinnedTabs();
       ]]></handler>
       <handler event="overflow"><![CDATA[
         if (event.detail == 0)
           return; // Ignore vertical events
+
         var tabs = document.getBindingParent(this);
-        var numberOfTabs = tabs.tabbrowser.visibleTabs.length;
-        if (numberOfTabs == 1)
-          return;
-
         tabs.setAttribute("overflow", "true");
         tabs._positionPinnedTabs();
         tabs._handleTabSelect(false);
       ]]></handler>
     </handlers>
   </binding>
 
   <binding id="tabbrowser-tabs"
@@ -3389,25 +3361,16 @@
         document.getAnonymousElementByAttribute(this, "anonid", "arrowscrollbox");
       </field>
 
       <field name="_firstTab">null</field>
       <field name="_lastTab">null</field>
       <field name="_afterSelectedTab">null</field>
       <field name="_beforeHoveredTab">null</field>
       <field name="_afterHoveredTab">null</field>
-      <field name="_hoveredTab">null</field>
-
-      <property name="_isCustomizing" readonly="true">
-        <getter>
-          let root = document.documentElement;
-          return root.getAttribute("customizing") == "true" ||
-                 root.getAttribute("customize-exiting") == "true";
-        </getter>
-      </property>
 
       <method name="_setPositionalAttributes">
         <body><![CDATA[
           let visibleTabs = this.tabbrowser.visibleTabs;
 
           if (!visibleTabs.length)
             return;
 
@@ -3428,22 +3391,16 @@
           if (this._firstTab)
             this._firstTab.removeAttribute("first-visible-tab");
           this._firstTab = visibleTabs[0];
           this._firstTab.setAttribute("first-visible-tab", "true");
           if (this._lastTab)
             this._lastTab.removeAttribute("last-visible-tab");
           this._lastTab = visibleTabs[lastVisible];
           this._lastTab.setAttribute("last-visible-tab", "true");
-
-          let hoveredTab = this._hoveredTab;
-          if (hoveredTab) {
-            hoveredTab._mouseleave();
-            hoveredTab._mouseenter();
-          }
         ]]></body>
       </method>
 
       <field name="_prefObserver"><![CDATA[({
         tabContainer: this,
 
         observe: function (subject, topic, data) {
           switch (data) {
@@ -3512,16 +3469,20 @@
       <method name="_propagateVisibility">
         <body><![CDATA[
           let visible = this.visible;
 
           document.getElementById("menu_closeWindow").hidden = !visible;
           document.getElementById("menu_close").setAttribute("label",
             this.tabbrowser.mStringBundle.getString(visible ? "tabs.closeTab" : "tabs.close"));
 
+          goSetCommandEnabled("cmd_ToggleTabsOnTop", visible);
+
+          TabsOnTop.syncUI();
+
           TabsInTitlebar.allowedBy("tabs-visible", visible);
         ]]></body>
       </method>
 
       <method name="updateVisibility">
         <body><![CDATA[
           if (this.childNodes.length - this.tabbrowser._removingTabs.length == 1)
             this.visible = window.toolbar.visible;
@@ -3863,26 +3824,26 @@
           switch (aEvent.type) {
             case "load":
               this.updateVisibility();
               break;
             case "resize":
               if (aEvent.target != window)
                 break;
 
-              TabsInTitlebar.updateAppearance();
-
-              if (this.tabbrowser.visibleTabs.length > 1) {
-                var width = this.mTabstrip.boxObject.width;
-                if (width != this.mTabstripWidth) {
-                  this.adjustTabstrip();
-                  this._fillTrailingGap();
-                  this._handleTabSelect();
-                  this.mTabstripWidth = width;
-                }
+              let sizemode = document.documentElement.getAttribute("sizemode");
+              TabsInTitlebar.allowedBy("sizemode",
+                                       sizemode == "maximized" || sizemode == "fullscreen");
+
+              var width = this.mTabstrip.boxObject.width;
+              if (width != this.mTabstripWidth) {
+                this.adjustTabstrip();
+                this._fillTrailingGap();
+                this._handleTabSelect();
+                this.mTabstripWidth = width;
               }
 
               this.tabbrowser.updateWindowResizers();
               break;
             case "mouseout":
               // If the "related target" (the node to which the pointer went) is not
               // a child of the current document, the mouse just left the window.
               let relatedTarget = aEvent.relatedTarget;
@@ -4154,17 +4115,18 @@
         }
       ]]></handler>
 
       <handler event="dblclick"><![CDATA[
 #ifndef XP_MACOSX
         // When the tabbar has an unified appearance with the titlebar
         // and menubar, a double-click in it should have the same behavior
         // as double-clicking the titlebar
-        if (TabsInTitlebar.enabled || this.parentNode._dragBindingAlive)
+        if (TabsInTitlebar.enabled ||
+            (TabsOnTop.enabled && this.parentNode._dragBindingAlive))
           return;
 #endif
 
         if (event.button != 0 ||
             event.originalTarget.localName != "box")
           return;
 
         // See hack note in the tabbrowser-close-tab-button binding
@@ -4277,17 +4239,17 @@
             return;
         }
         event.stopPropagation();
         event.preventDefault();
       ]]></handler>
 
       <handler event="dragstart"><![CDATA[
         var tab = this._getDragTargetTab(event);
-        if (!tab || this._isCustomizing)
+        if (!tab)
           return;
 
         let dt = event.dataTransfer;
         dt.mozSetDataAt(TAB_DROP_TYPE, tab, 0);
         let browser = tab.linkedBrowser;
 
         // We must not set text/x-moz-url or text/plain data here,
         // otherwise trying to deatch the tab by dropping it on the desktop
@@ -4521,17 +4483,17 @@
         // Note: while this case is correctly handled here, this event
         // isn't dispatched when the tab is moved within the tabstrip,
         // see bug 460801.
 
         this._finishAnimateTabMove();
 
         var dt = event.dataTransfer;
         var draggedTab = dt.mozGetDataAt(TAB_DROP_TYPE, 0);
-        if (dt.mozUserCancelled || dt.dropEffect != "none" || this._isCustomizing) {
+        if (dt.mozUserCancelled || dt.dropEffect != "none") {
           delete draggedTab._dragData;
           return;
         }
 
         // Disable detach within the browser toolbox
         var eX = event.screenX;
         var eY = event.screenY;
         var wX = window.screenX;
@@ -4628,17 +4590,17 @@
   <binding id="tabbrowser-tab" display="xul:hbox"
            extends="chrome://global/content/bindings/tabbox.xml#tab">
     <resources>
       <stylesheet src="chrome://browser/content/tabbrowser.css"/>
     </resources>
 
     <content context="tabContextMenu" closetabtext="&closeTab.label;">
       <xul:stack class="tab-stack" flex="1">
-        <xul:hbox xbl:inherits="pinned,selected,titlechanged,fadein"
+        <xul:hbox xbl:inherits="pinned,selected,titlechanged"
                   class="tab-background">
           <xul:hbox xbl:inherits="pinned,selected,titlechanged"
                     class="tab-background-start"/>
           <xul:hbox xbl:inherits="pinned,selected,titlechanged"
                     class="tab-background-middle"/>
           <xul:hbox xbl:inherits="pinned,selected,titlechanged"
                     class="tab-background-end"/>
         </xul:hbox>
@@ -4654,17 +4616,17 @@
                      role="presentation"/>
           <xul:label flex="1"
                      anonid="tab-label"
                      xbl:inherits="value=visibleLabel,crop,accesskey,fadein,pinned,selected"
                      class="tab-text tab-label"
                      role="presentation"/>
           <xul:toolbarbutton anonid="close-button"
                              xbl:inherits="fadein,pinned,selected"
-                             class="tab-close-button close-icon"/>
+                             class="tab-close-button"/>
         </xul:hbox>
       </xul:stack>
     </content>
 
     <implementation>
       <property name="label">
         <getter>
           return this.getAttribute("label");
@@ -4701,80 +4663,65 @@
           return this.getAttribute("hidden") == "true";
         </getter>
       </property>
 
       <field name="mOverCloseButton">false</field>
       <field name="mCorrespondingMenuitem">null</field>
       <field name="closing">false</field>
       <field name="lastAccessed">0</field>
-
-      <method name="_mouseenter">
-        <body><![CDATA[
-          if (this.closing)
-            return;
-
-          let tabContainer = this.parentNode;
-          let visibleTabs = tabContainer.tabbrowser.visibleTabs;
-          let tabIndex = visibleTabs.indexOf(this);
-          if (tabIndex == 0) {
-            tabContainer._beforeHoveredTab = null;
-          } else {
-            let candidate = visibleTabs[tabIndex - 1];
-            if (!candidate.selected) {
-              tabContainer._beforeHoveredTab = candidate;
-              candidate.setAttribute("beforehovered", "true");
-            }
-          }
-
-          if (tabIndex == visibleTabs.length - 1) {
-            tabContainer._afterHoveredTab = null;
-          } else {
-            let candidate = visibleTabs[tabIndex + 1];
-            if (!candidate.selected) {
-              tabContainer._afterHoveredTab = candidate;
-              candidate.setAttribute("afterhovered", "true");
-            }
-          }
-
-          tabContainer._hoveredTab = this;
-        ]]></body>
-      </method>
-
-      <method name="_mouseleave">
-        <body><![CDATA[
-          let tabContainer = this.parentNode;
-          if (tabContainer._beforeHoveredTab) {
-            tabContainer._beforeHoveredTab.removeAttribute("beforehovered");
-            tabContainer._beforeHoveredTab = null;
-          }
-          if (tabContainer._afterHoveredTab) {
-            tabContainer._afterHoveredTab.removeAttribute("afterhovered");
-            tabContainer._afterHoveredTab = null;
-          }
-
-          tabContainer._hoveredTab = null;
-        ]]></body>
-      </method>
     </implementation>
 
     <handlers>
       <handler event="mouseover"><![CDATA[
         let anonid = event.originalTarget.getAttribute("anonid");
         if (anonid == "close-button")
           this.mOverCloseButton = true;
 
-        this._mouseenter();
+        let tab = event.target;
+        if (tab.closing)
+          return;
+
+        let tabContainer = this.parentNode;
+        let visibleTabs = tabContainer.tabbrowser.visibleTabs;
+        let tabIndex = visibleTabs.indexOf(tab);
+        if (tabIndex == 0) {
+          tabContainer._beforeHoveredTab = null;
+        } else {
+          let candidate = visibleTabs[tabIndex - 1];
+          if (!candidate.selected) {
+            tabContainer._beforeHoveredTab = candidate;
+            candidate.setAttribute("beforehovered", "true");
+          }
+        }
+
+        if (tabIndex == visibleTabs.length - 1) {
+          tabContainer._afterHoveredTab = null;
+        } else {
+          let candidate = visibleTabs[tabIndex + 1];
+          if (!candidate.selected) {
+            tabContainer._afterHoveredTab = candidate;
+            candidate.setAttribute("afterhovered", "true");
+          }
+        }
       ]]></handler>
       <handler event="mouseout"><![CDATA[
         let anonid = event.originalTarget.getAttribute("anonid");
         if (anonid == "close-button")
           this.mOverCloseButton = false;
 
-        this._mouseleave();
+        let tabContainer = this.parentNode;
+        if (tabContainer._beforeHoveredTab) {
+          tabContainer._beforeHoveredTab.removeAttribute("beforehovered");
+          tabContainer._beforeHoveredTab = null;
+        }
+        if (tabContainer._afterHoveredTab) {
+          tabContainer._afterHoveredTab.removeAttribute("afterhovered");
+          tabContainer._afterHoveredTab = null;
+        }
       ]]></handler>
       <handler event="dragstart" phase="capturing">
         this.style.MozUserFocus = '';
       </handler>
       <handler event="mousedown" phase="capturing">
       <![CDATA[
         if (this.selected) {
           this.style.MozUserFocus = 'ignore';
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -19,16 +19,17 @@ support-files =
   bug564387.html
   bug564387_video1.ogv
   bug564387_video1.ogv^headers^
   bug592338.html
   bug792517-2.html
   bug792517.html
   bug792517.sjs
   bug839103.css
+  disablechrome.html
   discovery.html
   domplate_test.js
   download_page.html
   dummy_page.html
   feed_tab.html
   file_bug550565_favicon.ico
   file_bug550565_popup.html
   file_bug822367_1.html
@@ -108,16 +109,19 @@ run-if = crashreporter
 [browser_CTP_nonplugins.js]
 [browser_CTP_resize.js]
 [browser_URLBarSetURI.js]
 [browser_aboutHealthReport.js]
 skip-if = os == "linux" # Bug 924307
 [browser_aboutHome.js]
 [browser_aboutSyncProgress.js]
 [browser_addKeywordSearch.js]
+[browser_addon_bar_aomlistener.js]
+[browser_addon_bar_close_button.js]
+[browser_addon_bar_shortcut.js]
 [browser_alltabslistener.js]
 [browser_backButtonFitts.js]
 skip-if = os != "win" # The Fitts Law back button is only supported on Windows (bug 571454)
 [browser_blob-channelname.js]
 [browser_bookmark_titles.js]
 skip-if = toolkit == "windows" # Disabled on Windows due to frequent failures (bugs 825739, 841341)
 [browser_bug304198.js]
 [browser_bug321000.js]
@@ -189,17 +193,20 @@ run-if = toolkit == "cocoa"
 [browser_bug585785.js]
 [browser_bug585830.js]
 [browser_bug590206.js]
 [browser_bug592338.js]
 [browser_bug594131.js]
 [browser_bug595507.js]
 [browser_bug596687.js]
 [browser_bug597218.js]
+[browser_bug598923.js]
+[browser_bug599325.js]
 [browser_bug609700.js]
+[browser_bug616836.js]
 [browser_bug623155.js]
 [browser_bug623893.js]
 [browser_bug624734.js]
 [browser_bug647886.js]
 [browser_bug655584.js]
 [browser_bug664672.js]
 [browser_bug676619.js]
 [browser_bug678392.js]
@@ -232,19 +239,21 @@ run-if = toolkit == "cocoa"
 [browser_bug896291_closeMaxSessionStoreTabs.js]
 [browser_bug902156.js]
 [browser_bug906190.js]
 [browser_canonizeURL.js]
 [browser_clearplugindata.js]
 [browser_contentAreaClick.js]
 [browser_contextSearchTabPosition.js]
 [browser_ctrlTab.js]
+[browser_customize.js]
 [browser_customize_popupNotification.js]
 [browser_datareporting_notification.js]
 run-if = datareporting
+[browser_disablechrome.js]
 [browser_discovery.js]
 [browser_duplicateIDs.js]
 [browser_drag.js]
 skip-if = true # browser_drag.js is disabled, as it needs to be updated for the new behavior from bug 320638.
 [browser_findbarClose.js]
 [browser_fullscreen-window-open.js]
 [browser_gestureSupport.js]
 [browser_getshortcutoruri.js]
@@ -295,18 +304,17 @@ skip-if = true  # disabled until the tre
 [browser_save_video.js]
 [browser_scope.js]
 [browser_selectTabAtIndex.js]
 [browser_tabDrop.js]
 [browser_tabMatchesInAwesomebar_perwindowpb.js]
 [browser_tab_drag_drop_perwindow.js]
 [browser_tab_dragdrop.js]
 [browser_tab_dragdrop2.js]
-[browser_tabbar_big_widgets.js]
-skip-if = os == "linux" # No tabs in titlebar on linux
+[browser_tab_dragdrop2_frame1.xul]
 [browser_tabfocus.js]
 [browser_tabopen_reflows.js]
 [browser_tabs_isActive.js]
 [browser_tabs_owner.js]
 [browser_typeAheadFind.js]
 [browser_unloaddialogs.js]
 [browser_urlHighlight.js]
 [browser_urlbarAutoFillTrimURLs.js]
@@ -319,13 +327,12 @@ skip-if = os == "linux" # No tabs in tit
 [browser_utilityOverlay.js]
 [browser_visibleFindSelection.js]
 [browser_visibleLabel.js]
 [browser_visibleTabs.js]
 [browser_visibleTabs_bookmarkAllPages.js]
 [browser_visibleTabs_bookmarkAllTabs.js]
 [browser_visibleTabs_contextMenu.js]
 [browser_visibleTabs_tabPreview.js]
-[browser_windowopen_reflows.js]
 [browser_wyciwyg_urlbarCopying.js]
 [browser_zbug569342.js]
 [browser_registerProtocolHandler_notification.js]
 [browser_no_mcb_on_http_site.js]
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_addon_bar.js
@@ -0,0 +1,63 @@
+/* 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/. */
+
+function test() {
+  waitForExplicitFinish();
+
+  let addonbar = document.getElementById("addon-bar");
+  ok(addonbar.collapsed, "addon bar is collapsed by default");
+
+  let topMenu, toolbarMenu;
+
+  function onTopMenuShown(event) {
+    ok(1, "top menu popupshown listener called");
+    event.currentTarget.removeEventListener("popupshown", arguments.callee, false);
+    // open the customize or toolbars menu
+    toolbarMenu = document.getElementById("appmenu_customizeMenu") ||
+                      document.getElementById("viewToolbarsMenu").firstElementChild;
+    toolbarMenu.addEventListener("popupshown", onToolbarMenuShown, false);
+    toolbarMenu.addEventListener("popuphidden", onToolbarMenuHidden, false);
+    toolbarMenu.openPopup();
+  }
+
+  function onTopMenuHidden(event) {
+    ok(1, "top menu popuphidden listener called");
+    event.currentTarget.removeEventListener("popuphidden", arguments.callee, false);
+    finish();
+  }
+
+  function onToolbarMenuShown(event) {
+    ok(1, "sub menu popupshown listener called");
+    event.currentTarget.removeEventListener("popupshown", arguments.callee, false);
+
+    // test the menu item's default state
+    let menuitem = document.getElementById("toggle_addon-bar");
+    ok(menuitem, "found the menu item");
+    is(menuitem.getAttribute("checked"), "false", "menuitem is not checked by default");
+
+    // click on the menu item
+    // TODO: there's got to be a way to check+command in one shot
+    menuitem.setAttribute("checked", "true");
+    menuitem.click();
+
+    // now the addon bar should be visible and the menu checked
+    is(addonbar.getAttribute("collapsed"), "false", "addon bar is visible after executing the command");
+    is(menuitem.getAttribute("checked"), "true", "menuitem is checked after executing the command");
+
+    toolbarMenu.hidePopup();
+  }
+
+  function onToolbarMenuHidden(event) {
+    ok(1, "toolbar menu popuphidden listener called");
+    event.currentTarget.removeEventListener("popuphidden", arguments.callee, false);
+    topMenu.hidePopup();
+  }
+
+  // open the appmenu or view menu
+  topMenu = document.getElementById("appmenu-popup") ||
+            document.getElementById("menu_viewPopup");
+  topMenu.addEventListener("popupshown", onTopMenuShown, false);
+  topMenu.addEventListener("popuphidden", onTopMenuHidden, false);
+  topMenu.openPopup();
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_addon_bar_aomlistener.js
@@ -0,0 +1,67 @@
+/* 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/. */
+
+function test() {
+
+  let addonbar = document.getElementById("addon-bar");
+  ok(addonbar.collapsed, "addon bar is collapsed by default");
+
+  function addItem(id) {
+    let button = document.createElement("toolbarbutton");
+    button.id = id;
+    let palette = document.getElementById("navigator-toolbox").palette;
+    palette.appendChild(button);
+    addonbar.insertItem(id, null, null, false);
+  }
+
+  // call onInstalling
+  AddonsMgrListener.onInstalling();
+
+  // add item to the bar
+  let id = "testbutton";
+  addItem(id);
+
+  // call onInstalled
+  AddonsMgrListener.onInstalled();
+
+  // confirm bar is visible
+  ok(!addonbar.collapsed, "addon bar is not collapsed after toggle");
+
+  // call onUninstalling
+  AddonsMgrListener.onUninstalling();
+
+  // remove item from the bar
+  addonbar.currentSet = addonbar.currentSet.replace("," + id, "");
+
+  // call onUninstalled
+  AddonsMgrListener.onUninstalled();
+
+  // confirm bar is not visible
+  ok(addonbar.collapsed, "addon bar is collapsed after toggle");
+
+  // call onEnabling
+  AddonsMgrListener.onEnabling();
+
+  // add item to the bar
+  let id = "testbutton";
+  addItem(id);
+
+  // call onEnabled
+  AddonsMgrListener.onEnabled();
+
+  // confirm bar is visible
+  ok(!addonbar.collapsed, "addon bar is not collapsed after toggle");
+
+  // call onDisabling
+  AddonsMgrListener.onDisabling();
+
+  // remove item from the bar
+  addonbar.currentSet = addonbar.currentSet.replace("," + id, "");
+
+  // call onDisabled
+  AddonsMgrListener.onDisabled();
+
+  // confirm bar is not visible
+  ok(addonbar.collapsed, "addon bar is collapsed after toggle");
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_addon_bar_close_button.js
@@ -0,0 +1,19 @@
+/* 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/. */
+
+function test() {
+  let addonbar = document.getElementById("addon-bar");
+  ok(addonbar.collapsed, "addon bar is collapsed by default");
+
+  // make add-on bar visible
+  setToolbarVisibility(addonbar, true);
+  ok(!addonbar.collapsed, "addon bar is not collapsed after toggle");
+
+  // click the close button
+  let closeButton = document.getElementById("addonbar-closebutton");
+  EventUtils.synthesizeMouseAtCenter(closeButton, {});
+
+  // confirm addon bar is closed
+  ok(addonbar.collapsed, "addon bar is collapsed after clicking close button");
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_addon_bar_shortcut.js
@@ -0,0 +1,18 @@
+/* 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/. */
+
+function test() {
+  let addonbar = document.getElementById("addon-bar");
+  ok(addonbar.collapsed, "addon bar is collapsed by default");
+
+  // show the add-on bar
+  EventUtils.synthesizeKey("/", { accelKey: true }, window);
+  ok(!addonbar.collapsed, "addon bar is not collapsed after toggle");
+
+  // hide the add-on bar
+  EventUtils.synthesizeKey("/", { accelKey: true }, window);
+
+  // confirm addon bar is closed
+  ok(addonbar.collapsed, "addon bar is collapsed after toggle");
+}
--- a/browser/base/content/test/general/browser_bug462289.js
+++ b/browser/base/content/test/general/browser_bug462289.js
@@ -29,19 +29,26 @@ function step2()
   setTimeout(step3, 0);
 }
 
 function step3()
 {
   is(gBrowser.selectedTab, tab1, "2nd click on selected tab1 keeps tab selected");
   isnot(document.activeElement, tab1, "2nd click on selected tab1 does not activate tab");
 
-  ok(true, "focusing URLBar then sending 1 Shift+Tab.");
-  gURLBar.focus();
-  EventUtils.synthesizeKey("VK_TAB", {shiftKey: true});
+  if (gNavToolbox.getAttribute("tabsontop") == "true") {
+    ok(true, "[tabsontop=true] focusing URLBar then sending 1 Shift+Tab.");
+    gURLBar.focus();
+    EventUtils.synthesizeKey("VK_TAB", {shiftKey: true});
+  } else {
+    ok(true, "[tabsontop=false] focusing SearchBar then sending Tab(s) until out of nav-bar.");
+    document.getElementById("searchbar").focus();
+    while (focus_in_navbar())
+      EventUtils.synthesizeKey("VK_TAB", { });
+  }
   is(gBrowser.selectedTab, tab1, "tab key to selected tab1 keeps tab selected");
   is(document.activeElement, tab1, "tab key to selected tab1 activates tab");
 
   EventUtils.synthesizeMouseAtCenter(tab1, {});
   setTimeout(step4, 0);
 }
 
 function step4()
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_bug598923.js
@@ -0,0 +1,33 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Test:
+// * if add-on is installed to the add-on bar, the bar is made visible.
+// * if add-on is uninstalled from the add-on bar, and no more add-ons there,
+//   the bar is hidden.
+
+function test() {
+  let aml = AddonsMgrListener;
+  ok(aml, "AddonsMgrListener exists");
+  // check is hidden
+  is(aml.addonBar.collapsed, true, "add-on bar is hidden initially");
+  // aob gets the count
+  AddonsMgrListener.onInstalling();
+  // add an item
+  let element = document.createElement("toolbaritem");
+  element.id = "bug598923-addon-item";
+  aml.addonBar.appendChild(element);
+  // aob checks the count, makes visible
+  AddonsMgrListener.onInstalled();
+  // check is visible
+  is(aml.addonBar.collapsed, false, "add-on bar has been made visible");
+  // aob gets the count
+  AddonsMgrListener.onUninstalling();
+  // remove an item
+  aml.addonBar.removeChild(element);
+  // aob checks the count, makes hidden
+  AddonsMgrListener.onUninstalled();
+  // check is hidden
+  is(aml.addonBar.collapsed, true, "add-on bar is hidden again");
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_bug599325.js
@@ -0,0 +1,21 @@
+function test() {
+  waitForExplicitFinish();
+
+  let addonBar = document.getElementById("addon-bar");
+  ok(addonBar, "got addon bar");
+  ok(!isElementVisible(addonBar), "addon bar initially hidden");
+
+  openToolbarCustomizationUI(function () {
+    ok(isElementVisible(addonBar),
+       "add-on bar is visible during toolbar customization");
+
+    closeToolbarCustomizationUI(onClose);
+  });
+
+  function onClose() {
+    ok(!isElementVisible(addonBar),
+       "addon bar is hidden after toolbar customization");
+
+    finish();
+  }
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_bug616836.js
@@ -0,0 +1,4 @@
+function test() {
+  is(document.querySelectorAll("#appmenu-popup [accesskey]").length, 0,
+     "there should be no items with access keys in the app menu popup");
+}
--- a/browser/base/content/test/general/browser_bug624734.js
+++ b/browser/base/content/test/general/browser_bug624734.js
@@ -1,31 +1,23 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 // Bug 624734 - Star UI has no tooltip until bookmarked page is visited
 
-function finishTest() {
-  is(BookmarkingUI.button.getAttribute("buttontooltiptext"),
-     BookmarkingUI._unstarredTooltip,
-     "Star icon should have the unstarred tooltip text");
-
-  gBrowser.removeCurrentTab();
-  finish();
-}
-
 function test() {
   waitForExplicitFinish();
 
   let tab = gBrowser.selectedTab = gBrowser.addTab();
   tab.linkedBrowser.addEventListener("load", (function(event) {
     tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
 
-    if (BookmarkingUI.status == BookmarkingUI.STATUS_UPDATING) {
-      waitForCondition(function() BookmarkingUI.status != BookmarkingUI.STATUS_UPDATING, finishTest, "BookmarkingUI was updating for too long");
-    } else {
-      finishTest();
-    }
+    is(BookmarkingUI.star.getAttribute("tooltiptext"),
+       BookmarkingUI._unstarredTooltip,
+       "Star icon should have the unstarred tooltip text");
+  
+    gBrowser.removeCurrentTab();
+    finish();
   }), true);
 
   tab.linkedBrowser.loadURI("http://example.com/browser/browser/base/content/test/general/dummy_page.html");
 }
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_customize.js
@@ -0,0 +1,24 @@
+function test() {
+  waitForExplicitFinish();
+
+  openToolbarCustomizationUI(customizationWindowLoaded);
+}
+
+function customizationWindowLoaded(win) {
+  let x = win.screenX;
+  let iconModeList = win.document.getElementById("modelist");
+
+  iconModeList.addEventListener("popupshown", function popupshown() {
+    iconModeList.removeEventListener("popupshown", popupshown, false);
+
+    executeSoon(function () {
+      is(win.screenX, x,
+         "toolbar customization window shouldn't move when the iconmode menulist is opened");
+      iconModeList.open = false;
+    
+      closeToolbarCustomizationUI(finish);
+    });
+  }, false);
+
+  iconModeList.open = true;
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_disablechrome.js
@@ -0,0 +1,216 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Tests that the disablechrome attribute gets propogated to the main UI
+
+const HTTPSRC = "http://example.com/browser/browser/base/content/test/general/";
+
+function is_element_hidden(aElement) {
+  var style = window.getComputedStyle(document.getElementById("nav-bar"), "");
+  if (style.visibility != "visible" || style.display == "none")
+    return true;
+
+  if (aElement.ownerDocument != aElement.parentNode)
+    return is_element_hidden(aElement.parentNode);
+
+  return false;
+}
+
+function is_chrome_hidden() {
+  is(document.documentElement.getAttribute("disablechrome"), "true", "Attribute should be set");
+  if (TabsOnTop.enabled)
+    ok(is_element_hidden(document.getElementById("nav-bar")), "Toolbar should be hidden");
+  else
+    ok(!is_element_hidden(document.getElementById("nav-bar")), "Toolbar should not be hidden");
+}
+
+function is_chrome_visible() {
+  isnot(document.getElementById("main-window").getAttribute("disablechrome"), "true", "Attribute should not be set");
+  ok(!is_element_hidden(document.getElementById("nav-bar")), "Toolbar should not be hidden");
+}
+
+function load_page(aURL, aCanHide, aCallback) {
+  gNewBrowser.addEventListener("pageshow", function() {
+    // Filter out about:blank loads
+    if (gNewBrowser.currentURI.spec != aURL)
+      return;
+
+    gNewBrowser.removeEventListener("pageshow", arguments.callee, false);
+
+    if (aCanHide)
+      is_chrome_hidden();
+    else
+      is_chrome_visible();
+
+    if (aURL == "about:addons") {
+      function check_after_init() {
+        if (aCanHide)
+          is_chrome_hidden();
+        else
+          is_chrome_visible();
+
+        aCallback();
+      }
+
+      if (gNewBrowser.contentWindow.gIsInitializing) {
+        gNewBrowser.contentDocument.addEventListener("Initialized", function() {
+          gNewBrowser.contentDocument.removeEventListener("Initialized", arguments.callee, false);
+
+          check_after_init();
+        }, false);
+      }
+      else {
+        check_after_init();
+      }
+    }
+    else {
+      executeSoon(aCallback);
+    }
+  }, false);
+  gNewBrowser.loadURI(aURL);
+}
+
+var gOldTab;
+var gNewTab;
+var gNewBrowser;
+
+function test() {
+  // Opening the add-ons manager and waiting for it to load the discovery pane
+  // takes more time in windows debug builds
+  requestLongerTimeout(2);
+
+  var gOldTabsOnTop = TabsOnTop.enabled;
+  registerCleanupFunction(function() {
+    TabsOnTop.enabled = gOldTabsOnTop;
+  });
+
+  waitForExplicitFinish();
+
+  gOldTab = gBrowser.selectedTab;
+  gNewTab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+  gNewBrowser = gBrowser.selectedBrowser;
+
+  info("Tabs on top");
+  TabsOnTop.enabled = true;
+
+  run_http_test_1();
+}
+
+function end_test() {
+  gBrowser.removeTab(gNewTab);
+  finish();
+}
+
+function test_url(aURL, aCanHide, aNextTest) {
+  is_chrome_visible();
+  info("Page load");
+  load_page(aURL, aCanHide, function() {
+    info("Switch away");
+    gBrowser.selectedTab = gOldTab;
+    is_chrome_visible();
+
+    info("Switch back");
+    gBrowser.selectedTab = gNewTab;
+    if (aCanHide)
+      is_chrome_hidden();
+    else
+      is_chrome_visible();
+
+    gBrowser.removeTab(gNewTab);
+    gNewTab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
+    gNewBrowser = gBrowser.selectedBrowser;
+
+    gBrowser.selectedTab = gOldTab;
+
+    info("Background load");
+    load_page(aURL, false, function() {
+      info("Switch back");
+      gBrowser.selectedTab = gNewTab;
+      if (aCanHide)
+        is_chrome_hidden();
+      else
+        is_chrome_visible();
+
+      load_page("about:blank", false, aNextTest);
+    });
+  });
+}
+
+// Should never hide the chrome
+function run_http_test_1() {
+  info("HTTP tests");
+  test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test);
+}
+
+// Should hide the chrome
+function run_chrome_about_test() {
+  info("Chrome about: tests");
+  test_url("about:addons", true, function() {
+    info("Tabs on bottom");
+    TabsOnTop.enabled = false;
+    run_http_test_2();
+  });
+}
+
+// Should never hide the chrome
+function run_http_test_2() {
+  info("HTTP tests");
+  test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test_2);
+}
+
+// Should not hide the chrome
+function run_chrome_about_test_2() {
+  info("Chrome about: tests");
+  test_url("about:addons", true, run_http_test3);
+}
+
+function run_http_test3() {
+  info("HTTP tests");
+  test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test_3);
+}
+
+// Should not hide the chrome
+function run_chrome_about_test_3() {
+  info("Chrome about: tests");
+  test_url("about:Addons", true, function(){
+    info("Tabs on top");
+    TabsOnTop.enabled = true;
+    run_http_test4();
+  });
+}
+
+function run_http_test4() {
+  info("HTTP tests");
+  test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test_4);
+}
+
+function run_chrome_about_test_4() {
+  info("Chrome about: tests");
+  test_url("about:Addons", true, run_http_test5);
+ }
+
+function run_http_test5() {
+  info("HTTP tests");
+  test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test_5);
+}
+
+// Should hide the chrome
+function run_chrome_about_test_5() {
+  info("Chrome about: tests");
+  test_url("about:preferences", true, function(){
+    info("Tabs on bottom");
+    TabsOnTop.enabled = false;
+    run_http_test6();
+  });
+}
+
+function run_http_test6() {
+  info("HTTP tests");
+  test_url(HTTPSRC + "disablechrome.html", false, run_chrome_about_test_6);
+}
+
+function run_chrome_about_test_6() {
+  info("Chrome about: tests");
+  test_url("about:preferences", true, end_test);
+}
\ No newline at end of file
--- a/browser/base/content/test/general/browser_overflowScroll.js
+++ b/browser/base/content/test/general/browser_overflowScroll.js
@@ -2,18 +2,18 @@ var tabstrip = gBrowser.tabContainer.mTa
 var scrollbox = tabstrip._scrollbox;
 var originalSmoothScroll = tabstrip.smoothScroll;
 var tabs = gBrowser.tabs;
 
 function rect(ele)           ele.getBoundingClientRect();
 function width(ele)          rect(ele).width;
 function left(ele)           rect(ele).left;
 function right(ele)          rect(ele).right;
-function isLeft(ele, msg)    is(left(ele) + tabstrip._tabMarginLeft, left(scrollbox), msg);
-function isRight(ele, msg)   is(right(ele) - tabstrip._tabMarginRight, right(scrollbox), msg);
+function isLeft(ele, msg)    is(left(ele), left(scrollbox), msg);
+function isRight(ele, msg)   is(right(ele), right(scrollbox), msg);
 function elementFromPoint(x) tabstrip._elementFromPoint(x);
 function nextLeftElement()   elementFromPoint(left(scrollbox) - 1);
 function nextRightElement()  elementFromPoint(right(scrollbox) + 1);
 function firstScrollable()   tabs[gBrowser._numPinnedTabs];
 
 function test() {
   requestLongerTimeout(2);
   waitForExplicitFinish();
@@ -57,21 +57,17 @@ function runOverflowTests(aEvent) {
   gBrowser.selectedTab = tabs[tabs.length - 1];
   ok(right(gBrowser.selectedTab) <= right(scrollbox), "Selecting the last tab scrolls it into view " +
      "(" + right(gBrowser.selectedTab) + " <= " + right(scrollbox) + ")");
 
   element = nextLeftElement();
   EventUtils.synthesizeMouse(upButton, 1, 1, {});
   isLeft(element, "Scrolled one tab to the left with a single click");
 
-  let elementPoint = left(scrollbox) - width(scrollbox);
-  element = elementFromPoint(elementPoint);
-  if (elementPoint == right(element)) {
-    element = element.nextSibling;
-  }
+  element = elementFromPoint(left(scrollbox) - width(scrollbox));
   EventUtils.synthesizeMouse(upButton, 1, 1, {clickCount: 2});
   isLeft(element, "Scrolled one page of tabs with a double click");
 
   EventUtils.synthesizeMouse(upButton, 1, 1, {clickCount: 3});
   var firstScrollableLeft = left(firstScrollable());
   ok(left(scrollbox) <= firstScrollableLeft, "Scrolled to the start with a triple click " +
      "(" + left(scrollbox) + " <= " + firstScrollableLeft + ")");
 
deleted file mode 100644
--- a/browser/base/content/test/general/browser_tabbar_big_widgets.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const kButtonId = "test-tabbar-size-with-large-buttons";
-
-function test() {
-  registerCleanupFunction(cleanup);
-  let titlebar = document.getElementById("titlebar");
-  let originalHeight = titlebar.getBoundingClientRect().height;
-  let button = document.createElement("toolbarbutton");
-  button.id = kButtonId;
-  button.setAttribute("style", "min-height: 100px");
-  gNavToolbox.palette.appendChild(button);
-  CustomizableUI.addWidgetToArea(kButtonId, CustomizableUI.AREA_TABSTRIP);
-  let currentHeight = titlebar.getBoundingClientRect().height;
-  ok(currentHeight > originalHeight, "Titlebar should have grown");
-  CustomizableUI.removeWidgetFromArea(kButtonId);
-  currentHeight = titlebar.getBoundingClientRect().height;
-  is(currentHeight, originalHeight, "Titlebar should have gone back to its original size.");
-}
-
-function cleanup() {
-  let btn = document.getElementById(kButtonId);
-  if (btn) {
-    btn.remove();
-  }
-}
-
deleted file mode 100644
--- a/browser/base/content/test/general/browser_windowopen_reflows.js
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const EXPECTED_REFLOWS = [
-  // handleEvent flushes layout to get the tabstrip width after a resize.
-  "handleEvent@chrome://browser/content/tabbrowser.xml|",
-
-  // Loading a tab causes a reflow.
-  "loadTabs@chrome://browser/content/tabbrowser.xml|" +
-    "loadOneOrMoreURIs@chrome://browser/content/browser.js|" +
-    "gBrowserInit._delayedStartup@chrome://browser/content/browser.js|",
-
-  // Selecting the address bar causes a reflow.
-  "select@chrome://global/content/bindings/textbox.xml|" +
-    "focusAndSelectUrlBar@chrome://browser/content/browser.js|" +
-    "gBrowserInit._delayedStartup@chrome://browser/content/browser.js|",
-
-  // Focusing the content area causes a reflow.
-  "gBrowserInit._delayedStartup@chrome://browser/content/browser.js|",
-
-  // Sometimes sessionstore collects data during this test, which causes a sync reflow
-  // (https://bugzilla.mozilla.org/show_bug.cgi?id=892154 will fix this)
-  "ssi_getWindowDimension@resource:///modules/sessionstore/SessionStore.jsm",
-];
-
-if (Services.appinfo.OS == "Darwin") {
-  // TabsInTitlebar._update causes a reflow on OS X trying to do calculations
-  // since layout info is already dirty. This doesn't seem to happen before
-  // MozAfterPaint on other platforms.
-  EXPECTED_REFLOWS.push("rect@chrome://browser/content/browser.js|" +
-                          "TabsInTitlebar._update@chrome://browser/content/browser.js|" +
-                          "updateAppearance@chrome://browser/content/browser.js|" +
-                          "handleEvent@chrome://browser/content/tabbrowser.xml|");
-
-  // _onOverflow causes a reflow getting widths.
-  EXPECTED_REFLOWS.push("OverflowableToolbar.prototype._onOverflow@resource:///modules/CustomizableUI.jsm|" +
-                        "OverflowableToolbar.prototype.init@resource:///modules/CustomizableUI.jsm|" +
-                        "OverflowableToolbar.prototype.observe@resource:///modules/CustomizableUI.jsm|" +
-                        "gBrowserInit._delayedStartup@chrome://browser/content/browser.js|");
-  // Same as above since in packaged builds there are no function names and the resource URI includes "app"
-  EXPECTED_REFLOWS.push("@resource://app/modules/CustomizableUI.jsm|" +
-                          "@resource://app/modules/CustomizableUI.jsm|" +
-                          "@resource://app/modules/CustomizableUI.jsm|" +
-                          "gBrowserInit._delayedStartup@chrome://browser/content/browser.js|");
-}
-
-/*
- * This test ensures that there are no unexpected
- * uninterruptible reflows when opening new windows.
- */
-function test() {
-  waitForExplicitFinish();
-
-  // Add a reflow observer and open a new window
-  let win = OpenBrowserWindow();
-  let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor)
-                    .getInterface(Ci.nsIWebNavigation)
-                    .QueryInterface(Ci.nsIDocShell);
-  docShell.addWeakReflowObserver(observer);
-
-  // Wait until the mozafterpaint event occurs.
-  waitForMozAfterPaint(win, function paintListener() {
-    // Remove reflow observer and clean up.
-    docShell.removeWeakReflowObserver(observer);
-    win.close();
-
-    finish();
-  });
-}
-
-let observer = {
-  reflow: function (start, end) {
-    // Gather information about the current code path.
-    let stack = new Error().stack;
-    let path = stack.split("\n").slice(1).map(line => {
-      return line.replace(/:\d+$/, "");
-    }).join("|");
-    let pathWithLineNumbers = (new Error().stack).split("\n").slice(1).join("|");
-
-    // Stack trace is empty. Reflow was triggered by native code.
-    if (path === "") {
-      return;
-    }
-
-    // Check if this is an expected reflow.
-    for (let expectedStack of EXPECTED_REFLOWS) {
-      if (path.startsWith(expectedStack) ||
-          // Accept an empty function name for gBrowserInit._delayedStartup or TabsInTitlebar._update to workaround bug 906578.
-          path.startsWith(expectedStack.replace(/(^|\|)(gBrowserInit\._delayedStartup|TabsInTitlebar\._update)@/, "$1@"))) {
-        ok(true, "expected uninterruptible reflow '" + expectedStack + "'");
-        return;
-      }
-    }
-
-    ok(false, "unexpected uninterruptible reflow '" + pathWithLineNumbers + "'");
-  },
-
-  reflowInterruptible: function (start, end) {
-    // We're not interested in interruptible reflows.
-  },
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIReflowObserver,
-                                         Ci.nsISupportsWeakReference])
-};
-
-function waitForMozAfterPaint(win, callback) {
-  win.addEventListener("MozAfterPaint", function onEnd(event) {
-    if (event.target != win)
-      return;
-    win.removeEventListener("MozAfterPaint", onEnd);
-    executeSoon(callback);
-  });
-}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/disablechrome.html
@@ -0,0 +1,4 @@
+<html>
+<body>
+</body>
+</html>
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -32,37 +32,59 @@ function updateTabContextMenu(tab) {
     tab = gBrowser.selectedTab;
   var evt = new Event("");
   tab.dispatchEvent(evt);
   menu.openPopup(tab, "end_after", 0, 0, true, false, evt);
   is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
   menu.hidePopup();
 }
 
+function findToolbarCustomizationWindow(aBrowserWin) {
+  if (!aBrowserWin)
+    aBrowserWin = window;
+
+  let iframe = aBrowserWin.document.getElementById("customizeToolbarSheetIFrame");
+  let win = iframe && iframe.contentWindow;
+  if (win)
+    return win;
+
+  win = findChromeWindowByURI("chrome://global/content/customizeToolbar.xul");
+  if (win && win.opener == aBrowserWin)
+    return win;
+
+  throw Error("Failed to find the customization window");
+}
+
 function openToolbarCustomizationUI(aCallback, aBrowserWin) {
   if (!aBrowserWin)
     aBrowserWin = window;
 
-  aBrowserWin.gCustomizeMode.enter();
+  aBrowserWin.document.getElementById("cmd_CustomizeToolbars").doCommand();
+
+  aBrowserWin.gNavToolbox.addEventListener("beforecustomization", function UI_loaded() {
+    aBrowserWin.gNavToolbox.removeEventListener("beforecustomization", UI_loaded);
 
-  aBrowserWin.gNavToolbox.addEventListener("customizationready", function UI_loaded() {
-    aBrowserWin.gNavToolbox.removeEventListener("customizationready", UI_loaded);
-    executeSoon(function() {
-      aCallback(aBrowserWin)
-    });
+    let win = findToolbarCustomizationWindow(aBrowserWin);
+    waitForFocus(function () {
+      aCallback(win);
+    }, win);
   });
 }
 
 function closeToolbarCustomizationUI(aCallback, aBrowserWin) {
-  aBrowserWin.gNavToolbox.addEventListener("aftercustomization", function unloaded() {
-    aBrowserWin.gNavToolbox.removeEventListener("aftercustomization", unloaded);
+  let win = findToolbarCustomizationWindow(aBrowserWin);
+
+  win.addEventListener("unload", function unloaded() {
+    win.removeEventListener("unload", unloaded);
     executeSoon(aCallback);
   });
 
-  aBrowserWin.gCustomizeMode.exit();
+  let button = win.document.getElementById("donebutton");
+  button.focus();
+  button.doCommand();
 }
 
 function waitForCondition(condition, nextTest, errorMsg) {
   var tries = 0;
   var interval = setInterval(function() {
     if (tries >= 30) {
       ok(false, errorMsg);
       moveOn();
--- a/browser/base/content/test/social/browser_social_marks.js
+++ b/browser/base/content/test/social/browser_social_marks.js
@@ -59,86 +59,131 @@ function test() {
   let toolbar = document.getElementById("nav-bar");
   let currentsetAtStart = toolbar.currentSet;
   runSocialTestWithProvider(manifest, function () {
     runSocialTests(tests, undefined, undefined, function () {
       Services.prefs.clearUserPref("social.remote-install.enabled");
       // just in case the tests failed, clear these here as well
       Services.prefs.clearUserPref("social.allowMultipleWorkers");
       Services.prefs.clearUserPref("social.whitelist");
-      ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
-      CustomizableUI.reset();
-      finish();
+
+      // This post-test test ensures that a new window maintains the same
+      // toolbar button set as when we started. That means our insert/removal of
+      // persistent id's is working correctly
+      is(currentsetAtStart, toolbar.currentSet, "toolbar currentset unchanged");
+      openWindowAndWaitForInit(function(w1) {
+        checkSocialUI(w1);
+        // Sometimes the new window adds other buttons to currentSet that are
+        // outside the scope of what we're checking. So we verify that all
+        // buttons from startup are in currentSet for a new window, and that the
+        // provider buttons are properly removed. (e.g on try, window-controls
+        // was not present in currentsetAtStart, but present on the second
+        // window)
+        let tb1 = w1.document.getElementById("nav-bar");
+        let startupSet = Set(toolbar.currentSet.split(','));
+        let newSet = Set(tb1.currentSet.split(','));
+        let intersect = Set([x for (x of startupSet) if (newSet.has(x))]);
+        let difference = Set([x for (x of newSet) if (!startupSet.has(x))]);
+        is(startupSet.size, intersect.size, "new window toolbar same as old");
+        // verify that our provider buttons are not in difference
+        let id = SocialMarks._toolbarHelper.idFromOrgin(manifest2.origin);
+        ok(!difference.has(id), "mark button not persisted at end");
+        w1.close();
+        finish();
+      });
     });
   });
 }
 
 var tests = {
-  testNoButtonOnEnable: function(next) {
+  testNoButtonOnInstall: function(next) {
     // we expect the addon install dialog to appear, we need to accept the
     // install from the dialog.
+    info("Waiting for install dialog");
     let panel = document.getElementById("servicesInstall-notification");
     PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
       PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
       info("servicesInstall-notification panel opened");
       panel.button.click();
-    });
+    })
+
+    let id = "social-mark-button-" + manifest3.origin;
+    let toolbar = document.getElementById("nav-bar");
+    let currentset = toolbar.getAttribute("currentset").split(',');
+    ok(currentset.indexOf(id) < 0, "button is not part of currentset at start");
 
     let activationURL = manifest3.origin + "/browser/browser/base/content/test/social/social_activate.html"
     addTab(activationURL, function(tab) {
       let doc = tab.linkedBrowser.contentDocument;
       Social.installProvider(doc, manifest3, function(addonManifest) {
         // enable the provider so we know the button would have appeared
         SocialService.addBuiltinProvider(manifest3.origin, function(provider) {
-          is(provider.origin, manifest3.origin, "provider is installed");
-          let id = SocialMarks._toolbarHelper.idFromOrigin(provider.origin);
-          let widget = CustomizableUI.getWidget(id);
-          ok(!widget || !widget.forWindow(window).node, "no button added to widget set");
+          ok(provider, "provider is installed");
+          currentset = toolbar.getAttribute("currentset").split(',');
+          ok(currentset.indexOf(id) < 0, "button was not added to currentset");
           Social.uninstallProvider(manifest3.origin, function() {
             gBrowser.removeTab(tab);
             next();
           });
         });
       });
     });
   },
 
-  testButtonOnEnable: function(next) {
+  testButtonOnInstall: function(next) {
+    // we expect the addon install dialog to appear, we need to accept the
+    // install from the dialog.
+    info("Waiting for install dialog");
     let panel = document.getElementById("servicesInstall-notification");
     PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
       PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
       info("servicesInstall-notification panel opened");
       panel.button.click();
-    });
+    })
 
-    // enable the provider now
     let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
     addTab(activationURL, function(tab) {
       let doc = tab.linkedBrowser.contentDocument;
       Social.installProvider(doc, manifest2, function(addonManifest) {
-        SocialService.addBuiltinProvider(manifest2.origin, function(provider) {
-          is(provider.origin, manifest2.origin, "provider is installed");
-          let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
-          let widget = CustomizableUI.getWidget(id).forWindow(window)
-          ok(widget.node, "button added to widget set");
-          checkSocialUI(window);
-          gBrowser.removeTab(tab);
-          next();
-        });
+        // at this point, we should have a button id in the currentset for our provider
+        let id = "social-mark-button-" + manifest2.origin;
+        let toolbar = document.getElementById("nav-bar");
+
+        waitForCondition(function() {
+                            let currentset = toolbar.getAttribute("currentset").split(',');
+                            return currentset.indexOf(id) >= 0;
+                         },
+                         function() {
+                           // no longer need the tab
+                           gBrowser.removeTab(tab);
+                           next();
+                         }, "mark button added to currentset");
       });
     });
   },
 
+  testButtonOnEnable: function(next) {
+    // enable the provider now
+    SocialService.addBuiltinProvider(manifest2.origin, function(provider) {
+      ok(provider, "provider is installed");
+      let id = "social-mark-button-" + manifest2.origin;
+      waitForCondition(function() { return document.getElementById(id) },
+                       function() {
+                         checkSocialUI(window);
+                         next();
+                       }, "button exists after enabling social");
+    });
+  },
+
   testMarkPanel: function(next) {
     // click on panel to open and wait for visibility
     let provider = Social._getProviderFromOrigin(manifest2.origin);
     ok(provider.enabled, "provider is enabled");
-    let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
-    let widget = CustomizableUI.getWidget(id);
-    let btn = widget.forWindow(window).node;
+    let id = "social-mark-button-" + provider.origin;
+    let btn = document.getElementById(id)
     ok(btn, "got a mark button");
     let port = provider.getWorkerPort();
     ok(port, "got a port");
 
     // verify markbutton is disabled when there is no browser url
     ok(btn.disabled, "button is disabled");
     let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
     addTab(activationURL, function(tab) {
@@ -187,19 +232,18 @@ var tests = {
       port.postMessage({topic: "test-init"});
     });
   },
 
   testMarkPanelLoggedOut: function(next) {
     // click on panel to open and wait for visibility
     let provider = Social._getProviderFromOrigin(manifest2.origin);
     ok(provider.enabled, "provider is enabled");
-    let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
-    let widget = CustomizableUI.getWidget(id);
-    let btn = widget.forWindow(window).node;
+    let id = "social-mark-button-" + provider.origin;
+    let btn = document.getElementById(id)
     ok(btn, "got a mark button");
     let port = provider.getWorkerPort();
     ok(port, "got a port");
 
     // verify markbutton is disabled when there is no browser url
     ok(btn.disabled, "button is disabled");
     let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
     addTab(activationURL, function(tab) {
@@ -251,28 +295,36 @@ var tests = {
     });
   },
 
   testButtonOnDisable: function(next) {
     // enable the provider now
     let provider = Social._getProviderFromOrigin(manifest2.origin);
     ok(provider, "provider is installed");
     SocialService.removeProvider(manifest2.origin, function() {
-      let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin);
-      waitForCondition(function() {
-                        // getWidget now returns null since we've destroyed the widget
-                        return !CustomizableUI.getWidget(id)
-                       },
+      let id = "social-mark-button-" + manifest2.origin;
+      waitForCondition(function() { return !document.getElementById(id) },
                        function() {
                          checkSocialUI(window);
-                         Social.uninstallProvider(manifest2.origin, next);
+                         next();
                        }, "button does not exist after disabling the provider");
     });
   },
 
+  testButtonOnUninstall: function(next) {
+    Social.uninstallProvider(manifest2.origin, function() {
+      // test that the button is no longer persisted
+      let id = "social-mark-button-" + manifest2.origin;
+      let toolbar = document.getElementById("nav-bar");
+      let currentset = toolbar.getAttribute("currentset").split(',');
+      is(currentset.indexOf(id), -1, "button no longer in currentset");
+      next();
+    });
+  },
+
   testContextSubmenu: function(next) {
     // install 4 providers to test that the menu's are added as submenus
     let manifests = [
       makeMarkProvider("sub1.test1"),
       makeMarkProvider("sub2.test1"),
       makeMarkProvider("sub1.test2"),
       makeMarkProvider("sub2.test2")
     ];
@@ -291,34 +343,41 @@ var tests = {
       let panel = document.getElementById("servicesInstall-notification");
       PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
         PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
         info("servicesInstall-notification panel opened");
         panel.button.click();
       })
 
       let activationURL = manifest.origin + "/browser/browser/base/content/test/social/social_activate.html"
-      let id = SocialMarks._toolbarHelper.idFromOrigin(manifest.origin);
+      let id = "social-mark-button-" + manifest.origin;
       let toolbar = document.getElementById("nav-bar");
       addTab(activationURL, function(tab) {
         let doc = tab.linkedBrowser.contentDocument;
         Social.installProvider(doc, manifest, function(addonManifest) {
-          // enable the provider so we know the button would have appeared
-          SocialService.addBuiltinProvider(manifest.origin, function(provider) {
-            waitForCondition(function() { return CustomizableUI.getWidget(id) },
-                             function() {
-              gBrowser.removeTab(tab);
-              installed.push(manifest.origin);
-              // checkSocialUI will properly check where the menus are located
-              checkSocialUI(window);
-              executeSoon(function() {
-                addProviders(callback);
-              });
-            }, "button exists after enabling social");
-          });
+
+          waitForCondition(function() {
+            let currentset = toolbar.getAttribute("currentset").split(',');
+            return currentset.indexOf(id) >= 0;
+          },
+          function() {
+            // enable the provider so we know the button would have appeared
+            SocialService.addBuiltinProvider(manifest.origin, function(provider) {
+              waitForCondition(function() { return document.getElementById(id) },
+                               function() {
+                gBrowser.removeTab(tab);
+                installed.push(manifest.origin);
+                // checkSocialUI will properly check where the menus are located
+                checkSocialUI(window);
+                executeSoon(function() {
+                  addProviders(callback);
+                });
+              }, "button exists after enabling social");
+            });
+          }, "mark button added to currentset");
         });
       });
     }
 
     function removeProviders(callback) {
       let origin = installed.pop();
       if (!origin) {
         executeSoon(callback);
--- a/browser/base/content/test/social/browser_social_status.js
+++ b/browser/base/content/test/social/browser_social_status.js
@@ -36,94 +36,142 @@ function openWindowAndWaitForInit(callba
     executeSoon(() => callback(w));
   }, topic, false);
 }
 
 function test() {
   waitForExplicitFinish();
 
   Services.prefs.setBoolPref("social.allowMultipleWorkers", true);
+  let toolbar = document.getElementById("nav-bar");
+  let currentsetAtStart = toolbar.currentSet;
+  info("tb0 "+currentsetAtStart);
   runSocialTestWithProvider(manifest, function () {
     runSocialTests(tests, undefined, undefined, function () {
       Services.prefs.clearUserPref("social.remote-install.enabled");
       // just in case the tests failed, clear these here as well
       Services.prefs.clearUserPref("social.allowMultipleWorkers");
       Services.prefs.clearUserPref("social.whitelist");
-      ok(CustomizableUI.inDefaultState, "Should be in the default state when we finish");
-      CustomizableUI.reset();
-      finish();
+      
+      // This post-test test ensures that a new window maintains the same
+      // toolbar button set as when we started. That means our insert/removal of
+      // persistent id's is working correctly
+      is(currentsetAtStart, toolbar.currentSet, "toolbar currentset unchanged");
+      openWindowAndWaitForInit(function(w1) {
+        checkSocialUI(w1);
+        // Sometimes the new window adds other buttons to currentSet that are
+        // outside the scope of what we're checking. So we verify that all
+        // buttons from startup are in currentSet for a new window, and that the
+        // provider buttons are properly removed. (e.g on try, window-controls
+        // was not present in currentsetAtStart, but present on the second
+        // window)
+        let tb1 = w1.document.getElementById("nav-bar");
+        info("tb0 "+toolbar.currentSet);
+        info("tb1 "+tb1.currentSet);
+        let startupSet = Set(toolbar.currentSet.split(','));
+        let newSet = Set(tb1.currentSet.split(','));
+        let intersect = Set([x for (x of startupSet) if (newSet.has(x))]);
+        info("intersect "+intersect);
+        let difference = Set([x for (x of newSet) if (!startupSet.has(x))]);
+        info("difference "+difference);
+        is(startupSet.size, intersect.size, "new window toolbar same as old");
+        // verify that our provider buttons are not in difference
+        let id = SocialStatus._toolbarHelper.idFromOrgin(manifest2.origin);
+        ok(!difference.has(id), "status button not persisted at end");
+        w1.close();
+        finish();
+      });
     });
   });
 }
 
 var tests = {
-  testNoButtonOnEnable: function(next) {
+  testNoButtonOnInstall: function(next) {
     // we expect the addon install dialog to appear, we need to accept the
     // install from the dialog.
+    info("Waiting for install dialog");
     let panel = document.getElementById("servicesInstall-notification");
     PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
       PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
       info("servicesInstall-notification panel opened");
       panel.button.click();
     })
 
+    let id = "social-status-button-" + manifest3.origin;
+    let toolbar = document.getElementById("nav-bar");
+    let currentset = toolbar.getAttribute("currentset").split(',');
+    ok(currentset.indexOf(id) < 0, "button is not part of currentset at start");
+
     let activationURL = manifest3.origin + "/browser/browser/base/content/test/social/social_activate.html"
     addTab(activationURL, function(tab) {
       let doc = tab.linkedBrowser.contentDocument;
       Social.installProvider(doc, manifest3, function(addonManifest) {
         // enable the provider so we know the button would have appeared
         SocialService.addBuiltinProvider(manifest3.origin, function(provider) {
-          is(provider.origin, manifest3.origin, "provider is installed");
-          let id = SocialStatus._toolbarHelper.idFromOrigin(provider.origin);
-          let widget = CustomizableUI.getWidget(id);
-          ok(!widget || !widget.forWindow(window).node, "no button added to widget set");
+          ok(provider, "provider is installed");
+          currentset = toolbar.getAttribute("currentset").split(',');
+          ok(currentset.indexOf(id) < 0, "button was not added to currentset");
           Social.uninstallProvider(manifest3.origin, function() {
             gBrowser.removeTab(tab);
             next();
           });
         });
       });
     });
   },
-  testButtonOnEnable: function(next) {
+  testButtonOnInstall: function(next) {
+    // we expect the addon install dialog to appear, we need to accept the
+    // install from the dialog.
+    info("Waiting for install dialog");
     let panel = document.getElementById("servicesInstall-notification");
     PopupNotifications.panel.addEventListener("popupshown", function onpopupshown() {
       PopupNotifications.panel.removeEventListener("popupshown", onpopupshown);
       info("servicesInstall-notification panel opened");
       panel.button.click();
-    });
+    })
 
-    // enable the provider now
     let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
     addTab(activationURL, function(tab) {
       let doc = tab.linkedBrowser.contentDocument;
       Social.installProvider(doc, manifest2, function(addonManifest) {
-        SocialService.addBuiltinProvider(manifest2.origin, function(provider) {
-          is(provider.origin, manifest2.origin, "provider is installed");
-          let id = SocialStatus._toolbarHelper.idFromOrigin(manifest2.origin);
-          let widget = CustomizableUI.getWidget(id).forWindow(window);
-          ok(widget.node, "button added to widget set");
-          checkSocialUI(window);
-          gBrowser.removeTab(tab);
-          next();
-        });
+          // at this point, we should have a button id in the currentset for our provider
+          let id = "social-status-button-" + manifest2.origin;
+          let toolbar = document.getElementById("nav-bar");
+
+          waitForCondition(function() {
+                             let currentset = toolbar.getAttribute("currentset").split(',');
+                             return currentset.indexOf(id) >= 0;
+                           },
+                           function() {
+                             // no longer need the tab
+                             gBrowser.removeTab(tab);
+                             next();
+                           }, "status button added to currentset");
       });
     });
   },
+  testButtonOnEnable: function(next) {
+    // enable the provider now
+    SocialService.addBuiltinProvider(manifest2.origin, function(provider) {
+      ok(provider, "provider is installed");
+      let id = "social-status-button-" + manifest2.origin;
+      waitForCondition(function() { return document.getElementById(id) },
+                       next, "button exists after enabling social");
+    });
+  },
   testStatusPanel: function(next) {
     let icon = {
       name: "testIcon",
       iconURL: "chrome://browser/skin/Info.png",
       counter: 1
     };
     // click on panel to open and wait for visibility
     let provider = Social._getProviderFromOrigin(manifest2.origin);
-    let id = SocialStatus._toolbarHelper.idFromOrigin(manifest2.origin);
-    let widget = CustomizableUI.getWidget(id);
-    let btn = widget.forWindow(window).node;
+    let id = "social-status-button-" + provider.origin;
+    let btn = document.getElementById(id)
     ok(btn, "got a status button");
     let port = provider.getWorkerPort();
 
     port.onmessage = function (e) {
       let topic = e.data.topic;
       switch (topic) {
         case "test-init-done":
           ok(true, "test-init-done received");
@@ -149,16 +197,24 @@ var tests = {
     };
     port.postMessage({topic: "test-init"});
   },
   testButtonOnDisable: function(next) {
     // enable the provider now
     let provider = Social._getProviderFromOrigin(manifest2.origin);
     ok(provider, "provider is installed");
     SocialService.removeProvider(manifest2.origin, function() {
-      let id = SocialStatus._toolbarHelper.idFromOrigin(manifest2.origin);
+      let id = "social-status-button-" + manifest2.origin;
       waitForCondition(function() { return !document.getElementById(id) },
-                       function() {
-                        Social.uninstallProvider(manifest2.origin, next);
-                       }, "button does not exist after disabling the provider");
+                       next, "button does not exist after disabling the provider");
+    });
+  },
+  testButtonOnUninstall: function(next) {
+    Social.uninstallProvider(manifest2.origin, function() {
+      // test that the button is no longer persisted
+      let id = "social-status-button-" + manifest2.origin;
+      let toolbar = document.getElementById("nav-bar");
+      let currentset = toolbar.getAttribute("currentset").split(',');
+      is(currentset.indexOf(id), -1, "button no longer in currentset");
+      next();
     });
   }
 }
--- a/browser/base/content/test/social/browser_social_toolbar.js
+++ b/browser/base/content/test/social/browser_social_toolbar.js
@@ -14,19 +14,27 @@ let manifests = [{
   iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png",
 }];
 
 function test() {
   waitForExplicitFinish();
 
   // required to test status button in combination with the toolbaritem
   Services.prefs.setBoolPref("social.allowMultipleWorkers", true);
+
+  // Preset the currentSet so the statusbutton is in the toolbar on addition. We
+  // bypass the SocialStatus class here since it requires the manifest already
+  // be installed.
+  let tbh = SocialStatus._toolbarHelper;
+  tbh.setPersistentPosition(tbh.idFromOrgin(manifests[1].origin));
+
   runSocialTestWithProvider(manifests, function (finishcb) {
     runSocialTests(tests, undefined, undefined, function() {
       Services.prefs.clearUserPref("social.allowMultipleWorkers");
+      SocialStatus.removePosition(manifests[1].origin);
       finishcb();
     });
   });
 }
 
 var tests = {
   testProfileNone: function(next, useNull) {
     let profile = useNull ? null : {};
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -926,26 +926,26 @@
                   pack="end" align="center">
           <xul:button anonid="button"
                       class="popup-notification-menubutton"
                       type="menu-button"
                       xbl:inherits="oncommand=buttoncommand,label=buttonlabel,accesskey=buttonaccesskey">
             <xul:menupopup anonid="menupopup"
                            xbl:inherits="oncommand=menucommand">
               <children/>
-              <xul:menuitem class="menuitem-iconic popup-notification-closeitem close-icon"
+              <xul:menuitem class="menuitem-iconic popup-notification-closeitem"
                             label="&closeNotificationItem.label;"
                             xbl:inherits="oncommand=closeitemcommand"/>
             </xul:menupopup>
           </xul:button>
         </xul:hbox>
       </xul:vbox>
       <xul:vbox pack="start">
         <xul:toolbarbutton anonid="closebutton"
-                           class="messageCloseButton close-icon popup-notification-closebutton tabbable"
+                           class="messageCloseButton popup-notification-closebutton tabbable"
                            xbl:inherits="oncommand=closebuttoncommand"
                            tooltiptext="&closeNotification.tooltip;"/>
       </xul:vbox>
     </content>
     <implementation>
       <constructor><![CDATA[
         this.cancelbtn.setAttribute("tooltiptext", gNavigatorBundle.getString("addonDownloadCancelTooltip"));
 
@@ -1158,26 +1158,26 @@
                      style="visibility:hidden" width="16" height="16"/>
           <xul:button anonid="button"
                       type="menu-button"
                       class="popup-notification-menubutton"
                       xbl:inherits="oncommand=buttoncommand,label=buttonlabel,accesskey=buttonaccesskey">
             <xul:menupopup anonid="menupopup"
                            xbl:inherits="oncommand=menucommand">
               <children/>
-              <xul:menuitem class="menuitem-iconic popup-notification-closeitem close-icon"
+              <xul:menuitem class="menuitem-iconic popup-notification-closeitem"
                             label="&closeNotificationItem.label;"
                             xbl:inherits="oncommand=closeitemcommand"/>
             </xul:menupopup>
           </xul:button>
         </xul:hbox>
       </xul:vbox>
       <xul:vbox pack="start">
         <xul:toolbarbutton anonid="closebutton"
-                           class="messageCloseButton close-icon popup-notification-closebutton tabbable"
+                           class="messageCloseButton popup-notification-closebutton tabbable"
                            xbl:inherits="oncommand=closebuttoncommand"
                            tooltiptext="&closeNotification.tooltip;"/>
       </xul:vbox>
     </content>
     <implementation>
       <constructor><![CDATA[
         // this.notification.options.identity is used to pass identity-specific info to the binding
         let origin = this.identity.origin
@@ -1497,17 +1497,17 @@
       <xul:vbox flex="1" align="stretch" class="popup-notification-main-box"
                 xbl:inherits="popupid">
         <xul:hbox class="click-to-play-plugins-notification-description-box" flex="1" align="start">
           <xul:description class="click-to-play-plugins-outer-description" flex="1">
             <html:span anonid="click-to-play-plugins-notification-description" />
             <xul:label class="text-link click-to-play-plugins-notification-link" anonid="click-to-play-plugins-notification-link" />
           </xul:description>
           <xul:toolbarbutton anonid="closebutton"
-                             class="messageCloseButton popup-notification-closebutton tabbable close-icon"
+                             class="messageCloseButton popup-notification-closebutton tabbable"
                              xbl:inherits="oncommand=closebuttoncommand"
                              tooltiptext="&closeNotification.tooltip;"/>
         </xul:hbox>
         <xul:grid anonid="click-to-play-plugins-notification-center-box"
                   class="click-to-play-plugins-notification-center-box">
           <xul:columns>
             <xul:column flex="1"/>
             <xul:column/>
@@ -2016,17 +2016,17 @@
         <xul:hbox align="center" flex="1">
           <xul:image class="panel-promo-icon"/>
           <xul:description anonid="promo-message" class="panel-promo-message" flex="1">
             <xul:description anonid="promo-link"
                              class="plain text-link inline-link"
                              onclick="document.getBindingParent(this).onLinkClick();"/>
           </xul:description>
         </xul:hbox>
-        <xul:toolbarbutton class="panel-promo-closebutton close-icon"
+        <xul:toolbarbutton class="panel-promo-closebutton"
                            oncommand="document.getBindingParent(this).onCloseButtonCommand();"
                            tooltiptext="&closeNotification.tooltip;"/>
       </xul:hbox>
     </content>
 
     <implementation implements="nsIDOMEventListener">
       <constructor><![CDATA[
         this._panel.addEventListener("popupshowing", this, false);
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -8,17 +8,18 @@ browser.jar:
 %  overlay chrome://global/content/console.xul chrome://browser/content/jsConsoleOverlay.xul
 %  overlay chrome://mozapps/content/update/updates.xul chrome://browser/content/softwareUpdateOverlay.xul
 #endif
 #ifdef XP_WIN
 %  overlay chrome://browser/content/browser.xul chrome://browser/content/win6BrowserOverlay.xul os=WINNT osversion>=6
 #endif
 %  overlay chrome://global/content/viewSource.xul chrome://browser/content/viewSourceOverlay.xul
 %  overlay chrome://global/content/viewPartialSource.xul chrome://browser/content/viewSourceOverlay.xul
-
+%  style chrome://global/content/customizeToolbar.xul chrome://browser/content/browser.css
+%  style chrome://global/content/customizeToolbar.xul chrome://browser/skin/
 *       content/browser/aboutDialog.xul               (content/aboutDialog.xul)
 *       content/browser/aboutDialog.js                (content/aboutDialog.js)
         content/browser/aboutDialog.css               (content/aboutDialog.css)
         content/browser/aboutRobots.xhtml             (content/aboutRobots.xhtml)
         content/browser/abouthome/aboutHome.xhtml     (content/abouthome/aboutHome.xhtml)
         content/browser/abouthome/aboutHome.js        (content/abouthome/aboutHome.js)
 *       content/browser/abouthome/aboutHome.css       (content/abouthome/aboutHome.css)
         content/browser/abouthome/snippet1.png        (content/abouthome/snippet1.png)
--- a/browser/branding/nightly/branding.nsi
+++ b/browser/branding/nightly/branding.nsi
@@ -3,17 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # NSIS branding defines for nightly builds.
 # The official release build branding.nsi is located in other-license/branding/firefox/
 # The unofficial build branding.nsi is located in browser/branding/unofficial/
 
 # BrandFullNameInternal is used for some registry and file system values
 # instead of BrandFullName and typically should not be modified.
-!define BrandFullNameInternal "Nightly"
+!define BrandFullNameInternal "Holly"
 !define CompanyName           "mozilla.org"
 !define URLInfoAbout          "http://www.mozilla.org"
 !define URLUpdateInfo         "http://www.mozilla.org/projects/firefox"
 
 !define URLStubDownload "http://download.mozilla.org/?os=win&lang=${AB_CD}&product=firefox-nightly-latest"
 !define URLManualDownload "https://www.mozilla.org/${AB_CD}/firefox/installer-help/?channel=nightly&installer_lang=${AB_CD}"
 !define Channel "nightly"
 
--- a/browser/branding/nightly/configure.sh
+++ b/browser/branding/nightly/configure.sh
@@ -1,5 +1,5 @@
 # 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/.
 
-MOZ_APP_DISPLAYNAME=Nightly
+MOZ_APP_DISPLAYNAME=Holly
--- a/browser/branding/nightly/locales/en-US/brand.dtd
+++ b/browser/branding/nightly/locales/en-US/brand.dtd
@@ -1,8 +1,8 @@
 <!-- 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/. -->
 
-<!ENTITY  brandShortName        "Nightly">
-<!ENTITY  brandFullName         "Nightly">
+<!ENTITY  brandShortName        "Holly">
+<!ENTITY  brandFullName         "Holly">
 <!ENTITY  vendorShortName       "Mozilla">
 <!ENTITY  trademarkInfo.part1   " ">
--- a/browser/branding/nightly/locales/en-US/brand.properties
+++ b/browser/branding/nightly/locales/en-US/brand.properties
@@ -1,9 +1,9 @@
 # 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/.
 
-brandShortName=Nightly
-brandFullName=Nightly
+brandShortName=Holly
+brandFullName=Holly
 vendorShortName=Mozilla
 
 syncBrandShortName=Sync
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -87,18 +87,16 @@ static RedirEntry kRedirMap[] = {
   { "downloads", "chrome://browser/content/downloads/contentAreaDownloadsView.xul",
     nsIAboutModule::ALLOW_SCRIPT },
 #ifdef MOZ_SERVICES_HEALTHREPORT
   { "healthreport", "chrome://browser/content/abouthealthreport/abouthealth.xhtml",
     nsIAboutModule::ALLOW_SCRIPT },
 #endif
   { "app-manager", "chrome://browser/content/devtools/app-manager/index.xul",
     nsIAboutModule::ALLOW_SCRIPT },
-  { "customizing", "chrome://browser/content/customizableui/aboutCustomizing.xhtml",
-    nsIAboutModule::ALLOW_SCRIPT },
 };
 static const int kRedirTotal = NS_ARRAY_LENGTH(kRedirMap);
 
 static nsAutoCString
 GetAboutModuleName(nsIURI *aURI)
 {
   nsAutoCString path;
   aURI->GetPath(path);
--- a/browser/components/build/nsModule.cpp
+++ b/browser/components/build/nsModule.cpp
@@ -105,17 +105,16 @@ static const mozilla::Module::ContractID
     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "newtab", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "permissions", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "preferences", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "downloads", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
 #ifdef MOZ_SERVICES_HEALTHREPORT
     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "healthreport", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
 #endif
     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "app-manager", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "customizing", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
 #if defined(XP_WIN)
     { NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID },
 #elif defined(XP_MACOSX)
     { NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
 #endif
     { nullptr }
 };
 
deleted file mode 100644
--- a/browser/components/customizableui/content/aboutCustomizing.xhtml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- 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/. -->
-
-<!DOCTYPE html [
-  <!ENTITY % htmlDTD
-    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-    "DTD/xhtml1-strict.dtd">
-  %htmlDTD;
-  <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
-  %brandDTD;
-  <!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
-  %browserDTD;
-]>
-
-<html xmlns="http://www.w3.org/1999/xhtml"
-      disablefastfind="true">
-	<head>
-		<title>&customizeMode.tabTitle;</title>
-	</head>
-	<body></body>
-</html>
deleted file mode 100644
--- a/browser/components/customizableui/content/customizeMode.inc.xul
+++ /dev/null
@@ -1,28 +0,0 @@
-<!-- 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/. -->
-
-<hbox id="customization-container" flex="1" hidden="true">
-  <vbox flex="1" id="customization-palette-container">
-    <label id="customization-header" value="&customizeMode.menuAndToolbars.header;"/>
-    <vbox id="customization-palette" flex="1"/>
-    <hbox pack="start">
-      <button id="customization-reset-button" oncommand="gCustomizeMode.reset();" label="&customizeMode.restoreDefaults;" class="customizationmode-button"/>
-    </hbox>
-  </vbox>
-  <vbox id="customization-panel-container">
-    <vbox id="customization-panelWrapper">
-      <html:style html:type="text/html" scoped="scoped">
-        @import url(chrome://global/skin/popup.css);
-      </html:style>
-      <box class="panel-arrowbox">
-        <box flex="1"/>
-        <image class="panel-arrow" side="top"/>
-      </box>
-      <box class="panel-arrowcontent" side="top" flex="1">
-        <hbox id="customization-panelHolder"/>
-        <box class="panel-inner-arrowcontentfooter" hidden="true"/>
-      </box>
-    </vbox>
-  </vbox>
-</hbox>
deleted file mode 100644
--- a/browser/components/customizableui/content/jar.mn
+++ /dev/null
@@ -1,11 +0,0 @@
-# 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/.
-
-browser.jar:
-  content/browser/customizableui/aboutCustomizing.xhtml
-  content/browser/customizableui/panelUI.css
-  content/browser/customizableui/panelUI.js
-  content/browser/customizableui/panelUI.xml
-  content/browser/customizableui/toolbar.xml
-
deleted file mode 100644
--- a/browser/components/customizableui/content/moz.build
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
deleted file mode 100644
--- a/browser/components/customizableui/content/panelUI.css
+++ /dev/null
@@ -1,31 +0,0 @@
-/* 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/. */
-
-.panel-viewstack[viewtype="main"] > .panel-clickcapturer {
-  pointer-events: none;
-}
-
-.panel-mainview,
-.panel-viewcontainer,
-.panel-viewstack {
-  overflow: hidden;
-}
-
-.panel-viewstack {
-  position: relative;
-}
-
-.panel-subviews {
-  -moz-stack-sizing: ignore;
-  transform: translateX(0);
-  overflow-y: auto;
-}
-
-.panel-subviews[panelopen] {
-  transition: transform 150ms;
-}
-
-.panel-viewcontainer[panelopen]:-moz-any(:not([viewtype="main"]),[transitioning="true"]) {
-  transition: height 150ms;
-}
deleted file mode 100644
--- a/browser/components/customizableui/content/panelUI.inc.xul
+++ /dev/null
@@ -1,169 +0,0 @@
-<!-- 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/. -->
-
-<panel id="PanelUI-popup"
-       role="group"
-       type="arrow"
-       level="top"
-       hidden="true"
-       noautofocus="true">
-  <panelmultiview id="PanelUI-multiView" mainViewId="PanelUI-mainView">
-    <panelview id="PanelUI-mainView" context="customizationPanelContextMenu">
-      <vbox id="PanelUI-contents-scroller">
-        <vbox id="PanelUI-contents"/>
-      </vbox>
-
-      <footer id="PanelUI-footer">
-        <!-- The parentNode is used so that the footer is presented as the anchor
-             instead of just the button being the anchor. -->
-        <toolbarbutton id="PanelUI-customize" label="&appMenuCustomize.label;"
-                       exitLabel="&appMenuCustomizeExit.label;" tabindex="0"
-                       oncommand="gCustomizeMode.toggle();"/>
-        <toolbarbutton id="PanelUI-help" label="&helpMenu.label;" tabindex="0"
-                       tooltiptext="&helpMenu.label;"
-                       oncommand="PanelUI.showHelpView(this.parentNode);"/>
-        <toolbarbutton id="PanelUI-quit" tabindex="0"
-#ifdef XP_WIN
-                       label="&quitApplicationCmdWin.label;"
-                       tooltiptext="&quitApplicationCmdWin.label;"
-#else
-                       label="&quitApplicationCmd.label;"
-                       tooltiptext="&quitApplicationCmd.label;"
-#endif
-                       command="cmd_quitApplication"/>
-      </footer>
-    </panelview>
-
-    <panelview id="PanelUI-history" flex="1">
-      <label value="&appMenuHistory.label;"/>
-      <toolbarbutton id="appMenuClearRecentHistory" tabindex="0"
-                     label="&appMenuHistory.clearRecent.label;"
-                     command="Tools:Sanitize"/>
-      <toolbarbutton id="appMenuRestoreLastSession" tabindex="0"
-                     label="&appMenuHistory.restoreSession.label;"
-                     command="Browser:RestoreLastSession"/>
-      <menuseparator id="PanelUI-recentlyClosedTabs-separator"/>
-      <vbox id="PanelUI-recentlyClosedTabs"/>
-      <menuseparator id="PanelUI-recentlyClosedWindows-separator"/>
-      <vbox id="PanelUI-recentlyClosedWindows"/>
-      <menuseparator id="PanelUI-historyItems-separator"/>
-      <vbox id="PanelUI-historyItems"/>
-      <label value="&appMenuHistory.showAll.label;"
-             id="PanelUI-historyMore"
-             class="text-link"
-             onclick="PlacesCommandHook.showPlacesOrganizer('History'); CustomizableUI.hidePanelForNode(this);"/>
-    </panelview>
-
-    <panelview id="PanelUI-bookmarks" flex="1">
-      <toolbarbutton id="panelMenuBookmarkThisPage"
-                     label="&bookmarkThisPageCmd.label;"
-                     command="Browser:AddBookmarkAs"
-                     onclick="PanelUI.hide();"/>
-      <toolbarseparator/>
-      <toolbarbutton id="panelMenu_showAllBookmarks"
-                     label="&showAllBookmarks2.label;"
-                     command="Browser:ShowAllBookmarks"
-                     onclick="PanelUI.hide();"/>
-      <toolbarbutton id="panelMenu_viewBookmarksSidebar"
-                     label="&viewBookmarksSidebar2.label;"
-                     oncommand="toggleSidebar('viewBookmarksSidebar'); PanelUI.hide();">
-        <observes element="viewBookmarksSidebar" attribute="checked"/>
-      </toolbarbutton>
-      <toolbarbutton id="panelMenu_viewBookmarksToolbar"
-                     label="&viewBookmarksToolbar.label;"
-                     type="checkbox"
-                     toolbarId="PersonalToolbar"
-                     oncommand="onViewToolbarCommand(event); PanelUI.hide();"/>
-      <toolbarseparator/>
-      <toolbarbutton id="panelMenu_bookmarksToolbar"
-                     label="&personalbarCmd.label;"
-                     oncommand="PlacesCommandHook.showPlacesOrganizer('BookmarksToolbar'); PanelUI.hide();"/>
-      <toolbarbutton id="panelMenu_unsortedBookmarks"
-                     label="&unsortedBookmarksCmd.label;"
-                     oncommand="PlacesCommandHook.showPlacesOrganizer('UnfiledBookmarks'); PanelUI.hide();"/>
-      <toolbarseparator/>
-      <toolbaritem id="panelMenu_bookmarksMenu"
-                   flex="1"
-                   orient="vertical"
-                   smoothscroll="false"
-                   onclick="if (event.button == 1) BookmarkingUI.onPanelMenuViewCommand(event, this._placesView);"
-                   oncommand="BookmarkingUI.onPanelMenuViewCommand(event, this._placesView);"
-                   flatList="true"
-                   tooltip="bhTooltip">
-        <!-- bookmarks menu items -->
-      </toolbaritem>
-
-    </panelview>
-
-    <panelview id="PanelUI-feeds" flex="1" oncommand="FeedHandler.subscribeToFeed(null, event);"></panelview>
-
-    <panelview id="PanelUI-helpView" flex="1">
-      <label value="&helpMenu.label;"/>
-      <vbox id="PanelUI-helpItems"/>
-    </panelview>
-
-    <panelview id="PanelUI-developer" flex="1">
-      <label value="&webDeveloperMenu.label;"/>
-      <vbox id="PanelUI-developerItems"/>
-    </panelview>
-
-    <panelview id="PanelUI-characterEncodingView" flex="1">
-      <label value="&charsetMenu.label;"/>
-
-      <vbox id="PanelUI-characterEncodingView-customlist"
-            class="PanelUI-characterEncodingView-list"/>
-      <vbox>
-        <label value="&charsetMenuAutodet.label;"/>
-        <vbox id="PanelUI-characterEncodingView-autodetect"
-              class="PanelUI-characterEncodingView-list"/>
-      </vbox>
-    </panelview>
-
-  </panelmultiview>
-  <!-- These menupopups are located here to prevent flickering,
-       see bug 492960 comment 20. -->
-  <menupopup id="customizationPanelItemContextMenu">
-    <menuitem oncommand="gCustomizeMode.addToToolbar(document.popupNode)"
-              class="customize-context-addToToolbar"
-              accesskey="&customizeMenu.addToToolbar.accesskey;"
-              label="&customizeMenu.addToToolbar.label;"/>
-    <menuitem oncommand="gCustomizeMode.removeFromArea(document.popupNode)"
-              class="customize-context-removeFromPanel"
-              accesskey="&customizeMenu.removeFromMenu.accesskey;"
-              label="&customizeMenu.removeFromMenu.label;"/>
-    <menuseparator/>
-    <menuitem command="cmd_CustomizeToolbars"
-              class="viewCustomizeToolbar"
-              accesskey="&viewCustomizeToolbar.accesskey;"
-              label="&viewCustomizeToolbar.label;"/>
-  </menupopup>
-
-  <menupopup id="customizationPaletteItemContextMenu">
-    <menuitem oncommand="gCustomizeMode.addToToolbar(document.popupNode)"
-              class="customize-context-addToToolbar"
-              accesskey="&customizeMenu.addToToolbar.accesskey;"
-              label="&customizeMenu.addToToolbar.label;"/>
-    <menuitem oncommand="gCustomizeMode.addToPanel(document.popupNode)"
-              class="customize-context-addToPanel"
-              accesskey="&customizeMenu.addToPanel.accesskey;"
-              label="&customizeMenu.addToPanel.label;"/>
-  </menupopup>
-
-  <menupopup id="customizationPanelContextMenu">
-    <menuitem command="cmd_CustomizeToolbars"
-              accesskey="&customizeMenu.addMoreItems.accesskey;"
-              label="&customizeMenu.addMoreItems.label;"/>
-  </menupopup>
-</panel>
-
-<panel id="widget-overflow"
-       role="group"
-       type="arrow"
-       level="top"
-       hidden="true"
-       consumeoutsideclicks="true">
-  <vbox id="widget-overflow-scroller">
-    <vbox id="widget-overflow-list"/>
-  </vbox>
-</panel>
deleted file mode 100644
--- a/browser/components/customizableui/content/panelUI.js
+++ /dev/null
@@ -1,403 +0,0 @@
-/* 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/. */
-
-XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
-                                  "resource:///modules/CustomizableUI.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "ScrollbarSampler",
-                                  "resource:///modules/ScrollbarSampler.jsm");
-/**
- * Maintains the state and dispatches events for the main menu panel.
- */
-
-const PanelUI = {
-  /** Panel events that we listen for. **/
-  get kEvents() ["popupshowing", "popupshown", "popuphiding", "popuphidden"],
-  /**
-   * Used for lazily getting and memoizing elements from the document. Lazy
-   * getters are set in init, and memoizing happens after the first retrieval.
-   */
-  get kElements() {
-    return {
-      contents: "PanelUI-contents",
-      mainView: "PanelUI-mainView",
-      multiView: "PanelUI-multiView",
-      helpView: "PanelUI-helpView",
-      menuButton: "PanelUI-menu-button",
-      panel: "PanelUI-popup",
-      scroller: "PanelUI-contents-scroller"
-    };
-  },
-
-  init: function() {
-    for (let [k, v] of Iterator(this.kElements)) {
-      // Need to do fresh let-bindings per iteration
-      let getKey = k;
-      let id = v;
-      this.__defineGetter__(getKey, function() {
-        delete this[getKey];
-        return this[getKey] = document.getElementById(id);
-      });
-    }
-
-    this.menuButton.addEventListener("mousedown", this);
-    this.menuButton.addEventListener("keypress", this);
-  },
-
-  _eventListenersAdded: false,
-  _ensureEventListenersAdded: function() {
-    if (this._eventListenersAdded)
-      return;
-    this._addEventListeners();
-  },
-
-  _addEventListeners: function() {
-    for (let event of this.kEvents) {
-      this.panel.addEventListener(event, this);
-    }
-
-    this.helpView.addEventListener("ViewShowing", this._onHelpViewShow, false);
-    this.helpView.addEventListener("ViewHiding", this._onHelpViewHide, false);
-    this._eventListenersAdded = true;
-  },
-
-  uninit: function() {
-    if (!this._eventListenersAdded) {
-      return;
-    }
-
-    for (let event of this.kEvents) {
-      this.panel.removeEventListener(event, this);
-    }
-    this.helpView.removeEventListener("ViewShowing", this._onHelpViewShow);
-    this.helpView.removeEventListener("ViewHiding", this._onHelpViewHide);
-    this.menuButton.removeEventListener("mousedown", this);
-    this.menuButton.removeEventListener("keypress", this);
-  },
-
-  /**
-   * Customize mode extracts the mainView and puts it somewhere else while the
-   * user customizes. Upon completion, this function can be called to put the
-   * panel back to where it belongs in normal browsing mode.
-   *
-   * @param aMainView
-   *        The mainView node to put back into place.
-   */
-  setMainView: function(aMainView) {
-    this._ensureEventListenersAdded();
-    this.multiView.setMainView(aMainView);
-  },
-
-  /**
-   * Opens the menu panel if it's closed, or closes it if it's
-   * open.
-   *
-   * @param aEvent the event that triggers the toggle.
-   */
-  toggle: function(aEvent) {
-    // Don't show the panel if the window is in customization mode,
-    // since this button doubles as an exit path for the user in this case.
-    if (document.documentElement.hasAttribute("customizing")) {
-      return;
-    }
-    this._ensureEventListenersAdded();
-    if (this.panel.state == "open") {
-      this.hide();
-    } else if (this.panel.state == "closed") {
-      this.show(aEvent);
-    }
-  },
-
-  /**
-   * 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) {
-    if (this.panel.state == "open" || this.panel.state == "showing" ||
-        document.documentElement.hasAttribute("customizing")) {
-      return;
-    }
-
-    this.ensureReady().then(() => {
-      let editControlPlacement = CustomizableUI.getPlacementOfWidget("edit-controls");
-      if (editControlPlacement && editControlPlacement.area == CustomizableUI.AREA_PANEL) {
-        updateEditUIVisibility();
-      }
-
-      let anchor;
-      if (!aEvent ||
-          aEvent.type == "command") {
-        anchor = this.menuButton;
-      } else {
-        anchor = aEvent.target;
-      }
-      let iconAnchor =
-        document.getAnonymousElementByAttribute(anchor, "class",
-                                                "toolbarbutton-icon");
-
-      // Only focus the panel if it's opened using the keyboard, so that
-      // cut/copy/paste buttons will work for mouse users.
-      let keyboardOpened = aEvent && aEvent.sourceEvent &&
-                           aEvent.sourceEvent.target.localName == "key";
-      this.panel.setAttribute("noautofocus", !keyboardOpened);
-      this.panel.openPopup(iconAnchor || anchor, "bottomcenter topright");
-    });
-  },
-
-  /**
-   * If the menu panel is being shown, hide it.
-   */
-  hide: function() {
-    if (document.documentElement.hasAttribute("customizing")) {
-      return;
-    }
-
-    this.panel.hidePopup();
-  },
-
-  handleEvent: function(aEvent) {
-    switch (aEvent.type) {
-      case "popupshowing":
-        // Fall through
-      case "popupshown":
-        // Fall through
-      case "popuphiding":
-        // Fall through
-      case "popuphidden":
-        this._updatePanelButton(aEvent.target);
-        break;
-      case "mousedown":
-        if (aEvent.button == 0)
-          this.toggle(aEvent);
-        break;
-      case "keypress":
-        this.toggle(aEvent);
-        break;
-    }
-  },
-
-  /**
-   * Registering the menu panel is done lazily for performance reasons. This
-   * method is exposed so that CustomizationMode can force panel-readyness in the
-   * event that customization mode is started before the panel has been opened
-   * by the user.
-   *
-   * @param aCustomizing (optional) set to true if this was called while entering
-   *        customization mode. If that's the case, we trust that customization
-   *        mode will handle calling beginBatchUpdate and endBatchUpdate.
-   *
-   * @return a Promise that resolves once the panel is ready to roll.
-   */
-  ensureReady: function(aCustomizing=false) {
-    if (this._readyPromise) {
-      return this._readyPromise;
-    }
-    this._readyPromise = Task.spawn(function() {
-      if (!this._scrollWidth) {
-        // In order to properly center the contents of the panel, while ensuring
-        // that we have enough space on either side to show a scrollbar, we have to
-        // do a bit of hackery. In particular, we calculate a new width for the
-        // scroller, based on the system scrollbar width.
-        this._scrollWidth =
-          (yield ScrollbarSampler.getSystemScrollbarWidth()) + "px";
-        let cstyle = window.getComputedStyle(this.scroller);
-        let widthStr = cstyle.width;
-        // Get the calculated padding on the left and right sides of
-        // the scroller too. We'll use that in our final calculation so
-        // that if a scrollbar appears, we don't have the contents right
-        // up against the edge of the scroller.
-        let paddingLeft = cstyle.paddingLeft;
-        let paddingRight = cstyle.paddingRight;
-        let calcStr = [widthStr, this._scrollWidth,
-                       paddingLeft, paddingRight].join(" + ");
-        this.scroller.style.width = "calc(" + calcStr + ")";
-      }
-
-      if (aCustomizing) {
-        CustomizableUI.registerMenuPanel(this.contents);
-      } else {
-        this.beginBatchUpdate();
-        try {
-          CustomizableUI.registerMenuPanel(this.contents);
-        } finally {
-          this.endBatchUpdate();
-        }
-      }
-      this.panel.hidden = false;
-    }.bind(this)).then(null, Cu.reportError);
-
-    return this._readyPromise;
-  },
-
-  /**
-   * Switch the panel to the main view if it's not already
-   * in that view.
-   */
-  showMainView: function() {
-    this._ensureEventListenersAdded();
-    this.multiView.showMainView();
-  },
-