Bug 1819675 - Introduce a feature pref to toggle the recently-closed tabs from all windows behavior.r=sclements,dao,extension-reviewers,fxview-reviewers,robwu,sessionstore-reviewers

* Add a default-true pref to provide an escape hatch allowing us to revert to previous behavior
* in which recently-closed tabs are per-window,
* and undoing closed tabs restores them to the window they were closed from.
* Ensure we set the pref for tests which depend on its value
* Add some spot-checks in tests with the pref off

Differential Revision: https://phabricator.services.mozilla.com/D179574
This commit is contained in:
Sam Foster
2023-07-06 22:49:52 +00:00
parent b23b17ffa1
commit 1bd6b02cd7
12 changed files with 284 additions and 58 deletions

View File

@@ -407,6 +407,11 @@ export var SessionStore = {
* @param {Window} [aWindow] Optional window argument used to determine if we're counting for private or non-private windows
*/
getClosedTabCount: function ss_getClosedTabCount(aWindow) {
if (!SessionStoreInternal._closedTabsFromAllWindowsEnabled) {
return this.getClosedTabCountForWindow(
aWindow ?? SessionStoreInternal._getTopWindow()
);
}
return SessionStoreInternal.getClosedTabCount(aWindow);
},
@@ -423,6 +428,11 @@ export var SessionStore = {
* @param {Window} [aWindow] Optional window argument used to determine if we're collecting data for private or non-private windows
*/
getClosedTabData: function ss_getClosedTabData(aWindow) {
if (!SessionStoreInternal._closedTabsFromAllWindowsEnabled) {
return this.getClosedTabDataForWindow(
aWindow ?? SessionStoreInternal._getTopWindow()
);
}
return SessionStoreInternal.getClosedTabData(aWindow);
},
@@ -1201,6 +1211,16 @@ var SessionStoreInternal = {
);
this._prefBranch.addObserver("sessionstore.max_tabs_undo", this, true);
this._closedTabsFromAllWindowsEnabled = this._prefBranch.getBoolPref(
"sessionstore.closedTabsFromAllWindows",
true
);
this._prefBranch.addObserver(
"sessionstore.closedTabsFromAllWindows",
this,
true
);
this._max_windows_undo = this._prefBranch.getIntPref(
"sessionstore.max_windows_undo"
);
@@ -2699,6 +2719,12 @@ var SessionStoreInternal = {
"sessionstore.restore_on_demand"
);
break;
case "sessionstore.closedTabsFromAllWindows":
this._closedTabsFromAllWindowsEnabled = this._prefBranch.getBoolPref(
"sessionstore.closedTabsFromAllWindows",
true
);
break;
}
},