Bug 585855 - Test that the bookmark all tabs command is disabled when we have one visible and one hidden tab [r=dão sr=vlad a=gavin]
authorRaymond Lee <raymond@raysquare.com>
Sat, 14 Aug 2010 02:36:40 +0800
changeset 50697 62d9ac4292784438509be605608eca2924cff2ed
parent 50696 f61b0b275541b781d87b11ab4320d203b81c1c79
child 50698 8fb3151c8db4c44eeee4a5c14e0a53af9a9baf32
child 51320 dcae4884a07dc0ea779880f539cdcae36ae00fde
push idunknown
push userunknown
push dateunknown
reviewersd, vlad, gavin
bugs585855
milestone2.0b4pre
Bug 585855 - Test that the bookmark all tabs command is disabled when we have one visible and one hidden tab [r=dão sr=vlad a=gavin]
browser/base/content/browser.js
browser/base/content/tabbrowser.xml
browser/base/content/tabview/ui.js
browser/base/content/test/Makefile.in
browser/base/content/test/browser_visibleTabs_bookmarkAllPages.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6764,18 +6764,18 @@ function formatURL(aFormat, aIsPref) {
  * This also takes care of updating the command enabled-state when tabs are
  * created or removed.
  */
 var gBookmarkAllTabsHandler = {
   init: function () {
     this._command = document.getElementById("Browser:BookmarkAllTabs");
     gBrowser.tabContainer.addEventListener("TabOpen", this, true);
     gBrowser.tabContainer.addEventListener("TabClose", this, true);
-    gBrowser.tabContainer.addEventListener("TabSelect", this, true);
-    gBrowser.tabContainer.addEventListener("TabMove", this, true);
+    gBrowser.tabContainer.addEventListener("TabShow", this, true);
+    gBrowser.tabContainer.addEventListener("TabHide", this, true);
     this._updateCommandState();
   },
 
   _updateCommandState: function BATH__updateCommandState() {
     let remainingTabs = gBrowser.visibleTabs.filter(function(tab) {
       return gBrowser._removingTabs.indexOf(tab) == -1;
     });
 
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -764,17 +764,17 @@
                 (oldBrowser.pageReport && !newBrowser.pageReport) ||
                 (!oldBrowser.pageReport && newBrowser.pageReport))
               updatePageReport = true;
 
             newBrowser.setAttribute("type", "content-primary");
             newBrowser.docShell.isActive = true;
             this.mCurrentBrowser = newBrowser;
             this.mCurrentTab = this.selectedTab;
-            this.mCurrentTab.hidden = false;
+            this.showTab(this.mCurrentTab);
 
             if (updatePageReport)
               this.mCurrentBrowser.updatePageReport();
 
             // Update the URL bar.
             var loc = this.mCurrentBrowser.currentURI;
 
             var webProgress = this.mCurrentBrowser.webProgress;
@@ -1786,18 +1786,49 @@
         </body>
       </method>
 
       <method name="showOnlyTheseTabs">
         <parameter name="aTabs"/>
         <body>
         <![CDATA[
           Array.forEach(this.tabs, function(tab) {
-            tab.hidden = aTabs.indexOf(tab) == -1 && !tab.pinned && !tab.selected;
-          });
+            if (aTabs.indexOf(tab) == -1)
+              this.hideTab(tab);
+            else
+              this.showTab(tab);
+          }, this);
+        ]]>
+        </body>
+      </method>
+
+      <method name="showTab">
+        <parameter name="aTab"/>
+        <body>
+        <![CDATA[
+          if (aTab.hidden) {
+            aTab.hidden = false;
+            let event = document.createEvent("Events");
+            event.initEvent("TabShow", true, false);
+            aTab.dispatchEvent(event);
+          }
+        ]]>
+        </body>
+      </method>
+
+      <method name="hideTab">
+        <parameter name="aTab"/>
+        <body>
+        <![CDATA[
+          if (!aTab.hidden && !aTab.pinned && !aTab.selected) {
+            aTab.hidden = true;
+            let event = document.createEvent("Events");
+            event.initEvent("TabHide", true, false);
+            aTab.dispatchEvent(event);
+          }
         ]]>
         </body>
       </method>
 
       <method name="selectTabAtIndex">
         <parameter name="aIndex"/>
         <parameter name="aEvent"/>
         <body>
--- a/browser/base/content/tabview/ui.js
+++ b/browser/base/content/tabview/ui.js
@@ -120,17 +120,17 @@ var UIManager = {
           });
         }
         if (e.originalTarget.id == "content")
           self._createGroupItemOnDrag(e)
       });
 
       iQ(window).bind("beforeunload", function() {
         Array.forEach(gBrowser.tabs, function(tab) {
-          tab.hidden = false;
+          gBrowser.showTab(tab);
         });
       });
       iQ(window).bind("unload", function() {
         self.uninit();
       });
 
       gWindow.addEventListener("tabviewhide", function() {
         var activeTab = self.getActiveTab();
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -166,16 +166,17 @@ endif
                  browser_sanitizeDialog.js \
                  browser_scope.js \
                  browser_selectTabAtIndex.js \
                  browser_tabfocus.js \
                  browser_tabs_owner.js \
                  browser_visibleTabs.js \
                  browser_visibleTabs_contextMenu.js \
                  browser_visibleTabs_bookmarkAllPages.js \
+                 browser_visibleTabs_bookmarkAllTabs.js \
                  browser_visibleTabs_tabPreview.js \
                  discovery.html \
                  moz.png \
                  test_bug435035.html \
                  test_bug462673.html \
                  page_style_sample.html \
                  feed_tab.html \
                  plugin_unknown.html \
--- a/browser/base/content/test/browser_visibleTabs_bookmarkAllPages.js
+++ b/browser/base/content/test/browser_visibleTabs_bookmarkAllPages.js
@@ -53,15 +53,15 @@ function test() {
     let uris = PlacesCommandHook._getUniqueTabInfo();
     is(uris.length, 1, "Only one uri is returned");
 
     is(uris[0].spec, tabTwo.linkedBrowser.currentURI.spec, "It's the correct URI");
 
     gBrowser.removeTab(tabOne);
     gBrowser.removeTab(tabTwo);
     Array.forEach(gBrowser.tabs, function(tab) {
-      tab.hidden = false;
+      gBrowser.showTab(tab);
     });
 
     finish();
   }
   browser.addEventListener("load", onLoad, true);
 }