Bug 1169993 - Fix setTheme in theme.js to really trigger a theme change in Developer Tools. r=bgrins

This commit is contained in:
Sami Jaktholm 2015-05-31 14:12:39 +03:00
Родитель 40947280a2
Коммит b5d493f508
2 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -27,6 +27,14 @@ function testGetTheme () {
function testSetTheme () {
let originalTheme = getTheme();
gDevTools.once("pref-changed", (_, { pref, oldValue, newValue }) => {
is(pref, "devtools.theme",
"The 'pref-changed' event triggered by setTheme has correct pref.");
is(oldValue, originalTheme,
"The 'pref-changed' event triggered by setTheme has correct oldValue.");
is(newValue, "dark",
"The 'pref-changed' event triggered by setTheme has correct newValue.");
});
setTheme("dark");
is(Services.prefs.getCharPref("devtools.theme"), "dark", "setTheme() correctly sets dark theme.");
setTheme("light");

Просмотреть файл

@ -85,10 +85,12 @@ const getColor = exports.getColor = (type, theme) => {
* the themeing.
*/
const setTheme = exports.setTheme = (newTheme) => {
let oldTheme = getTheme();
Services.prefs.setCharPref("devtools.theme", newTheme);
gDevTools.emit("pref-changed", {
pref: "devtools.theme",
newValue: newTheme,
oldValue: getTheme()
oldValue: oldTheme
});
};