Backing out 49f9273e22a9 to fix orange, was fix for bug 528776 which isn't blocking or approved

This commit is contained in:
Peter Van der Beken 2009-11-28 15:15:18 +01:00
Родитель 0807b80b59
Коммит c2c0f2f0e2
3 изменённых файлов: 32 добавлений и 71 удалений

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

@ -186,6 +186,9 @@ SessionStoreService.prototype = {
// whether we clearing history on shutdown
_clearingOnShutdown: false,
// List of windows that are being closed during setBrowserState.
_closingWindows: [],
#ifndef XP_MACOSX
// whether the last window was closed and should be restored
_restoreLastWindow: false,
@ -337,9 +340,17 @@ SessionStoreService.prototype = {
aSubject.addEventListener("load", function(aEvent) {
aEvent.currentTarget.removeEventListener("load", arguments.callee, false);
_this.onLoad(aEvent.currentTarget);
}, false);
}, false);
break;
case "domwindowclosed": // catch closed windows
if (this._closingWindows.length > 0) {
let index = this._closingWindows.indexOf(aSubject);
if (index != -1) {
this._closingWindows.splice(index, 1);
if (this._closingWindows.length == 0)
this._sendRestoreCompletedNotifications(true);
}
}
this.onClose(aSubject);
break;
case "quit-application-requested":
@ -888,8 +899,6 @@ SessionStoreService.prototype = {
},
setBrowserState: function sss_setBrowserState(aState) {
this._handleClosedWindows();
try {
var state = this._safeEval("(" + aState + ")");
}
@ -906,20 +915,21 @@ SessionStoreService.prototype = {
return;
}
// close all other browser windows
this._forEachBrowserWindow(function(aWindow) {
if (aWindow != window) {
aWindow.close();
this.onClose(aWindow);
}
});
// make sure closed window data isn't kept
this._closedWindows = [];
// determine how many windows are meant to be restored
this._restoreCount = state.windows ? state.windows.length : 0;
var self = this;
// close all other browser windows
this._forEachBrowserWindow(function(aWindow) {
if (aWindow != window) {
self._closingWindows.push(aWindow);
aWindow.close();
}
});
// restore to the given state
this.restoreWindow(window, state, true);
},
@ -1710,8 +1720,6 @@ SessionStoreService.prototype = {
* @returns string
*/
_getCurrentState: function sss_getCurrentState(aUpdateAll) {
this._handleClosedWindows();
var activeWindow = this._getMostRecentBrowserWindow();
if (this._loadState == STATE_RUNNING) {
@ -1725,7 +1733,7 @@ SessionStoreService.prototype = {
else { // always update the window features (whose change alone never triggers a save operation)
this._updateWindowFeatures(aWindow);
}
});
}, this);
this._dirtyWindows = [];
}
@ -2657,24 +2665,6 @@ SessionStoreService.prototype = {
#endif
},
/**
* Calls onClose for windows that are determined to be closed but aren't
* destroyed yet, which would otherwise cause getBrowserState and
* setBrowserState to treat them as open windows.
*/
_handleClosedWindows: function sss_handleClosedWindows() {
var windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
var windowsEnum = windowMediator.getEnumerator("navigator:browser");
while (windowsEnum.hasMoreElements()) {
var window = windowsEnum.getNext();
if (window.closed) {
this.onClose(window);
}
}
},
/**
* open a new browser window for a given session state
* called when restoring a multi-window session
@ -2886,16 +2876,17 @@ SessionStoreService.prototype = {
return jsonString;
},
_sendRestoreCompletedNotifications: function sss_sendRestoreCompletedNotifications() {
if (this._restoreCount) {
_sendRestoreCompletedNotifications:
function sss_sendRestoreCompletedNotifications(aOnWindowClose) {
if (this._restoreCount && !aOnWindowClose)
this._restoreCount--;
if (this._restoreCount == 0) {
// This was the last window restored at startup, notify observers.
this._observerService.notifyObservers(null,
this._browserSetState ? NOTIFY_BROWSER_STATE_RESTORED : NOTIFY_WINDOWS_RESTORED,
"");
this._browserSetState = false;
}
if (this._restoreCount == 0 && this._closingWindows.length == 0) {
// This was the last window restored at startup, notify observers.
this._observerService.notifyObservers(null,
this._browserSetState ? NOTIFY_BROWSER_STATE_RESTORED : NOTIFY_WINDOWS_RESTORED,
"");
this._browserSetState = false;
}
},

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

@ -109,7 +109,6 @@ _BROWSER_TEST_FILES = \
browser_514751.js \
browser_522545.js \
browser_526613.js \
browser_528776.js \
$(NULL)
libs:: $(_BROWSER_TEST_FILES)

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

@ -1,29 +0,0 @@
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
function browserWindowsCount(expected) {
var count = 0;
var e = wm.getEnumerator("navigator:browser");
while (e.hasMoreElements()) {
if (!e.getNext().closed)
++count;
}
is(count, expected,
"number of open browser windows according to nsIWindowMediator");
is(JSON.parse(ss.getBrowserState()).windows.length, expected,
"number of open browser windows according to getBrowserState");
}
function test() {
waitForExplicitFinish();
browserWindowsCount(1);
var win = openDialog(location, "", "chrome,all,dialog=no");
win.addEventListener("load", function () {
browserWindowsCount(2);
win.close();
browserWindowsCount(1);
finish();
}, false);
}