commit 68c66709ccd36b3a645e0dba833a8cec9ea41ee9
parent 94c9f2a64f9caaddcac86acbfc796d810721c61a
Author: Cristian Tuns <ctuns@mozilla.com>
Date: Wed, 7 Jan 2026 21:55:06 -0500
Revert "Bug 2005086 - Auto start IPP Proxy on session restore. r=ip-protection-reviewers,baku" for causing xpcshell failures in test_IPPAutoStart.js DONTBUILD
This reverts commit 9f50838225c7945c02eab2680cbd2179c12dd7cd.
Diffstat:
5 files changed, 4 insertions(+), 256 deletions(-)
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
@@ -3554,7 +3554,6 @@ pref("browser.ipProtection.features.autoStart", false);
// Prefs to track the user turning on autostart preference
pref("browser.ipProtection.autoStartEnabled", false);
pref("browser.ipProtection.autoStartPrivateEnabled", false);
-pref("browser.ipProtection.autoRestoreEnabled", true);
// Pref to track whether the user has turned IP protection on
pref("browser.ipProtection.userEnabled", false);
// Pref to track which experiment version the user is enrolled in
diff --git a/browser/components/ipprotection/IPPAutoStart.sys.mjs b/browser/components/ipprotection/IPPAutoStart.sys.mjs
@@ -17,13 +17,10 @@ ChromeUtils.defineESModuleGetters(lazy, {
"moz-src:///browser/components/ipprotection/IPProtectionService.sys.mjs",
IPProtectionStates:
"moz-src:///browser/components/ipprotection/IPProtectionService.sys.mjs",
- SessionStartup: "resource:///modules/sessionstore/SessionStartup.sys.mjs",
});
const AUTOSTART_FEATURE_ENABLE_PREF = "browser.ipProtection.features.autoStart";
const AUTOSTART_PREF = "browser.ipProtection.autoStartEnabled";
-const USER_ENABLED_PREF = "browser.ipProtection.userEnabled";
-const AUTO_RESTORE_PREF = "browser.ipProtection.autoRestoreEnabled";
/**
* This class monitors the auto-start pref and if it sees a READY state, it
@@ -116,116 +113,16 @@ class IPPAutoStartSingleton {
const IPPAutoStart = new IPPAutoStartSingleton();
/**
- * A helper that manages the auto-restore of the VPN connection on session restore.
- * If the user had the VPN active before closing the browser and the session is
- * being restored, this class will start the VPN again once the IPProtectionService
- * reaches the READY state.
- */
-export class IPPAutoRestoreSingleton {
- #willRestore = false;
- #forceRestore = false;
-
- /**
- * @class
- * @param {boolean} forceRestore
- */
- constructor(forceRestore = false) {
- this.#forceRestore = forceRestore;
- this.handleEvent = this.#handleEvent.bind(this);
-
- XPCOMUtils.defineLazyPreferenceGetter(
- this,
- "userEnabled",
- USER_ENABLED_PREF,
- false
- );
-
- // If auto-start is enabled, auto-restore is not needed.
- XPCOMUtils.defineLazyPreferenceGetter(
- this,
- "autoStartPref",
- AUTOSTART_PREF,
- false
- );
-
- XPCOMUtils.defineLazyPreferenceGetter(
- this,
- "autoRestorePref",
- AUTO_RESTORE_PREF,
- false
- );
- }
-
- init() {
- if (!this.shouldRestore) {
- return;
- }
- this.#willRestore = true;
- lazy.IPProtectionService.addEventListener(
- "IPProtectionService:StateChanged",
- this.handleEvent
- );
- }
-
- initOnStartupCompleted() {}
-
- uninit() {
- if (!this.#willRestore) {
- return;
- }
- this.#willRestore = false;
- lazy.IPProtectionService.removeEventListener(
- "IPProtectionService:StateChanged",
- this.handleEvent
- );
- }
-
- get shouldRestore() {
- if (!this.autoRestorePref || this.autoStartPref) {
- return false;
- }
-
- if (this.#forceRestore) {
- return this.userEnabled;
- }
-
- let willRestore =
- lazy.SessionStartup.willRestore() &&
- !lazy.SessionStartup.willRestoreAsCrashed();
-
- return (
- lazy.IPProtectionServerlist.hasList && willRestore && this.userEnabled
- );
- }
-
- #handleEvent(_event) {
- switch (lazy.IPProtectionService.state) {
- case lazy.IPProtectionStates.READY:
- lazy.IPPProxyManager.start(/* user action: */ false);
- break;
-
- default:
- break;
- }
- // Only get the cached state.
- this.uninit();
- }
-}
-
-const IPPAutoRestore = new IPPAutoRestoreSingleton();
-
-/**
* This class monitors the startup phases and registers/unregisters the channel
* filter to avoid data leak. The activation of the VPN is done by the
- * IPPAutoStart and IPPAutoRestore objects above.
+ * IPPAutoStart object above.
*/
class IPPEarlyStartupFilter {
#autoStartAndAtStartup = false;
constructor() {
this.handleEvent = this.#handleEvent.bind(this);
- this.#autoStartAndAtStartup =
- IPPAutoStart.autoStart || IPPAutoRestore.shouldRestore;
+ this.#autoStartAndAtStartup = IPPAutoStart.autoStart;
}
init() {
@@ -285,10 +182,6 @@ class IPPEarlyStartupFilter {
}
}
-const IPPAutoStartHelpers = [
- IPPAutoRestore,
- IPPAutoStart,
- new IPPEarlyStartupFilter(),
-];
+const IPPAutoStartHelpers = [IPPAutoStart, new IPPEarlyStartupFilter()];
export { IPPAutoStartHelpers };
diff --git a/browser/components/ipprotection/IPProtectionService.sys.mjs b/browser/components/ipprotection/IPProtectionService.sys.mjs
@@ -98,8 +98,7 @@ class IPProtectionServiceSingleton extends EventTarget {
async maybeEarlyInit() {
if (
this.featureEnabled &&
- (Services.prefs.getBoolPref("browser.ipProtection.autoStartEnabled") ||
- Services.prefs.getBoolPref("browser.ipProtection.userEnabled"))
+ Services.prefs.getBoolPref("browser.ipProtection.autoStartEnabled")
) {
await this.init();
}
diff --git a/browser/components/ipprotection/tests/xpcshell/test_IPPAutoStart.js b/browser/components/ipprotection/tests/xpcshell/test_IPPAutoStart.js
@@ -1,141 +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 http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const { IPPAutoRestoreSingleton } = ChromeUtils.importESModule(
- "moz-src:///browser/components/ipprotection/IPPAutoStart.sys.mjs"
-);
-
-add_setup(async function () {
- await putServerInRemoteSettings();
- Services.prefs.setBoolPref("browser.ipProtection.autoRestoreEnabled", true);
- IPProtectionService.uninit();
-
- registerCleanupFunction(async () => {
- Services.prefs.clearUserPref("browser.ipProtection.userEnabled");
- Services.prefs.clearUserPref("browser.ipProtection.autoRestoreEnabled");
- IPProtectionService.init();
- });
-});
-
-/**
- * Tests that the VPN auto-starts when if the user had previously enabled it.
- */
-add_task(async function test_IPPStart_AutoRestore_if_userEnabled() {
- // Simulate user having previously enabled the VPN
- Services.prefs.setBoolPref("browser.ipProtection.userEnabled", true);
-
- let sandbox = sinon.createSandbox();
- setupStubs(sandbox);
-
- const autoRestore = new IPPAutoRestoreSingleton(true);
-
- const waitForReady = waitForEvent(
- IPProtectionService,
- "IPProtectionService:StateChanged",
- () => IPProtectionService.state === IPProtectionStates.READY
- );
-
- IPProtectionService.init();
- autoRestore.init();
-
- await waitForReady;
-
- Assert.ok(
- autoRestore.shouldRestore,
- "Will auto-start when userEnabled is true"
- );
-
- Assert.equal(
- IPPProxyManager.state,
- IPPProxyStates.ACTIVATING,
- "Proxy is activating"
- );
-
- autoRestore.uninit();
- IPProtectionService.uninit();
- sandbox.restore();
-});
-
-/**
- * Tests that the VPN does not auto-start if the user had previously disabled it.
- */
-add_task(async function test_IPPAutoStart_restore_if_userDisabled() {
- // Simulate user having previously disabled the VPN
- Services.prefs.setBoolPref("browser.ipProtection.userEnabled", false);
-
- let sandbox = sinon.createSandbox();
- setupStubs(sandbox);
-
- const autoRestore = new IPPAutoRestoreSingleton(true);
-
- const waitForReady = waitForEvent(
- IPProtectionService,
- "IPProtectionService:StateChanged",
- () => IPProtectionService.state === IPProtectionStates.READY
- );
-
- IPProtectionService.init();
- autoRestore.init();
-
- await waitForReady;
-
- Assert.ok(
- !autoRestore.shouldRestore,
- "Will not auto-start when userEnabled is false"
- );
-
- Assert.equal(
- IPPProxyManager.state,
- IPPProxyStates.READY,
- "Proxy is still ready"
- );
-
- await IPPProxyManager.stop(false);
-
- autoRestore.uninit();
- IPProtectionService.uninit();
- sandbox.restore();
-});
-
-/**
- * Tests that the VPN does not auto-start if the state is not READY.
- */
-add_task(async function test_IPPAutoStart_restore_if_notReady() {
- // Simulate user having previously enabled the VPN
- Services.prefs.setBoolPref("browser.ipProtection.userEnabled", true);
-
- let sandbox = sinon.createSandbox();
- setupStubs(sandbox);
-
- const autoRestore = new IPPAutoRestoreSingleton(true);
-
- const waitForUnavailable = waitForEvent(
- IPProtectionService,
- "IPProtectionService:StateChanged",
- () => IPProtectionService.state === IPProtectionStates.UNAVAILABLE
- );
-
- IPProtectionService.init();
- IPProtectionService.setState(IPProtectionStates.UNAVAILABLE);
-
- autoRestore.init();
- await waitForUnavailable;
-
- Assert.ok(
- autoRestore.shouldRestore,
- "Can auto-start when userEnabled is true"
- );
-
- Assert.equal(
- IPPProxyManager.state,
- IPPProxyStates.READY,
- "Proxy is still not ready"
- );
-
- autoRestore.uninit();
- IPProtectionService.uninit();
- sandbox.restore();
-});
diff --git a/browser/components/ipprotection/tests/xpcshell/xpcshell.toml b/browser/components/ipprotection/tests/xpcshell/xpcshell.toml
@@ -11,8 +11,6 @@ prefs = [
["test_GuardianClient.js"]
-["test_IPPAutoStart.js"]
-
["test_IPPChannelFilter.js"]
["test_IPPExceptionsManager.js"]