Skip to content

Commit

Permalink
Bug 1001167 - Don't let invalid sessionstore.js files break sessionst…
Browse files Browse the repository at this point in the history
…ore. r=smacleod, a=lsblakk
  • Loading branch information
Tim Taubert committed Apr 25, 2014
1 parent 00a42c1 commit d35367b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
5 changes: 3 additions & 2 deletions browser/components/sessionstore/src/nsSessionStartup.js
Expand Up @@ -124,15 +124,16 @@ SessionStartup.prototype = {
return;
}

this._initialState = this._parseStateString(stateString);
this._initialState = this._parseStateString(stateString);

let shouldResumeSessionOnce = Services.prefs.getBoolPref("browser.sessionstore.resume_session_once");
let shouldResumeSession = shouldResumeSessionOnce ||
Services.prefs.getIntPref("browser.startup.page") == BROWSER_STARTUP_RESUME_SESSION;

// If this is a normal restore then throw away any previous session
if (!shouldResumeSessionOnce)
if (!shouldResumeSessionOnce && this._initialState) {
delete this._initialState.lastSessionState;
}

let resumeFromCrash = Services.prefs.getBoolPref("browser.sessionstore.resume_from_crash");

Expand Down
@@ -0,0 +1,3 @@
{
"windows": // invalid json
}
@@ -0,0 +1,21 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */

function run_test() {
let profd = do_get_profile();

let sourceSession = do_get_file("data/sessionstore_invalid.js");
sourceSession.copyTo(profd, "sessionstore.js");

let sourceCheckpoints = do_get_file("data/sessionCheckpoints_all.json");
sourceCheckpoints.copyTo(profd, "sessionCheckpoints.json");

do_test_pending();
let startup = Cc["@mozilla.org/browser/sessionstartup;1"].
getService(Ci.nsISessionStartup);

afterSessionStartupInitialization(function cb() {
do_check_eq(startup.sessionType, Ci.nsISessionStartup.NO_SESSION);
do_test_finished();
});
}
2 changes: 2 additions & 0 deletions browser/components/sessionstore/test/unit/xpcshell.ini
Expand Up @@ -4,9 +4,11 @@ tail =
firefox-appdir = browser
support-files =
data/sessionCheckpoints_all.json
data/sessionstore_invalid.js
data/sessionstore_valid.js

[test_backup.js]
[test_backup_once.js]
[test_startup_nosession_async.js]
[test_startup_session_async.js]
[test_startup_invalid_session.js]

0 comments on commit d35367b

Please sign in to comment.