From d1a6774d157efc8999c20bd33401c924ad90fdb8 Mon Sep 17 00:00:00 2001 From: Sandor Molnar Date: Tue, 8 Oct 2024 00:10:34 +0300 Subject: [PATCH] Backed out changeset 0ded63123e6c (bug 1908418) for causing multiple perma failures. --- .../sessionstore/SessionStore.sys.mjs | 27 +---- .../sessionstore/TabGroupState.sys.mjs | 37 ------ .../components/sessionstore/TabState.sys.mjs | 8 +- browser/components/sessionstore/moz.build | 1 - .../components/sessionstore/test/browser.toml | 4 - .../test/browser_tab_groups_empty.js | 34 ------ .../test/browser_tab_groups_state.js | 105 ------------------ 7 files changed, 3 insertions(+), 213 deletions(-) delete mode 100644 browser/components/sessionstore/TabGroupState.sys.mjs delete mode 100644 browser/components/sessionstore/test/browser_tab_groups_empty.js delete mode 100644 browser/components/sessionstore/test/browser_tab_groups_state.js diff --git a/browser/components/sessionstore/SessionStore.sys.mjs b/browser/components/sessionstore/SessionStore.sys.mjs index 2367a729a6fd..bf5f79a05125 100644 --- a/browser/components/sessionstore/SessionStore.sys.mjs +++ b/browser/components/sessionstore/SessionStore.sys.mjs @@ -117,12 +117,6 @@ const TAB_EVENTS = [ "TabHide", "TabPinned", "TabUnpinned", - "TabGroupCreate", - "TabGroupRemove", - "TabGrouped", - "TabUngrouped", - "TabGroupCollapse", - "TabGroupExpand", ]; const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; @@ -184,7 +178,6 @@ ChromeUtils.defineESModuleGetters(lazy, { "resource://gre/modules/sessionstore/SessionStoreHelper.sys.mjs", TabAttributes: "resource:///modules/sessionstore/TabAttributes.sys.mjs", TabCrashHandler: "resource:///modules/ContentCrashHandlers.sys.mjs", - TabGroupState: "resource:///modules/sessionstore/TabGroupState.sys.mjs", TabState: "resource:///modules/sessionstore/TabState.sys.mjs", TabStateCache: "resource:///modules/sessionstore/TabStateCache.sys.mjs", TabStateFlusher: "resource:///modules/sessionstore/TabStateFlusher.sys.mjs", @@ -846,10 +839,7 @@ var SessionStoreInternal = { // defaults to now if no session was restored or timestamp doesn't exist _sessionStartTime: Date.now(), - /** - * states for all currently opened windows - * @type {object.} - */ + // states for all currently opened windows _windows: {}, // counter for creating unique window IDs @@ -1697,14 +1687,6 @@ var SessionStoreInternal = { case "SwapDocShells": this.saveStateDelayed(win); break; - case "TabGroupCreate": - case "TabGroupRemove": - case "TabGrouped": - case "TabUngrouped": - case "TabGroupCollapse": - case "TabGroupExpand": - this.saveStateDelayed(win); - break; case "oop-browser-crashed": case "oop-browser-buildid-mismatch": if (aEvent.isTopFrame) { @@ -1764,7 +1746,6 @@ var SessionStoreInternal = { // and create its data object this._windows[aWindow.__SSi] = { tabs: [], - groups: [], selected: 0, _closedTabs: [], _lastClosedTabGroupCount: -1, @@ -4750,7 +4731,6 @@ var SessionStoreInternal = { let tabbrowser = aWindow.gBrowser; let tabs = tabbrowser.tabs; - /** @type {WindowStateData} */ let winData = this._windows[aWindow.__SSi]; let tabsData = (winData.tabs = []); @@ -4764,11 +4744,6 @@ var SessionStoreInternal = { tabsData.push(tabData); } - // update tab group state for this window - winData.groups = aWindow.gBrowser.tabGroups.map(tabGroup => - lazy.TabGroupState.collect(tabGroup) - ); - let selectedIndex = tabbrowser.tabbox.selectedIndex + 1; // We don't store the Firefox View tab in Session Store, so if it was the last selected "tab" when // a window is closed, point to the first item in the tab strip instead (it will never be the Firefox View tab, diff --git a/browser/components/sessionstore/TabGroupState.sys.mjs b/browser/components/sessionstore/TabGroupState.sys.mjs deleted file mode 100644 index 0854a2fb4786..000000000000 --- a/browser/components/sessionstore/TabGroupState.sys.mjs +++ /dev/null @@ -1,37 +0,0 @@ -/* 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/. */ - -/** - * Module that contains tab group state collection methods. - */ -export const TabGroupState = Object.freeze({ - /** - * @param {MozTabbrowserTabGroup} tabGroup - * Tab group browser element - * @returns {TabGroupStateData} - * Serialized tab group data - */ - collect(tabGroup) { - return TabGroupStateInternal.collect(tabGroup); - }, -}); - -const TabGroupStateInternal = { - /** - * Collect data related to a single tab group, synchronously. - * - * @param {MozTabbrowserTabGroup} tabGroup - * Tab group browser element - * @returns {TabGroupStateData} - * Serialized tab group data - */ - collect(tabGroup) { - return { - id: tabGroup.id, - name: tabGroup.label, - color: tabGroup.color, - collapsed: tabGroup.collapsed, - }; - }, -}; diff --git a/browser/components/sessionstore/TabState.sys.mjs b/browser/components/sessionstore/TabState.sys.mjs index f401c4ff5fb6..26f5671c849d 100644 --- a/browser/components/sessionstore/TabState.sys.mjs +++ b/browser/components/sessionstore/TabState.sys.mjs @@ -47,7 +47,7 @@ var TabStateInternal = { * @param [extData] * optional dictionary object, containing custom tab values. * - * @returns {TabStateData} An object with the data for this tab. If the + * @returns {TabData} An object with the data for this tab. If the * tab has not been invalidated since the last call to * collect(aTab), the same object is returned. */ @@ -81,7 +81,7 @@ var TabStateInternal = { * {extData: object} optional dictionary object, containing custom tab values * {includePrivateData: true} to always include private data * - * @returns {TabStateData} An object with the basic data for this tab. + * @returns {object} An object with the basic data for this tab. */ _collectBaseTabData(tab, options) { let tabData = { entries: [], lastAccessed: tab.lastAccessed }; @@ -98,10 +98,6 @@ var TabStateInternal = { tabData.muteReason = tab.muteReason; } - if (tab.group) { - tabData.groupId = tab.group.id; - } - tabData.searchMode = tab.ownerGlobal.gURLBar.getSearchMode(browser, true); tabData.userContextId = tab.userContextId || 0; diff --git a/browser/components/sessionstore/moz.build b/browser/components/sessionstore/moz.build index c2e74907d7f9..97554aab310f 100644 --- a/browser/components/sessionstore/moz.build +++ b/browser/components/sessionstore/moz.build @@ -25,7 +25,6 @@ EXTRA_JS_MODULES.sessionstore = [ "SessionWriter.sys.mjs", "StartupPerformance.sys.mjs", "TabAttributes.sys.mjs", - "TabGroupState.sys.mjs", "TabState.sys.mjs", "TabStateCache.sys.mjs", "TabStateFlusher.sys.mjs", diff --git a/browser/components/sessionstore/test/browser.toml b/browser/components/sessionstore/test/browser.toml index 39b657a1905b..158e65c72143 100644 --- a/browser/components/sessionstore/test/browser.toml +++ b/browser/components/sessionstore/test/browser.toml @@ -273,10 +273,6 @@ tags = "os_integration" ["browser_switch_remoteness.js"] -["browser_tab_groups_empty.js"] - -["browser_tab_groups_state.js"] - ["browser_tab_label_during_restore.js"] https_first_disabled = true diff --git a/browser/components/sessionstore/test/browser_tab_groups_empty.js b/browser/components/sessionstore/test/browser_tab_groups_empty.js deleted file mode 100644 index 607f6c21dd5e..000000000000 --- a/browser/components/sessionstore/test/browser_tab_groups_empty.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; - -/** @type {Window} */ -let win; - -add_setup(async () => { - win = await promiseNewWindowLoaded(); - SessionStoreTestUtils.init(this, win); -}); - -registerCleanupFunction(async () => { - await BrowserTestUtils.closeWindow(win); -}); - -add_task(async function test_ZeroTabGroups() { - const state = ss.getWindowState(win); - - Assert.equal(state.windows.length, 1, "should have state from 1 window"); - const windowState = state.windows[0]; - - Assert.ok(windowState.groups, "window state should have a `groups` property"); - Assert.equal( - windowState.groups.length, - 0, - "`groups` property should be 0 since there are no tab groups" - ); - - const countOfGroupedTabs = windowState.tabs.filter(tab => tab.groupId).length; - Assert.equal( - countOfGroupedTabs, - 0, - "none of the tabs should refer to a tab group" - ); -}); diff --git a/browser/components/sessionstore/test/browser_tab_groups_state.js b/browser/components/sessionstore/test/browser_tab_groups_state.js deleted file mode 100644 index 75f2d24b46c1..000000000000 --- a/browser/components/sessionstore/test/browser_tab_groups_state.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; - -/** @type {Window} */ -let win; - -add_setup(async () => { - win = await promiseNewWindowLoaded(); - SessionStoreTestUtils.init(this, win); -}); - -registerCleanupFunction(async () => { - await BrowserTestUtils.closeWindow(win); -}); - -/** - * @param {WindowStateData} windowState - * @returns {TabStateData|undefined} - */ -function findTabStateByUrl(windowState, url) { - return windowState.tabs.find(tabState => tabState.userTypedValue == url); -} - -add_task(async function test_TabGroupsInState() { - let aboutRobotsTab = BrowserTestUtils.addTab(win.gBrowser, "about:robots"); - let aboutCrashesTab = BrowserTestUtils.addTab(win.gBrowser, "about:crashes"); - BrowserTestUtils.addTab(win.gBrowser, "about:about"); - - let group = win.gBrowser.addTabGroup("blue", "non-meta about pages", [ - aboutRobotsTab, - aboutCrashesTab, - ]); - - let state = ss.getWindowState(win); - - Assert.equal(state.windows.length, 1, "should have state from 1 window"); - let windowState = state.windows[0]; - - Assert.ok(windowState.groups, "window state should have a `groups` property"); - Assert.equal(windowState.groups.length, 1, "there should be one tab group"); - let groupState = windowState.groups[0]; - - Assert.equal( - groupState.id, - group.id, - "tab group ID should be recorded in state" - ); - Assert.equal( - groupState.name, - group.label, - "tab group name should be recorded in state" - ); - Assert.equal( - groupState.color, - group.color, - "tab group color should be recorded in state" - ); - Assert.equal( - groupState.collapsed, - group.collapsed, - "tab group collapsed state should be recorded in state" - ); - - Assert.equal( - windowState.tabs.length, - 3, - "there should be 3 tabs in session state" - ); - - const aboutRobotsTabState = findTabStateByUrl(windowState, "about:robots"); - Assert.ok(aboutRobotsTabState, "about:robots tab should be in session state"); - Assert.equal( - aboutRobotsTabState.groupId, - group.id, - "about:robots tab should be part of the tab group" - ); - - const aboutCrashesTabState = findTabStateByUrl(windowState, "about:crashes"); - Assert.ok( - aboutCrashesTabState, - "about:crashes tab should be in session state" - ); - Assert.equal( - aboutCrashesTabState.groupId, - group.id, - "about:crashes tab should be part of the tab group" - ); - - const aboutAboutTabState = findTabStateByUrl(windowState, "about:about"); - Assert.ok(aboutAboutTabState, "about:about tab should be in session state"); - Assert.ok( - !aboutAboutTabState.groupId, - "about:about tab should NOT be part of the tab group" - ); - - // collapse the tab group and make sure the tab group data updates - group.collapsed = true; - - state = ss.getWindowState(win); - groupState = state.windows[0].groups[0]; - Assert.equal( - groupState.collapsed, - group.collapsed, - "updated tab group collapsed state should be recorded in state" - ); -});