tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 369d1019f57689030bb0702f10e0137972e9612f
parent deef70bdaa869d5ab904b77abb5481692be58bb3
Author: Benjamin VanderSloot <bvandersloot@mozilla.com>
Date:   Mon, 22 Dec 2025 20:46:57 +0000

Bug 2001195 - Implement Browsing data card - r=emz,fluent-reviewers,akulyk,bolsson

Using temporary strings

Differential Revision: https://phabricator.services.mozilla.com/D276290

Diffstat:
Mbrowser/components/preferences/main.js | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbrowser/components/preferences/privacy.inc.xhtml | 3++-
Mbrowser/components/preferences/privacy.js | 1+
Mbrowser/components/preferences/tests/siteData/browser.toml | 5+++++
Abrowser/components/preferences/tests/siteData/browser_siteData_srd.js | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbrowser/locales-preview/privacyPreferences.ftl | 17++++++++++++++++-
6 files changed, 182 insertions(+), 2 deletions(-)

diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js @@ -2920,6 +2920,74 @@ SettingGroupManager.registerGroups({ }, ], }, + cookiesAndSiteData2: { + inProgress: true, + l10nId: "sitedata-heading", + headingLevel: 2, + items: [ + { + id: "siteDataSize", + l10nId: "sitedata-total-size-calculating", + control: "moz-box-item", + supportPage: "sitedata-learn-more", + }, + { + id: "manageDataSettingsGroup", + control: "moz-box-group", + controlAttrs: { + type: "default", + }, + items: [ + { + id: "clearSiteDataButton", + l10nId: "sitedata-clear2", + control: "moz-box-button", + iconSrc: "chrome://browser/skin/flame.svg", + controlAttrs: { + "search-l10n-ids": ` + clear-site-data-cookies-empty.label, + clear-site-data-cache-empty.label + `, + }, + }, + { + id: "siteDataSettings", + l10nId: "sitedata-settings3", + control: "moz-box-button", + controlAttrs: { + "search-l10n-ids": ` + site-data-settings-window.title, + site-data-column-host.label, + site-data-column-cookies.label, + site-data-column-storage.label, + site-data-settings-description, + site-data-remove-all.label, + `, + }, + }, + { + id: "cookieExceptions", + l10nId: "sitedata-cookies-exceptions3", + control: "moz-box-button", + controlAttrs: { + "search-l10n-ids": ` + permissions-address, + permissions-block.label, + permissions-allow.label, + permissions-remove.label, + permissions-remove-all.label, + permissions-exceptions-cookie-desc + `, + }, + }, + ], + }, + { + id: "deleteOnClose", + l10nId: "sitedata-delete-on-close", + }, + ], + }, networkProxy: { items: [ { diff --git a/browser/components/preferences/privacy.inc.xhtml b/browser/components/preferences/privacy.inc.xhtml @@ -403,10 +403,11 @@ </groupbox> -<groupbox id="siteDataGroup" data-category="panePrivacy" hidden="true" aria-describedby="totalSiteDataSize"> +<groupbox id="siteDataGroup" data-category="panePrivacy" hidden="true" aria-describedby="totalSiteDataSize" data-srd-groupid="cookiesAndSiteData2"> <label><html:h2 data-l10n-id="sitedata-header"/></label> <html:setting-group groupid="cookiesAndSiteData"/> </groupbox> +<html:setting-group groupid="cookiesAndSiteData2" data-category="panePrivacy" hidden="true" /> <!-- Cookie Banner Handling --> <groupbox id="cookieBannerHandlingGroup" data-category="panePrivacy" data-subcategory="cookiebanner" hidden="true"> diff --git a/browser/components/preferences/privacy.js b/browser/components/preferences/privacy.js @@ -3774,6 +3774,7 @@ var gPrivacyPane = { initSettingGroup("httpsOnly"); initSettingGroup("browsingProtection"); initSettingGroup("cookiesAndSiteData"); + initSettingGroup("cookiesAndSiteData2"); initSettingGroup("certificates"); initSettingGroup("ipprotection"); initSettingGroup("history"); diff --git a/browser/components/preferences/tests/siteData/browser.toml b/browser/components/preferences/tests/siteData/browser.toml @@ -25,3 +25,8 @@ skip-if = [ skip-if = [ "tsan", # Bug 1683730 ] + +["browser_siteData_srd.js"] +prefs = [ + "browser.settings-redesign.cookiesAndSiteData2.enabled=true" +] diff --git a/browser/components/preferences/tests/siteData/browser_siteData_srd.js b/browser/components/preferences/tests/siteData/browser_siteData_srd.js @@ -0,0 +1,90 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// When the settings redesign is complete, we should remove +// this and replace test_ui_loading_state in +// ./browser_siteData.js with this version. + +add_task(async function test_ui_loading_state() { + let updatedPromise = promiseSiteDataManagerSitesUpdated(); + await openPreferencesViaOpenPreferencesAPI("privacy", { leaveOpen: true }); + await updatedPromise; + let cacheSize = await SiteDataManager.getCacheSize(); + + let doc = gBrowser.selectedBrowser.contentDocument; + let clearBtn = doc.getElementById("clearSiteDataButton"); + let settingsButton = doc.getElementById("siteDataSettings"); + let totalSiteDataSizeLabel = doc.getElementById("siteDataSize"); + is( + clearBtn.disabled, + false, + "Should enable clear button after sites updated" + ); + is( + settingsButton.disabled, + false, + "Should enable settings button after sites updated" + ); + await SiteDataManager.getTotalUsage().then(usage => { + let [value, unit] = DownloadUtils.convertByteUnits(usage + cacheSize); + Assert.deepEqual( + doc.l10n.getAttributes(totalSiteDataSizeLabel), + { + id: "sitedata-total-size3", + args: { value, unit }, + }, + "Should show the right total site data size" + ); + }); + + Services.obs.notifyObservers(null, "sitedatamanager:updating-sites"); + // Wait a tick for the UI to update. + await new Promise(resolve => requestAnimationFrame(resolve)); + + is( + clearBtn.disabled, + true, + "Should disable clear button while updating sites" + ); + is( + settingsButton.disabled, + true, + "Should disable settings button while updating sites" + ); + Assert.equal( + doc.l10n.getAttributes(totalSiteDataSizeLabel).id, + "sitedata-total-size-calculating2", + "Should show the loading message while updating" + ); + + Services.obs.notifyObservers(null, "sitedatamanager:sites-updated"); + // Wait a tick for the UI to update. + await new Promise(resolve => setTimeout(resolve, 0)); + + is( + clearBtn.disabled, + false, + "Should enable clear button after sites updated" + ); + is( + settingsButton.disabled, + false, + "Should enable settings button after sites updated" + ); + cacheSize = await SiteDataManager.getCacheSize(); + await SiteDataManager.getTotalUsage().then(usage => { + let [value, unit] = DownloadUtils.convertByteUnits(usage + cacheSize); + Assert.deepEqual( + doc.l10n.getAttributes(totalSiteDataSizeLabel), + { + id: "sitedata-total-size3", + args: { value, unit }, + }, + "Should show the right total site data size" + ); + }); + + BrowserTestUtils.removeTab(gBrowser.selectedTab); +}); diff --git a/browser/locales-preview/privacyPreferences.ftl b/browser/locales-preview/privacyPreferences.ftl @@ -322,4 +322,19 @@ do-not-track-removal3 = .message = We no longer support the “Do Not Track” feature non-technical-privacy-heading = - .label = Website Privacy Preferences + .label = Website Privacy Preferences + +## Site Data + +sitedata-heading = + .label = Browsing data + .description = Manage your cookies, history, cache, website data, and more. + +sitedata-settings3 = + .label = Clear data for specific sites + .accesskey = s + +sitedata-cookies-exceptions3 = + .label = Manage exceptions + .accesskey = x + .description = Choose how specific sites handle cookies and site data.