Bug 1389939 - Stop syncing devtools theme and compact themes;r=Gijs

MozReview-Commit-ID: GUjgHU5pgg1

--HG--
extra : rebase_source : eeed943d058a0649a899be9295c63c37c8bbfd8d
This commit is contained in:
Brian Grinstead 2017-08-23 10:18:51 -07:00
Родитель bd5fb0a92d
Коммит 4752caa33a
2 изменённых файлов: 0 добавлений и 88 удалений

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

@ -32,14 +32,10 @@ loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scrat
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";
/**
@ -163,24 +159,6 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
.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) {
@ -210,20 +188,6 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
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;
}
},
@ -783,7 +747,6 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
*/
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");
@ -823,7 +786,6 @@ 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.

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

@ -3,15 +3,11 @@
/* 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() {
@ -34,49 +30,3 @@ add_task(function* testDevtoolsTheme() {
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);
});