tor-browser

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

commit 8ea4758d577bf6fe3345f553def548159cd57efb
parent 2f46993c8fe60bb5ca5e600dc7e1340f29d834fc
Author: Jens Stutte <jstutte@mozilla.com>
Date:   Thu,  2 Oct 2025 13:23:46 +0000

Bug 1991844 - WebsiteFilter.init should not register observer for "http-on-examine-response" twice. r=mkaply

This might happen on reloading the policies, I suspect this can happen also outside from tests.

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

Diffstat:
Mbrowser/components/enterprisepolicies/helpers/WebsiteFilter.sys.mjs | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/browser/components/enterprisepolicies/helpers/WebsiteFilter.sys.mjs b/browser/components/enterprisepolicies/helpers/WebsiteFilter.sys.mjs @@ -44,6 +44,8 @@ ChromeUtils.defineLazyGetter(lazy, "log", () => { }); export let WebsiteFilter = { + _observerAdded: false, + init(blocklist, exceptionlist) { let blockArray = [], exceptionArray = []; @@ -102,7 +104,11 @@ export let WebsiteFilter = { } // We have to do this to catch 30X redirects. // See bug 456957. - Services.obs.addObserver(this, "http-on-examine-response", true); + if (!this._observerAdded) { + this._observerAdded = true; + // We rely on weak references, so we never remove this observer. + Services.obs.addObserver(this, "http-on-examine-response", true); + } }, shouldLoad(contentLocation, loadInfo) {