tor-browser

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

commit f2f4aa5ed427daae506c06b12fc662b9a8844a5a
parent 7dc370bd78d10b6737809c8b33d8437ef6c7b144
Author: Cristina Horotan <chorotan@mozilla.com>
Date:   Thu, 16 Oct 2025 17:10:24 +0300

Revert "Bug 1991526 - Bypass profile-after-change gate for BTP xpcshell tests. r=manuel" for causing build bustages at ProfileAfterChangeGate.cpp

This reverts commit 70fe48978804cdc35093b6a41aff0be470d541c6.

Revert "Bug 1991526 - Prevent BTP init before profile-after-change. r=manuel"

This reverts commit f847752b79eb5b8c6c38f1dc25d423388a72d142.

Diffstat:
Mtoolkit/components/antitracking/bouncetrackingprotection/BounceTrackingProtection.cpp | 8--------
Mtoolkit/components/antitracking/bouncetrackingprotection/BounceTrackingState.cpp | 8--------
Dtoolkit/components/antitracking/bouncetrackingprotection/ProfileAfterChangeGate.cpp | 27---------------------------
Dtoolkit/components/antitracking/bouncetrackingprotection/ProfileAfterChangeGate.h | 24------------------------
Mtoolkit/components/antitracking/bouncetrackingprotection/components.conf | 10----------
Mtoolkit/components/antitracking/bouncetrackingprotection/moz.build | 2--
Dtoolkit/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-
14 files changed, 19 insertions(+), 96 deletions(-)

diff --git a/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingProtection.cpp b/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingProtection.cpp @@ -11,7 +11,6 @@ #include "BounceTrackingMapEntry.h" #include "ClearDataCallback.h" #include "PromiseNativeWrapper.h" -#include "ProfileAfterChangeGate.h" #include "BounceTrackingStateGlobal.h" #include "ErrorList.h" @@ -67,13 +66,6 @@ already_AddRefed<BounceTrackingProtection> BounceTrackingProtection::GetSingleton() { MOZ_ASSERT(XRE_IsParentProcess()); - nsresult rv = EnsurePastProfileAfterChange(); - if (NS_FAILED(rv)) { - // We haven't reached "profile-after-change" yet, so we can't initialize - // BounceTrackingProtection. Return nullptr. - return nullptr; - } - // Init previously failed, don't try again. if (sInitFailed) { return nullptr; diff --git a/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingState.cpp b/toolkit/components/antitracking/bouncetrackingprotection/BounceTrackingState.cpp @@ -7,7 +7,6 @@ #include "BounceTrackingProtection.h" #include "BounceTrackingState.h" #include "BounceTrackingRecord.h" -#include "ProfileAfterChangeGate.h" #include "BounceTrackingStorageObserver.h" #include "ErrorList.h" @@ -69,13 +68,6 @@ already_AddRefed<BounceTrackingState> BounceTrackingState::GetOrCreate( dom::BrowsingContextWebProgress* aWebProgress, nsresult& aRv) { aRv = NS_OK; - // Do not init before profile-after-change. - nsresult rv = EnsurePastProfileAfterChange(); - if (NS_FAILED(rv)) { - aRv = rv; - return nullptr; - } - if (!aWebProgress) { aRv = NS_ERROR_INVALID_ARG; return nullptr; diff --git a/toolkit/components/antitracking/bouncetrackingprotection/ProfileAfterChangeGate.cpp b/toolkit/components/antitracking/bouncetrackingprotection/ProfileAfterChangeGate.cpp @@ -1,27 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// ProfileAfterChangeGate.cpp -#include "ProfileAfterChangeGate.h" -#include "nsError.h" -#include <string.h> - -static bool sPastPAC = false; // main-thread only - -NS_IMPL_ISUPPORTS(ProfileAfterChangeGate, nsIObserver) - -NS_IMETHODIMP -ProfileAfterChangeGate::Observe(nsISupports*, const char* aTopic, - const char16_t*) { - MOZ_ASSERT(NS_IsMainThread()); - if (strcmp(aTopic, "profile-after-change") == 0) { - sPastPAC = true; - } - return NS_OK; -} - -nsresult EnsurePastProfileAfterChange() { - MOZ_ASSERT(NS_IsMainThread()); - return sPastPAC ? NS_OK : NS_ERROR_NOT_AVAILABLE; -} diff --git a/toolkit/components/antitracking/bouncetrackingprotection/ProfileAfterChangeGate.h b/toolkit/components/antitracking/bouncetrackingprotection/ProfileAfterChangeGate.h @@ -1,24 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// ProfileAfterChangeGate.h -#ifndef mozilla_ProfileAfterChangeGate_h -#define mozilla_ProfileAfterChangeGate_h - -#include "nsIObserver.h" - -// Tiny observer that flips a file-scope flag at "profile-after-change". - -class ProfileAfterChangeGate final : public nsIObserver { - public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - private: - ~ProfileAfterChangeGate() = default; -}; - -// NS_OK if past "profile-after-change", else NS_ERROR_NOT_AVAILABLE. -nsresult EnsurePastProfileAfterChange(); - -#endif diff --git a/toolkit/components/antitracking/bouncetrackingprotection/components.conf b/toolkit/components/antitracking/bouncetrackingprotection/components.conf @@ -27,14 +27,4 @@ Classes = [ 'constructor': 'BTPRemoteExceptionList', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, - { - 'cid': '{F8319188-1992-4C16-A581-C06A950B01BF}', - 'contract_ids': ['@mozilla.org/profile-after-change-gate;1'], - 'type': 'ProfileAfterChangeGate', - 'headers': ['mozilla/ProfileAfterChangeGate.h'], - 'categories': { - 'profile-after-change': 'service,@mozilla.org/profile-after-change-gate;1', - }, - 'singleton': True, - }, ] diff --git a/toolkit/components/antitracking/bouncetrackingprotection/moz.build b/toolkit/components/antitracking/bouncetrackingprotection/moz.build @@ -34,7 +34,6 @@ EXPORTS.mozilla += [ "BounceTrackingStateGlobal.h", "BounceTrackingStorageObserver.h", "ClearDataCallback.h", - "ProfileAfterChangeGate.h", "PromiseNativeWrapper.h", ] @@ -48,7 +47,6 @@ UNIFIED_SOURCES += [ "BounceTrackingStateGlobal.cpp", "BounceTrackingStorageObserver.cpp", "ClearDataCallback.cpp", - "ProfileAfterChangeGate.cpp", "PromiseNativeWrapper.cpp", ] diff --git a/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/head.js b/toolkit/components/antitracking/bouncetrackingprotection/test/xpcshell/head.js @@ -1,16 +0,0 @@ -/* 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,6 +4,9 @@ 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,6 +39,9 @@ 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,6 +67,9 @@ 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,6 +32,9 @@ 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,6 +65,10 @@ 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,6 +6,9 @@ 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,5 +1,4 @@ [DEFAULT] -head = "head.js" prefs = [ "privacy.bounceTrackingProtection.mode=1", "privacy.bounceTrackingProtection.enableTestMode=true",