commit f149a7343239d27b1d7323eb0633be21f62f41d0 parent 6f03a3bf6d9883b9824f0c1506d2a3d2e9588fb9 Author: agoloman <agoloman@mozilla.com> Date: Sat, 18 Oct 2025 03:26:07 +0300 Revert "Bug 1991951 - (part 3) Connect backup prefs to enterprise policies. r=cdupuis,fluent-reviewers,fchasen,bolsson,mkaply" for causing xpc failures @test_sorted_alphabetically.js. This reverts commit beff0e12866e45faddddd9e9138a6b5781c49d8d. Revert "Bug 1991951 - (part 2) Split up prefs for backup service to backup and restore. r=omc-reviewers,akulyk,nrishel,mviar,fchasen,jprickett" This reverts commit dc44d12594f1402e8c4b6e021975d04001b9cb26. Diffstat:
17 files changed, 70 insertions(+), 363 deletions(-)
diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js @@ -3417,10 +3417,8 @@ pref("browser.mailto.dualPrompt.dismissXClickMinutes", 1440); // one day pref("browser.backup.enabled", true); // Pref to control whether scheduled backups run or not. pref("browser.backup.scheduled.enabled", false); -// Pref to control visibility and usability of the create backup feature. -pref("browser.backup.archive.enabled", false); -// Pref to control visibility and usability of the restore from backup feature. -pref("browser.backup.restore.enabled", false); +// Pref to control the visibility of the backup section in about:preferences +pref("browser.backup.preferences.ui.enabled", false); // The number of SQLite database pages to backup per step. pref("browser.backup.sqlite.pages_per_step", 50); // The delay between SQLite database backup steps in milliseconds. diff --git a/browser/components/DesktopActorRegistry.sys.mjs b/browser/components/DesktopActorRegistry.sys.mjs @@ -248,6 +248,7 @@ let JSWINDOWACTORS = { "about:welcome*", "chrome://browser/content/spotlight.html", ], + enablePreference: "browser.backup.preferences.ui.enabled", }, BlockedSite: { diff --git a/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_restore_backup.js b/browser/components/aboutwelcome/tests/browser/browser_aboutwelcome_restore_backup.js @@ -57,9 +57,7 @@ add_task(async function test_aboutwelcome_embedded_backup_restore_properties() { await pushPrefs([ "browser.backup.enabled", true, - "browser.backup.archive.enabled", - true, - "browser.backup.restore.enabled", + "browser.backup.preferences.ui.enabled", true, ]); diff --git a/browser/components/backup/BackupService.sys.mjs b/browser/components/backup/BackupService.sys.mjs @@ -22,8 +22,6 @@ import { BackupError } from "resource:///modules/backup/BackupError.mjs"; const BACKUP_DIR_PREF_NAME = "browser.backup.location"; const BACKUP_ERROR_CODE_PREF_NAME = "browser.backup.errorCode"; const SCHEDULED_BACKUPS_ENABLED_PREF_NAME = "browser.backup.scheduled.enabled"; -const BACKUP_ARCHIVE_ENABLED_PREF_NAME = "browser.backup.archive.enabled"; -const BACKUP_RESTORE_ENABLED_PREF_NAME = "browser.backup.restore.enabled"; const IDLE_THRESHOLD_SECONDS_PREF_NAME = "browser.backup.scheduled.idle-threshold-seconds"; const MINIMUM_TIME_BETWEEN_BACKUPS_SECONDS_PREF_NAME = @@ -620,13 +618,6 @@ export class BackupService extends EventTarget { }; } - if (!Services.prefs.getBoolPref(BACKUP_ARCHIVE_ENABLED_PREF_NAME)) { - return { - enabled: false, - reason: "Archiving a profile disabled by user pref.", - }; - } - return { enabled: true }; } @@ -646,13 +637,6 @@ export class BackupService extends EventTarget { }; } - if (!Services.prefs.getBoolPref(BACKUP_RESTORE_ENABLED_PREF_NAME)) { - return { - enabled: false, - reason: "Restoring a profile disabled by user pref.", - }; - } - return { enabled: true }; } @@ -1034,7 +1018,6 @@ export class BackupService extends EventTarget { if (this.#instance) { return this.#instance; } - this.#instance = new BackupService(DefaultBackupResources); this.#instance.checkForPostRecovery(); @@ -1068,7 +1051,6 @@ export class BackupService extends EventTarget { constructor(backupResources = DefaultBackupResources) { super(); lazy.logConsole.debug("Instantiated"); - this.#registerStatusObservers(); for (const resourceName in backupResources) { let resource = backupResources[resourceName]; @@ -3607,7 +3589,6 @@ export class BackupService extends EventTarget { } case "quit-application-granted": { this.uninitBackupScheduler(); - this.#unregisterStatusObservers(); break; } case "passwordmgr-storage-changed": { @@ -3658,38 +3639,6 @@ export class BackupService extends EventTarget { } } - #registerStatusObservers() { - // We don't use this.#observer since any changes to the prefs or nimbus should - // immediately reflect across any observers, instead of waiting on idle - Services.prefs.addObserver( - BACKUP_ARCHIVE_ENABLED_PREF_NAME, - this.#notifyStatusObservers - ); - Services.prefs.addObserver( - BACKUP_RESTORE_ENABLED_PREF_NAME, - this.#notifyStatusObservers - ); - lazy.NimbusFeatures.backupService.onUpdate(this.#notifyStatusObservers); - } - - #unregisterStatusObservers() { - Services.prefs.removeObserver( - BACKUP_ARCHIVE_ENABLED_PREF_NAME, - this.#notifyStatusObservers - ); - Services.prefs.removeObserver( - BACKUP_RESTORE_ENABLED_PREF_NAME, - this.#notifyStatusObservers - ); - } - - /** - * Notify any listeners about the availability of the backup service. - */ - #notifyStatusObservers = () => { - Services.obs.notifyObservers(null, "backup-service-status-updated"); - }; - /** * Called when the last known backup should be deleted and a new one * created. This uses the #regenerationDebouncer to debounce clusters of diff --git a/browser/components/backup/content/backup-settings.mjs b/browser/components/backup/content/backup-settings.mjs @@ -7,12 +7,6 @@ import { MozLitElement } from "chrome://global/content/lit-utils.mjs"; import { getErrorL10nId } from "chrome://browser/content/backup/backup-errors.mjs"; import { ERRORS } from "chrome://browser/content/backup/backup-constants.mjs"; -const lazy = {}; - -ChromeUtils.defineESModuleGetters(lazy, { - BackupService: "resource:///modules/backup/BackupService.sys.mjs", -}); - // eslint-disable-next-line import/no-unassigned-import import "chrome://browser/content/backup/turn-on-scheduled-backups.mjs"; // eslint-disable-next-line import/no-unassigned-import @@ -32,14 +26,11 @@ const BACKUP_ERROR_CODE_PREF_NAME = "browser.backup.errorCode"; */ export default class BackupSettings extends MozLitElement { #placeholderIconURL = "chrome://global/skin/icons/page-portrait.svg"; - #backupService = lazy.BackupService.get(); static properties = { backupServiceState: { type: Object }, backupErrorCode: { type: Number }, _enableEncryptionTypeAttr: { type: String }, - _archiveEnabled: { type: Boolean }, - _restoreEnabled: { type: Boolean }, }; static get queries() { @@ -97,19 +88,8 @@ export default class BackupSettings extends MozLitElement { }; this.backupErrorCode = this.#readBackupErrorPref(); this._enableEncryptionTypeAttr = ""; - this.updateArchiveAndRestoreState(); - - Services.obs.addObserver( - this.updateArchiveAndRestoreState, - "backup-service-status-updated" - ); } - updateArchiveAndRestoreState = () => { - this._archiveEnabled = this.#backupService.archiveEnabledStatus.enabled; - this._restoreEnabled = this.#backupService.restoreEnabledStatus.enabled; - }; - /** * Dispatches the BackupUI:InitWidget custom event upon being attached to the * DOM, which registers with BackupUIChild for BackupService state updates. @@ -478,46 +458,46 @@ export default class BackupSettings extends MozLitElement { ${this.turnOffScheduledBackupsDialogTemplate()} ${this.enableBackupEncryptionDialogTemplate()} ${this.disableBackupEncryptionDialogTemplate()} - ${this._archiveEnabled - ? html` <section id="scheduled-backups"> - <div class="backups-control"> - <span - id="scheduled-backups-enabled" - data-l10n-id=${scheduledBackupsEnabledL10nID} - class="heading-medium" - ></span> - - <moz-button - id="backup-trigger-button" - @click=${this.handleBackupTrigger} - data-l10n-id=${backupTriggerL10nID} - ?disabled=${this.backupServiceState.backupInProgress || - !this.backupServiceState.scheduledBackupsEnabled} - ></moz-button> - - <moz-button - id="backup-toggle-scheduled-button" - @click=${this.handleShowScheduledBackups} - data-l10n-id="settings-data-backup-toggle" - ></moz-button> - - ${this.backupServiceState.scheduledBackupsEnabled - ? null - : this.scheduledBackupsDescriptionTemplate()} - </div> - - ${this.backupServiceState.lastBackupDate - ? this.lastBackupInfoTemplate() - : null} - ${this.backupServiceState.scheduledBackupsEnabled - ? this.backupLocationTemplate() - : null} - ${this.backupServiceState.scheduledBackupsEnabled - ? this.sensitiveDataTemplate() - : null} - </section>` - : null} - ${this._restoreEnabled ? this.restoreFromBackupTemplate() : null} `; + + <section id="scheduled-backups"> + <div class="backups-control"> + <span + id="scheduled-backups-enabled" + data-l10n-id=${scheduledBackupsEnabledL10nID} + class="heading-medium" + ></span> + + <moz-button + id="backup-trigger-button" + @click=${this.handleBackupTrigger} + data-l10n-id=${backupTriggerL10nID} + ?disabled=${this.backupServiceState.backupInProgress || + !this.backupServiceState.scheduledBackupsEnabled} + ></moz-button> + + <moz-button + id="backup-toggle-scheduled-button" + @click=${this.handleShowScheduledBackups} + data-l10n-id="settings-data-backup-toggle" + ></moz-button> + + ${this.backupServiceState.scheduledBackupsEnabled + ? null + : this.scheduledBackupsDescriptionTemplate()} + </div> + + ${this.backupServiceState.lastBackupDate + ? this.lastBackupInfoTemplate() + : null} + ${this.backupServiceState.scheduledBackupsEnabled + ? this.backupLocationTemplate() + : null} + ${this.backupServiceState.scheduledBackupsEnabled + ? this.sensitiveDataTemplate() + : null} + </section> + + ${this.restoreFromBackupTemplate()} `; } } diff --git a/browser/components/backup/tests/browser/browser.toml b/browser/components/backup/tests/browser/browser.toml @@ -1,16 +1,13 @@ [DEFAULT] prefs = [ "browser.backup.enabled=true", - "browser.backup.archive.enabled=true", - "browser.backup.restore.enabled=true", + "browser.backup.preferences.ui.enabled=true", "browser.backup.scheduled.enabled=false", ] support-files = [ "head.js", ] -["browser_backup_policies.js"] - ["browser_password_validation_inputs.js"] ["browser_settings.js"] diff --git a/browser/components/backup/tests/browser/browser_backup_policies.js b/browser/components/backup/tests/browser/browser_backup_policies.js @@ -1,107 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. -https://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -const { EnterprisePolicyTesting, PoliciesPrefTracker } = - ChromeUtils.importESModule( - "resource://testing-common/EnterprisePolicyTesting.sys.mjs" - ); - -function checkPrefs( - expectedBackupServiceState, - expectedArchiveEnabledState, - expectedRestoreEnabledState -) { - Assert.equal( - Services.prefs.getBoolPref("browser.backup.enabled"), - expectedBackupServiceState, - `Backup Service state should match the expected state` - ); - Assert.equal( - Services.prefs.getBoolPref("browser.backup.archive.enabled"), - expectedArchiveEnabledState, - `Archive state should match the expected state` - ); - Assert.equal( - Services.prefs.getBoolPref("browser.backup.restore.enabled"), - expectedRestoreEnabledState, - `Restore state should match the expected state` - ); -} - -add_setup(async () => { - // let's set the prefs to a default so that we can see if the policies - // adhere to the defaults when they aren't present - await SpecialPowers.pushPrefEnv({ - set: [ - ["browser.backup.enabled", false], - ["browser.backup.archive.enabled", false], - ["browser.backup.restore.enabled", true], - ], - }); - - registerCleanupFunction(async () => { - await SpecialPowers.popPrefEnv(); - }); -}); - -add_task(async function test_backup_disabled_enterprise_policies() { - PoliciesPrefTracker.start(); - await EnterprisePolicyTesting.setupPolicyEngineWithJson({ - policies: { - BrowserDataBackup: false, - }, - }); - - checkPrefs(false, false, false); - PoliciesPrefTracker.stop(); -}); - -add_task(async function test_backup_archive_enabled_enterprise_policies() { - PoliciesPrefTracker.start(); - await EnterprisePolicyTesting.setupPolicyEngineWithJson({ - policies: { - BrowserDataBackup: { - AllowBackup: true, - }, - }, - }); - - checkPrefs(true, true, true); - PoliciesPrefTracker.stop(); -}); - -add_task(async function test_backup_restore_enabled_enterprise_policies() { - PoliciesPrefTracker.start(); - await EnterprisePolicyTesting.setupPolicyEngineWithJson({ - policies: { - BrowserDataBackup: { - AllowRestore: true, - }, - }, - }); - - checkPrefs(true, false, true); - PoliciesPrefTracker.stop(); -}); - -add_task(async function test_backup_service_disabled_enterprise_policies() { - PoliciesPrefTracker.start(); - - await SpecialPowers.pushPrefEnv({ - set: [["browser.backup.enabled", true]], - }); - - await EnterprisePolicyTesting.setupPolicyEngineWithJson({ - policies: { - BrowserDataBackup: { - AllowBackup: false, - AllowRestore: false, - }, - }, - }); - - checkPrefs(false, false, false); - PoliciesPrefTracker.stop(); -}); diff --git a/browser/components/backup/tests/browser/browser_settings.js b/browser/components/backup/tests/browser/browser_settings.js @@ -8,8 +8,6 @@ const { MockRegistrar } = ChromeUtils.importESModule( ); const SCHEDULED_BACKUPS_ENABLED_PREF = "browser.backup.scheduled.enabled"; -const BACKUP_ARCHIVE_ENABLED_PREF = "browser.backup.archive.enabled"; -const BACKUP_RESTORE_ENABLED_PREF = "browser.backup.restore.enabled"; add_setup(async () => { MockFilePicker.init(window.browsingContext); @@ -37,7 +35,7 @@ add_task(async function test_preferences_visibility() { }); await SpecialPowers.pushPrefEnv({ - set: [[BACKUP_ARCHIVE_ENABLED_PREF, false]], + set: [["browser.backup.preferences.ui.enabled", false]], }); await BrowserTestUtils.withNewTab("about:preferences#sync", async browser => { @@ -46,40 +44,12 @@ add_task(async function test_preferences_visibility() { Assert.ok(backupSection, "Found backup preferences section"); Assert.ok( - BrowserTestUtils.isVisible(backupSection), - "Backup section is still visible" - ); - - let settings = browser.contentDocument.querySelector("backup-settings"); - let backupArchiveSection = settings.querySelector("#scheduled-backups"); - - Assert.ok(!backupArchiveSection, "Backup archive section is not available"); - - Assert.ok( - settings.restoreFromBackupEl, - "Backup restore section is available" - ); - }); - await SpecialPowers.pushPrefEnv({ - set: [[BACKUP_RESTORE_ENABLED_PREF, false]], - }); - await BrowserTestUtils.withNewTab("about:preferences#sync", async browser => { - let settings = browser.contentDocument.querySelector("backup-settings"); - Assert.ok( - !settings.restoreFromBackupEl, - "Backup Restore section is not available" - ); - - let backupSection = - browser.contentDocument.querySelector("#dataBackupGroup"); - Assert.ok( BrowserTestUtils.isHidden(backupSection), "Backup section is now hidden" ); }); await SpecialPowers.popPrefEnv(); - await SpecialPowers.popPrefEnv(); }); /** @@ -96,15 +66,6 @@ add_task(async function test_disable_backup_encryption_confirm() { .stub(BackupService.prototype, "disableEncryption") .resolves(true); - Assert.ok( - Services.prefs.getBoolPref(BACKUP_RESTORE_ENABLED_PREF), - "Restore pref is back to true" - ); - Assert.ok( - Services.prefs.getBoolPref(BACKUP_ARCHIVE_ENABLED_PREF), - "Archive pref is back to true" - ); - await SpecialPowers.pushPrefEnv({ set: [[SCHEDULED_BACKUPS_ENABLED_PREF, true]], }); diff --git a/browser/components/backup/tests/chrome/chrome.toml b/browser/components/backup/tests/chrome/chrome.toml @@ -1,8 +1,6 @@ [DEFAULT] prefs = [ "browser.backup.scheduled.enabled=false", - "browser.backup.archive.enabled=true", - "browser.backup.restore.enabled=true", ] support-files = ["head.js"] diff --git a/browser/components/backup/tests/marionette/test_backup.py b/browser/components/backup/tests/marionette/test_backup.py @@ -22,12 +22,7 @@ class BackupTest(MarionetteTestCase): # by default for Marionette. Also "browser.backup.log" has to be set # to true before Firefox starts in order for it to be displayed. self.marionette.enforce_gecko_prefs( - { - "browser.backup.enabled": True, - "browser.backup.log": True, - "browser.backup.archive.enabled": True, - "browser.backup.restore.enabled": True, - } + {"browser.backup.enabled": True, "browser.backup.log": True} ) self.marionette.set_context("chrome") diff --git a/browser/components/backup/tests/xpcshell/xpcshell.toml b/browser/components/backup/tests/xpcshell/xpcshell.toml @@ -4,8 +4,6 @@ head = "head.js" firefox-appdir = "browser" prefs = [ "browser.backup.log=true", - "browser.backup.archive.enabled=true", - "browser.backup.restore.enabled=true", ] ["test_AddonsBackupResource.js"] diff --git a/browser/components/enterprisepolicies/Policies.sys.mjs b/browser/components/enterprisepolicies/Policies.sys.mjs @@ -346,55 +346,6 @@ export var Policies = { }, }, - BrowserDataBackup: { - onBeforeUIStartup(manager, param) { - if (typeof param === "boolean") { - setAndLockPref("browser.backup.enabled", param); - setAndLockPref("browser.backup.archive.enabled", param); - setAndLockPref("browser.backup.restore.enabled", param); - } else { - const hasBackup = "AllowBackup" in param; - const hasRestore = "AllowRestore" in param; - let serviceValue; - - if (hasBackup && hasRestore) { - // both present but could be set to false - serviceValue = param.AllowBackup || param.AllowRestore; - } else if (hasBackup && param.AllowBackup) { - // only AllowBackup is true - serviceValue = true; - } else if (hasRestore && param.AllowRestore) { - // only AllowRestore is true - serviceValue = true; - } - - if (serviceValue !== undefined) { - PoliciesUtils.setDefaultPref( - "browser.backup.enabled", - serviceValue, - true - ); - } - - if (hasBackup) { - PoliciesUtils.setDefaultPref( - "browser.backup.archive.enabled", - param.AllowBackup, - true - ); - } - - if (hasRestore) { - PoliciesUtils.setDefaultPref( - "browser.backup.restore.enabled", - param.AllowRestore, - true - ); - } - } - }, - }, - BlockAboutAddons: { onBeforeUIStartup(manager, param) { if (param) { diff --git a/browser/components/enterprisepolicies/content/aboutPolicies.js b/browser/components/enterprisepolicies/content/aboutPolicies.js @@ -296,7 +296,6 @@ function generateDocumentation() { SecurityDevices: "SecurityDevices2", SkipTermsOfUse: "SkipTermsOfUse2", WindowsSSO: "Windows10SSO", - Backup: "BrowserDataBackup", }; let deprecated_policies = ["DisablePocket"]; diff --git a/browser/components/enterprisepolicies/schemas/policies-schema.json b/browser/components/enterprisepolicies/schemas/policies-schema.json @@ -121,18 +121,6 @@ "type": "boolean" }, - "BrowserDataBackup": { - "type": ["boolean", "object"], - "properties": { - "AllowBackup": { - "type": "boolean" - }, - "AllowRestore": { - "type": "boolean" - } - } - }, - "BlockAboutAddons": { "type": "boolean" }, diff --git a/browser/components/preferences/sync.js b/browser/components/preferences/sync.js @@ -19,12 +19,7 @@ const FXA_LOGIN_FAILED = 2; const SYNC_DISCONNECTED = 0; const SYNC_CONNECTED = 1; -const BACKUP_ARCHIVE_ENABLED_PREF_NAME = "browser.backup.archive.enabled"; -const BACKUP_RESTORE_ENABLED_PREF_NAME = "browser.backup.restore.enabled"; - -ChromeUtils.defineESModuleGetters(lazy, { - BackupService: "resource:///modules/backup/BackupService.sys.mjs", -}); +const BACKUP_UI_ENABLED_PREF = "browser.backup.preferences.ui.enabled"; var gSyncPane = { get page() { @@ -298,9 +293,10 @@ var gSyncPane = { }, updateBackupUIVisibility() { - let bs = lazy.BackupService.get(); - let isBackupUIEnabled = - bs.archiveEnabledStatus.enabled || bs.restoreEnabledStatus.enabled; + const isBackupUIEnabled = Services.prefs.getBoolPref( + BACKUP_UI_ENABLED_PREF, + false + ); let dataBackupSectionEl = document.getElementById("dataBackupSection"); @@ -312,25 +308,23 @@ var gSyncPane = { let dataBackupGroupEl = document.getElementById("dataBackupGroup"); let backupGroupHeaderEl = document.getElementById("backupCategory"); - dataBackupSectionEl.hidden = !isBackupUIEnabled; dataBackupGroupEl.hidden = !isBackupUIEnabled; backupGroupHeaderEl.hidden = !isBackupUIEnabled; }, _addPrefObservers() { - Services.obs.addObserver( - this.updateBackupUIVisibility, - "backup-service-status-updated" + Services.prefs.addObserver( + BACKUP_UI_ENABLED_PREF, + this.updateBackupUIVisibility ); window.addEventListener( "unload", - () => { - Services.obs.removeObserver( - this.updateBackupUIVisibility, - "backup-service-status-updated" - ); - }, + () => + Services.prefs.removeObserver( + BACKUP_UI_ENABLED_PREF, + this.updateBackupUIVisibility + ), { once: true } ); }, diff --git a/browser/components/preferences/tests/browser_bug731866.js b/browser/components/preferences/tests/browser_bug731866.js @@ -7,9 +7,8 @@ const browserContainersGroupDisabled = !SpecialPowers.getBoolPref( const cookieBannerHandlingDisabled = !SpecialPowers.getBoolPref( "cookiebanners.ui.desktop.enabled" ); -const backupSectionDisabled = !( - SpecialPowers.getBoolPref("browser.backup.archive.enabled") || - SpecialPowers.getBoolPref("browser.backup.restore.enabled") +const backupSectionDisabled = !SpecialPowers.getBoolPref( + "browser.backup.preferences.ui.enabled" ); const profilesGroupDisabled = !SelectableProfileService.isEnabled; const updatePrefContainers = ["updatesCategory", "updateApp"]; diff --git a/toolkit/components/nimbus/FeatureManifest.yaml b/toolkit/components/nimbus/FeatureManifest.yaml @@ -4778,6 +4778,14 @@ backupService: description: >- When true, the profile backup service will be initialized soon after startup. + prefsUIEnabled: + type: boolean + setPref: + branch: default + pref: browser.backup.preferences.ui.enabled + description: >- + When true, the section in about:preferences to control the backup + feature is visible. sqlitePagesPerStep: description: >- The number of database pages to backup per step when backing up an