Bug 641802 - 'Move to group' option stays populated with the old data even after the groups have been deleted in panorama [f=raymond, r=ian]
authorTim Taubert <tim.taubert@gmx.de>
Wed, 06 Apr 2011 14:03:41 -0700
changeset 67650 6d32268b979211c753a66ae654c1422cab718a8c
parent 67649 75ff341e00a6434ac6f041831985ac4fc707d32c
child 67651 3f0b5355069a5b5605a1191e8e4ebd2a4d248c40
push id19407
push usereakhgari@mozilla.com
push dateFri, 08 Apr 2011 18:05:50 +0000
treeherdermozilla-central@1d17596bbf5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersian
bugs641802
milestone2.2a1pre
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 641802 - 'Move to group' option stays populated with the old data even after the groups have been deleted in panorama [f=raymond, r=ian]
browser/base/content/browser-tabview.js
browser/base/content/test/tabview/Makefile.in
browser/base/content/test/tabview/browser_tabview_bug641802.js
--- a/browser/base/content/browser-tabview.js
+++ b/browser/base/content/browser-tabview.js
@@ -315,18 +315,20 @@ let TabView = {
   afterUndoCloseTab: function () {
     if (this._window)
       this._window.UI.restoredClosedTab = false;
   },
 
   // ----------
   // On move to group pop showing.
   moveToGroupPopupShowing: function TabView_moveToGroupPopupShowing(event) {
-    // there are hidden tabs so initialize the iframe and update the context menu
-    if ((gBrowser.tabs.length - gBrowser.visibleTabs.length) > 0)
+    // Update the context menu only if Panorama was already initialized or if
+    // there are hidden tabs.
+    let numHiddenTabs = gBrowser.tabs.length - gBrowser.visibleTabs.length;
+    if (this._window || numHiddenTabs > 0)
       this.updateContextMenu(TabContextMenu.contextTab, event.target);
   },
 
   // ----------
   // Function: _addToolbarButton
   // Adds the TabView button to the TabsToolbar.
   _addToolbarButton: function TabView__addToolbarButton() {
     let buttonId = "tabview-button";
--- a/browser/base/content/test/tabview/Makefile.in
+++ b/browser/base/content/test/tabview/Makefile.in
@@ -118,16 +118,17 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug630157.js \
                  browser_tabview_bug631662.js \
                  browser_tabview_bug631752.js \
                  browser_tabview_bug633788.js \
                  browser_tabview_bug634077.js \
                  browser_tabview_bug634085.js \
                  browser_tabview_bug634158.js \
                  browser_tabview_bug635696.js \
+                 browser_tabview_bug641802.js \
                  browser_tabview_bug645653.js \
                  browser_tabview_dragdrop.js \
                  browser_tabview_exit_button.js \
                  browser_tabview_expander.js \
                  browser_tabview_firstrun_pref.js \
                  browser_tabview_group.js \
                  browser_tabview_launch.js \
                  browser_tabview_multiwindow_search.js \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug641802.js
@@ -0,0 +1,64 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  let openMoveToGroupPopup = function () {
+    let tab = gBrowser.selectedTab;
+    document.popupNode = tab;
+    contextMenu.openPopup(tab, "end_after", 0, 0, true, false);
+    tvMenuPopup.openPopup(tvMenu, "end_after", 0, 0, true, false);
+  }
+
+  let hideMoveToGroupPopup = function () {
+    tvMenuPopup.hidePopup();
+    contextMenu.hidePopup();
+  }
+
+  let assertValidPrerequisites = function (visible) {
+    let cw = TabView.getContentWindow();
+    is(cw.GroupItems.groupItems.length, 1, "there is one groupItem");
+    is(gBrowser.tabs.length, 1, "there is one tab");
+    is(TabView.isVisible(), visible, "tabview is visible");
+  }
+
+  let tvMenu = document.getElementById("context_tabViewMenu");
+  let contextMenu = document.getElementById("tabContextMenu");
+  let tvMenuPopup = document.getElementById("context_tabViewMenuPopup");
+
+  waitForExplicitFinish();
+
+  registerCleanupFunction(function () {
+    hideMoveToGroupPopup();
+    hideTabView(function () {});
+
+    let groupItems = TabView.getContentWindow().GroupItems.groupItems;
+    if (groupItems.length > 1)
+      closeGroupItem(groupItems[0], function () {});
+  });
+
+  showTabView(function () {
+    assertValidPrerequisites(true);
+
+    hideTabView(function () {
+      let groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1);
+      groupItem.setTitle("group2");
+
+      gBrowser.selectedTab = gBrowser.tabs[0];
+
+      executeSoon(function () {
+        openMoveToGroupPopup();
+        is(tvMenuPopup.firstChild.getAttribute("label"), "group2", "menuItem is present");
+        hideMoveToGroupPopup();
+
+        closeGroupItem(groupItem, function () {
+          openMoveToGroupPopup();
+          is(tvMenuPopup.firstChild.tagName, "menuseparator", "menuItem is not present");
+          hideMoveToGroupPopup();
+
+          assertValidPrerequisites(false);
+          finish();
+        });
+      });
+    });
+  });
+}