tor-browser

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

commit 8f931cc8aa6dcd2a5769ac87d9b61587ef5d1d80
parent 037127a8da825afb83c5922529ce42bbec10cf98
Author: Duncan McIntosh <dmcintosh@mozilla.com>
Date:   Wed,  5 Nov 2025 22:08:36 +0000

Bug 1997685 - Use the default directory when enabling scheduled backups unless the user selects one. r=kpatenio,cdupuis

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

Diffstat:
Mbrowser/components/backup/content/turn-on-scheduled-backups.mjs | 17+++--------------
Mbrowser/components/backup/tests/browser/browser_settings_turn_on_scheduled_backups.js | 36++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/browser/components/backup/content/turn-on-scheduled-backups.mjs b/browser/components/backup/content/turn-on-scheduled-backups.mjs @@ -186,20 +186,9 @@ export default class TurnOnScheduledBackups extends MozLitElement { } handleConfirm() { - let detail; - if (this._newPath) { - detail = { - parentDirPath: this._newPath, - }; - } else if (this.backupServiceState?.backupDirPath) { - detail = { - parentDirPath: this.backupServiceState?.backupDirPath, - }; - } else { - detail = { - parentDirPath: this.defaultPath, - }; - } + let detail = { + parentDirPath: this._newPath || this.defaultPath, + }; if (this._showPasswordOptions && this._passwordsMatch) { detail.password = this._inputPassValue; diff --git a/browser/components/backup/tests/browser/browser_settings_turn_on_scheduled_backups.js b/browser/components/backup/tests/browser/browser_settings_turn_on_scheduled_backups.js @@ -513,3 +513,39 @@ add_task(async function test_turn_on_scheduled_backups_encryption_error() { ); }); }); + +/** + * Tests that a backup will go into the default directory unless the user + * specifically selects a folder. (Before, the directory previously selected + * would be used.) + */ +add_task(async function test_default_location_selected() { + await SpecialPowers.pushPrefEnv({ + set: [["browser.backup.location", "backup dir path"]], + }); + + await BrowserTestUtils.withNewTab("about:preferences#sync", async browser => { + let settings = browser.contentDocument.querySelector("backup-settings"); + await settings.updateComplete; + + let turnOnButton = settings.scheduledBackupsButtonEl; + turnOnButton.click(); + await settings.updateComplete; + + let turnOnScheduledBackups = settings.turnOnScheduledBackupsEl; + let promise = BrowserTestUtils.waitForEvent( + turnOnScheduledBackups, + "BackupUI:EnableScheduledBackups" + ); + turnOnScheduledBackups.confirmButtonEl.click(); + let event = await promise; + + is( + event.detail.parentDirPath, + settings.backupServiceState.defaultParent.path, + "Default path was used when nothing was explicitly selected" + ); + }); + + await SpecialPowers.popPrefEnv(); +});