diff --git a/browser/components/sessionstore/test/browser/browser_394759.js b/browser/components/sessionstore/test/browser/browser_394759.js index 0588b20a815..bafd400b625 100644 --- a/browser/components/sessionstore/test/browser/browser_394759.js +++ b/browser/components/sessionstore/test/browser/browser_394759.js @@ -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"); }); }); }); diff --git a/browser/components/sessionstore/test/browser/browser_461634.js b/browser/components/sessionstore/test/browser/browser_461634.js index c4dfde0ff8d..4780acc6c47 100644 --- a/browser/components/sessionstore/test/browser/browser_461634.js +++ b/browser/components/sessionstore/test/browser/browser_461634.js @@ -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); diff --git a/browser/components/sessionstore/test/browser/browser_461743.js b/browser/components/sessionstore/test/browser/browser_461743.js index 097a1e19027..702ca7ce918 100644 --- a/browser/components/sessionstore/test/browser/browser_461743.js +++ b/browser/components/sessionstore/test/browser/browser_461743.js @@ -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"); diff --git a/browser/components/sessionstore/test/browser/browser_463205.js b/browser/components/sessionstore/test/browser/browser_463205.js index 56dc2a78e4b..eab926d2744 100644 --- a/browser/components/sessionstore/test/browser/browser_463205.js +++ b/browser/components/sessionstore/test/browser/browser_463205.js @@ -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, diff --git a/browser/components/sessionstore/test/browser/browser_463206.js b/browser/components/sessionstore/test/browser/browser_463206.js index c269f4eb771..bc5f604382c 100644 --- a/browser/components/sessionstore/test/browser/browser_463206.js +++ b/browser/components/sessionstore/test/browser/browser_463206.js @@ -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; diff --git a/browser/components/sessionstore/test/browser/browser_464199.js b/browser/components/sessionstore/test/browser/browser_464199.js index 0f31f355975..dd1dd4892ff 100644 --- a/browser/components/sessionstore/test/browser/browser_464199.js +++ b/browser/components/sessionstore/test/browser/browser_464199.js @@ -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(); diff --git a/browser/components/sessionstore/test/browser/browser_522545.js b/browser/components/sessionstore/test/browser/browser_522545.js index d0c398c4c66..47351982a14 100644 --- a/browser/components/sessionstore/test/browser/browser_522545.js +++ b/browser/components/sessionstore/test/browser/browser_522545.js @@ -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();