Bug 694378 - session restore fails when selectedWindow > number of windows [r=dietrich]

This commit is contained in:
Paul O’Shannessy 2011-10-25 10:19:29 -07:00
parent 9709f3cbf0
commit 18f17914d7
3 changed files with 37 additions and 1 deletions

View File

@ -2577,7 +2577,7 @@ SessionStoreService.prototype = {
this._closedWindows = root._closedWindows;
var winData;
if (!root.selectedWindow) {
if (!root.selectedWindow || root.selectedWindow > root.windows.length) {
root.selectedWindow = 0;
} else {
// put the selected window at the beginning of the array to ensure that

View File

@ -154,6 +154,7 @@ _BROWSER_TEST_FILES = \
browser_662812.js \
browser_665702-state_session.js \
browser_682507.js \
browser_694378.js \
$(NULL)
ifneq ($(OS_ARCH),Darwin)

View File

@ -0,0 +1,35 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Test Summary:
// 1. call ss.setWindowState with a broken state
// 1a. ensure that it doesn't throw.
function test() {
waitForExplicitFinish();
let brokenState = {
windows: [
{ tabs: [{ entries: [{ url: "about:mozilla" }] }] }
//{ tabs: [{ entries: [{ url: "about:robots" }] }] },
],
selectedWindow: 2
};
let brokenStateString = JSON.stringify(brokenState);
let gotError = false;
try {
ss.setWindowState(window, brokenStateString, true);
}
catch (ex) {
gotError = true;
info(ex);
}
ok(!gotError, "ss.setWindowState did not throw an error");
// Make sure that we reset the state. Use a full state just in case things get crazy.
let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank" }] }]}]};
waitForBrowserState(blankState, finish);
}