tor-browser

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

commit 70fe48978804cdc35093b6a41aff0be470d541c6
parent f847752b79eb5b8c6c38f1dc25d423388a72d142
Author: Emma Zuehlcke <emz@mozilla.com>
Date:   Thu, 16 Oct 2025 13:26:16 +0000

Bug 1991526 - Bypass profile-after-change gate for BTP xpcshell tests. r=manuel

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

Diffstat:
Atoolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/head.js | 16++++++++++++++++
Mtoolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_clearExpiredUserActivation.js | 3---
Mtoolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_importUserActivationPermissions.js | 3---
Mtoolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_purge.js | 3---
Mtoolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_purge_telemetry.js | 3---
Mtoolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_storage_batch_write.js | 4----
Mtoolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_telemetry_purge_num_hosts.js | 3---
Mtoolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/xpcshell.toml | 1+
8 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/head.js b/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/head.js @@ -0,0 +1,16 @@ +/* Any copyright is dedicated to the Public Domain. +http://creativecommons.org/publicdomain/zero/1.0/ */ + +add_setup(function () { + // BTP needs a temporary profile for storage. + do_get_profile(); + + // Simulate profile-after-change to remove BTP init gate. do_get_profile(true) + // can dispatch this, but it won't reach BTP because it goes through the + // regular observer service and not the category manager. So we do it + // manually. + let pacGate = Cc["@mozilla.org/profile-after-change-gate;1"].getService( + Ci.nsIObserver + ); + pacGate.observe(null, "profile-after-change", null); +}); diff --git a/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_clearExpiredUserActivation.js b/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_clearExpiredUserActivation.js @@ -4,9 +4,6 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; add_setup(function () { - // BTP needs a profile for storage. - do_get_profile(); - Services.prefs.setIntPref( "privacy.bounceTrackingProtection.mode", Ci.nsIBounceTrackingProtection.MODE_ENABLED diff --git a/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_importUserActivationPermissions.js b/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_importUserActivationPermissions.js @@ -39,9 +39,6 @@ function cleanup() { } add_setup(function () { - // Need a profile to data clearing calls. - do_get_profile(); - Services.prefs.setIntPref( "privacy.bounceTrackingProtection.mode", Ci.nsIBounceTrackingProtection.MODE_ENABLED diff --git a/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_purge.js b/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_purge.js @@ -67,9 +67,6 @@ function assertEmpty() { } add_setup(function () { - // Need a profile to data clearing calls. - do_get_profile(); - Services.prefs.setIntPref( "privacy.bounceTrackingProtection.mode", Ci.nsIBounceTrackingProtection.MODE_ENABLED diff --git a/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_purge_telemetry.js b/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_purge_telemetry.js @@ -32,9 +32,6 @@ function waitForPurgeTelemetry(siteHosts) { } add_setup(async function () { - // Need a profile to data clearing calls. - do_get_profile(); - Services.prefs.setIntPref( "privacy.bounceTrackingProtection.mode", Ci.nsIBounceTrackingProtection.MODE_ENABLED diff --git a/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_storage_batch_write.js b/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_storage_batch_write.js @@ -65,10 +65,6 @@ async function waitForDBSkipFlush() { } add_setup(async function () { - // BTP storage needs a profile directory to work. That's where the sqlite - // database file is stored. - do_get_profile(); - // Get the sqlite database file path. let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile); let dbFile = profileDir.clone(); diff --git a/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_telemetry_purge_num_hosts.js b/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/test_bouncetracking_telemetry_purge_num_hosts.js @@ -6,9 +6,6 @@ let btp; add_setup(function () { - // Need a profile to data clearing calls. - do_get_profile(); - Services.prefs.setIntPref( "privacy.bounceTrackingProtection.mode", Ci.nsIBounceTrackingProtection.MODE_ENABLED diff --git a/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/xpcshell.toml b/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/xpcshell.toml @@ -1,4 +1,5 @@ [DEFAULT] +head = "head.js" prefs = [ "privacy.bounceTrackingProtection.mode=1", "privacy.bounceTrackingProtection.enableTestMode=true",