summaryrefslogtreecommitdiffstats
path: root/browser/components/backup/content
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
commitdef92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch)
tree2ef34b9ad8bb9a9220e05d60352558b15f513894 /browser/components/backup/content
parentAdding debian version 125.0.3-1. (diff)
downloadfirefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz
firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/backup/content')
-rw-r--r--browser/components/backup/content/debug.html46
-rw-r--r--browser/components/backup/content/debug.js59
2 files changed, 105 insertions, 0 deletions
diff --git a/browser/components/backup/content/debug.html b/browser/components/backup/content/debug.html
new file mode 100644
index 0000000000..5d6517cf2a
--- /dev/null
+++ b/browser/components/backup/content/debug.html
@@ -0,0 +1,46 @@
+<!-- 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 http://mozilla.org/MPL/2.0/. -->
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Profile backup debug tool</title>
+
+ <link rel="stylesheet" href="chrome://global/skin/in-content/common.css" />
+ </head>
+ <body>
+ <header>
+ <h1>Profile backup debug tool</h1>
+ </header>
+
+ <main>
+ <section>
+ <h2>State</h2>
+ <ol>
+ <li>
+ <input
+ type="checkbox"
+ preference="browser.backup.enabled"
+ />BackupService component enabled
+ </li>
+ <li>
+ <input
+ type="checkbox"
+ preference="browser.backup.log"
+ />BackupService debug logging enabled
+ </li>
+ </ol>
+ </section>
+ <section id="controls">
+ <h2>Controls</h2>
+ <button id="create-backup">Create backup</button>
+ <button id="open-backup-folder">Open backups folder</button>
+ </section>
+ </main>
+
+ <script src="chrome://global/content/preferencesBindings.js"></script>
+ <script src="chrome://browser/content/backup/debug.js"></script>
+ </body>
+</html>
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();