Bug 1349896 - Part 1: Add theme property to Toolbox, r?rpl draft
authorBob Silverberg <bsilverberg@mozilla.com>
Mon, 08 May 2017 16:46:51 -0400
changeset 574439 e35e494148107ba5cd198b797ea7380c5446ddd0
parent 571518 9f26a16ee21b773f379ace256f27923ef8d408d6
child 627597 69c6cd4fd30a1ce3513190a2e5489871cf749a71
push id57711
push userbmo:bob.silverberg@gmail.com
push dateMon, 08 May 2017 21:31:31 +0000
reviewersrpl
bugs1349896
milestone55.0a1
Bug 1349896 - Part 1: Add theme property to Toolbox, r?rpl This uses getTheme() from devtools/client/shared/theme.js in order to abstract the code away from the preference. devtools/client/shared/css-reload.js also uses getTheme() from shared/theme.js, so this seems like a safe abstraction to use. MozReview-Commit-ID: F8OHVC4DSCv
devtools/client/framework/toolbox.js
devtools/client/shared/test/browser_theme_switching.js
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -24,16 +24,17 @@ var {Task} = require("devtools/shared/ta
 var {gDevTools} = require("devtools/client/framework/devtools");
 var EventEmitter = require("devtools/shared/event-emitter");
 var Telemetry = require("devtools/client/shared/telemetry");
 var { attachThread, detachThread } = require("./attach-thread");
 var Menu = require("devtools/client/framework/menu");
 var MenuItem = require("devtools/client/framework/menu-item");
 var { DOMHelpers } = require("resource://devtools/client/shared/DOMHelpers.jsm");
 const { KeyCodes } = require("devtools/client/shared/keycodes");
+const { getTheme } = require("devtools/client/shared/theme");
 
 const { BrowserLoader } =
   Cu.import("resource://devtools/client/shared/browser-loader.js", {});
 
 const {LocalizationHelper} = require("devtools/shared/l10n");
 const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
 
 loader.lazyRequireGetter(this, "getHighlighterUtils",
@@ -367,16 +368,23 @@ Toolbox.prototype = {
    * Get the toolbox's node selection. Note that it may not always have been
    * initialized first. Use `initInspector()` if needed.
    */
   get selection() {
     return this._selection;
   },
 
   /**
+   * Get the theme of the toolbox.
+   */
+  get theme() {
+    return getTheme();
+  },
+
+  /**
    * Get the toggled state of the split console
    */
   get splitConsole() {
     return this._splitConsole;
   },
 
   /**
    * Get the focused state of the split console
--- a/devtools/client/shared/test/browser_theme_switching.js
+++ b/devtools/client/shared/test/browser_theme_switching.js
@@ -10,16 +10,17 @@ add_task(function* () {
   let doc = toolbox.doc;
   let root = doc.documentElement;
 
   let platform = root.getAttribute("platform");
   let expectedPlatform = getPlatform();
   is(platform, expectedPlatform, ":root[platform] is correct");
 
   let theme = Services.prefs.getCharPref("devtools.theme");
+  is(toolbox.theme, theme, "toolbox.theme is correct");
   let className = "theme-" + theme;
   ok(root.classList.contains(className),
      ":root has " + className + " class (current theme)");
 
   // Convert the xpath result into an array of strings
   // like `href="{URL}" type="text/css"`
   let sheetsIterator = doc.evaluate("processing-instruction('xml-stylesheet')",
                        doc, null, XPathResult.ANY_TYPE, null);