tor-browser

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

commit f9ccf619aaeb3d2677940078c80847383ba9120a
parent 7d387e8f7272e4106b6050c4d4dbb61ab50e41f5
Author: Sebastian Streich <sstreich@mozilla.com>
Date:   Thu, 18 Dec 2025 13:32:32 +0000

Bug 1999946 - Cancel Channelfilter on a failed start call r=ip-protection-reviewers,baku

If we have an exception after we created the channelfilter, it will queue up pending channels, with no option to recover.

Given we show "OFF" in that state, we should cancel the channelFilter.

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

Diffstat:
Mbrowser/components/ipprotection/IPPProxyManager.sys.mjs | 1+
Mbrowser/components/ipprotection/tests/browser/browser_IPPProxyManager.js | 43+++++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/browser/components/ipprotection/IPPProxyManager.sys.mjs b/browser/components/ipprotection/IPPProxyManager.sys.mjs @@ -210,6 +210,7 @@ class IPPProxyManagerSingleton extends EventTarget { started = await this.#startInternal(); } catch (error) { this.#setErrorState(ERRORS.GENERIC, error); + this.cancelChannelFilter(); return; } diff --git a/browser/components/ipprotection/tests/browser/browser_IPPProxyManager.js b/browser/components/ipprotection/tests/browser/browser_IPPProxyManager.js @@ -118,3 +118,46 @@ add_task(async function test_IPPProxyManager_handleProxyErrorEvent() { await cleanupAlpha(); cleanupService(); }); + +/** + * Test for Bug 1999946 - When having an issue in IPPProxyManager.start + * we must make sure we don't have an invalid connection left running. + */ +add_task(async function test_IPPProxyManager_bug_1999946() { + const { IPPChannelFilter } = ChromeUtils.importESModule( + "resource:///modules/ipprotection/IPPChannelFilter.sys.mjs" + ); + + // Hook the Call to create to capture the created channel filter + let channelFilterRef = null; + const sandbox = sinon.createSandbox(); + const originalCreate = IPPChannelFilter.create.bind(IPPChannelFilter); + sandbox.stub(IPPChannelFilter, "create").callsFake(function () { + channelFilterRef = originalCreate(); + sandbox.spy(channelFilterRef, "stop"); + return channelFilterRef; + }); + + STUBS.fetchProxyPass.rejects(new Error("Simulate a Fail")); + + setupService({ + isSignedIn: true, + canEnroll: true, + }); + + let cleanupAlpha = await setupExperiment({ enabled: true, variant: "alpha" }); + + await IPProtectionServerlist.maybeFetchList(); + + await IPPProxyManager.start(); + + Assert.ok(channelFilterRef, "Channel filter should have been created"); + Assert.ok( + channelFilterRef.stop.calledOnce, + "Channel filter stop should be called when fetchProxyPass fails" + ); + + sandbox.restore(); + await cleanupAlpha(); + cleanupService(); +});