Bug 1094821 - Backout 01482cdccd72 for test failures in Aurora simulation;r=me;a=RyanVM

This commit is contained in:
Brian Grinstead 2015-03-30 09:20:48 -07:00
parent 3e44325c80
commit 6563db2e15
19 changed files with 352 additions and 108 deletions

View File

@ -1328,8 +1328,11 @@ pref("services.sync.prefs.sync.xpinstall.whitelist.required", true);
// Developer edition preferences
#ifdef MOZ_DEV_EDITION
pref("lightweightThemes.selectedThemeID", "firefox-devedition@mozilla.org");
pref("browser.devedition.theme.enabled", true);
pref("browser.devedition.theme.showCustomizeButton", true);
#else
pref("browser.devedition.theme.enabled", false);
pref("browser.devedition.theme.showCustomizeButton", false);
#endif
// Developer edition promo preferences

View File

@ -7,37 +7,46 @@
* to browser.xul if a pref is set and no other themes are applied.
*/
let DevEdition = {
_prefName: "browser.devedition.theme.enabled",
_themePrefName: "general.skins.selectedSkin",
_lwThemePrefName: "lightweightThemes.selectedThemeID",
_devtoolsThemePrefName: "devtools.theme",
styleSheetLocation: "chrome://browser/skin/devedition.css",
styleSheet: null,
get isThemeCurrentlyApplied() {
let theme = LightweightThemeManager.currentTheme;
return theme && theme.id == "firefox-devedition@mozilla.org";
},
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.
Services.prefs.addObserver(this._lwThemePrefName, this, false);
Services.prefs.addObserver(this._prefName, this, false);
Services.prefs.addObserver(this._devtoolsThemePrefName, this, false);
Services.obs.addObserver(this, "lightweight-theme-styling-update", false);
this._updateDevtoolsThemeAttribute();
if (this.isThemeCurrentlyApplied) {
this._toggleStyleSheet(true);
}
},
observe: function (subject, topic, data) {
if (topic == "lightweight-theme-styling-update") {
let newTheme = JSON.parse(data);
if (newTheme && newTheme.id == "firefox-devedition@mozilla.org") {
this._toggleStyleSheet(true);
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);
}
}
if (topic == "nsPref:changed" && data == this._devtoolsThemePrefName) {
this._updateDevtoolsThemeAttribute();
if (topic == "nsPref:changed") {
if (data == this._devtoolsThemePrefName) {
this._updateDevtoolsThemeAttribute();
} else {
this._updateStyleSheetFromPrefs();
}
}
},
@ -61,6 +70,24 @@ let DevEdition = {
}
document.documentElement.setAttribute("devtoolstheme", devtoolsTheme);
this._inferBrightness();
this._updateStyleSheetFromPrefs();
},
_updateStyleSheetFromPrefs: function() {
let lightweightThemeSelected = false;
try {
lightweightThemeSelected = !!Services.prefs.getCharPref(this._lwThemePrefName);
} catch(e) {}
let defaultThemeSelected = false;
try {
defaultThemeSelected = Services.prefs.getCharPref(this._themePrefName) == "classic/1.0";
} catch(e) {}
let deveditionThemeEnabled = Services.prefs.getBoolPref(this._prefName) &&
!lightweightThemeSelected && defaultThemeSelected;
this._toggleStyleSheet(deveditionThemeEnabled);
},
handleEvent: function(e) {
@ -68,6 +95,7 @@ let DevEdition = {
this.styleSheet.removeEventListener("load", this);
gBrowser.tabContainer._positionPinnedTabs();
this._inferBrightness();
Services.obs.notifyObservers(window, "devedition-theme-state-changed", true);
}
},
@ -86,10 +114,13 @@ let DevEdition = {
this.styleSheet = null;
gBrowser.tabContainer._positionPinnedTabs();
this._inferBrightness();
Services.obs.notifyObservers(window, "devedition-theme-state-changed", false);
}
},
uninit: function () {
Services.prefs.removeObserver(this._lwThemePrefName, this);
Services.prefs.removeObserver(this._prefName, this);
Services.prefs.removeObserver(this._devtoolsThemePrefName, this);
Services.obs.removeObserver(this, "lightweight-theme-styling-update", false);
if (this.styleSheet) {

View File

@ -45,8 +45,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "Favicons",
XPCOMUtils.defineLazyServiceGetter(this, "gDNSService",
"@mozilla.org/network/dns-service;1",
"nsIDNSService");
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
"resource://gre/modules/LightweightThemeManager.jsm");
const nsIWebNavigation = Ci.nsIWebNavigation;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -5,56 +5,63 @@
* are applied.
*/
const PREF_DEVEDITION_THEME = "browser.devedition.theme.enabled";
const PREF_LWTHEME = "lightweightThemes.selectedThemeID";
const PREF_LWTHEME_USED_THEMES = "lightweightThemes.usedThemes";
const PREF_DEVTOOLS_THEME = "devtools.theme";
const {LightweightThemeManager} = Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", {});
LightweightThemeManager.clearBuiltInThemes();
LightweightThemeManager.addBuiltInTheme(dummyLightweightTheme("firefox-devedition@mozilla.org"));
registerCleanupFunction(() => {
// Set preferences back to their original values
LightweightThemeManager.currentTheme = null;
Services.prefs.clearUserPref(PREF_DEVEDITION_THEME);
Services.prefs.clearUserPref(PREF_LWTHEME);
Services.prefs.clearUserPref(PREF_DEVTOOLS_THEME);
Services.prefs.clearUserPref(PREF_LWTHEME_USED_THEMES);
LightweightThemeManager.currentTheme = null;
LightweightThemeManager.clearBuiltInThemes();
});
add_task(function* startTests() {
Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "dark");
info ("Setting the current theme to null");
LightweightThemeManager.currentTheme = null;
ok (!DevEdition.styleSheet, "There is no devedition style sheet when no lw theme is applied.");
info ("Setting browser.devedition.theme.enabled to false.");
Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, false);
ok (!DevEdition.styleSheet, "There is no devedition style sheet when the pref is false.");
info ("Setting browser.devedition.theme.enabled to true.");
Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, true);
ok (DevEdition.styleSheet, "There is a devedition stylesheet when no themes are applied and pref is set.");
info ("Adding a lightweight theme.");
LightweightThemeManager.currentTheme = dummyLightweightTheme("preview0");
ok (!DevEdition.styleSheet, "The devedition stylesheet has been removed when a lightweight theme is applied.");
info ("Applying the devedition lightweight theme.");
info ("Removing a lightweight theme.");
let onAttributeAdded = waitForBrightTitlebarAttribute();
LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org");
ok (DevEdition.styleSheet, "The devedition stylesheet has been added when the devedition lightweight theme is applied");
LightweightThemeManager.currentTheme = null;
ok (DevEdition.styleSheet, "The devedition stylesheet has been added when a lightweight theme is removed.");
yield onAttributeAdded;
is (document.documentElement.getAttribute("brighttitlebarforeground"), "true",
"The brighttitlebarforeground attribute is set on the window.");
info ("Unapplying all themes.");
LightweightThemeManager.currentTheme = null;
ok (!DevEdition.styleSheet, "There is no devedition style sheet when no lw theme is applied.");
info ("Setting browser.devedition.theme.enabled to false.");
Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, false);
ok (!DevEdition.styleSheet, "The devedition stylesheet has been removed.");
info ("Applying the devedition lightweight theme.");
onAttributeAdded = waitForBrightTitlebarAttribute();
LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org");
ok (DevEdition.styleSheet, "The devedition stylesheet has been added when the devedition lightweight theme is applied");
yield onAttributeAdded;
ok (document.documentElement.hasAttribute("brighttitlebarforeground"),
"The brighttitlebarforeground attribute is set on the window with dark devtools theme.");
ok (!document.documentElement.hasAttribute("brighttitlebarforeground"),
"The brighttitlebarforeground attribute is not set on the window after devedition.theme is false.");
});
add_task(function* testDevtoolsTheme() {
info ("Checking that Australis is shown when the light devtools theme is applied.");
let onAttributeAdded = waitForBrightTitlebarAttribute();
Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, true);
ok (DevEdition.styleSheet, "The devedition stylesheet exists.");
yield onAttributeAdded;
ok (document.documentElement.hasAttribute("brighttitlebarforeground"),
"The brighttitlebarforeground attribute is set on the window with dark devtools theme.");
info ("Checking stylesheet and :root attributes based on devtools theme.");
Services.prefs.setCharPref(PREF_DEVTOOLS_THEME, "light");
is (document.documentElement.getAttribute("devtoolstheme"), "light",
@ -82,16 +89,16 @@ function dummyLightweightTheme(id) {
return {
id: id,
name: id,
headerURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.header.png",
iconURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.icon.png",
headerURL: "resource:///chrome/browser/content/browser/defaultthemes/1.header.jpg",
iconURL: "resource:///chrome/browser/content/browser/defaultthemes/1.icon.jpg",
textcolor: "red",
accentcolor: "blue"
};
}
add_task(function* testLightweightThemePreview() {
info ("Setting devedition to current and the previewing others");
LightweightThemeManager.currentTheme = LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org");
info ("Turning the pref on, then previewing lightweight themes");
Services.prefs.setBoolPref(PREF_DEVEDITION_THEME, true);
ok (DevEdition.styleSheet, "The devedition stylesheet is enabled.");
LightweightThemeManager.previewTheme(dummyLightweightTheme("preview0"));
ok (!DevEdition.styleSheet, "The devedition stylesheet is not enabled after a lightweight theme preview.");
@ -100,15 +107,24 @@ add_task(function* testLightweightThemePreview() {
ok (!DevEdition.styleSheet, "The devedition stylesheet is not enabled after a second lightweight theme preview.");
LightweightThemeManager.resetPreview();
ok (DevEdition.styleSheet, "The devedition stylesheet is enabled again after resetting the preview.");
LightweightThemeManager.currentTheme = null;
ok (!DevEdition.styleSheet, "The devedition stylesheet is gone after removing the current theme.");
info ("Previewing the devedition theme");
LightweightThemeManager.previewTheme(LightweightThemeManager.getUsedTheme("firefox-devedition@mozilla.org"));
info ("Turning the pref on, then previewing a 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("preview2"));
ok (!DevEdition.styleSheet, "The devedition stylesheet is not enabled after a lightweight theme preview.");
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 now disabled after resetting the preview.");
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(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.");
});
// Use a mutation observer to wait for the brighttitlebarforeground

View File

@ -98,8 +98,6 @@ browser.jar:
content/browser/defaultthemes/5.header.png (content/defaultthemes/5.header.png)
content/browser/defaultthemes/5.icon.jpg (content/defaultthemes/5.icon.jpg)
content/browser/defaultthemes/5.preview.jpg (content/defaultthemes/5.preview.jpg)
content/browser/defaultthemes/devedition.header.png (content/defaultthemes/devedition.header.png)
content/browser/defaultthemes/devedition.icon.png (content/defaultthemes/devedition.icon.png)
content/browser/newtab/newTab.xul (content/newtab/newTab.xul)
* content/browser/newtab/newTab.js (content/newtab/newTab.js)
content/browser/newtab/newTab.css (content/newtab/newTab.css)

View File

@ -37,6 +37,7 @@ const kPrefCustomizationState = "browser.uiCustomization.state";
const kPrefCustomizationAutoAdd = "browser.uiCustomization.autoAdd";
const kPrefCustomizationDebug = "browser.uiCustomization.debug";
const kPrefDrawInTitlebar = "browser.tabs.drawInTitlebar";
const kPrefDeveditionTheme = "browser.devedition.theme.enabled";
const kPrefWebIDEInNavbar = "devtools.webide.widget.inNavbarByDefault";
/**
@ -2331,6 +2332,7 @@ let CustomizableUIInternal = {
_resetUIState: function() {
try {
gUIStateBeforeReset.drawInTitlebar = Services.prefs.getBoolPref(kPrefDrawInTitlebar);
gUIStateBeforeReset.deveditionTheme = Services.prefs.getBoolPref(kPrefDeveditionTheme);
gUIStateBeforeReset.uiCustomizationState = Services.prefs.getCharPref(kPrefCustomizationState);
} catch(e) { }
@ -2338,6 +2340,7 @@ let CustomizableUIInternal = {
Services.prefs.clearUserPref(kPrefCustomizationState);
Services.prefs.clearUserPref(kPrefDrawInTitlebar);
Services.prefs.clearUserPref(kPrefDeveditionTheme);
LOG("State reset");
// Reset placements to make restoring default placements possible.
@ -2399,13 +2402,15 @@ let CustomizableUIInternal = {
*/
undoReset: function() {
if (gUIStateBeforeReset.uiCustomizationState == null ||
gUIStateBeforeReset.drawInTitlebar == null) {
gUIStateBeforeReset.drawInTitlebar == null ||
gUIStateBeforeReset.deveditionTheme == null) {
return;
}
gUndoResetting = true;
let uiCustomizationState = gUIStateBeforeReset.uiCustomizationState;
let drawInTitlebar = gUIStateBeforeReset.drawInTitlebar;
let deveditionTheme = gUIStateBeforeReset.deveditionTheme;
// Need to clear the previous state before setting the prefs
// because pref observers may check if there is a previous UI state.
@ -2413,6 +2418,7 @@ let CustomizableUIInternal = {
Services.prefs.setCharPref(kPrefCustomizationState, uiCustomizationState);
Services.prefs.setBoolPref(kPrefDrawInTitlebar, drawInTitlebar);
Services.prefs.setBoolPref(kPrefDeveditionTheme, deveditionTheme);
this.loadSavedState();
// If the user just customizes toolbar/titlebar visibility, gSavedState will be null
// and we don't need to do anything else here:
@ -2590,6 +2596,10 @@ let CustomizableUIInternal = {
LOG(kPrefDrawInTitlebar + " pref is non-default");
return false;
}
if (Services.prefs.prefHasUserValue(kPrefDeveditionTheme)) {
LOG(kPrefDeveditionTheme + " pref is non-default");
return false;
}
return true;
},
@ -3290,7 +3300,8 @@ this.CustomizableUI = {
*/
get canUndoReset() {
return gUIStateBeforeReset.uiCustomizationState != null ||
gUIStateBeforeReset.drawInTitlebar != null;
gUIStateBeforeReset.drawInTitlebar != null ||
gUIStateBeforeReset.deveditionTheme != null;
},
/**

View File

@ -17,6 +17,9 @@ const kPlaceholderClass = "panel-customization-placeholder";
const kSkipSourceNodePref = "browser.uiCustomization.skipSourceNodeCheck";
const kToolbarVisibilityBtn = "customization-toolbar-visibility-button";
const kDrawInTitlebarPref = "browser.tabs.drawInTitlebar";
const kDeveditionThemePref = "browser.devedition.theme.enabled";
const kDeveditionButtonPref = "browser.devedition.theme.showCustomizeButton";
const kDeveditionChangedNotification = "devedition-theme-state-changed";
const kMaxTransitionDurationMs = 2000;
const kPanelItemContextMenu = "customizationPanelItemContextMenu";
@ -64,12 +67,17 @@ function CustomizeMode(aWindow) {
this.tipPanel = this.document.getElementById("customization-tipPanel");
if (Services.prefs.getCharPref("general.skins.selectedSkin") != "classic/1.0") {
let lwthemeButton = this.document.getElementById("customization-lwtheme-button");
let deveditionButton = this.document.getElementById("customization-devedition-theme-button");
lwthemeButton.setAttribute("hidden", "true");
deveditionButton.setAttribute("hidden", "true");
}
#ifdef CAN_DRAW_IN_TITLEBAR
this._updateTitlebarButton();
Services.prefs.addObserver(kDrawInTitlebarPref, this, false);
#endif
this._updateDevEditionThemeButton();
Services.prefs.addObserver(kDeveditionButtonPref, this, false);
Services.obs.addObserver(this, kDeveditionChangedNotification, false);
this.window.addEventListener("unload", this);
};
@ -105,6 +113,8 @@ CustomizeMode.prototype = {
#ifdef CAN_DRAW_IN_TITLEBAR
Services.prefs.removeObserver(kDrawInTitlebarPref, this);
#endif
Services.prefs.removeObserver(kDeveditionButtonPref, this);
Services.obs.removeObserver(this, kDeveditionChangedNotification);
},
toggle: function() {
@ -1497,6 +1507,13 @@ CustomizeMode.prototype = {
}
}
break;
case kDeveditionChangedNotification:
if (aSubject == this.window) {
this._updateDevEditionThemeButton();
this._updateResetButton();
this._updateUndoResetButton();
}
break;
}
},
@ -1521,6 +1538,44 @@ CustomizeMode.prototype = {
},
#endif
_updateDevEditionThemeButton: function() {
let button = this.document.getElementById("customization-devedition-theme-button");
let themeEnabled = !!this.window.DevEdition.styleSheet;
if (themeEnabled) {
button.setAttribute("checked", "true");
} else {
button.removeAttribute("checked");
}
let buttonVisible = Services.prefs.getBoolPref(kDeveditionButtonPref);
if (buttonVisible) {
button.removeAttribute("hidden");
} else {
button.setAttribute("hidden", "true");
}
},
toggleDevEditionTheme: function(shouldEnable) {
const DEFAULT_THEME_ID = "{972ce4c6-7e08-4474-a285-3208198ce6fd}";
Services.prefs.setBoolPref(kDeveditionThemePref, shouldEnable);
let currentLWT = LightweightThemeManager.currentTheme;
if (currentLWT && shouldEnable) {
this._lastLightweightTheme = currentLWT;
AddonManager.getAddonByID(DEFAULT_THEME_ID, function(aDefaultTheme) {
// Theoretically, this could race if people are /very/ quick in switching
// something else here, so doublecheck:
if (Services.prefs.getBoolPref(kDeveditionThemePref)) {
aDefaultTheme.userDisabled = false;
}
});
} else if (!currentLWT && !shouldEnable && this._lastLightweightTheme) {
LightweightThemeManager.currentTheme = this._lastLightweightTheme;
}
},
_onDragStart: function(aEvent) {
__dumpDragData(aEvent);
let item = aEvent.target;

View File

@ -53,6 +53,13 @@
</panel>
</button>
<button id="customization-devedition-theme-button"
class="customizationmode-button"
hidden="true"
label="&customizeMode.deveditionTheme.label2;"
oncommand="gCustomizeMode.toggleDevEditionTheme(this.hasAttribute('checked'))"
type="checkbox" />
<spacer id="customization-footer-spacer"/>
<button id="customization-undo-reset-button"
class="customizationmode-button"

View File

@ -5,12 +5,10 @@
"use strict";
const DEFAULT_THEME_ID = "{972ce4c6-7e08-4474-a285-3208198ce6fd}";
const {LightweightThemeManager} = Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", {});
add_task(function () {
Services.prefs.clearUserPref("lightweightThemes.usedThemes");
Services.prefs.clearUserPref("lightweightThemes.recommendedThemes");
LightweightThemeManager.clearBuiltInThemes();
yield startCustomizing();

View File

@ -101,6 +101,48 @@ add_task(function() {
is(undoResetButton.hidden, true, "Undo reset button should be hidden at end of test");
});
// Bug 1082108 - Restore Defaults should clear user pref for devedition theme
add_task(function() {
let prefName = "browser.devedition.theme.enabled";
Services.prefs.setBoolPref("browser.devedition.theme.showCustomizeButton", true);
let defaultValue = Services.prefs.getBoolPref(prefName);
let restoreDefaultsButton = document.getElementById("customization-reset-button");
let deveditionThemeButton = document.getElementById("customization-devedition-theme-button");
let undoResetButton = document.getElementById("customization-undo-reset-button");
ok(CustomizableUI.inDefaultState, "Should be in default state at start of test");
ok(restoreDefaultsButton.disabled, "Restore defaults button should be disabled when in default state");
is(deveditionThemeButton.hasAttribute("checked"), defaultValue, "Devedition theme button should reflect pref value");
is(undoResetButton.hidden, true, "Undo reset button should be hidden at start of test");
Services.prefs.setBoolPref(prefName, !defaultValue);
yield waitForCondition(() => !restoreDefaultsButton.disabled);
ok(!restoreDefaultsButton.disabled, "Restore defaults button should be enabled when pref changed");
is(deveditionThemeButton.hasAttribute("checked"), !defaultValue, "Devedition theme button should reflect changed pref value");
ok(!CustomizableUI.inDefaultState, "With devedition theme flipped, no longer default");
is(undoResetButton.hidden, true, "Undo reset button should be hidden after pref change");
yield gCustomizeMode.reset();
ok(restoreDefaultsButton.disabled, "Restore defaults button should be disabled after reset");
is(deveditionThemeButton.hasAttribute("checked"), defaultValue, "devedition theme button should reflect default value after reset");
is(Services.prefs.getBoolPref(prefName), defaultValue, "Reset should reset devedition.theme.enabled");
ok(CustomizableUI.inDefaultState, "In default state after devedition theme reset");
is(undoResetButton.hidden, false, "Undo reset button should be visible after reset");
ok(!undoResetButton.disabled, "Undo reset button should be enabled after reset");
yield gCustomizeMode.undoReset();
ok(!restoreDefaultsButton.disabled, "Restore defaults button should be enabled after undo-reset");
is(deveditionThemeButton.hasAttribute("checked"), !defaultValue, "devedition theme button should reflect undo-reset value");
ok(!CustomizableUI.inDefaultState, "No longer in default state after undo");
is(Services.prefs.getBoolPref(prefName), !defaultValue, "Undo-reset goes back to previous pref value");
is(undoResetButton.hidden, true, "Undo reset button should be hidden after undo-reset clicked");
//XXXgijs this line should be removed once bug 1094509 lands
Services.prefs.clearUserPref("devtools.theme");
Services.prefs.clearUserPref(prefName);
ok(CustomizableUI.inDefaultState, "In default state after pref cleared");
is(undoResetButton.hidden, true, "Undo reset button should be hidden at end of test");
});
add_task(function asyncCleanup() {
yield gCustomizeMode.reset();
yield endCustomizing();

View File

@ -151,9 +151,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "ReaderParent",
XPCOMUtils.defineLazyModuleGetter(this, "AddonWatcher",
"resource://gre/modules/AddonWatcher.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
"resource://gre/modules/LightweightThemeManager.jsm");
const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
const PREF_PLUGINS_UPDATEURL = "plugins.update.url";
@ -718,21 +715,6 @@ BrowserGlue.prototype = {
DebugUserAgent.init();
#endif
#ifndef RELEASE_BUILD
let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
let brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
let themeName = browserBundle.GetStringFromName("deveditionTheme.name");
let vendorShortName = brandBundle.GetStringFromName("vendorShortName");
LightweightThemeManager.addBuiltInTheme({
id: "firefox-devedition@mozilla.org",
name: themeName,
headerURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.header.png",
iconURL: "resource:///chrome/browser/content/browser/defaultthemes/devedition.icon.png",
author: vendorShortName,
});
#endif
Services.obs.notifyObservers(null, "browser-ui-startup-complete", "");
AddonWatcher.init(this._notifySlowAddon);
@ -1980,42 +1962,6 @@ BrowserGlue.prototype = {
}
}
if (currentUIVersion < 28) {
// Convert old devedition theme pref to lightweight theme storage
let lightweightThemeSelected = false;
let selectedThemeID = null;
try {
lightweightThemeSelected = Services.prefs.prefHasUserValue("lightweightThemes.selectedThemeID");
selectedThemeID = Services.prefs.getCharPref("lightweightThemes.selectedThemeID");
} catch(e) {}
let defaultThemeSelected = false;
try {
defaultThemeSelected = Services.prefs.getCharPref("general.skins.selectedSkin") == "classic/1.0";
} catch(e) {}
let deveditionThemeEnabled = false;
try {
deveditionThemeEnabled = Services.prefs.getBoolPref("browser.devedition.theme.enabled");
} catch(e) {}
// If we are on the devedition channel, the devedition theme is on by
// default. But we need to handle the case where they didn't want it
// applied, and unapply the theme.
let userChoseToNotUseDeveditionTheme =
!deveditionThemeEnabled ||
!defaultThemeSelected ||
(lightweightThemeSelected && selectedThemeID != "firefox-devedition@mozilla.org");
if (userChoseToNotUseDeveditionTheme && selectedThemeID == "firefox-devedition@mozilla.org") {
Services.prefs.setCharPref("lightweightThemes.selectedThemeID", "");
}
// Not clearing browser.devedition.theme.enabled, to preserve user's pref
// if for some reason this function runs again (even though it shouldn't)
Services.prefs.clearUserPref("browser.devedition.showCustomizeButton");
}
if (currentUIVersion < 29) {
let group = null;
try {

View File

@ -26,6 +26,7 @@ support-files =
[browser_toolbox_hosts.js]
[browser_toolbox_hosts_size.js]
[browser_toolbox_options.js]
[browser_toolbox_options_devedition.js]
[browser_toolbox_options_disable_buttons.js]
[browser_toolbox_options_disable_cache-01.js]
skip-if = e10s # Bug 1030318

View File

@ -0,0 +1,59 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that changing preferences in the options panel updates the prefs
// and toggles appropriate things in the toolbox.
let doc = null, toolbox = null, panelWin = null;
const PREF_ENABLED = "browser.devedition.theme.enabled";
const PREF_SHOW = "browser.devedition.theme.showCustomizeButton";
const URL = "data:text/html;charset=utf8,test for toggling dev edition browser theme toggling";
add_task(function*() {
// Set preference to false by default so this could
// run in Developer Edition which has it on by default.
Services.prefs.setBoolPref(PREF_ENABLED, false);
Services.prefs.setBoolPref(PREF_SHOW, true);
let tab = yield addTab(URL);
let target = TargetFactory.forTab(tab);
toolbox = yield gDevTools.showToolbox(target);
let tool = yield toolbox.selectTool("options");
panelWin = tool.panelWin;
let checkbox = tool.panelDoc.getElementById("devtools-browser-theme");
ise(Services.prefs.getBoolPref(PREF_ENABLED), false, "Dev Theme pref off on start");
let themeStatus = yield clickAndWaitForThemeChange(checkbox, panelWin);
ise(themeStatus, true, "Theme has been toggled on.");
themeStatus = yield clickAndWaitForThemeChange(checkbox, panelWin);
ise(themeStatus, false, "Theme has been toggled off.");
yield cleanup();
});
function clickAndWaitForThemeChange (el, win) {
let deferred = promise.defer();
gDevTools.on("pref-changed", function handler (event, {pref}) {
if (pref === PREF_ENABLED) {
gDevTools.off("pref-changed", handler);
deferred.resolve(Services.prefs.getBoolPref(PREF_ENABLED));
}
});
EventUtils.synthesizeMouseAtCenter(el, {}, win);
return deferred.promise;
}
function* cleanup() {
yield toolbox.destroy();
gBrowser.removeCurrentTab();
Services.prefs.clearUserPref(PREF_ENABLED);
Services.prefs.clearUserPref(PREF_SHOW);
toolbox = doc = panelWin = null;
}

View File

@ -9,6 +9,9 @@ const Services = require("Services");
const promise = require("promise");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", "resource:///modules/devtools/gDevTools.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CustomizeMode", "resource:///modules/CustomizeMode.jsm");
const kDeveditionChangedNotification = "devedition-theme-state-changed";
const DEVEDITION_THEME_PREF = "browser.devedition.theme.enabled";
exports.OptionsPanel = OptionsPanel;
@ -84,6 +87,7 @@ function OptionsPanel(iframeWindow, toolbox) {
this._addListeners();
Services.obs.addObserver(this, kDeveditionChangedNotification, false);
const EventEmitter = require("devtools/toolkit/event-emitter");
EventEmitter.decorate(this);
}
@ -108,6 +112,7 @@ OptionsPanel.prototype = {
this.setupToolsList();
this.setupToolbarButtonsList();
this.setupThemeList();
this.setupBrowserThemeButton();
this.populatePreferences();
this.updateDefaultTheme();
}).then(() => {
@ -141,6 +146,8 @@ OptionsPanel.prototype = {
}
else if (data.pref === "devtools.theme") {
this.updateCurrentTheme();
} else if (data.pref === "browser.devedition.theme.enabled") {
this.updateBrowserTheme();
}
},
@ -276,6 +283,52 @@ OptionsPanel.prototype = {
this.updateCurrentTheme();
},
/**
* Similar to `populatePrefs`, except we want more
* special rules for the browser theme button.
*/
setupBrowserThemeButton: function() {
let checkbox = this.panelDoc.getElementById("devtools-browser-theme");
checkbox.addEventListener("command", function() {
setPrefAndEmit(DEVEDITION_THEME_PREF, this.checked);
}.bind(checkbox));
this.updateBrowserThemeButton();
},
/**
* Called on theme changed via observer of "devedition-theme-state-changed".
*/
updateBrowserThemeButton: function() {
let checkbox = this.panelDoc.getElementById("devtools-browser-theme");
// Check if the dev edition style sheet is applied -- will not
// be applied when dev edition theme is disabled, or when there's
// a LWT applied.
if (this._isDevEditionThemeOn()) {
checkbox.setAttribute("checked", "true");
} else {
checkbox.removeAttribute("checked");
}
// Should the button be shown
if (GetPref("browser.devedition.theme.showCustomizeButton")) {
checkbox.removeAttribute("hidden");
} else {
checkbox.setAttribute("hidden", "true");
}
},
/**
* Called when clicking the browser theme button to enable/disable
* the dev edition browser theme.
*/
updateBrowserTheme: function() {
let enabled = GetPref("browser.devedition.theme.enabled");
CustomizeMode.prototype.toggleDevEditionTheme.call(this, enabled);
},
populatePreferences: function() {
let prefCheckboxes = this.panelDoc.querySelectorAll("checkbox[data-pref]");
for (let checkbox of prefCheckboxes) {
@ -364,6 +417,25 @@ OptionsPanel.prototype = {
this.target.activeTab.reconfigure(options);
},
/**
* Returns a boolean indicating whether or not the dev edition
* browser theme is applied.
*/
_isDevEditionThemeOn: function() {
let win = Services.wm.getMostRecentWindow("navigator:browser");
return !!(win && win.DevEdition.styleSheet);
},
/**
* Called on observer notification for "devedition-theme-state-changed"
* to possibly change the state of the dev edition button
*/
observe: function(aSubject, aTopic, aData) {
if (aTopic === kDeveditionChangedNotification) {
this.updateBrowserThemeButton();
}
},
destroy: function() {
if (this.destroyPromise) {
return this.destroyPromise;
@ -388,6 +460,8 @@ OptionsPanel.prototype = {
this.panelWin = this.panelDoc = this.disableJSNode = null;
Services.obs.removeObserver(this, kDeveditionChangedNotification);
return deferred.promise;
}
};

View File

@ -35,6 +35,9 @@
data-pref="devtools.theme"
orient="horizontal">
</radiogroup>
<checkbox id="devtools-browser-theme"
label="&options.usedeveditiontheme.label;"
tooltiptext="&options.usedeveditiontheme.tooltip;"/>
</vbox>
<label>&options.commonPrefs.label;</label>
<vbox id="commonprefs-options" class="options-groupbox">

View File

@ -52,6 +52,7 @@ let connect = Task.async(function*() {
function setPrefDefaults() {
Services.prefs.setBoolPref("devtools.inspector.showUserAgentStyles", true);
Services.prefs.setBoolPref("devtools.profiler.ui.show-platform-data", true);
Services.prefs.setBoolPref("browser.devedition.theme.showCustomizeButton", false);
Services.prefs.setBoolPref("devtools.inspector.showAllAnonymousContent", true);
Services.prefs.setBoolPref("browser.dom.window.dump.enabled", true);
Services.prefs.setBoolPref("devtools.command-button-frames.enabled", true);

View File

@ -742,6 +742,7 @@ just addresses the organization to follow, e.g. "This site is run by " -->
<!ENTITY customizeMode.lwthemes.menuManage.accessKey "M">
<!ENTITY customizeMode.lwthemes.menuGetMore "Get More Themes">
<!ENTITY customizeMode.lwthemes.menuGetMore.accessKey "G">
<!ENTITY customizeMode.deveditionTheme.label2 "Use Developer Edition Theme">
<!ENTITY social.chatBar.commandkey "c">
<!ENTITY social.chatBar.label "Focus chats">