tor-browser

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

commit 60553d188e832c99e8b31fbbafcab7afa6fe8e28
parent bf4417acd315988a33a9d4e2ee5ef77e920124d6
Author: Emily McMinn <emcminn@mozilla.com>
Date:   Wed,  5 Nov 2025 20:12:04 +0000

Bug 1997069 - Disable the continue button if various errors are present r=hsohaney

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

Diffstat:
Mbrowser/components/backup/content/turn-on-scheduled-backups.mjs | 18+++++++++++++++++-
Mbrowser/components/backup/tests/chrome/test_turn_on_scheduled_backups.html | 28++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/browser/components/backup/content/turn-on-scheduled-backups.mjs b/browser/components/backup/content/turn-on-scheduled-backups.mjs @@ -120,6 +120,7 @@ export default class TurnOnScheduledBackups extends MozLitElement { this._showPasswordOptions = false; this._passwordsMatch = false; this.enableBackupErrorCode = 0; + this.disableSubmit = false; } connectedCallback() { @@ -237,6 +238,7 @@ export default class TurnOnScheduledBackups extends MozLitElement { this._passwordsMatch = false; this._inputPassValue = ""; this.enableBackupErrorCode = 0; + this.disableSubmit = false; // we don't want to reset the path when embedded in the spotlight if (!this.embeddedFxBackupOptIn) { this._newPath = ""; @@ -367,6 +369,20 @@ export default class TurnOnScheduledBackups extends MozLitElement { } contentTemplate() { + // All the situations where we want to disable submit: + // - passwords don't match + // - there's no destination folder + // - other unknown errors + if ( + (this._showPasswordOptions && !this._passwordsMatch) || + (this._newPath == "" && this.defaultLabel == "") || + this.enableBackupErrorCode != ERRORS.NONE + ) { + this.disableSubmit = true; + } else { + this.disableSubmit = false; + } + return html` <form id="backup-turn-on-scheduled-wrapper" @@ -412,7 +428,7 @@ export default class TurnOnScheduledBackups extends MozLitElement { type="primary" data-l10n-id=${this.turnOnBackupConfirmBtnL10nId || "turn-on-scheduled-backups-confirm-button"} - ?disabled=${this._showPasswordOptions && !this._passwordsMatch} + ?disabled=${this.disableSubmit} ></moz-button> </moz-button-group> </form> diff --git a/browser/components/backup/tests/chrome/test_turn_on_scheduled_backups.html b/browser/components/backup/tests/chrome/test_turn_on_scheduled_backups.html @@ -42,7 +42,16 @@ let turnOnScheduledBackups = document.getElementById("test-turn-on-scheduled-backups"); let confirmButton = turnOnScheduledBackups.confirmButtonEl; + // The confirm button will be disabled if BackupService cannot find a file path + const defaultPathFilename = "testdefaultpath"; + let defaultPath = PathUtils.join(PathUtils.tempDir, defaultPathFilename); + turnOnScheduledBackups.defaultPath = defaultPath; + turnOnScheduledBackups.defaultLabel = defaultPathFilename; + + await turnOnScheduledBackups.updateComplete; + ok(confirmButton, "Confirm button should be found"); + ok(!confirmButton.disabled, "confirm button should be active"); let content = document.getElementById("content"); let promise = BrowserTestUtils.waitForEvent(content, "BackupUI:EnableScheduledBackups"); @@ -132,6 +141,25 @@ }) /** + * Tests that the Confirm button cannot be selected if the file path is invalid. + */ + add_task(async function test_filepathValidityConfirmButton() { + let turnOnScheduledBackups = document.getElementById("test-turn-on-scheduled-backups"); + + // The confirm button will be disabled if BackupService cannot find a file path + const emptyPathFilename = ""; + let emptyPath = PathUtils.join(PathUtils.tempDir, emptyPathFilename); + turnOnScheduledBackups.defaultPath = emptyPath; + turnOnScheduledBackups.defaultLabel = emptyPathFilename; + + await turnOnScheduledBackups.updateComplete; + + let confirmButton = turnOnScheduledBackups.confirmButtonEl; + ok(confirmButton, "Confirm button should be found"); + ok(confirmButton.disabled, "Confirm button should be disabled since there is no default file path"); + }) + + /** * Tests that the dialog displays a default save location for backups and updates to a custom one * if there is one selected. */