Skip to content

Commit

Permalink
Bug 1730477 - Change SessionStore.getWindowState to return an object …
Browse files Browse the repository at this point in the history
…instead of a string. r=kashav

Differential Revision: https://phabricator.services.mozilla.com/D125382
  • Loading branch information
Standard8 committed Sep 14, 2021
1 parent f1425a2 commit ad1d276
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions browser/components/sessionstore/SessionStore.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2934,12 +2934,12 @@ var SessionStoreInternal = {

getWindowState: function ssi_getWindowState(aWindow) {
if ("__SSi" in aWindow) {
return JSON.stringify(this._getWindowState(aWindow));
return Cu.cloneInto(this._getWindowState(aWindow), {});
}

if (DyingWindowCache.has(aWindow)) {
let data = DyingWindowCache.get(aWindow);
return JSON.stringify({ windows: [data] });
return Cu.cloneInto({ windows: [data] }, {});
}

throw Components.Exception(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_task(async function test() {

const { outerWidth, outerHeight, screenX, screenY } = win;
function checkCurrentState(sizemode) {
let state = JSON.parse(ss.getWindowState(win));
let state = ss.getWindowState(win);
let winState = state.windows[0];
let msgSuffix = ` should match on ${sizemode} mode`;
is(winState.width, outerWidth, "width" + msgSuffix);
Expand Down
4 changes: 2 additions & 2 deletions browser/components/sessionstore/test/browser_662812.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ function test() {
window.addEventListener(
"SSWindowStateBusy",
function() {
let state = JSON.parse(ss.getWindowState(window));
let state = ss.getWindowState(window);
ok(state.windows[0].busy, "window is busy");

window.addEventListener(
"SSWindowStateReady",
function() {
let state2 = JSON.parse(ss.getWindowState(window));
let state2 = ss.getWindowState(window);
ok(!state2.windows[0].busy, "window is not busy");

executeSoon(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ add_task(async function test() {
function checkWindowState(window) {
let {
windows: [{ tabs }],
} = JSON.parse(ss.getWindowState(window));
} = ss.getWindowState(window);
is(tabs.length, 1, "the window has a single tab");
is(tabs[0].entries[0].url, "about:mozilla", "the tab is about:mozilla");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ add_task(async function test() {
}

function checkCurrentState(sizemodeBeforeMinimized) {
let state = JSON.parse(ss.getWindowState(win));
let state = ss.getWindowState(win);
let winState = state.windows[0];
is(
winState.sizemodeBeforeMinimized,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ add_task(async function() {
// userContextId.
win.gBrowser.moveTabTo(win.gBrowser.tabs[0], win.gBrowser.tabs.length - 1);

let winState = JSON.parse(ss.getWindowState(win));
let winState = ss.getWindowState(win);

for (let i = 0; i < 4; i++) {
Assert.equal(
Expand Down Expand Up @@ -121,7 +121,7 @@ add_task(async function() {
// win should have 1 default tab, and 1 container tab.
Assert.equal(win.gBrowser.tabs.length, 2, "win should have 2 tabs");

let winState = JSON.parse(ss.getWindowState(win));
let winState = ss.getWindowState(win);

for (let i = 0; i < 2; i++) {
Assert.equal(
Expand Down

0 comments on commit ad1d276

Please sign in to comment.