diff --git a/src/browser/components/sessionstore/fix-library-session.patch b/src/browser/components/sessionstore/fix-library-session.patch new file mode 100644 index 0000000000..ec5487f4da --- /dev/null +++ b/src/browser/components/sessionstore/fix-library-session.patch @@ -0,0 +1,16 @@ +diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs +--- a/browser/components/sessionstore/SessionStore.sys.mjs ++++ b/browser/components/sessionstore/SessionStore.sys.mjs +@@ -2139,6 +2139,12 @@ var SessionStoreInternal = { + let closedWindowState = this._collectWindowData(aWindow); + + if (closedWindowState) { ++ // Only save session state for actual browser windows (windowtype="navigator:browser") ++ // This prevents non-browser windows like Library (Places:Organizer) from affecting the session ++ if (aWindow.document.documentElement.getAttribute("windowtype") !== "navigator:browser") { ++ return; ++ } ++ + let newWindowState; + if ( + !lazy.SessionStartup.willRestore() \ No newline at end of file diff --git a/src/zen/tests/sessionstore/browser_library_window_session.js b/src/zen/tests/sessionstore/browser_library_window_session.js new file mode 100644 index 0000000000..b84633408d --- /dev/null +++ b/src/zen/tests/sessionstore/browser_library_window_session.js @@ -0,0 +1,30 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +"use strict"; + +add_task(async function test_library_window_session() { + // Open a new window with some tabs + let win = await BrowserTestUtils.openNewBrowserWindow(); + let tab1 = await BrowserTestUtils.addTab(win.gBrowser, "about:mozilla"); + let tab2 = await BrowserTestUtils.addTab(win.gBrowser, "about:config"); + + // Open the library window + let libraryWin = await BrowserTestUtils.promiseLibraryWindow(); + + // Close the main browser window + await BrowserTestUtils.closeWindow(win); + + // Wait a bit to ensure session is saved + await TestUtils.waitForTick(); + + // Close library window + await BrowserTestUtils.closeWindow(libraryWin); + + // Get the state file directly to verify it has content + let state = SessionFile.read(); + ok(state, "Session file should exist"); + ok(state.windows?.length > 0, "Session should have windows"); + ok(state.windows[0].tabs?.length >= 2, "Session should have our test tabs"); +}); \ No newline at end of file