summaryrefslogtreecommitdiffstats
path: root/comm/mail/base/content/troubleshootMode.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--comm/mail/base/content/troubleshootMode.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/comm/mail/base/content/troubleshootMode.js b/comm/mail/base/content/troubleshootMode.js
new file mode 100644
index 0000000000..79343f3004
--- /dev/null
+++ b/comm/mail/base/content/troubleshootMode.js
@@ -0,0 +1,74 @@
+/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+var { XPIDatabase } = ChromeUtils.import(
+ "resource://gre/modules/addons/XPIDatabase.jsm"
+);
+
+function restartApp() {
+ Services.startup.quit(
+ Services.startup.eForceQuit | Services.startup.eRestart
+ );
+}
+
+function deleteLocalstore() {
+ // Delete the xulstore file.
+ let xulstoreFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
+ xulstoreFile.append("xulstore.json");
+ if (xulstoreFile.exists()) {
+ xulstoreFile.remove(false);
+ }
+}
+
+async function disableAddons() {
+ XPIDatabase.syncLoadDB(false);
+ let addons = XPIDatabase.getAddons();
+ for (let addon of addons) {
+ if (addon.type == "theme") {
+ // Setting userDisabled to false on the default theme activates it,
+ // disables all other themes and deactivates the applied persona, if
+ // any.
+ const DEFAULT_THEME_ID = "default-theme@mozilla.org";
+ if (addon.id == DEFAULT_THEME_ID) {
+ await XPIDatabase.updateAddonDisabledState(addon, {
+ userDisabled: false,
+ });
+ }
+ } else {
+ await XPIDatabase.updateAddonDisabledState(addon, { userDisabled: true });
+ }
+ }
+}
+
+async function onOK(event) {
+ event.preventDefault();
+ if (document.getElementById("resetToolbars").checked) {
+ deleteLocalstore();
+ }
+ if (document.getElementById("disableAddons").checked) {
+ await disableAddons();
+ }
+ restartApp();
+}
+
+function onCancel() {
+ Services.startup.quit(Services.startup.eForceQuit);
+}
+
+function onLoad() {
+ document
+ .getElementById("tasks")
+ .addEventListener("CheckboxStateChange", updateOKButtonState);
+
+ document.addEventListener("dialogaccept", onOK);
+ document.addEventListener("dialogcancel", onCancel);
+ document.addEventListener("dialogextra1", () => window.close());
+}
+
+function updateOKButtonState() {
+ document.querySelector("dialog").getButton("accept").disabled =
+ !document.getElementById("resetToolbars").checked &&
+ !document.getElementById("disableAddons").checked;
+}