Count open browser windows for bug 528776

This commit is contained in:
Dão Gottwald 2009-11-18 09:20:19 +01:00
parent 7bf0e0c4ea
commit 80f39a0574

View File

@ -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();
}
)
)
)