Bug 698557 - Port Bug 665702 [expose session information in getBrowserState]. r=Neil

This commit is contained in:
Misak Khachatryan 2011-11-05 13:36:06 +04:00
Родитель 60ad6fffbd
Коммит b0809e3b17
3 изменённых файлов: 39 добавлений и 9 удалений

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

@ -2210,7 +2210,19 @@ SessionStoreService.prototype = {
if (ix != -1 && total[ix].sizemode == "minimized")
ix = -1;
return { windows: total, selectedWindow: ix + 1, _closedWindows: lastClosedWindowsCopy };
let session = {
state: this._loadState == STATE_RUNNING ? STATE_RUNNING_STR : STATE_STOPPED_STR,
lastUpdate: Date.now(),
startTime: this._sessionStartTime,
recentCrashes: this._recentCrashes
};
return {
windows: total,
selectedWindow: ix + 1,
_closedWindows: lastClosedWindowsCopy,
session: session
};
},
/**
@ -3182,14 +3194,6 @@ SessionStoreService.prototype = {
if (!oState)
return;
oState.session = {
state: this._loadState == STATE_RUNNING ? STATE_RUNNING_STR : STATE_STOPPED_STR,
lastUpdate: Date.now(),
startTime: this._sessionStartTime
};
if (this._recentCrashes)
oState.session.recentCrashes = this._recentCrashes;
this._saveStateObject(oState);
},

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

@ -103,6 +103,7 @@ _BROWSER_FILES = \
browser_607016.js \
browser_615394-SSWindowState_events.js \
browser_625257.js \
browser_665702-state_session.js \
browser_694378.js \
browser_isempty.js \
browser_markPageAsFollowedLink.js \

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

@ -0,0 +1,25 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function compareArray(a, b) {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
function test() {
let currentState = JSON.parse(ss.getBrowserState());
ok(currentState.session, "session data returned by getBrowserState");
let keys = Object.keys(currentState.session);
let expectedKeys = ["state", "lastUpdate", "startTime", "recentCrashes"];
info("keys "+JSON.stringify(keys.sort())+" expectedKeys "+JSON.stringify(expectedKeys.sort()));
ok(compareArray(keys.sort(), expectedKeys.sort()),
"session object from getBrowserState has correct keys");
}