tor-browser

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

commit cdd7ecd0cc1e59a8bf9e88ecc771f8aecde2327d
parent cf10e9399e97907b96cb823d635e1b25ec10f392
Author: John Bieling <john@thunderbird.net>
Date:   Mon, 17 Nov 2025 17:17:03 +0000

Bug 1999202 - Ensure test_data_collection_not_in_db.js also tests with extensions.dataCollectionPermissions.enabled disabled. r=robwu

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

Diffstat:
Mtoolkit/mozapps/extensions/test/xpcshell/test_data_collection_not_in_db.js | 42++++++++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_data_collection_not_in_db.js b/toolkit/mozapps/extensions/test/xpcshell/test_data_collection_not_in_db.js @@ -4,12 +4,16 @@ // We don't have an easy way to serve update manifests from a secure URL. Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false); -Services.prefs.setBoolPref(PREF_DATA_COLLECTION_PERMISSIONS_ENABLED, true); const server = AddonTestUtils.createHttpServer(); add_setup(async () => { ExtensionTestUtils.mockAppInfo(); + + registerCleanupFunction(() => { + Services.prefs.clearUserPref(PREF_EM_CHECK_UPDATE_SECURITY); + Services.prefs.clearUserPref(PREF_DATA_COLLECTION_PERMISSIONS_ENABLED); + }); }); async function deleteDataCollectionFromDB(addonId) { @@ -64,9 +68,20 @@ function prepareToServeUpdate(extensionData) { ); } -// Regression test for https://bugzilla.mozilla.org/show_bug.cgi?id=1984724 -add_task(async function test_db_without_data_collection_background_update() { - const ID = "@addon-without-data_collection-in-extensions.json"; +/** + * + * @param {string} ID - The ID for the generated add-on. + * @param {boolean} permissionEnabled - Whether the preference for data collection + * (PREF_DATA_COLLECTION_PERMISSIONS_ENABLED) is enabled during the test. + */ +async function do_test_db_without_data_collection_background_update( + ID, + permissionEnabled +) { + Services.prefs.setBoolPref( + PREF_DATA_COLLECTION_PERMISSIONS_ENABLED, + permissionEnabled + ); await promiseStartupManager(); @@ -129,10 +144,11 @@ add_task(async function test_db_without_data_collection_background_update() { let addon = await AddonManager.getAddonByID(ID); equal(addon.version, "2.0", "Add-on was updated"); + const expected_data_collection = permissionEnabled ? ["none"] : []; Assert.deepEqual( addon.userPermissions, - { permissions: [], origins: [], data_collection: ["none"] }, - ".userPermissions now contains the updated data_collection" + { permissions: [], origins: [], data_collection: expected_data_collection }, + ".userPermissions now contains the expected data_collection" ); Services.obs.removeObserver( promptObserver, @@ -141,4 +157,18 @@ add_task(async function test_db_without_data_collection_background_update() { await addon.uninstall(); await promiseShutdownManager(); +} + +// Regression test for https://bugzilla.mozilla.org/show_bug.cgi?id=1984724 +add_task(async function test_db_without_data_collection_background_update() { + const ID = "@addon-without-data_collection-in-extensions-db-feature-enabled"; + await do_test_db_without_data_collection_background_update(ID, true); +}); + +// Test for platforms where data_collection_permissions is disabled, as for +// Thunderbird (see Bug 1987828). Also verify that these platforms are unaffected +// by regressions such as Bug 1984724. +add_task(async function test_db_with_data_collection_feature_disabled() { + const ID = "@addon-without-data_collection-in-extensions-db-feature-disabled"; + await do_test_db_without_data_collection_background_update(ID, false); });