зеркало из https://github.com/mozilla/pjs.git
Count open browser windows for bug 528776
This commit is contained in:
Родитель
ccf1563e4f
Коммит
25315cdcf7
|
@ -35,6 +35,18 @@
|
|||
*
|
||||
* ***** 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 waitForBrowserState(aState, aSetStateCallback) {
|
||||
let os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
|
@ -52,6 +64,7 @@ function waitForBrowserState(aState, aSetStateCallback) {
|
|||
|
||||
function test() {
|
||||
/** Test for Bug 394759 **/
|
||||
is(browserWindowsCount(), 1, "Only one browser window should be open initially");
|
||||
|
||||
// test setup
|
||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
||||
|
@ -313,6 +326,7 @@ function test() {
|
|||
test_behavior(function() {
|
||||
test_purge(function() {
|
||||
finish();
|
||||
is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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 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);
|
||||
|
@ -65,9 +78,8 @@ function test() {
|
|||
}
|
||||
|
||||
// open a window and add the above closed tab list
|
||||
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
|
||||
let newWin = open(location, "", "chrome,all");
|
||||
newWin.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, false);
|
||||
gPrefService.setIntPref("browser.sessionstore.max_tabs_undo",
|
||||
test_state.windows[0]._closedTabs.length);
|
||||
ss.setWindowState(newWin, JSON.stringify(test_state), true);
|
||||
|
@ -103,6 +115,7 @@ function test() {
|
|||
|
||||
// clean up
|
||||
newWin.close();
|
||||
is(browserWindowsCount(), 1, "Only one browser window should be open eventually");
|
||||
gPrefService.clearUserPref("browser.sessionstore.max_tabs_undo");
|
||||
finish();
|
||||
}, false);
|
||||
|
|
|
@ -46,7 +46,7 @@ function test() {
|
|||
info("New tab added");
|
||||
tab.linkedBrowser.addEventListener("load", function(aEvent) {
|
||||
info("New tab loaded");
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
executeSoon(function() {
|
||||
let tab2 = gBrowser.duplicateTab(tab);
|
||||
info("Duplicated tab");
|
||||
|
|
|
@ -48,7 +48,7 @@ function test() {
|
|||
// wait for all frames to load completely
|
||||
if (frameCount++ < 3)
|
||||
return;
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
function typeText(aTextField, aValue) {
|
||||
aTextField.value = aValue;
|
||||
|
@ -69,7 +69,7 @@ function test() {
|
|||
// wait for all frames to load (and reload!) completely
|
||||
if (frameCount++ < 4)
|
||||
return;
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
tab2.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
let win = tab2.linkedBrowser.contentWindow;
|
||||
isnot(win.frames[0].document.getElementById("original").value, uniqueValue,
|
||||
|
|
|
@ -48,7 +48,7 @@ function test() {
|
|||
// wait for all frames to load completely
|
||||
if (frameCount++ < 5)
|
||||
return;
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
function typeText(aTextField, aValue) {
|
||||
aTextField.value = aValue;
|
||||
|
@ -69,7 +69,7 @@ function test() {
|
|||
// wait for all frames to load completely
|
||||
if (frameCount++ < 5)
|
||||
return;
|
||||
this.removeEventListener("load", arguments.callee, true);
|
||||
tab2.linkedBrowser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
let doc = tab2.linkedBrowser.contentDocument;
|
||||
let win = tab2.linkedBrowser.contentWindow;
|
||||
|
|
|
@ -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 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);
|
||||
|
@ -73,9 +86,8 @@ function test() {
|
|||
aClosedTabList.filter(function(aData) aData.title == aTitle).length;
|
||||
|
||||
// open a window and add the above closed tab list
|
||||
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
|
||||
let newWin = open(location, "", "chrome,all");
|
||||
newWin.addEventListener("load", function(aEvent) {
|
||||
this.removeEventListener("load", arguments.callee, false);
|
||||
gPrefService.setIntPref("browser.sessionstore.max_tabs_undo",
|
||||
test_state.windows[0]._closedTabs.length);
|
||||
ss.setWindowState(newWin, JSON.stringify(test_state), true);
|
||||
|
@ -103,6 +115,7 @@ function test() {
|
|||
|
||||
// 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");
|
||||
finish();
|
||||
|
|
|
@ -300,6 +300,8 @@ function test() {
|
|||
test_getBrowserState_lotsOfTabsOpening,
|
||||
test_getBrowserState_userTypedValue, test_userTypedClearLoadURI];
|
||||
let originalState = ss.getBrowserState();
|
||||
info(JSON.parse(originalState).windows.length);
|
||||
info(originalState);
|
||||
function runNextTest() {
|
||||
if (tests.length) {
|
||||
tests.shift().call();
|
||||
|
|
Загрузка…
Ссылка в новой задаче