Bug 599325 - Addon bar should be shown when customizing (r=mano, a=blocking)
authorDietrich Ayala <dietrich@mozilla.com>
Tue, 16 Nov 2010 20:06:18 +0700
changeset 57572 2bcf34fc37a76cb179447839bfb30e30f1f1efb0
parent 57571 a42e9b001bc86834134c57d15f519a3b67eb8fcf
child 57573 6b25735eebd08801845e958e0f88ee5c1d57f79a
push id16986
push userdietrich@mozilla.com
push dateTue, 16 Nov 2010 13:18:17 +0000
treeherdermozilla-central@2bcf34fc37a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmano, blocking
bugs599325
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 599325 - Addon bar should be shown when customizing (r=mano, a=blocking)
browser/base/content/browser.js
browser/base/content/test/Makefile.in
browser/base/content/test/browser_bug599325.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3427,16 +3427,22 @@ function BrowserCustomizeToolbar()
   if (splitter)
     splitter.parentNode.removeChild(splitter);
 
   CombinedStopReload.uninit();
 
   PlacesToolbarHelper.customizeStart();
   BookmarksMenuButton.customizeStart();
 
+  let addonBar = document.getElementById("addon-bar");
+  if (addonBar.collapsed) {
+    addonBar.wasCollapsed = addonBar.collapsed;
+    addonBar.collapsed = false;
+  }
+
   var customizeURL = "chrome://global/content/customizeToolbar.xul";
   gCustomizeSheet = getBoolPref("toolbar.customization.usesheet", false);
 
   if (gCustomizeSheet) {
     var sheetFrame = document.getElementById("customizeToolbarSheetIFrame");
     var panel = document.getElementById("customizeToolbarSheetPopup");
     sheetFrame.hidden = false;
     sheetFrame.toolbox = gNavToolbox;
@@ -3485,16 +3491,22 @@ function BrowserToolboxCustomizeDone(aTo
 #ifndef XP_MACOSX
     updateEditUIVisibility();
 #endif
   }
 
   PlacesToolbarHelper.customizeDone();
   BookmarksMenuButton.customizeDone();
 
+  let addonBar = document.getElementById("addon-bar");
+  if (addonBar.wasCollapsed === true) {
+    addonBar.collapsed = true;
+    delete addonBar.wasCollapsed;
+  }
+
   // 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();
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -155,16 +155,17 @@ endif
                  browser_bug581947.js \
                  browser_bug585785.js \
                  browser_bug585830.js \
                  browser_bug592338.js \
                  browser_bug594131.js \
                  browser_bug595507.js \
                  browser_bug596687.js \
                  browser_bug597218.js \
+                 browser_bug599325.js \
                  browser_bug609700.js \
                  browser_contextSearchTabPosition.js \
                  browser_ctrlTab.js \
                  browser_discovery.js \
                  browser_duplicateIDs.js \
                  browser_gestureSupport.js \
                  browser_getshortcutoruri.js \
                  browser_hide_removing.js \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/browser_bug599325.js
@@ -0,0 +1,63 @@
+function test() {
+  waitForExplicitFinish();
+  
+  // test the main (normal) browser window
+  testCustomize(window, testChromeless);
+}
+
+function testChromeless() {
+  // test a chromeless window
+  var newWin = openDialog("chrome://browser/content/", "_blank",
+                      "chrome,dialog=no,toolbar=no", "about:blank");
+  ok(newWin, "got new window");
+
+  function runWindowTest() {
+    function finalize() {
+      newWin.removeEventListener("load", runWindowTest, false);
+      newWin.close();
+      finish();
+    }
+    testCustomize(newWin, finalize);
+  }
+
+  newWin.addEventListener("load", runWindowTest, false);
+}
+
+function testCustomize(aWindow, aCallback) {
+  var addonBar = aWindow.document.getElementById("addon-bar");
+  ok(addonBar, "got addon bar");
+  is(addonBar.collapsed, true, "addon bar initially disabled");
+
+  // Launch toolbar customization
+  // ctEl is either iframe that contains the customize sheet, or the dialog
+  var ctEl = aWindow.BrowserCustomizeToolbar();
+
+  is(addonBar.collapsed, false,
+     "file menu is not collapsed during toolbar customization");
+
+  aWindow.gNavToolbox.addEventListener("beforecustomization", function () {
+    aWindow.gNavToolbox.removeEventListener("beforecustomization", arguments.callee, false);
+    executeSoon(ctInit);
+  }, false);
+
+  function ctInit() {
+    // Close toolbar customization
+    closeToolbarCustomization(aWindow, ctEl);
+
+    is(addonBar.getAttribute("collapsed"), "true",
+       "addon bar is collapsed after toolbar customization");
+
+    if (aCallback)
+      aCallback();
+  }
+}
+
+function closeToolbarCustomization(aWindow, aCTWindow) {
+  // Force the cleanup code to be run now instead of onunload.
+  // This also hides the sheet on Mac.
+  aCTWindow.finishToolbarCustomization();
+
+  // On windows and linux, need to explicitly close the window.
+  if (!gCustomizeSheet)
+    aCTWindow.close();
+}