tor-browser

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

commit a9afdf5a46f7f660101d8d87ccf1ac07ba1c32de
parent 7260b458c74d9dcb381e55ab0e1312be3ccf499f
Author: Cristina Horotan <chorotan@mozilla.com>
Date:   Fri, 24 Oct 2025 20:38:05 +0300

Revert "Bug 1944147 - Option to turn off newtab for automated tests and other automation. r=mconley" for causing bc failures on browser_preloading_tab_moving.js

This reverts commit 00d49864ddaf2301fa40f3cbf3a76a048e7e2a79.

Diffstat:
Mbrowser/modules/AboutNewTab.sys.mjs | 26+++++---------------------
Mbrowser/modules/test/browser/browser.toml | 2--
Dbrowser/modules/test/browser/browser_aboutnewtab_init_gate.js | 49-------------------------------------------------
3 files changed, 5 insertions(+), 72 deletions(-)

diff --git a/browser/modules/AboutNewTab.sys.mjs b/browser/modules/AboutNewTab.sys.mjs @@ -21,7 +21,6 @@ const PREF_ACTIVITY_STREAM_DEBUG = "browser.newtabpage.activity-stream.debug"; // AboutHomeStartupCache needs us in "quit-application", so stay alive longer. // TODO: We could better have a shared async shutdown blocker? const TOPIC_APP_QUIT = "profile-before-change"; -const PREF_SHOULD_INITIALIZE = "browser.newtabpage.shouldInitialize"; export const AboutNewTab = { QueryInterface: ChromeUtils.generateQI([ @@ -51,16 +50,6 @@ export const AboutNewTab = { return; } - // For tests/automation: when false, newtab won't initialize in this session. - // Flipping after initialization has no effect on the current session. - const shouldInitialize = Services.prefs.getBoolPref( - PREF_SHOULD_INITIALIZE, - true - ); - if (!shouldInitialize) { - return; - } - Services.obs.addObserver(this, TOPIC_APP_QUIT); if (!AppConstants.RELEASE_OR_BETA) { XPCOMUtils.defineLazyPreferenceGetter( @@ -249,16 +238,11 @@ export const AboutNewTab = { this.activityStream.uninit(); this.activityStream = null; } - try { - Services.obs.removeObserver(this, TOPIC_APP_QUIT); - Services.obs.removeObserver( - this, - lazy.TelemetryReportingPolicy.TELEMETRY_TOU_ACCEPTED_OR_INELIGIBLE - ); - } catch (e) { - // If init failed before registering these observers, removeObserver may throw. - // Safe to ignore during shutdown. - } + Services.obs.removeObserver(this, TOPIC_APP_QUIT); + Services.obs.removeObserver( + this, + lazy.TelemetryReportingPolicy.TELEMETRY_TOU_ACCEPTED_OR_INELIGIBLE + ); this.initialized = false; }, diff --git a/browser/modules/test/browser/browser.toml b/browser/modules/test/browser/browser.toml @@ -77,8 +77,6 @@ https_first_disabled = true ["browser_UsageTelemetry_uniqueOriginsVisitedInPast24Hours.js"] https_first_disabled = true -["browser_aboutnewtab_init_gate.js"] - ["browser_preloading_tab_moving.js"] ["browser_taskbar_preview.js"] diff --git a/browser/modules/test/browser/browser_aboutnewtab_init_gate.js b/browser/modules/test/browser/browser_aboutnewtab_init_gate.js @@ -1,49 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -const PREF = "browser.newtabpage.shouldInitialize"; - -add_task(async function test_aboutnewtab_does_not_init_when_pref_false() { - await SpecialPowers.pushPrefEnv({ set: [[PREF, false]] }); - - // Reset for a clean start just in case. - AboutNewTab.uninit(); - - // Call init(); with pref=false, we should bail out early. - AboutNewTab.init(); - - ok( - !AboutNewTab.initialized, - "AboutNewTab should not be initialized when pref is false" - ); - - // Cleanup just in case, also shouldn't throw or hang. - AboutNewTab.uninit(); - ok( - !AboutNewTab.initialized, - "AboutNewTab should still be uninitialized after uninit()" - ); -}); - -add_task(async function test_aboutnewtab_initializes_by_default() { - await SpecialPowers.pushPrefEnv({ set: [[PREF, true]] }); - - // Reset for a clean start just in case. - AboutNewTab.uninit(); - - // Call init(); with pref=true, we should initialize. - AboutNewTab.init(); - - ok( - AboutNewTab.initialized, - "AboutNewTab should initialize when pref is true" - ); - - AboutNewTab.uninit(); - ok( - !AboutNewTab.initialized, - "AboutNewTab should be uninitialized after uninit()" - ); -});