diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /browser/components/backup/content/debug.js | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/backup/content/debug.js')
-rw-r--r-- | browser/components/backup/content/debug.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/browser/components/backup/content/debug.js b/browser/components/backup/content/debug.js new file mode 100644 index 0000000000..fd673818c0 --- /dev/null +++ b/browser/components/backup/content/debug.js @@ -0,0 +1,59 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +/* import-globals-from /toolkit/content/preferencesBindings.js */ + +Preferences.addAll([ + { id: "browser.backup.enabled", type: "bool" }, + { id: "browser.backup.log", type: "bool" }, +]); + +const { BackupService } = ChromeUtils.importESModule( + "resource:///modules/backup/BackupService.sys.mjs" +); + +let DebugUI = { + init() { + let controls = document.querySelector("#controls"); + controls.addEventListener("click", this); + }, + + handleEvent(event) { + let target = event.target; + if (HTMLButtonElement.isInstance(event.target)) { + this.onButtonClick(target); + } + }, + + async onButtonClick(button) { + switch (button.id) { + case "create-backup": { + let service = BackupService.get(); + button.disabled = true; + await service.createBackup(); + button.disabled = false; + break; + } + case "open-backup-folder": { + let backupsDir = PathUtils.join(PathUtils.profileDir, "backups"); + + let nsLocalFile = Components.Constructor( + "@mozilla.org/file/local;1", + "nsIFile", + "initWithPath" + ); + + if (await IOUtils.exists(backupsDir)) { + new nsLocalFile(backupsDir).reveal(); + } else { + alert("backups folder doesn't exist yet"); + } + + break; + } + } + }, +}; + +DebugUI.init(); |