Bug 1861215 - Skip recording closed tabs in SessionStore for PBM reset action. r=sfoster,sessionstore-reviewers,tabbrowser-reviewers,dao

Differential Revision: https://phabricator.services.mozilla.com/D192686
This commit is contained in:
Paul Zuehlcke 2023-11-08 12:07:17 +00:00
Родитель 83bab8c1db
Коммит 5e49f50910
3 изменённых файлов: 31 добавлений и 19 удалений

Просмотреть файл

@ -3635,11 +3635,19 @@
* using it in tandem with `runBeforeUnloadForTabs`.
* @param {boolean} options.skipRemoves
* Skips actually removing the tabs. The beforeunload handlers still run.
* @param {boolean} options.skipSessionStore
* If true, don't record the closed tabs in SessionStore.
* @returns {_startRemoveTabsReturnValue}
*/
_startRemoveTabs(
tabs,
{ animate, suppressWarnAboutClosingWindow, skipPermitUnload, skipRemoves }
{
animate,
suppressWarnAboutClosingWindow,
skipPermitUnload,
skipRemoves,
skipSessionStore,
}
) {
// Note: if you change any of the unload algorithm, consider also
// changing `runBeforeUnloadForTabs` above.
@ -3685,6 +3693,7 @@
animate,
prewarmed: true,
skipPermitUnload: true,
skipSessionStore,
});
}
} else {
@ -3717,6 +3726,7 @@
animate,
prewarmed: true,
skipPermitUnload,
skipSessionStore,
});
}
}
@ -3786,6 +3796,8 @@
* @param {boolean} [options.skipPermitUnload]
* Skips the before unload checks for the tabs. Only set this to true when
* using it in tandem with `runBeforeUnloadForTabs`.
* @param {boolean} [options.skipSessionStore]
* If true, don't record the closed tabs in SessionStore.
*/
removeTabs(
tabs,
@ -3793,6 +3805,7 @@
animate = true,
suppressWarnAboutClosingWindow = false,
skipPermitUnload = false,
skipSessionStore = false,
} = {}
) {
// When 'closeWindowWithLastTab' pref is enabled, closing all tabs
@ -3820,6 +3833,7 @@
suppressWarnAboutClosingWindow,
skipPermitUnload,
skipRemoves: false,
skipSessionStore,
});
// Wait for all the beforeunload events to have been processed by content processes.
@ -3842,6 +3856,7 @@
animate,
prewarmed: true,
skipPermitUnload,
skipSessionStore,
};
// Now run again sequentially the beforeunload listeners that will result in a prompt.
@ -3886,6 +3901,7 @@
skipPermitUnload,
closeWindowWithLastTab,
prewarmed,
skipSessionStore,
} = {}
) {
if (UserInteraction.running("browser.tabs.opening", window)) {
@ -3924,6 +3940,7 @@
skipPermitUnload,
closeWindowWithLastTab,
prewarmed,
skipSessionStore,
})
) {
TelemetryStopwatch.cancel("FX_TAB_CLOSE_TIME_ANIM_MS", aTab);
@ -4004,6 +4021,7 @@
closeWindowFastpath,
skipPermitUnload,
prewarmed,
skipSessionStore = false,
} = {}
) {
if (aTab.closing || this._windowIsClosing) {
@ -4149,7 +4167,7 @@
// inspect the tab that's about to close.
let evt = new CustomEvent("TabClose", {
bubbles: true,
detail: { adoptedBy: adoptedByTab },
detail: { adoptedBy: adoptedByTab, skipSessionStore },
});
aTab.dispatchEvent(evt);

Просмотреть файл

@ -183,6 +183,9 @@ export const ResetPBMPanel = {
newTab,
{
skipPermitUnload: true,
// Instruct the SessionStore to not save closed tab data for these tabs.
// We don't want to leak them into the next private browsing session.
skipSessionStore: true,
animate: false,
},
true

Просмотреть файл

@ -1847,7 +1847,9 @@ var SessionStoreInternal = {
target.linkedBrowser,
aEvent.detail.adoptedBy.linkedBrowser
);
} else {
} else if (!aEvent.detail.skipSessionStore) {
// `skipSessionStore` is set by tab close callers to indicate that we
// shouldn't record the closed tab.
this.onTabClose(win, target);
}
this.onTabRemove(win, target);
@ -2728,23 +2730,12 @@ var SessionStoreInternal = {
// Clear closed tab data.
if (windowData._closedTabs.length) {
// Remove all of the closed tabs from the _lastClosedActions list
for (let closedTab of windowData._closedTabs) {
// If the closed tab's state still has a .permanentKey property then we
// haven't seen its final update message yet. Remove it from the map of
// closed tabs so that we will simply discard its last messages and will
// not add it back to the list of closed tabs again.
if (closedTab.permanentKey) {
this._closingTabMap.delete(closedTab.permanentKey);
this._tabClosingByWindowMap.delete(closedTab.permanentKey);
delete closedTab.permanentKey;
// Remove all of the closed tabs data.
// This also clears out the permenentKey-mapped data for pending state updates
// and removes the tabs from from the _lastClosedActions list
while (windowData._closedTabs.length) {
this.removeClosedTabData(windowData, windowData._closedTabs, 0);
}
this._removeClosedAction(
this._LAST_ACTION_CLOSED_TAB,
closedTab.closedId
);
}
// Reset the closed tab list.
windowData._closedTabs = [];
windowData._lastClosedTabGroupCount = -1;