No bug - Remove browserWindowsCount checks from sessionstore tests since the browser-chrome test framework does similar checks
authorDão Gottwald <dao@mozilla.com>
Sat, 25 Jun 2011 09:39:42 +0200
changeset 71690 b7439d5baf498cfe625ba8b7b4af1ebc2bb39dae
parent 71689 ce10fd5d82c64d7c1fda532619e89ddd4a8526ad
child 71691 a8b1330b8ac90438340562cd10f5da9e28ffcd65
push id20599
push userdgottwald@mozilla.com
push dateSat, 25 Jun 2011 07:42:50 +0000
treeherdermozilla-central@a8b1330b8ac9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone7.0a1
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
No bug - Remove browserWindowsCount checks from sessionstore tests since the browser-chrome test framework does similar checks
browser/components/sessionstore/test/browser/browser_394759_privatebrowsing.js
browser/components/sessionstore/test/browser/browser_423132.js
browser/components/sessionstore/test/browser/browser_461634.js
browser/components/sessionstore/test/browser/browser_464199.js
browser/components/sessionstore/test/browser/browser_465223.js
browser/components/sessionstore/test/browser/browser_477657.js
browser/components/sessionstore/test/browser/browser_480148.js
browser/components/sessionstore/test/browser/browser_490040.js
browser/components/sessionstore/test/browser/browser_491168.js
browser/components/sessionstore/test/browser/browser_491577.js
browser/components/sessionstore/test/browser/browser_493467.js
browser/components/sessionstore/test/browser/browser_495495.js
browser/components/sessionstore/test/browser/browser_514751.js
browser/components/sessionstore/test/browser/browser_522545.js
browser/components/sessionstore/test/browser/browser_524745.js
browser/components/sessionstore/test/browser/browser_597071.js
--- a/browser/components/sessionstore/test/browser/browser_394759_privatebrowsing.js
+++ b/browser/components/sessionstore/test/browser/browser_394759_privatebrowsing.js
@@ -32,29 +32,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Private Browsing Test for Bug 394759 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   waitForExplicitFinish();
 
   // Set interval to a large time so state won't be written while we setup env.
   gPrefService.setIntPref("browser.sessionstore.interval", 100000);
 
   // Set up the browser in a blank state. Popup windows in previous tests result
   // in different states on different platforms.
@@ -165,19 +154,17 @@ function continue_test() {
 
                     let data = JSON.parse(ss.getClosedWindowData())[0];
                     ok(JSON.stringify(data).indexOf(TESTS[aTestIndex - 1].value) > -1,
                        "The data associated with the recently closed window was " +
                        "restored when exiting PB mode");
                   }
 
                   if (aTestIndex == TESTS.length - 1) {
-                    if (gPrefService.prefHasUserValue("browser.sessionstore.interval"))
-                      gPrefService.clearUserPref("browser.sessionstore.interval");
-                    is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
+                    gPrefService.clearUserPref("browser.sessionstore.interval");
                     finish();
                   }
                   else {
                     // Run next test.
                     openWindowAndTest(aTestIndex + 1, !aRunNextTestInPBMode);
                   }
                 });
               });
--- a/browser/components/sessionstore/test/browser/browser_423132.js
+++ b/browser/components/sessionstore/test/browser/browser_423132.js
@@ -29,30 +29,19 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   // test that cookies are stored and restored correctly by sessionstore,
   // bug 423132.
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   // test setup
   waitForExplicitFinish();
 
   let cs = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
   cs.removeAll();
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
@@ -107,14 +96,13 @@ function test() {
       is(cookie.value, cookie2.value, "cookie value successfully restored");
       is(cookie.path, cookie2.path, "cookie path successfully restored");
 
       // clean up
       if (gPrefService.prefHasUserValue("browser.sessionstore.interval"))
         gPrefService.clearUserPref("browser.sessionstore.interval");
       cs.removeAll();
       newWin.close();
-      is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
       finish();
     }, true);
   }, false);
 }
 
--- a/browser/components/sessionstore/test/browser/browser_461634.js
+++ b/browser/components/sessionstore/test/browser/browser_461634.js
@@ -30,29 +30,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 461634 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   // test setup
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
 
   const REMEMBER = Date.now(), FORGET = Math.random();
   let test_state = { windows: [{ "tabs": [{ "entries": [] }], _closedTabs: [
     { state: { entries: [{ url: "http://www.example.net/" }] }, title: FORGET },
@@ -110,13 +99,12 @@ function test() {
        "The correct amout of tabs was removed");
     is(countByTitle(closedTabs, FORGET), 0,
        "All tabs specifically forgotten were indeed removed");
     is(countByTitle(closedTabs, REMEMBER), remember_count,
        "... and tabs not specifically forgetten weren't.");
 
     // clean up
     newWin.close();
-    is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
     gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");
     finish();
   }, false);
 }
--- a/browser/components/sessionstore/test/browser/browser_464199.js
+++ b/browser/components/sessionstore/test/browser/browser_464199.js
@@ -29,29 +29,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 464199 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   // test setup
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
 
   const REMEMBER = Date.now(), FORGET = Math.random();
   let test_state = { windows: [{ "tabs": [{ "entries": [] }], _closedTabs: [
     { state: { entries: [{ url: "http://www.example.net/" }] }, title: FORGET },
@@ -110,14 +99,12 @@ function test() {
        "The correct amout of tabs was removed");
     is(countByTitle(closedTabs, FORGET), 0,
        "All tabs to be forgotten were indeed removed");
     is(countByTitle(closedTabs, REMEMBER), remember_count,
        "... and tabs to be remembered weren't.");
 
     // clean up
     newWin.close();
-    is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
-    if (gPrefService.prefHasUserValue("browser.sessionstore.max_tabs_undo"))
-      gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");
+    gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");
     finish();
   }, false);
 }
--- a/browser/components/sessionstore/test/browser/browser_465223.js
+++ b/browser/components/sessionstore/test/browser/browser_465223.js
@@ -29,29 +29,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 465223 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   // test setup
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
 
   let uniqueKey1 = "bug 465223.1";
   let uniqueKey2 = "bug 465223.2";
   let uniqueValue1 = "unik" + Date.now();
@@ -82,12 +71,11 @@ function test() {
        "original tabs were overwritten");
     is(ss.getWindowValue(newWin, uniqueKey1), "",
        "window value was cleared");
     is(ss.getWindowValue(newWin, uniqueKey2), uniqueValue1,
        "window value was correctly overwritten");
 
     // clean up
     newWin.close();
-    is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
     finish();
   }, false);
 }
--- a/browser/components/sessionstore/test/browser/browser_477657.js
+++ b/browser/components/sessionstore/test/browser/browser_477657.js
@@ -29,29 +29,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 477657 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   // Test fails randomly on OS X (bug 482975)
   if ("nsILocalFileMac" in Ci)
     return;
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
   
@@ -99,15 +88,14 @@ function test() {
         newState.windows[0].sizemode = "normal";
         ss.setWindowState(newWin, JSON.stringify(newState), true);
 
         setTimeout(function() {
           isnot(newWin.windowState, newWin.STATE_MAXIMIZED,
                 "the window was explicitly unmaximized");
 
           newWin.close();
-          is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
           finish();
         }, 0);
       }, 0);
     }, 0);
   }, false);
 }
--- a/browser/components/sessionstore/test/browser/browser_480148.js
+++ b/browser/components/sessionstore/test/browser/browser_480148.js
@@ -29,30 +29,19 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 484108 **/
   requestLongerTimeout(2);
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
 
   // builds the tests state based on a few parameters
   function buildTestState(num, selected, hidden) {
     let state = { windows: [ { "tabs": [], "selected": selected } ] };
     while (num--) {
@@ -119,17 +108,16 @@ function test() {
            "Test #" + testNum + ": 'visible' tabs restored first");
 
         // cleanup
         this.window.close();
         // if we're all done, explicitly finish
         if (++completedTests == numTests) {
           this.window.removeEventListener("load", this, false);
           this.window.removeEventListener("SSTabRestoring", this, false);
-          is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
           finish();
         }
       },
 
       handleLoad: function (aEvent) {
         let _this = this;
         executeSoon(function () {
           let extent = _this.window.outerWidth - _this.window.gBrowser.tabContainer.mTabstrip.scrollClientSize;
--- a/browser/components/sessionstore/test/browser/browser_490040.js
+++ b/browser/components/sessionstore/test/browser/browser_490040.js
@@ -30,29 +30,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 490040 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].
            getService(Ci.nsISessionStore);
 
   waitForExplicitFinish();
 
   function testWithState(aState) {
     // Ensure we can store the window if needed.
@@ -156,17 +145,15 @@ function test() {
   ];
 
   function runNextTest() {
     if (states.length) {
       let state = states.shift();
       testWithState(state);
     }
     else {
-      if (gPrefService.prefHasUserValue("browser.sessionstore.max_windows_undo"))
-        gPrefService.clearUserPref("browser.sessionstore.max_windows_undo");
-      is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
+      gPrefService.clearUserPref("browser.sessionstore.max_windows_undo");
       finish();
     }
   }
   runNextTest();
 }
 
--- a/browser/components/sessionstore/test/browser/browser_491168.js
+++ b/browser/components/sessionstore/test/browser/browser_491168.js
@@ -29,29 +29,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 491168 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   // test setup
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
 
   waitForExplicitFinish();
 
   const REFERRER1 = "http://example.org/?" + Date.now();
   const REFERRER2 = "http://example.org/?" + Math.random();
@@ -77,17 +66,16 @@ function test() {
       gBrowser.removeTab(tab);
       let newTab = ss.undoCloseTab(window, 0);
       newTab.addEventListener("SSTabRestored", function() {
         newTab.removeEventListener("SSTabRestored", arguments.callee, true);
 
         is(window.content.document.referrer, REFERRER2, "document.referrer is still correct after closing and reopening the tab.");
         gBrowser.removeTab(newTab);
 
-        is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
         finish();
       }, true);
     }, true);
   },true);
 
   let referrerURI = Services.io.newURI(REFERRER1, null, null);
   browser.loadURI("http://example.org", referrerURI, null);
 }
--- a/browser/components/sessionstore/test/browser/browser_491577.js
+++ b/browser/components/sessionstore/test/browser/browser_491577.js
@@ -30,29 +30,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 491577 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
   
   // test setup
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
   
   const REMEMBER = Date.now(), FORGET = Math.random();
   let test_state = {
     windows: [ { tabs: [{ entries: [{ url: "http://example.com/" }] }], selected: 1 } ],
@@ -155,14 +144,12 @@ function test() {
        "The correct amount of windows were removed");
     is(countByTitle(closedWindows, FORGET), 0,
        "All windows specifically forgotten were indeed removed");
     is(countByTitle(closedWindows, REMEMBER), remember_count,
        "... and windows not specifically forgetten weren't.");
 
     // clean up
     newWin.close();
-    is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
-    if (gPrefService.prefHasUserValue("browser.sessionstore.max_windows_undo"))
-      gPrefService.clearUserPref("browser.sessionstore.max_windows_undo");
+    gPrefService.clearUserPref("browser.sessionstore.max_windows_undo");
     finish();
   }, false);
 }
--- a/browser/components/sessionstore/test/browser/browser_493467.js
+++ b/browser/components/sessionstore/test/browser/browser_493467.js
@@ -29,29 +29,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 493467 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
   
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   
   let tab = gBrowser.addTab();
   tab.linkedBrowser.stop();
   let tabState = JSON.parse(ss.getTabState(tab));
   is(tabState.disallow || "", "", "Everything is allowed per default");
   
@@ -72,10 +61,9 @@ function test() {
   let disallow = tabState.disallow.split(",");
   permissions.forEach(function(aName) {
     ok(disallow.indexOf(aName) > -1, "Saved state of allow" + aName);
   });
   // IF A TEST FAILS, please add the missing permission's name (without the
   // leading "allow") to nsSessionStore.js's CAPABILITIES array. Thanks.
   
   gBrowser.removeTab(tab);
-  is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
 }
--- a/browser/components/sessionstore/test/browser/browser_495495.js
+++ b/browser/components/sessionstore/test/browser/browser_495495.js
@@ -29,29 +29,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 495495 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
   
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
   waitForExplicitFinish();
 
   let newWin = openDialog(location, "_blank", "chrome,all,dialog=no,toolbar=yes");
   newWin.addEventListener("load", function() {
     newWin.removeEventListener("load", arguments.callee, false);
 
@@ -84,20 +73,15 @@ function test() {
                  "URL bar autocomplete state should be restored correctly");
 
               win.close();
               executeSoon(callback);
             }, false);
           }
 
           testState(state1, {readOnly: false, enablehistory: "true"}, function() {
-            testState(state2, {readOnly: true, enablehistory: "false"}, function() {
-              executeSoon(function () {
-                is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
-                finish();
-              });
-            });
+            testState(state2, {readOnly: true, enablehistory: "false"}, finish);
           });
         });
       }, false);
     });
   }, false);
 }
--- a/browser/components/sessionstore/test/browser/browser_514751.js
+++ b/browser/components/sessionstore/test/browser/browser_514751.js
@@ -29,29 +29,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 514751 (Wallpaper) **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].
            getService(Ci.nsISessionStore);
 
   waitForExplicitFinish();
 
   let state = {
     windows: [{
@@ -73,14 +62,13 @@ function test() {
       try {
         ss.setWindowState(theWin, JSON.stringify(state), true);
       } catch (e) {
         if (/NS_ERROR_MALFORMED_URI/.test(e))
           gotError = true;
       }
       ok(!gotError, "Didn't get a malformed URI error.");
       theWin.close();
-      is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
       finish();
     });
   }, false);
 }
 
--- a/browser/components/sessionstore/test/browser/browser_522545.js
+++ b/browser/components/sessionstore/test/browser/browser_522545.js
@@ -30,29 +30,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 522545 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   waitForExplicitFinish();
   requestLongerTimeout(2);
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].
            getService(Ci.nsISessionStore);
 
   // This tests the following use case:
@@ -299,18 +288,15 @@ function test() {
       tabs: [{ entries: [{ url: "about:blank" }] }]
     }]
   };
   function runNextTest() {
     if (tests.length) {
       waitForBrowserState(state, tests.shift());
     } else {
       ss.setBrowserState(originalState);
-      executeSoon(function () {
-        is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
-        finish();
-      });
+      executeSoon(finish);
     }
   }
 
   // Run the tests!
   runNextTest();
 }
--- a/browser/components/sessionstore/test/browser/browser_524745.js
+++ b/browser/components/sessionstore/test/browser/browser_524745.js
@@ -30,29 +30,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 524745 **/
-  is(browserWindowsCount(), 1, "Only one browser window should be open initially");
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].
            getService(Ci.nsISessionStore);
   let uniqKey = "bug524745";
   let uniqVal = Date.now();
 
   waitForExplicitFinish();
 
@@ -80,15 +69,13 @@ function test() {
           window.minimize();
           state = JSON.parse(ss.getBrowserState());
           is(state.selectedWindow, 0,
              "selectedWindow should be 0 when all windows are minimized");
 
           // Cleanup
           window.restore();
           window_B.close();
-          is(browserWindowsCount(), 1,
-             "Only one browser window should be open eventually");
           finish();
         });
       }, window_B);
   }, false);
 }
--- a/browser/components/sessionstore/test/browser/browser_597071.js
+++ b/browser/components/sessionstore/test/browser/browser_597071.js
@@ -30,26 +30,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-function browserWindowsCount() {
-  let count = 0;
-  let e = Services.wm.getEnumerator("navigator:browser");
-  while (e.hasMoreElements()) {
-    if (!e.getNext().closed)
-      ++count;
-  }
-  return count;
-}
-
 function test() {
   /** Test for Bug 597071 **/
 
   waitForExplicitFinish();
 
   let ss = Cc["@mozilla.org/browser/sessionstore;1"].
            getService(Ci.nsISessionStore);
   let pb = Cc["@mozilla.org/privatebrowsing;1"].
@@ -73,33 +63,29 @@ function test() {
   let newWin = openDialog(location, "", "chrome,all,dialog=no", "http://example.com");
   newWin.addEventListener("load", function(aEvent) {
     newWin.removeEventListener("load", arguments.callee, false);
 
     newWin.gBrowser.addEventListener("load", function(aEvent) {
       newWin.gBrowser.removeEventListener("load", arguments.callee, true);
 
       newWin.gBrowser.addTab().linkedBrowser.stop();
-      // make sure there are 2 windows open
-      is(browserWindowsCount(), 2, "there should be 2 windows open currently");
+
       // make sure sessionstore sees this window
       let state = JSON.parse(ss.getBrowserState());
       is(state.windows.length, 2, "sessionstore knows about this window");
 
       newWin.close();
       newWin.addEventListener("unload", function(aEvent) {
         newWin.removeEventListener("unload", arguments.callee, false);
 
         is(ss.getClosedWindowCount(), closedWindowCount + 1,
            "increased closed window count");
-        is(browserWindowsCount(), 1, "there should be 1 window open currently");
 
-        try {
-          Services.prefs.clearUserPref("browser.sessionstore.max_windows_undo");
-        } catch (e) {}
+        Services.prefs.clearUserPref("browser.sessionstore.max_windows_undo");
         ss.setBrowserState(currentState);
         executeSoon(finish);
 
       }, false);
     }, true);
   }, false);
 }