Bug 658738 - reset TabContextMenu.contextTab when manually calling TabContextMenu.updateContextMenu
authorDão Gottwald <dao@mozilla.com>
Sun, 12 Jun 2011 21:49:35 +0200
changeset 70952 bbbc80a2bd8cd616e1341637148494d53ad6ade2
parent 70951 b892cefd50005a9ad11cef6dd325d672a0867f76
child 70953 78ad95eaf1f140ec71b81c6701652b91f167e95a
push id20457
push userdgottwald@mozilla.com
push dateMon, 13 Jun 2011 06:46:49 +0000
treeherdermozilla-central@bbbc80a2bd8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs658738
milestone7.0a1
first release with
nightly linux32
bbbc80a2bd8c / 7.0a1 / 20110613030722 / files
nightly linux64
bbbc80a2bd8c / 7.0a1 / 20110613030722 / files
nightly mac
bbbc80a2bd8c / 7.0a1 / 20110613030722 / files
nightly win32
bbbc80a2bd8c / 7.0a1 / 20110613030722 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 658738 - reset TabContextMenu.contextTab when manually calling TabContextMenu.updateContextMenu
browser/base/content/test/browser_bug580956.js
browser/base/content/test/browser_visibleTabs_bookmarkAllTabs.js
browser/base/content/test/browser_visibleTabs_contextMenu.js
browser/base/content/test/tabview/browser_tabview_bug625195.js
browser/base/content/test/tabview/browser_tabview_bug626791.js
--- a/browser/base/content/test/browser_bug580956.js
+++ b/browser/base/content/test/browser_bug580956.js
@@ -1,16 +1,17 @@
 function numClosedTabs()
   Cc["@mozilla.org/browser/sessionstore;1"].
     getService(Ci.nsISessionStore).
     getClosedTabCount(window);
 
 function isUndoCloseEnabled() {
   document.popupNode = gBrowser.tabs[0];
   TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
+  TabContextMenu.contextTab = null;
   return !document.getElementById("context_undoCloseTab").disabled;
 }
 
 function test() {
   waitForExplicitFinish();
 
   gPrefService.setIntPref("browser.sessionstore.max_tabs_undo", 0);
   gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");
--- a/browser/base/content/test/browser_visibleTabs_bookmarkAllTabs.js
+++ b/browser/base/content/test/browser_visibleTabs_bookmarkAllTabs.js
@@ -86,17 +86,18 @@ function test() {
     is(origTab.hidden, false, "and it's not hidden -- visible!");
     finish();
   }, true);
 }
 
 function Disabled() {
   document.popupNode = gBrowser.selectedTab;
   TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
-  let command = document.getElementById("Browser:BookmarkAllTabs");
-  return command.hasAttribute("disabled") && command.getAttribute("disabled") === "true";
+  TabContextMenu.contextTab = null;
+  return document.getElementById("Browser:BookmarkAllTabs").getAttribute("disabled") == "true";
 }
 
 function Hidden() {
   document.popupNode = gBrowser.selectedTab;
   TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
+  TabContextMenu.contextTab = null;
   return document.getElementById("context_bookmarkAllTabs").hidden;
 }
--- a/browser/base/content/test/browser_visibleTabs_contextMenu.js
+++ b/browser/base/content/test/browser_visibleTabs_contextMenu.js
@@ -39,51 +39,49 @@ function test() {
   // There should be one tab when we start the test
   let [origTab] = gBrowser.visibleTabs;
   is(gBrowser.visibleTabs.length, 1, "there is one visible tab");
   let testTab = gBrowser.addTab();
   is(gBrowser.visibleTabs.length, 2, "there are now two visible tabs");
 
   // Check the context menu with two tabs
   popup(origTab);
-  is(TabContextMenu.contextTab, origTab, "TabContextMenu context is the original tab");
   is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled");
   is(document.getElementById("context_reloadAllTabs").disabled, false, "Reload All Tabs is enabled");
 
   // Hide the original tab.
   gBrowser.selectedTab = testTab;
   gBrowser.showOnlyTheseTabs([testTab]);
   is(gBrowser.visibleTabs.length, 1, "now there is only one visible tab");
   
   // Check the context menu with one tab.
   popup(testTab);
-  is(TabContextMenu.contextTab, testTab, "TabContextMenu context is the test tab");
   is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled when more than one tab exists");
   is(document.getElementById("context_reloadAllTabs").disabled, true, "Reload All Tabs is disabled");
   
   // Add a tab that will get pinned
   // So now there's one pinned tab, one visible unpinned tab, and one hidden tab
   let pinned = gBrowser.addTab();
   gBrowser.pinTab(pinned);
   is(gBrowser.visibleTabs.length, 2, "now there are two visible tabs");
 
   // Check the context menu on the unpinned visible tab
   popup(testTab);
-  is(TabContextMenu.contextTab, testTab, "TabContextMenu context is again the test tab");
   is(document.getElementById("context_closeOtherTabs").disabled, true, "Close Other Tabs is disabled");
 
   // Show all tabs
   let allTabs = [tab for each (tab in gBrowser.tabs)];
   gBrowser.showOnlyTheseTabs(allTabs);
 
   // Check the context menu now
   popup(testTab);
-  is(TabContextMenu.contextTab, testTab, "TabContextMenu context is yet again the test tab");
   is(document.getElementById("context_closeOtherTabs").disabled, false, "Close Other Tabs is enabled");
   
   gBrowser.removeTab(testTab);
   gBrowser.removeTab(pinned);
 }
 
 function popup(tab) {
   document.popupNode = tab;
   TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
-}
\ No newline at end of file
+  is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
+  TabContextMenu.contextTab = null;
+}
--- a/browser/base/content/test/tabview/browser_tabview_bug625195.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug625195.js
@@ -44,10 +44,12 @@ function test() {
     let newGroup = contentWindow.GroupItems.newGroup();
     newGroup.newTab();
   });
 }
 
 function popup(tab) {
   document.popupNode = tab;
   TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
+  is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
+  TabContextMenu.contextTab = null;
 }
 
--- a/browser/base/content/test/tabview/browser_tabview_bug626791.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug626791.js
@@ -134,46 +134,45 @@ function test() {
       next();
     });
   }
 
   let tests = [testNameGroup, testDragToCreateGroup, testCreateOrphan,
                testDragToCreateOrphan, testReAddingAfterRemoval];
 
   let next = function () {
+    if (win)
+      win.close();
+
     let test = tests.shift();
 
     if (!test) {
       finish();
       return;
     }
 
-    if (win)
-      win.close();
-
     TabView.firstUseExperienced = false;
 
     let onLoad = function (newWin) {
       win = newWin;
       removeToolbarButton();
-    }
+    };
 
     let onShow = function () {
       cw = win.TabView.getContentWindow();
 
       let groupItem = cw.GroupItems.groupItems[0];
       groupItem.setSize(200, 200, true);
       groupItem.setUserSize();
 
       SimpleTest.waitForFocus(function () {
         assertToolbarButtonNotExists();
         test();
       }, cw);
-    }
+    };
 
     newWindowWithTabView(onShow, onLoad);
   }
 
   waitForExplicitFinish();
-  registerCleanupFunction(function () win && win.close());
 
   next();
 }