diff --git a/browser/components/sessionstore/test/browser/browser_354894.js b/browser/components/sessionstore/test/browser/browser_354894.js index 0072c67b8093..c68ca8af0576 100644 --- a/browser/components/sessionstore/test/browser/browser_354894.js +++ b/browser/components/sessionstore/test/browser/browser_354894.js @@ -104,7 +104,22 @@ * nsSessionStore restore a window next time it gets a chance and will post * notifications. The latter won't. */ + +function browserWindowsCount() { + let count = 0; + let e = Cc["@mozilla.org/appshell/window-mediator;1"] + .getService(Ci.nsIWindowMediator) + .getEnumerator("navigator:browser"); + while (e.hasMoreElements()) { + if (!e.getNext().closed) + ++count; + } + return count; +} + function test() { + is(browserWindowsCount(), 1, "Only one browser window should be open initially"); + waitForExplicitFinish(); // Some urls that might be opened in tabs and/or popups @@ -217,9 +232,9 @@ function test() { newWin.removeEventListener("load", arguments.callee, false); newWin.gBrowser.addEventListener("load", function(aEvent) { newWin.gBrowser.removeEventListener("load", arguments.callee, true); - for each (let url in TEST_URLS) { + TEST_URLS.forEach(function (url) { newWin.gBrowser.addTab(url); - } + }); executeSoon(function() testFn(newWin)); }, true); @@ -498,7 +513,11 @@ function test() { // Mac tests testMacNotifications( function() testNotificationCount( - function() cleanupTestsuite() + finish() + function() { + cleanupTestsuite(); + is(browserWindowsCount(), 1, "Only one browser window should be open eventually"); + finish(); + } ) ); } @@ -510,7 +529,11 @@ function test() { function() testOpenCloseOnlyPopup( function() testOpenCloseRestoreFromPopup ( function() testNotificationCount( - function() cleanupTestsuite() + finish() + function() { + cleanupTestsuite(); + is(browserWindowsCount(), 1, "Only one browser window should be open eventually"); + finish(); + } ) ) )