Bug 1059308 - Switch to the next available top level window when the current one is destroyed. r=jryans

This commit is contained in:
Alexandre Poirot 2015-02-26 03:54:00 +01:00
parent f99c89ffdd
commit a5270da9e8

View File

@ -1017,10 +1017,24 @@ TabActor.prototype = {
}
if (webProgress.DOMWindow == this._originalWindow) {
// If for some reason (typically during Firefox shutdown), the original
// document is destroyed, we detach the tab actor to unregister all listeners
// and prevent any exception.
this.exit();
// If the original top level document we connected to is removed,
// we try to switch to any other top level document
let rootDocShells = this.docShells
.filter(d => {
return d != this.docShell &&
this._isRootDocShell(d);
});
if (rootDocShells.length > 0) {
let newRoot = rootDocShells[0];
this._originalWindow = newRoot.DOMWindow;
this._changeTopLevelDocument(this._originalWindow);
} else {
// If for some reason (typically during Firefox shutdown), the original
// document is destroyed, and there is no other top level docshell,
// we detach the tab actor to unregister all listeners and prevent any
// exception
this.exit();
}
return;
}