Count open browser windows for bug 528776

This commit is contained in:
Dão Gottwald 2009-11-17 01:04:28 +01:00
Родитель 8a41af9985
Коммит 34c0c6a928
5 изменённых файлов: 73 добавлений и 1 удалений

Просмотреть файл

@ -35,8 +35,21 @@
*
* ***** END LICENSE BLOCK ***** */
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() {
/** 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);
@ -154,6 +167,7 @@ function test() {
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");
finish();
}
}

Просмотреть файл

@ -34,8 +34,21 @@
*
* ***** END LICENSE BLOCK ***** */
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() {
/** 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);
@ -72,6 +85,7 @@ function test() {
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);

Просмотреть файл

@ -35,8 +35,21 @@
*
* ***** END LICENSE BLOCK ***** */
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() {
/** 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);
@ -149,6 +162,7 @@ function test() {
// 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");
finish();

Просмотреть файл

@ -34,8 +34,21 @@
*
* ***** END LICENSE BLOCK ***** */
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() {
/** 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);
@ -66,4 +79,5 @@ function test() {
// leading "allow") to nsSessionStore.js's CAPABILITIES array. Thanks.
gBrowser.removeTab(tab);
is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
}

Просмотреть файл

@ -34,8 +34,21 @@
*
* ***** END LICENSE BLOCK ***** */
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() {
/** 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();
@ -79,7 +92,10 @@ function test() {
testState(state1, {readOnly: false, enablehistory: "true"}, function() {
testState(state2, {readOnly: true, enablehistory: "false"}, function() {
executeSoon(finish);
executeSoon(function () {
is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
finish();
});
});
});
});