This commit is contained in:
Dão Gottwald 2009-11-19 08:22:09 +01:00
Родитель 9ee34ca80c
Коммит 9d95df6754
1 изменённых файлов: 28 добавлений и 25 удалений

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

@ -68,9 +68,8 @@ function test() {
gPrefService.setIntPref("browser.sessionstore.max_windows_undo", max_windows_undo + 1);
let closedWindowCount = ss.getClosedWindowCount();
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no", testURL);
let newWin = openDialog(location, "", "chrome,all,dialog=no", testURL);
newWin.addEventListener("load", function(aEvent) {
newWin.removeEventListener("load", arguments.callee, false);
newWin.gBrowser.addEventListener("load", function(aEvent) {
newWin.gBrowser.removeEventListener("load", arguments.callee, true);
@ -99,7 +98,6 @@ function test() {
"The reopened window was removed from Recently Closed Windows");
newWin2.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, false);
newWin2.gBrowser.addEventListener("SSTabRestored", function(aEvent) {
newWin2.gBrowser.removeEventListener("SSTabRestored", arguments.callee, true);
@ -154,18 +152,17 @@ function test() {
let settings = "chrome,dialog=no," +
(winData.isPopup ? "all=no" : "all");
let url = "http://window" + windowsToOpen.length + ".example.com";
let window = openDialog(location, "_blank", settings, url);
window.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
window.gBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
let win = openDialog(location, "", settings, url);
win.addEventListener("load", function(aEvent) {
win.gBrowser.addEventListener("load", function(aEvent) {
win.gBrowser.removeEventListener("load", arguments.callee, true);
// the window _should_ have state with a tab of url, but it doesn't
// always happend before window.close(). addTab ensure we don't treat
// this window as a stateless window
window.gBrowser.addTab();
win.gBrowser.addTab();
executeSoon(function() {
window.close();
win.close();
executeSoon(function() {
openWindowRec(windowsToOpen, expectedResults, recCallback);
});
@ -203,6 +200,12 @@ function test() {
// backup old state
let oldState = ss.getBrowserState();
let oldState_wins = JSON.parse(oldState).windows.length;
if (oldState_wins != 1) {
ok(false, "oldState in test_purge has " + oldState_wins + " windows instead of 1");
info(oldState);
}
// create a new state for testing
const REMEMBER = Date.now(), FORGET = Math.random();
let testState = {
@ -269,30 +272,30 @@ function test() {
let closedWindowData = JSON.parse(ss.getClosedWindowData());
// First set of tests for _closedWindows[0] - tests basics
let window = closedWindowData[0];
is(window.tabs.length, 1, "1 tab was removed");
is(countOpenTabsByTitle(window.tabs, FORGET), 0,
let win = closedWindowData[0];
is(win.tabs.length, 1, "1 tab was removed");
is(countOpenTabsByTitle(win.tabs, FORGET), 0,
"The correct tab was removed");
is(countOpenTabsByTitle(window.tabs, REMEMBER), 1,
is(countOpenTabsByTitle(win.tabs, REMEMBER), 1,
"The correct tab was remembered");
is(window.selected, 1, "Selected tab has changed");
is(window.title, REMEMBER, "The window title was correctly updated");
is(win.selected, 1, "Selected tab has changed");
is(win.title, REMEMBER, "The window title was correctly updated");
// Test more complicated case
window = closedWindowData[1];
is(window.tabs.length, 3, "2 tabs were removed");
is(countOpenTabsByTitle(window.tabs, FORGET), 0,
win = closedWindowData[1];
is(win.tabs.length, 3, "2 tabs were removed");
is(countOpenTabsByTitle(win.tabs, FORGET), 0,
"The correct tabs were removed");
is(countOpenTabsByTitle(window.tabs, REMEMBER), 3,
is(countOpenTabsByTitle(win.tabs, REMEMBER), 3,
"The correct tabs were remembered");
is(window.selected, 3, "Selected tab has changed");
is(window.title, REMEMBER, "The window title was correctly updated");
is(win.selected, 3, "Selected tab has changed");
is(win.title, REMEMBER, "The window title was correctly updated");
// Tests handling of _closedTabs
window = closedWindowData[2];
is(countClosedTabsByTitle(window._closedTabs, REMEMBER), 1,
win = closedWindowData[2];
is(countClosedTabsByTitle(win._closedTabs, REMEMBER), 1,
"The correct number of tabs were removed, and the correct ones");
is(countClosedTabsByTitle(window._closedTabs, FORGET), 0,
is(countClosedTabsByTitle(win._closedTabs, FORGET), 0,
"All tabs to be forgotten were indeed removed");
// restore pre-test state