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
--- 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);