Files
tubestation/browser/components/sessionstore/TabGroupState.sys.mjs
Stephen Thompson 4b0b5070a8 Bug 1933574 - saved tab groups session schema change r=dao,sessionstore-reviewers,tabbrowser-reviewers
This patch makes saved tab groups use the "closed tabs" schema for storing tab data. This makes saved tab groups consistent with closed tabs and closed tab groups. The tab/tab group restoration code is built to work with the "closed tabs" schema, so this schema change allows saved tab groups to be restored correctly.

Bug 1933114 will add and improve the tests for restoring tab groups.

Differential Revision: https://phabricator.services.mozilla.com/D231818
2024-12-11 16:47:41 +00:00

40 lines
1.1 KiB
JavaScript

/* 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/. */
/**
* @typedef {object} TabGroupStateData
* @property {string} id
* Unique ID of the tab group.
* @property {string} name
* User-defined name of the tab group.
* @property {"blue"|"purple"|"cyan"|"orange"|"yellow"|"pink"|"green"|"gray"|"red"} color
* User-selected color name for the tab group's label/icons.
* @property {boolean} collapsed
* Whether the tab group is collapsed or expanded in the tab strip.
*/
/**
* Module that contains tab group state collection methods.
*/
class _TabGroupState {
/**
* 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,
};
}
}
export const TabGroupState = new _TabGroupState();