Bug 1389939 - Stop syncing devtools theme and compact themes;r=Gijs draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 23 Aug 2017 10:18:51 -0700
changeset 651380 eeed943d058a0649a899be9295c63c37c8bbfd8d
parent 651207 b911a4c97fde5d8bdeebfd5d0266ee9f7b9e59b2
child 727696 c949864b4bc895c2fe82efa0b72da0b6e66b0759
push id75710
push userbgrinstead@mozilla.com
push dateWed, 23 Aug 2017 17:18:58 +0000
reviewersGijs
bugs1389939
milestone57.0a1
Bug 1389939 - Stop syncing devtools theme and compact themes;r=Gijs MozReview-Commit-ID: GUjgHU5pgg1
devtools/client/framework/devtools-browser.js
devtools/client/framework/test/browser_toolbox_theme.js
--- a/devtools/client/framework/devtools-browser.js
+++ b/devtools/client/framework/devtools-browser.js
@@ -27,24 +27,20 @@ loader.lazyRequireGetter(this, "appendSt
 loader.lazyRequireGetter(this, "DeveloperToolbar", "devtools/client/shared/developer-toolbar", true);
 loader.lazyImporter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm");
 loader.lazyImporter(this, "ResponsiveUIManager", "resource://devtools/client/responsivedesign/responsivedesign.jsm");
 loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
 
 loader.lazyImporter(this, "CustomizableUI", "resource:///modules/CustomizableUI.jsm");
 loader.lazyImporter(this, "CustomizableWidgets", "resource:///modules/CustomizableWidgets.jsm");
 loader.lazyImporter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm");
-loader.lazyImporter(this, "LightweightThemeManager", "resource://gre/modules/LightweightThemeManager.jsm");
 
 const {LocalizationHelper} = require("devtools/shared/l10n");
 const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
 
-const COMPACT_LIGHT_ID = "firefox-compact-light@mozilla.org";
-const COMPACT_DARK_ID = "firefox-compact-dark@mozilla.org";
-
 const BROWSER_STYLESHEET_URL = "chrome://devtools/skin/devtools-browser.css";
 
 /**
  * gDevToolsBrowser exposes functions to connect the gDevTools instance with a
  * Firefox instance.
  */
 var gDevToolsBrowser = exports.gDevToolsBrowser = {
   /**
@@ -158,34 +154,16 @@ var gDevToolsBrowser = exports.gDevTools
 
     // Style gcli and the splitter between the toolbox and page content.  This used to
     // set the attribute on the browser's root node but that regressed tpaint:
     // bug 1331449.
     win.document.getElementById("browser-bottombox")
        .setAttribute("devtoolstheme", devtoolsTheme);
     win.document.getElementById("content")
        .setAttribute("devtoolstheme", devtoolsTheme);
-
-    // If the toolbox color changes and we have the opposite compact theme applied,
-    // change it to match.  For example:
-    // 1) toolbox changes to dark, and the light compact theme was applied.
-    //    Switch to the dark compact theme.
-    // 2) toolbox changes to light or firebug, and the dark compact theme was applied.
-    //    Switch to the light compact theme.
-    // 3) No compact theme was applied. Do nothing.
-    let currentTheme = LightweightThemeManager.currentTheme;
-    let currentThemeID = currentTheme && currentTheme.id;
-    if (currentThemeID == COMPACT_LIGHT_ID && devtoolsTheme == "dark") {
-      LightweightThemeManager.currentTheme =
-        LightweightThemeManager.getUsedTheme(COMPACT_DARK_ID);
-    }
-    if (currentThemeID == COMPACT_DARK_ID && devtoolsTheme == "light") {
-      LightweightThemeManager.currentTheme =
-        LightweightThemeManager.getUsedTheme(COMPACT_LIGHT_ID);
-    }
   },
 
   observe(subject, topic, prefName) {
     switch (topic) {
       case "browser-delayed-startup-finished":
         this._registerBrowserWindow(subject);
         break;
       case "nsPref:changed":
@@ -205,30 +183,16 @@ var gDevToolsBrowser = exports.gDevTools
         break;
       case "sdk:loader:destroy":
         // This event is fired when the devtools loader unloads, which happens
         // only when the add-on workflow ask devtools to be reloaded.
         if (subject.wrappedJSObject == require("@loader/unload")) {
           gDevToolsBrowser.destroy({ shuttingDown: false });
         }
         break;
-      case "lightweight-theme-changed":
-        let currentTheme = LightweightThemeManager.currentTheme;
-        let currentThemeID = currentTheme && currentTheme.id;
-        let devtoolsTheme = Services.prefs.getCharPref("devtools.theme");
-
-        // If the current lightweight theme changes to one of the compact themes, then
-        // keep the devtools color in sync.
-        if (currentThemeID == COMPACT_LIGHT_ID && devtoolsTheme == "dark") {
-          Services.prefs.setCharPref("devtools.theme", "light");
-        }
-        if (currentThemeID == COMPACT_DARK_ID && devtoolsTheme == "light") {
-          Services.prefs.setCharPref("devtools.theme", "dark");
-        }
-        break;
     }
   },
 
   _prefObserverRegistered: false,
 
   ensurePrefObserver() {
     if (!this._prefObserverRegistered) {
       this._prefObserverRegistered = true;
@@ -778,17 +742,16 @@ var gDevToolsBrowser = exports.gDevTools
 
    * @param {boolean} shuttingDown
    *        True if firefox is currently shutting down. We may prevent doing
    *        some cleanups to speed it up. Otherwise everything need to be
    *        cleaned up in order to be able to load devtools again.
    */
   destroy({ shuttingDown }) {
     Services.prefs.removeObserver("devtools.", gDevToolsBrowser);
-    Services.obs.removeObserver(gDevToolsBrowser, "lightweight-theme-changed");
     Services.obs.removeObserver(gDevToolsBrowser, "browser-delayed-startup-finished");
     Services.obs.removeObserver(gDevToolsBrowser, "quit-application");
     Services.obs.removeObserver(gDevToolsBrowser, "sdk:loader:destroy");
 
     for (let win of gDevToolsBrowser._trackedBrowserWindows) {
       gDevToolsBrowser._forgetBrowserWindow(win);
     }
 
@@ -818,17 +781,16 @@ gDevTools.on("tool-unregistered", functi
 
 gDevTools.on("toolbox-ready", gDevToolsBrowser._updateMenuCheckbox);
 gDevTools.on("toolbox-destroyed", gDevToolsBrowser._updateMenuCheckbox);
 
 Services.obs.addObserver(gDevToolsBrowser, "quit-application");
 Services.obs.addObserver(gDevToolsBrowser, "browser-delayed-startup-finished");
 // Watch for module loader unload. Fires when the tools are reloaded.
 Services.obs.addObserver(gDevToolsBrowser, "sdk:loader:destroy");
-Services.obs.addObserver(gDevToolsBrowser, "lightweight-theme-changed");
 
 // Fake end of browser window load event for all already opened windows
 // that is already fully loaded.
 let enumerator = Services.wm.getEnumerator(gDevTools.chromeWindowType);
 while (enumerator.hasMoreElements()) {
   let win = enumerator.getNext();
   if (win.gBrowserInit && win.gBrowserInit.delayedStartupFinished) {
     gDevToolsBrowser._registerBrowserWindow(win);
--- a/devtools/client/framework/test/browser_toolbox_theme.js
+++ b/devtools/client/framework/test/browser_toolbox_theme.js
@@ -1,22 +1,18 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
-const COMPACT_LIGHT_ID = "firefox-compact-light@mozilla.org";
-const COMPACT_DARK_ID = "firefox-compact-dark@mozilla.org";
 const PREF_DEVTOOLS_THEME = "devtools.theme";
-const {LightweightThemeManager} = Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", {});
 
 registerCleanupFunction(() => {
   // Set preferences back to their original values
   Services.prefs.clearUserPref(PREF_DEVTOOLS_THEME);
-  LightweightThemeManager.currentTheme = null;
 });
 
 add_task(function* testDevtoolsTheme() {
   info("Checking stylesheet and :root attributes based on devtools theme.");
   Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "light");
   is(document.getElementById("browser-bottombox").getAttribute("devtoolstheme"), "light",
     "The element has an attribute based on devtools theme.");
   is(document.getElementById("content").getAttribute("devtoolstheme"), "light",
@@ -29,54 +25,8 @@ add_task(function* testDevtoolsTheme() {
     "The element has an attribute based on devtools theme.");
 
   Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "firebug");
   is(document.getElementById("browser-bottombox").getAttribute("devtoolstheme"), "light",
     "The element has 'light' as a default for the devtoolstheme attribute.");
   is(document.getElementById("content").getAttribute("devtoolstheme"), "light",
     "The element has 'light' as a default for the devtoolstheme attribute.");
 });
-
-add_task(function* testDevtoolsAndCompactThemeSyncing() {
-  if (!AppConstants.INSTALL_COMPACT_THEMES) {
-    ok(true, "No need to run this test since themes aren't installed");
-    return;
-  }
-
-  info("Devtools theme light -> dark when dark compact applied");
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "light");
-  LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme(COMPACT_DARK_ID);
-  is(Services.prefs.getCharPref(PREF_DEVTOOLS_THEME), "dark");
-
-  info("Devtools theme dark -> light when light compact applied");
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "dark");
-  LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme(COMPACT_LIGHT_ID);
-  is(Services.prefs.getCharPref(PREF_DEVTOOLS_THEME), "light");
-
-  info("Devtools theme shouldn't change if it wasn't light or dark during lwt change");
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "firebug");
-  LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme(COMPACT_DARK_ID);
-  is(Services.prefs.getCharPref(PREF_DEVTOOLS_THEME), "firebug");
-
-  info("Compact theme dark -> light when devtools changes dark -> light");
-  LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme(COMPACT_DARK_ID);
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "dark");
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "light");
-  is(LightweightThemeManager.currentTheme, LightweightThemeManager.getUsedTheme(COMPACT_LIGHT_ID));
-
-  info("Compact theme dark -> light when devtools changes dark -> firebug");
-  LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme(COMPACT_DARK_ID);
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "dark");
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "firebug");
-  is(LightweightThemeManager.currentTheme, LightweightThemeManager.getUsedTheme(COMPACT_LIGHT_ID));
-
-  info("Compact theme light -> dark when devtools changes light -> dark");
-  LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme(COMPACT_LIGHT_ID);
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "light");
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "dark");
-  is(LightweightThemeManager.currentTheme, LightweightThemeManager.getUsedTheme(COMPACT_DARK_ID));
-
-  info("Compact theme shouldn't change if it wasn't set during devtools change");
-  LightweightThemeManager.currentTheme = null;
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "light");
-  Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "dark");
-  is(LightweightThemeManager.currentTheme, null);
-});