tor-browser

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

commit 407b6ab2994e1b75b3717a0a838eedb7411b9f4b
parent 3a7422627b2a8daf3767ffe0f0577f349f785101
Author: Harsheet <hsohaney@mozilla.com>
Date:   Fri,  3 Oct 2025 13:50:22 +0000

Bug 1991508 - Switch to Date from ChromeUtils to show the correct last backup date in the UI. r=kpatenio

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

Diffstat:
Mbrowser/components/backup/BackupService.sys.mjs | 8++++----
Mbrowser/components/backup/tests/xpcshell/test_BackupService_scheduler.js | 2+-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/browser/components/backup/BackupService.sys.mjs b/browser/components/backup/BackupService.sys.mjs @@ -1453,7 +1453,7 @@ export class BackupService extends EventTarget { manifest.meta ); - let nowSeconds = Math.floor(ChromeUtils.now() / 1000); + let nowSeconds = Math.floor(Date.now() / 1000); Services.prefs.setIntPref( LAST_BACKUP_TIMESTAMP_PREF_NAME, nowSeconds @@ -1484,7 +1484,7 @@ export class BackupService extends EventTarget { Services.prefs.setStringPref( BACKUP_DEBUG_INFO_PREF_NAME, JSON.stringify({ - lastBackupAttempt: Math.floor(ChromeUtils.now() / 1000), + lastBackupAttempt: Math.floor(Date.now() / 1000), errorCode: e instanceof BackupError ? e : ERRORS.UNKNOWN, lastRunStep: currentStep, }) @@ -3576,7 +3576,7 @@ export class BackupService extends EventTarget { if (lazy.scheduledBackupsPref) { lazy.logConsole.debug("Scheduled backups enabled."); - let now = Math.floor(ChromeUtils.now() / 1000); + let now = Math.floor(Date.now() / 1000); let lastBackupDate = this.#_state.lastBackupDate; if (lastBackupDate && lastBackupDate > now) { lazy.logConsole.error( @@ -3625,7 +3625,7 @@ export class BackupService extends EventTarget { * into its own method to make it easier to stub out in tests. */ createBackupOnIdleDispatch() { - let now = Math.floor(ChromeUtils.now() / 1000); + let now = Math.floor(Date.now() / 1000); let errorStateDebugInfo = Services.prefs.getStringPref( BACKUP_DEBUG_INFO_PREF_NAME, "" diff --git a/browser/components/backup/tests/xpcshell/test_BackupService_scheduler.js b/browser/components/backup/tests/xpcshell/test_BackupService_scheduler.js @@ -193,7 +193,7 @@ add_task(async function test_BackupService_idle_no_backup_exists() { */ add_task(async function test_BackupService_idle_not_expired_backup() { // Let's calculate a Date that's five seconds ago. - let fiveSecondsAgo = ChromeUtils.now() - 5000; /* 5 seconds in milliseconds */ + let fiveSecondsAgo = Date.now() - 5000; /* 5 seconds in milliseconds */ let lastBackupPrefValue = Math.floor(fiveSecondsAgo / 1000); Services.prefs.setIntPref( LAST_BACKUP_TIMESTAMP_PREF_NAME,