Bug 1093368 - Customize mode theme picker shouldn't pass the default theme object to LightweightThemeManager.previewTheme. r=jaws, a=lsblakk
authorDão Gottwald <dao@mozilla.com>
Sat, 08 Nov 2014 20:30:00 +0100
changeset 235082 11deca361be25acccbaa336f870ed2a1c9d871dc
parent 235081 a8221dcf14d9773e86fa8bd8a78b300fafbdbddd
child 235083 b4d1f862183ec39afbb4a5a5f66a0ed410b4fe23
push id611
push userraliiev@mozilla.com
push dateMon, 05 Jan 2015 23:23:16 +0000
treeherdermozilla-release@345cd3b9c445 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, lsblakk
bugs1093368
milestone35.0a2
Bug 1093368 - Customize mode theme picker shouldn't pass the default theme object to LightweightThemeManager.previewTheme. r=jaws, a=lsblakk
browser/base/content/browser-devedition.js
browser/base/content/test/general/browser_devedition.js
browser/components/customizableui/CustomizeMode.jsm
toolkit/mozapps/extensions/LightweightThemeManager.jsm
--- a/browser/base/content/browser-devedition.js
+++ b/browser/base/content/browser-devedition.js
@@ -9,17 +9,16 @@
 let DevEdition = {
   _prefName: "browser.devedition.theme.enabled",
   _themePrefName: "general.skins.selectedSkin",
   _lwThemePrefName: "lightweightThemes.isThemeSelected",
   _devtoolsThemePrefName: "devtools.theme",
 
   styleSheetLocation: "chrome://browser/skin/devedition.css",
   styleSheet: null,
-  defaultThemeID: "{972ce4c6-7e08-4474-a285-3208198ce6fd}",
 
   init: function () {
     this._updateDevtoolsThemeAttribute();
     this._updateStyleSheetFromPrefs();
 
     // Listen for changes to all prefs except for complete themes.
     // No need for this since changing a complete theme requires a
     // restart.
@@ -27,17 +26,17 @@ let DevEdition = {
     Services.prefs.addObserver(this._prefName, this, false);
     Services.prefs.addObserver(this._devtoolsThemePrefName, this, false);
     Services.obs.addObserver(this, "lightweight-theme-styling-update", false);
   },
 
   observe: function (subject, topic, data) {
     if (topic == "lightweight-theme-styling-update") {
       let newTheme = JSON.parse(data);
-      if (!newTheme || newTheme.id === this.defaultThemeID) {
+      if (!newTheme) {
         // A lightweight theme has been unapplied, so just re-read prefs.
         this._updateStyleSheetFromPrefs();
       } else {
         // A lightweight theme has been applied, but the pref may not be
         // set yet if this happened from customize menu or addons page.
         this._toggleStyleSheet(false);
       }
     }
--- a/browser/base/content/test/general/browser_devedition.js
+++ b/browser/base/content/test/general/browser_devedition.js
@@ -100,13 +100,13 @@ function testLightweightThemePreview() {
   Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, false);
   ok (!DevEdition.styleSheet, "The devedition stylesheet is not enabled after pref is turned off.");
   LightweightThemeManager.resetPreview();
   ok (!DevEdition.styleSheet, "The devedition stylesheet is still disabled after resetting the preview.");
 
   info ("Turning the pref on, then previewing the default theme, turning it off and resetting the preview");
   Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, true);
   ok (DevEdition.styleSheet, "The devedition stylesheet is enabled.");
-  LightweightThemeManager.previewTheme(dummyLightweightTheme("{972ce4c6-7e08-4474-a285-3208198ce6fd}"));
+  LightweightThemeManager.previewTheme(null);
   ok (DevEdition.styleSheet, "The devedition stylesheet is still enabled after the default theme is applied.");
   LightweightThemeManager.resetPreview();
   ok (DevEdition.styleSheet, "The devedition stylesheet is still enabled after resetting the preview.");
 }
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -1288,17 +1288,18 @@ CustomizeMode.prototype = {
     this.window.openUILinkIn(getMoreURL, "tab");
   },
 
   onLWThemesMenuShowing: function(aEvent) {
     const DEFAULT_THEME_ID = "{972ce4c6-7e08-4474-a285-3208198ce6fd}";
     const RECENT_LWT_COUNT = 5;
 
     function previewTheme(aEvent) {
-      LightweightThemeManager.previewTheme(aEvent.target.theme);
+      LightweightThemeManager.previewTheme(aEvent.target.theme.id != DEFAULT_THEME_ID ?
+                                           aEvent.target.theme : null);
     }
 
     function resetPreview() {
       LightweightThemeManager.resetPreview();
     }
 
     AddonManager.getAddonByID(DEFAULT_THEME_ID, function(aDefaultTheme) {
       let doc = this.window.document;
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -137,19 +137,16 @@ this.LightweightThemeManager = {
       AddonManagerPrivate.notifyAddonChanged(null, ADDON_TYPE, false);
     }
 
     _updateUsedThemes(_usedThemesExceptId(aId));
     AddonManagerPrivate.callAddonListeners("onUninstalled", wrapper);
   },
 
   previewTheme: function LightweightThemeManager_previewTheme(aData) {
-    if (!aData)
-      return;
-
     let cancel = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
     cancel.data = false;
     Services.obs.notifyObservers(cancel, "lightweight-theme-preview-requested",
                                  JSON.stringify(aData));
     if (cancel.data)
       return;
 
     if (_previewTimer)