From ad1d27699ffefdf9743edab91e3eee77c4e06042 Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Tue, 14 Sep 2021 07:25:29 +0000 Subject: [PATCH] Bug 1730477 - Change SessionStore.getWindowState to return an object instead of a string. r=kashav Differential Revision: https://phabricator.services.mozilla.com/D125382 --- browser/components/sessionstore/SessionStore.jsm | 4 ++-- .../sessionstore/test/browser_1446343-windowsize.js | 2 +- browser/components/sessionstore/test/browser_662812.js | 4 ++-- browser/components/sessionstore/test/browser_dying_cache.js | 2 +- .../sessionstore/test/browser_sizemodeBeforeMinimized.js | 2 +- .../sessionstore/test/browser_windowStateContainer.js | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index d9d2f06567e2..f8f2b15f3bf9 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -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( diff --git a/browser/components/sessionstore/test/browser_1446343-windowsize.js b/browser/components/sessionstore/test/browser_1446343-windowsize.js index 362f1a2fd68b..97f664a460d9 100644 --- a/browser/components/sessionstore/test/browser_1446343-windowsize.js +++ b/browser/components/sessionstore/test/browser_1446343-windowsize.js @@ -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); diff --git a/browser/components/sessionstore/test/browser_662812.js b/browser/components/sessionstore/test/browser_662812.js index e053d558f34b..9a5145343299 100644 --- a/browser/components/sessionstore/test/browser_662812.js +++ b/browser/components/sessionstore/test/browser_662812.js @@ -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(() => { diff --git a/browser/components/sessionstore/test/browser_dying_cache.js b/browser/components/sessionstore/test/browser_dying_cache.js index 15867195877b..f1e1d01491da 100644 --- a/browser/components/sessionstore/test/browser_dying_cache.js +++ b/browser/components/sessionstore/test/browser_dying_cache.js @@ -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"); diff --git a/browser/components/sessionstore/test/browser_sizemodeBeforeMinimized.js b/browser/components/sessionstore/test/browser_sizemodeBeforeMinimized.js index c5fa31a3acf8..a832e71bcf46 100644 --- a/browser/components/sessionstore/test/browser_sizemodeBeforeMinimized.js +++ b/browser/components/sessionstore/test/browser_sizemodeBeforeMinimized.js @@ -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, diff --git a/browser/components/sessionstore/test/browser_windowStateContainer.js b/browser/components/sessionstore/test/browser_windowStateContainer.js index 0b48bee569a4..bf255b99c43d 100644 --- a/browser/components/sessionstore/test/browser_windowStateContainer.js +++ b/browser/components/sessionstore/test/browser_windowStateContainer.js @@ -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( @@ -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(