feat: Close tab and switch to recent tab when going back with no history, p=#11190

Co-authored-by: mr. m <91018726+mr-cheffy@users.noreply.github.com>
This commit is contained in:
Kyle Kincer
2025-11-09 12:32:13 -05:00
committed by GitHub
parent c382001253
commit 421adade52
7 changed files with 72 additions and 10 deletions

View File

@@ -107,4 +107,19 @@ var gZenCommonActions = {
timer = setTimeout(() => f.apply(this, args), delay);
};
},
/**
* Determines if a tab should be closed when navigating back with no history.
* Only tabs with an owner that are not pinned and not empty are eligible.
* Respects the user preference zen.tabs.close-on-back-with-no-history.
*
* @return {boolean} True if the tab should be closed on back
*/
shouldCloseTabOnBack() {
if (!Services.prefs.getBoolPref('zen.tabs.close-on-back-with-no-history', true)) {
return false;
}
const tab = gBrowser.selectedTab;
return Boolean(tab.owner && !tab.pinned && !tab.hasAttribute('zen-empty-tab'));
},
};