Bug 1379338 - scriptify preferences XBL; r=jaws

MozReview-Commit-ID: Egyzs2KxhzH
This commit is contained in:
Myk Melez
2018-01-04 21:37:47 -08:00
parent 775ab4e404
commit 30f98a841a
75 changed files with 1638 additions and 2784 deletions

View File

@@ -6,54 +6,48 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<?xml-stylesheet href="chrome://global/skin/"?> <?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
<?xml-stylesheet href="chrome://browser/skin/sanitizeDialog.css"?> <?xml-stylesheet href="chrome://browser/skin/sanitizeDialog.css"?>
<?xml-stylesheet href="chrome://browser/content/sanitizeDialog.css"?> <?xml-stylesheet href="chrome://browser/content/sanitizeDialog.css"?>
<!DOCTYPE prefwindow [ <!DOCTYPE dialog [
<!ENTITY % preferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
<!ENTITY % globalKeysDTD SYSTEM "chrome://global/locale/globalKeys.dtd">
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd"> <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
<!ENTITY % sanitizeDTD SYSTEM "chrome://browser/locale/sanitize.dtd"> <!ENTITY % sanitizeDTD SYSTEM "chrome://browser/locale/sanitize.dtd">
%preferencesDTD;
%globalKeysDTD;
%brandDTD; %brandDTD;
%sanitizeDTD; %sanitizeDTD;
]> ]>
<prefwindow id="SanitizeDialog" type="child" <dialog id="SanitizeDialog" class="prefwindow" type="child"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
dlgbuttons="accept,cancel" buttons="accept,cancel"
title="&sanitizeDialog2.title;" persist="lastSelected screenX screenY"
noneverythingtitle="&sanitizeDialog2.title;" closebuttonlabel="&preferencesCloseButton.label;"
style="width: &sanitizeDialog2.width;;" closebuttonaccesskey="&preferencesCloseButton.accesskey;"
ondialogaccept="return gSanitizePromptDialog.sanitize();"> role="dialog"
title="&sanitizeDialog2.title;"
noneverythingtitle="&sanitizeDialog2.title;"
style="width: &sanitizeDialog2.width;;"
onload="gSanitizePromptDialog.init();"
ondialogaccept="return gSanitizePromptDialog.sanitize();">
<prefpane id="SanitizeDialogPane" onpaneload="gSanitizePromptDialog.init();"> <vbox id="SanitizeDialogPane" class="prefpane">
<stringbundle id="bundleBrowser" <stringbundle id="bundleBrowser"
src="chrome://browser/locale/browser.properties"/> src="chrome://browser/locale/browser.properties"/>
<script type="application/javascript" <script type="application/javascript"
src="chrome://browser/content/sanitize.js"/> src="chrome://browser/content/sanitize.js"/>
<script type="application/javascript"
src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript" <script type="application/javascript"
src="chrome://browser/content/sanitizeDialog.js"/> src="chrome://browser/content/sanitizeDialog.js"/>
<preferences id="sanitizePreferences">
<preference id="privacy.cpd.history" name="privacy.cpd.history" type="bool"/>
<preference id="privacy.cpd.formdata" name="privacy.cpd.formdata" type="bool"/>
<preference id="privacy.cpd.downloads" name="privacy.cpd.downloads" type="bool" disabled="true"/>
<preference id="privacy.cpd.cookies" name="privacy.cpd.cookies" type="bool"/>
<preference id="privacy.cpd.cache" name="privacy.cpd.cache" type="bool"/>
<preference id="privacy.cpd.sessions" name="privacy.cpd.sessions" type="bool"/>
<preference id="privacy.cpd.offlineApps" name="privacy.cpd.offlineApps" type="bool"/>
<preference id="privacy.cpd.siteSettings" name="privacy.cpd.siteSettings" type="bool"/>
</preferences>
<preferences id="nonItemPreferences">
<preference id="privacy.sanitize.timeSpan"
name="privacy.sanitize.timeSpan"
type="int"/>
</preferences>
<hbox id="SanitizeDurationBox" align="center"> <hbox id="SanitizeDurationBox" align="center">
<label value="&clearTimeDuration.label;" <label value="&clearTimeDuration.label;"
accesskey="&clearTimeDuration.accesskey;" accesskey="&clearTimeDuration.accesskey;"
@@ -144,5 +138,5 @@
onsyncfrompreference="return gSanitizePromptDialog.onReadGeneric();"/> onsyncfrompreference="return gSanitizePromptDialog.onReadGeneric();"/>
</listbox> </listbox>
</prefpane> </vbox>
</prefwindow> </dialog>

View File

@@ -3,12 +3,26 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from ../../../toolkit/content/preferencesBindings.js */
var Cc = Components.classes; var Cc = Components.classes;
var Ci = Components.interfaces; var Ci = Components.interfaces;
var Cu = Components.utils; var Cu = Components.utils;
var {Sanitizer} = Cu.import("resource:///modules/Sanitizer.jsm", {}); var {Sanitizer} = Cu.import("resource:///modules/Sanitizer.jsm", {});
Preferences.addAll([
{ id: "privacy.cpd.history", type: "bool" },
{ id: "privacy.cpd.formdata", type: "bool" },
{ id: "privacy.cpd.downloads", type: "bool", disabled: true },
{ id: "privacy.cpd.cookies", type: "bool" },
{ id: "privacy.cpd.cache", type: "bool" },
{ id: "privacy.cpd.sessions", type: "bool" },
{ id: "privacy.cpd.offlineApps", type: "bool" },
{ id: "privacy.cpd.siteSettings", type: "bool" },
{ id: "privacy.sanitize.timeSpan", type: "int" },
]);
var gSanitizePromptDialog = { var gSanitizePromptDialog = {
get bundleBrowser() { get bundleBrowser() {
@@ -22,14 +36,6 @@ var gSanitizePromptDialog = {
return parseInt(durList.value); return parseInt(durList.value);
}, },
get sanitizePreferences() {
if (!this._sanitizePreferences) {
this._sanitizePreferences =
document.getElementById("sanitizePreferences");
}
return this._sanitizePreferences;
},
get warningBox() { get warningBox() {
return document.getElementById("sanitizeEverythingWarningBox"); return document.getElementById("sanitizeEverythingWarningBox");
}, },
@@ -140,22 +146,22 @@ var gSanitizePromptDialog = {
this.bundleBrowser.getString(warningStringID); this.bundleBrowser.getString(warningStringID);
}, },
/**
* Return the boolean prefs that enable/disable clearing of various kinds
* of history. The only pref this excludes is privacy.sanitize.timeSpan.
*/
_getItemPrefs() {
return Preferences.getAll().filter(p => p.id !== "privacy.sanitize.timeSpan");
},
/** /**
* Called when the value of a preference element is synced from the actual * Called when the value of a preference element is synced from the actual
* pref. Enables or disables the OK button appropriately. * pref. Enables or disables the OK button appropriately.
*/ */
onReadGeneric() { onReadGeneric() {
var found = false; // Find any other pref that's checked and enabled (except for
// privacy.sanitize.timeSpan, which doesn't affect the button's status).
// Find any other pref that's checked and enabled. var found = this._getItemPrefs().some(pref => !!pref.value && !pref.disabled);
var i = 0;
while (!found && i < this.sanitizePreferences.childNodes.length) {
var preference = this.sanitizePreferences.childNodes[i];
found = !!preference.value &&
!preference.disabled;
i++;
}
try { try {
document.documentElement.getButton("accept").disabled = !found; document.documentElement.getButton("accept").disabled = !found;
@@ -171,23 +177,22 @@ var gSanitizePromptDialog = {
* Sanitizer.prototype.sanitize() requires the prefs to be up-to-date. * Sanitizer.prototype.sanitize() requires the prefs to be up-to-date.
* Because the type of this prefwindow is "child" -- and that's needed because * Because the type of this prefwindow is "child" -- and that's needed because
* without it the dialog has no OK and Cancel buttons -- the prefs are not * without it the dialog has no OK and Cancel buttons -- the prefs are not
* updated on dialogaccept on platforms that don't support instant-apply * updated on dialogaccept. We must therefore manually set the prefs
* (i.e., Windows). We must therefore manually set the prefs from their * from their corresponding preference elements.
* corresponding preference elements.
*/ */
updatePrefs() { updatePrefs() {
Sanitizer.prefs.setIntPref("timeSpan", this.selectedTimespan); Sanitizer.prefs.setIntPref("timeSpan", this.selectedTimespan);
// Keep the pref for the download history in sync with the history pref. // Keep the pref for the download history in sync with the history pref.
document.getElementById("privacy.cpd.downloads").value = Preferences.get("privacy.cpd.downloads").value =
document.getElementById("privacy.cpd.history").value; Preferences.get("privacy.cpd.history").value;
// Now manually set the prefs from their corresponding preference // Now manually set the prefs from their corresponding preference
// elements. // elements.
var prefs = this.sanitizePreferences.rootBranch; var prefs = this._getItemPrefs();
for (let i = 0; i < this.sanitizePreferences.childNodes.length; ++i) { for (let i = 0; i < prefs.length; ++i) {
var p = this.sanitizePreferences.childNodes[i]; var p = prefs[i];
prefs.setBoolPref(p.name, p.value); Services.prefs.setBoolPref(p.name, p.value);
} }
}, },
@@ -197,7 +202,7 @@ var gSanitizePromptDialog = {
hasNonSelectedItems() { hasNonSelectedItems() {
let checkboxes = document.querySelectorAll("#itemList > [preference]"); let checkboxes = document.querySelectorAll("#itemList > [preference]");
for (let i = 0; i < checkboxes.length; ++i) { for (let i = 0; i < checkboxes.length; ++i) {
let pref = document.getElementById(checkboxes[i].getAttribute("preference")); let pref = Preferences.get(checkboxes[i].getAttribute("preference"));
if (!pref.value) if (!pref.value)
return true; return true;
} }

View File

@@ -715,7 +715,7 @@ WindowHelper.prototype = {
var cb = this.win.document.querySelectorAll("#itemList > [preference]"); var cb = this.win.document.querySelectorAll("#itemList > [preference]");
ok(cb.length > 1, "found checkboxes for preferences"); ok(cb.length > 1, "found checkboxes for preferences");
for (var i = 0; i < cb.length; ++i) { for (var i = 0; i < cb.length; ++i) {
var pref = this.win.document.getElementById(cb[i].getAttribute("preference")); var pref = this.win.Preferences.get(cb[i].getAttribute("preference"));
if (!!pref.value ^ check) if (!!pref.value ^ check)
cb[i].click(); cb[i].click();
} }

View File

@@ -935,7 +935,7 @@ function openPrefsHelp() {
// since its probably behind the window. // since its probably behind the window.
var instantApply = getBoolPref("browser.preferences.instantApply"); var instantApply = getBoolPref("browser.preferences.instantApply");
var helpTopic = document.getElementsByTagName("prefwindow")[0].currentPane.helpTopic; var helpTopic = document.documentElement.getAttribute("helpTopic");
openHelpLink(helpTopic, !instantApply); openHelpLink(helpTopic, !instantApply);
} }

View File

@@ -19,6 +19,8 @@
<script type="application/javascript" <script type="application/javascript"
src="chrome://browser/content/utilityOverlay.js"/> src="chrome://browser/content/utilityOverlay.js"/>
<script type="application/javascript"
src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript" <script type="application/javascript"
src="chrome://browser/content/preferences/applicationManager.js"/> src="chrome://browser/content/preferences/applicationManager.js"/>

View File

@@ -0,0 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from ../../../toolkit/content/preferencesBindings.js */
Preferences.addAll([
{ id: "browser.display.document_color_use", type: "int" },
{ id: "browser.anchor_color", type: "string" },
{ id: "browser.visited_color", type: "string" },
{ id: "browser.underline_anchors", type: "bool" },
{ id: "browser.display.foreground_color", type: "string" },
{ id: "browser.display.background_color", type: "string" },
{ id: "browser.display.use_system_colors", type: "bool" },
]);

View File

@@ -6,36 +6,41 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
#ifdef XP_MACOSX
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?> <?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
#endif
<!DOCTYPE prefwindow SYSTEM "chrome://browser/locale/preferences/colors.dtd" > <!DOCTYPE dialog [
<!ENTITY % preferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
%preferencesDTD;
<!ENTITY % colorsDTD SYSTEM "chrome://browser/locale/preferences/colors.dtd">
%colorsDTD;
]>
<prefwindow id="ColorsDialog" type="child" <dialog id="ColorsDialog" type="child" class="prefwindow"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&colorsDialog.title;" title="&colorsDialog.title;"
dlgbuttons="accept,cancel,help" buttons="accept,cancel,help"
ondialoghelp="openPrefsHelp()" persist="lastSelected screenX screenY"
closebuttonlabel="&preferencesCloseButton.label;"
closebuttonaccesskey="&preferencesCloseButton.accesskey;"
role="dialog"
helpTopic="prefs-fonts-and-colors"
ondialoghelp="openPrefsHelp()"
#ifdef XP_MACOSX #ifdef XP_MACOSX
style="width: &window.macWidth; !important;"> style="width: &window.macWidth; !important;">
#else #else
style="width: &window.width; !important;"> style="width: &window.width; !important;">
#endif #endif
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/> <script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
<prefpane id="ColorsDialogPane" <script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
helpTopic="prefs-fonts-and-colors">
<preferences> <keyset>
<preference id="browser.display.document_color_use" name="browser.display.document_color_use" type="int"/> <key key="&windowClose.key;" modifiers="accel" oncommand="Preferences.close(event)"/>
<preference id="browser.anchor_color" name="browser.anchor_color" type="string"/> </keyset>
<preference id="browser.visited_color" name="browser.visited_color" type="string"/>
<preference id="browser.underline_anchors" name="browser.underline_anchors" type="bool"/> <vbox id="ColorsDialogPane" class="prefpane">
<preference id="browser.display.foreground_color" name="browser.display.foreground_color" type="string"/>
<preference id="browser.display.background_color" name="browser.display.background_color" type="string"/> <script type="application/javascript" src="chrome://browser/content/preferences/colors.js"/>
<preference id="browser.display.use_system_colors" name="browser.display.use_system_colors" type="bool"/>
</preferences>
<hbox> <hbox>
<groupbox flex="1"> <groupbox flex="1">
@@ -100,5 +105,5 @@
</menulist> </menulist>
</hbox> </hbox>
</vbox> </vbox>
</prefpane> </vbox>
</prefwindow> </dialog>

View File

@@ -4,10 +4,43 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from ../../base/content/utilityOverlay.js */ /* import-globals-from ../../base/content/utilityOverlay.js */
/* import-globals-from ../../../toolkit/content/preferencesBindings.js */
Preferences.addAll([
{ id: "network.proxy.type", type: "int" },
{ id: "network.proxy.http", type: "string" },
{ id: "network.proxy.http_port", type: "int" },
{ id: "network.proxy.ftp", type: "string" },
{ id: "network.proxy.ftp_port", type: "int" },
{ id: "network.proxy.ssl", type: "string" },
{ id: "network.proxy.ssl_port", type: "int" },
{ id: "network.proxy.socks", type: "string" },
{ id: "network.proxy.socks_port", type: "int" },
{ id: "network.proxy.socks_version", type: "int" },
{ id: "network.proxy.socks_remote_dns", type: "bool" },
{ id: "network.proxy.no_proxies_on", type: "string" },
{ id: "network.proxy.autoconfig_url", type: "string" },
{ id: "network.proxy.share_proxy_settings", type: "bool" },
{ id: "signon.autologin.proxy", type: "bool" },
{ id: "pref.advanced.proxies.disable_button.reload", type: "bool" },
{ id: "network.proxy.backup.ftp", type: "string" },
{ id: "network.proxy.backup.ftp_port", type: "int" },
{ id: "network.proxy.backup.ssl", type: "string" },
{ id: "network.proxy.backup.ssl_port", type: "int" },
{ id: "network.proxy.backup.socks", type: "string" },
{ id: "network.proxy.backup.socks_port", type: "int" },
]);
window.addEventListener("DOMContentLoaded", () => {
Preferences.get("network.proxy.type").on("change",
gConnectionsDialog.proxyTypeChanged.bind(gConnectionsDialog));
Preferences.get("network.proxy.socks_version").on("change",
gConnectionsDialog.updateDNSPref.bind(gConnectionsDialog));
}, { once: true, capture: true });
var gConnectionsDialog = { var gConnectionsDialog = {
beforeAccept() { beforeAccept() {
var proxyTypePref = document.getElementById("network.proxy.type"); var proxyTypePref = Preferences.get("network.proxy.type");
if (proxyTypePref.value == 2) { if (proxyTypePref.value == 2) {
this.doAutoconfigURLFixup(); this.doAutoconfigURLFixup();
return true; return true;
@@ -16,14 +49,14 @@ var gConnectionsDialog = {
if (proxyTypePref.value != 1) if (proxyTypePref.value != 1)
return true; return true;
var httpProxyURLPref = document.getElementById("network.proxy.http"); var httpProxyURLPref = Preferences.get("network.proxy.http");
var httpProxyPortPref = document.getElementById("network.proxy.http_port"); var httpProxyPortPref = Preferences.get("network.proxy.http_port");
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); var shareProxiesPref = Preferences.get("network.proxy.share_proxy_settings");
// If the port is 0 and the proxy server is specified, focus on the port and cancel submission. // If the port is 0 and the proxy server is specified, focus on the port and cancel submission.
for (let prefName of ["http", "ssl", "ftp", "socks"]) { for (let prefName of ["http", "ssl", "ftp", "socks"]) {
let proxyPortPref = document.getElementById("network.proxy." + prefName + "_port"); let proxyPortPref = Preferences.get("network.proxy." + prefName + "_port");
let proxyPref = document.getElementById("network.proxy." + prefName); let proxyPref = Preferences.get("network.proxy." + prefName);
// Only worry about ports which are currently active. If the share option is on, then ignore // Only worry about ports which are currently active. If the share option is on, then ignore
// all ports except the HTTP port // all ports except the HTTP port
if (proxyPref.value != "" && proxyPortPref.value == 0 && if (proxyPref.value != "" && proxyPortPref.value == 0 &&
@@ -37,10 +70,10 @@ var gConnectionsDialog = {
if (shareProxiesPref.value) { if (shareProxiesPref.value) {
var proxyPrefs = ["ssl", "ftp", "socks"]; var proxyPrefs = ["ssl", "ftp", "socks"];
for (var i = 0; i < proxyPrefs.length; ++i) { for (var i = 0; i < proxyPrefs.length; ++i) {
var proxyServerURLPref = document.getElementById("network.proxy." + proxyPrefs[i]); var proxyServerURLPref = Preferences.get("network.proxy." + proxyPrefs[i]);
var proxyPortPref = document.getElementById("network.proxy." + proxyPrefs[i] + "_port"); var proxyPortPref = Preferences.get("network.proxy." + proxyPrefs[i] + "_port");
var backupServerURLPref = document.getElementById("network.proxy.backup." + proxyPrefs[i]); var backupServerURLPref = Preferences.get("network.proxy.backup." + proxyPrefs[i]);
var backupPortPref = document.getElementById("network.proxy.backup." + proxyPrefs[i] + "_port"); var backupPortPref = Preferences.get("network.proxy.backup." + proxyPrefs[i] + "_port");
backupServerURLPref.value = backupServerURLPref.value || proxyServerURLPref.value; backupServerURLPref.value = backupServerURLPref.value || proxyServerURLPref.value;
backupPortPref.value = backupPortPref.value || proxyPortPref.value; backupPortPref.value = backupPortPref.value || proxyPortPref.value;
proxyServerURLPref.value = httpProxyURLPref.value; proxyServerURLPref.value = httpProxyURLPref.value;
@@ -59,34 +92,34 @@ var gConnectionsDialog = {
}, },
proxyTypeChanged() { proxyTypeChanged() {
var proxyTypePref = document.getElementById("network.proxy.type"); var proxyTypePref = Preferences.get("network.proxy.type");
// Update http // Update http
var httpProxyURLPref = document.getElementById("network.proxy.http"); var httpProxyURLPref = Preferences.get("network.proxy.http");
httpProxyURLPref.disabled = proxyTypePref.value != 1; httpProxyURLPref.disabled = proxyTypePref.value != 1;
var httpProxyPortPref = document.getElementById("network.proxy.http_port"); var httpProxyPortPref = Preferences.get("network.proxy.http_port");
httpProxyPortPref.disabled = proxyTypePref.value != 1; httpProxyPortPref.disabled = proxyTypePref.value != 1;
// Now update the other protocols // Now update the other protocols
this.updateProtocolPrefs(); this.updateProtocolPrefs();
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); var shareProxiesPref = Preferences.get("network.proxy.share_proxy_settings");
shareProxiesPref.disabled = proxyTypePref.value != 1; shareProxiesPref.disabled = proxyTypePref.value != 1;
var autologinProxyPref = document.getElementById("signon.autologin.proxy"); var autologinProxyPref = Preferences.get("signon.autologin.proxy");
autologinProxyPref.disabled = proxyTypePref.value == 0; autologinProxyPref.disabled = proxyTypePref.value == 0;
var noProxiesPref = document.getElementById("network.proxy.no_proxies_on"); var noProxiesPref = Preferences.get("network.proxy.no_proxies_on");
noProxiesPref.disabled = proxyTypePref.value != 1; noProxiesPref.disabled = proxyTypePref.value != 1;
var autoconfigURLPref = document.getElementById("network.proxy.autoconfig_url"); var autoconfigURLPref = Preferences.get("network.proxy.autoconfig_url");
autoconfigURLPref.disabled = proxyTypePref.value != 2; autoconfigURLPref.disabled = proxyTypePref.value != 2;
this.updateReloadButton(); this.updateReloadButton();
}, },
updateDNSPref() { updateDNSPref() {
var socksVersionPref = document.getElementById("network.proxy.socks_version"); var socksVersionPref = Preferences.get("network.proxy.socks_version");
var socksDNSPref = document.getElementById("network.proxy.socks_remote_dns"); var socksDNSPref = Preferences.get("network.proxy.socks_remote_dns");
var proxyTypePref = document.getElementById("network.proxy.type"); var proxyTypePref = Preferences.get("network.proxy.type");
var isDefinitelySocks4 = !socksVersionPref.disabled && socksVersionPref.value == 4; var isDefinitelySocks4 = !socksVersionPref.disabled && socksVersionPref.value == 4;
socksDNSPref.disabled = (isDefinitelySocks4 || proxyTypePref.value == 0); socksDNSPref.disabled = (isDefinitelySocks4 || proxyTypePref.value == 0);
return undefined; return undefined;
@@ -99,13 +132,13 @@ var gConnectionsDialog = {
// in prefs. // in prefs.
var typedURL = document.getElementById("networkProxyAutoconfigURL").value; var typedURL = document.getElementById("networkProxyAutoconfigURL").value;
var proxyTypeCur = document.getElementById("network.proxy.type").value; var proxyTypeCur = Preferences.get("network.proxy.type").value;
var pacURL = Services.prefs.getCharPref("network.proxy.autoconfig_url"); var pacURL = Services.prefs.getCharPref("network.proxy.autoconfig_url");
var proxyType = Services.prefs.getIntPref("network.proxy.type"); var proxyType = Services.prefs.getIntPref("network.proxy.type");
var disableReloadPref = var disableReloadPref =
document.getElementById("pref.advanced.proxies.disable_button.reload"); Preferences.get("pref.advanced.proxies.disable_button.reload");
disableReloadPref.disabled = disableReloadPref.disabled =
(proxyTypeCur != 2 || proxyType != 2 || typedURL != pacURL); (proxyTypeCur != 2 || proxyType != 2 || typedURL != pacURL);
}, },
@@ -116,17 +149,17 @@ var gConnectionsDialog = {
}, },
updateProtocolPrefs() { updateProtocolPrefs() {
var proxyTypePref = document.getElementById("network.proxy.type"); var proxyTypePref = Preferences.get("network.proxy.type");
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); var shareProxiesPref = Preferences.get("network.proxy.share_proxy_settings");
var proxyPrefs = ["ssl", "ftp", "socks"]; var proxyPrefs = ["ssl", "ftp", "socks"];
for (var i = 0; i < proxyPrefs.length; ++i) { for (var i = 0; i < proxyPrefs.length; ++i) {
var proxyServerURLPref = document.getElementById("network.proxy." + proxyPrefs[i]); var proxyServerURLPref = Preferences.get("network.proxy." + proxyPrefs[i]);
var proxyPortPref = document.getElementById("network.proxy." + proxyPrefs[i] + "_port"); var proxyPortPref = Preferences.get("network.proxy." + proxyPrefs[i] + "_port");
// Restore previous per-proxy custom settings, if present. // Restore previous per-proxy custom settings, if present.
if (!shareProxiesPref.value) { if (!shareProxiesPref.value) {
var backupServerURLPref = document.getElementById("network.proxy.backup." + proxyPrefs[i]); var backupServerURLPref = Preferences.get("network.proxy.backup." + proxyPrefs[i]);
var backupPortPref = document.getElementById("network.proxy.backup." + proxyPrefs[i] + "_port"); var backupPortPref = Preferences.get("network.proxy.backup." + proxyPrefs[i] + "_port");
if (backupServerURLPref.hasUserValue) { if (backupServerURLPref.hasUserValue) {
proxyServerURLPref.value = backupServerURLPref.value; proxyServerURLPref.value = backupServerURLPref.value;
backupServerURLPref.reset(); backupServerURLPref.reset();
@@ -142,20 +175,20 @@ var gConnectionsDialog = {
proxyServerURLPref.disabled = proxyTypePref.value != 1 || shareProxiesPref.value; proxyServerURLPref.disabled = proxyTypePref.value != 1 || shareProxiesPref.value;
proxyPortPref.disabled = proxyServerURLPref.disabled; proxyPortPref.disabled = proxyServerURLPref.disabled;
} }
var socksVersionPref = document.getElementById("network.proxy.socks_version"); var socksVersionPref = Preferences.get("network.proxy.socks_version");
socksVersionPref.disabled = proxyTypePref.value != 1 || shareProxiesPref.value; socksVersionPref.disabled = proxyTypePref.value != 1 || shareProxiesPref.value;
this.updateDNSPref(); this.updateDNSPref();
return undefined; return undefined;
}, },
readProxyProtocolPref(aProtocol, aIsPort) { readProxyProtocolPref(aProtocol, aIsPort) {
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); var shareProxiesPref = Preferences.get("network.proxy.share_proxy_settings");
if (shareProxiesPref.value) { if (shareProxiesPref.value) {
var pref = document.getElementById("network.proxy.http" + (aIsPort ? "_port" : "")); var pref = Preferences.get("network.proxy.http" + (aIsPort ? "_port" : ""));
return pref.value; return pref.value;
} }
var backupPref = document.getElementById("network.proxy.backup." + aProtocol + (aIsPort ? "_port" : "")); var backupPref = Preferences.get("network.proxy.backup." + aProtocol + (aIsPort ? "_port" : ""));
return backupPref.hasUserValue ? backupPref.value : undefined; return backupPref.hasUserValue ? backupPref.value : undefined;
}, },
@@ -166,7 +199,7 @@ var gConnectionsDialog = {
doAutoconfigURLFixup() { doAutoconfigURLFixup() {
var autoURL = document.getElementById("networkProxyAutoconfigURL"); var autoURL = document.getElementById("networkProxyAutoconfigURL");
var autoURLPref = document.getElementById("network.proxy.autoconfig_url"); var autoURLPref = Preferences.get("network.proxy.autoconfig_url");
try { try {
autoURLPref.value = autoURL.value = autoURLPref.value = autoURL.value =
Services.uriFixup.createFixupURI(autoURL.value, 0).spec; Services.uriFixup.createFixupURI(autoURL.value, 0).spec;
@@ -174,7 +207,7 @@ var gConnectionsDialog = {
}, },
sanitizeNoProxiesPref() { sanitizeNoProxiesPref() {
var noProxiesPref = document.getElementById("network.proxy.no_proxies_on"); var noProxiesPref = Preferences.get("network.proxy.no_proxies_on");
// replace substrings of ; and \n with commas if they're neither immediately // replace substrings of ; and \n with commas if they're neither immediately
// preceded nor followed by a valid separator character // preceded nor followed by a valid separator character
noProxiesPref.value = noProxiesPref.value.replace(/([^, \n;])[;\n]+(?![,\n;])/g, "$1,"); noProxiesPref.value = noProxiesPref.value.replace(/([^, \n;])[;\n]+(?![,\n;])/g, "$1,");
@@ -183,14 +216,14 @@ var gConnectionsDialog = {
}, },
readHTTPProxyServer() { readHTTPProxyServer() {
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); var shareProxiesPref = Preferences.get("network.proxy.share_proxy_settings");
if (shareProxiesPref.value) if (shareProxiesPref.value)
this.updateProtocolPrefs(); this.updateProtocolPrefs();
return undefined; return undefined;
}, },
readHTTPProxyPort() { readHTTPProxyPort() {
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); var shareProxiesPref = Preferences.get("network.proxy.share_proxy_settings");
if (shareProxiesPref.value) if (shareProxiesPref.value)
this.updateProtocolPrefs(); this.updateProtocolPrefs();
return undefined; return undefined;

View File

@@ -4,65 +4,46 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE prefwindow SYSTEM "chrome://browser/locale/preferences/connection.dtd"> <!DOCTYPE dialog [
<!ENTITY % preferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
%preferencesDTD;
<!ENTITY % connectionDTD SYSTEM "chrome://browser/locale/preferences/connection.dtd">
%connectionDTD;
]>
<?xml-stylesheet href="chrome://global/skin/"?> <?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
<dialog id="ConnectionsDialog" type="child" class="prefwindow"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&connectionsDialog.title;"
buttons="accept,cancel,help"
persist="lastSelected screenX screenY"
closebuttonlabel="&preferencesCloseButton.label;"
closebuttonaccesskey="&preferencesCloseButton.accesskey;"
role="dialog"
onbeforeaccept="return gConnectionsDialog.beforeAccept();"
onload="gConnectionsDialog.checkForSystemProxy();"
helpTopic="prefs-connection-settings"
ondialoghelp="openPrefsHelp()"
<prefwindow id="ConnectionsDialog" type="child"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&connectionsDialog.title;"
dlgbuttons="accept,cancel,help"
onbeforeaccept="return gConnectionsDialog.beforeAccept();"
onload="gConnectionsDialog.checkForSystemProxy();"
ondialoghelp="openPrefsHelp()"
#ifdef XP_MACOSX #ifdef XP_MACOSX
style="width: &window.macWidth2; !important;"> style="width: &window.macWidth2; !important;">
#else #else
style="width: &window.width2; !important;"> style="width: &window.width2; !important;">
#endif #endif
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/> <script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<prefpane id="ConnectionsDialogPane" <keyset>
class="largeDialogContainer" <key key="&windowClose.key;" modifiers="accel" oncommand="Preferences.close(event)"/>
helpTopic="prefs-connection-settings"> </keyset>
<preferences> <vbox id="ConnectionsDialogPane" class="prefpane largeDialogContainer">
<preference id="network.proxy.type" name="network.proxy.type" type="int" onchange="gConnectionsDialog.proxyTypeChanged();"/>
<preference id="network.proxy.http" name="network.proxy.http" type="string"/>
<preference id="network.proxy.http_port" name="network.proxy.http_port" type="int"/>
<preference id="network.proxy.ftp" name="network.proxy.ftp" type="string"/>
<preference id="network.proxy.ftp_port" name="network.proxy.ftp_port" type="int"/>
<preference id="network.proxy.ssl" name="network.proxy.ssl" type="string"/>
<preference id="network.proxy.ssl_port" name="network.proxy.ssl_port" type="int"/>
<preference id="network.proxy.socks" name="network.proxy.socks" type="string"/>
<preference id="network.proxy.socks_port" name="network.proxy.socks_port" type="int"/>
<preference id="network.proxy.socks_version" name="network.proxy.socks_version" type="int" onchange="gConnectionsDialog.updateDNSPref();"/>
<preference id="network.proxy.socks_remote_dns" name="network.proxy.socks_remote_dns" type="bool"/>
<preference id="network.proxy.no_proxies_on" name="network.proxy.no_proxies_on" type="string"/>
<preference id="network.proxy.autoconfig_url" name="network.proxy.autoconfig_url" type="string"/>
<preference id="network.proxy.share_proxy_settings"
name="network.proxy.share_proxy_settings"
type="bool"/>
<preference id="signon.autologin.proxy"
name="signon.autologin.proxy"
type="bool"/>
<preference id="pref.advanced.proxies.disable_button.reload"
name="pref.advanced.proxies.disable_button.reload"
type="bool"/>
<preference id="network.proxy.backup.ftp" name="network.proxy.backup.ftp" type="string"/>
<preference id="network.proxy.backup.ftp_port" name="network.proxy.backup.ftp_port" type="int"/>
<preference id="network.proxy.backup.ssl" name="network.proxy.backup.ssl" type="string"/>
<preference id="network.proxy.backup.ssl_port" name="network.proxy.backup.ssl_port" type="int"/>
<preference id="network.proxy.backup.socks" name="network.proxy.backup.socks" type="string"/>
<preference id="network.proxy.backup.socks_port" name="network.proxy.backup.socks_port" type="int"/>
</preferences>
<script type="application/javascript" src="chrome://browser/content/preferences/connection.js"/>
<stringbundle id="preferencesBundle" src="chrome://browser/locale/preferences/preferences.properties"/> <stringbundle id="preferencesBundle" src="chrome://browser/locale/preferences/preferences.properties"/>
<script type="application/javascript" src="chrome://browser/content/preferences/connection.js"/>
<groupbox> <groupbox>
<caption><label>&proxyTitle.label;</label></caption> <caption><label>&proxyTitle.label;</label></caption>
@@ -169,5 +150,5 @@
tooltiptext="&autologinproxy.tooltip;"/> tooltiptext="&autologinproxy.tooltip;"/>
<checkbox id="networkProxySOCKSRemoteDNS" preference="network.proxy.socks_remote_dns" label="&socksRemoteDNS.label2;" accesskey="&socksRemoteDNS.accesskey;" /> <checkbox id="networkProxySOCKSRemoteDNS" preference="network.proxy.socks_remote_dns" label="&socksRemoteDNS.label2;" accesskey="&socksRemoteDNS.accesskey;" />
<separator/> <separator/>
</prefpane> </vbox>
</prefwindow> </dialog>

View File

@@ -18,6 +18,12 @@ const kFontSizeFmtVariable = "font.size.variable.%LANG%";
const kFontSizeFmtFixed = "font.size.fixed.%LANG%"; const kFontSizeFmtFixed = "font.size.fixed.%LANG%";
const kFontMinSizeFmt = "font.minimum-size.%LANG%"; const kFontMinSizeFmt = "font.minimum-size.%LANG%";
Preferences.addAll([
{ id: "font.language.group", type: "wstring" },
{ id: "browser.display.use_document_fonts", type: "int" },
{ id: "intl.charset.fallback.override", type: "string" },
]);
var gFontsDialog = { var gFontsDialog = {
_selectLanguageGroupPromise: Promise.resolve(), _selectLanguageGroupPromise: Promise.resolve(),
@@ -44,16 +50,11 @@ var gFontsDialog = {
{ format: kFontSizeFmtFixed, type: "int", element: "sizeMono", fonttype: null }, { format: kFontSizeFmtFixed, type: "int", element: "sizeMono", fonttype: null },
{ format: kFontMinSizeFmt, type: "int", element: "minSize", fonttype: null } { format: kFontMinSizeFmt, type: "int", element: "minSize", fonttype: null }
]; ];
var preferences = document.getElementById("fontPreferences");
for (var i = 0; i < prefs.length; ++i) { for (var i = 0; i < prefs.length; ++i) {
var preference = document.getElementById(prefs[i].format.replace(/%LANG%/, aLanguageGroup)); var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup);
var preference = Preferences.get(name);
if (!preference) { if (!preference) {
preference = document.createElement("preference"); preference = Preferences.add({ id: name, type: prefs[i].type });
var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup);
preference.id = name;
preference.setAttribute("name", name);
preference.setAttribute("type", prefs[i].type);
preferences.appendChild(preference);
} }
if (!prefs[i].element) if (!prefs[i].element)
@@ -74,13 +75,13 @@ var gFontsDialog = {
}, },
readFontLanguageGroup() { readFontLanguageGroup() {
var languagePref = document.getElementById("font.language.group"); var languagePref = Preferences.get("font.language.group");
this._selectLanguageGroup(languagePref.value); this._selectLanguageGroup(languagePref.value);
return undefined; return undefined;
}, },
readUseDocumentFonts() { readUseDocumentFonts() {
var preference = document.getElementById("browser.display.use_document_fonts"); var preference = Preferences.get("browser.display.use_document_fonts");
return preference.value == 1; return preference.value == 1;
}, },
@@ -90,13 +91,12 @@ var gFontsDialog = {
}, },
onBeforeAccept() { onBeforeAccept() {
let preferences = document.querySelectorAll("preference[id*='font.minimum-size']");
// It would be good if we could avoid touching languages the pref pages won't use, but // It would be good if we could avoid touching languages the pref pages won't use, but
// unfortunately the language group APIs (deducing language groups from language codes) // unfortunately the language group APIs (deducing language groups from language codes)
// are C++ - only. So we just check all the things the user touched: // are C++ - only. So we just check all the things the user touched:
// Don't care about anything up to 24px, or if this value is the same as set previously: // Don't care about anything up to 24px, or if this value is the same as set previously:
preferences = Array.filter(preferences, prefEl => { let preferences = Preferences.getAll().filter(pref => {
return prefEl.value > 24 && prefEl.value != prefEl.valueFromPreferences; return pref.id.includes("font.minimum-size") && pref.value > 24 && pref.value != pref.valueFromPreferences;
}); });
if (!preferences.length) { if (!preferences.length) {
return true; return true;

View File

@@ -1,38 +1,40 @@
<?xml version="1.0"?> <?xml version="1.0"?>
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- <!-- -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -->
# This Source Code Form is subject to the terms of the Mozilla Public <!-- This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
#ifdef XP_MACOSX
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?> <?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
#endif
<!DOCTYPE prefwindow SYSTEM "chrome://browser/locale/preferences/fonts.dtd" > <!DOCTYPE dialog [
<!ENTITY % preferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
%preferencesDTD;
<!ENTITY % fontsDTD SYSTEM "chrome://browser/locale/preferences/fonts.dtd">
%fontsDTD;
]>
<prefwindow id="FontsDialog" type="child" <dialog id="FontsDialog" type="child" class="prefwindow"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&fontsDialog.title;" title="&fontsDialog.title;"
dlgbuttons="accept,cancel,help" buttons="accept,cancel,help"
ondialoghelp="openPrefsHelp()" persist="lastSelected screenX screenY"
onbeforeaccept="return gFontsDialog.onBeforeAccept();" closebuttonlabel="&preferencesCloseButton.label;"
style=""> closebuttonaccesskey="&preferencesCloseButton.accesskey;"
role="dialog"
helpTopic="prefs-fonts-and-colors"
ondialoghelp="openPrefsHelp()"
onbeforeaccept="return gFontsDialog.onBeforeAccept();">
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/> <script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<prefpane id="FontsDialogPane" <keyset>
class="largeDialogContainer" <key key="&windowClose.key;" modifiers="accel" oncommand="Preferences.close(event)"/>
helpTopic="prefs-fonts-and-colors"> </keyset>
<preferences id="fontPreferences"> <vbox id="FontsDialogPane" class="prefpane largeDialogContainer">
<preference id="font.language.group" name="font.language.group" type="wstring"/>
<preference id="browser.display.use_document_fonts"
name="browser.display.use_document_fonts"
type="int"/>
<preference id="intl.charset.fallback.override" name="intl.charset.fallback.override" type="string"/>
</preferences>
<stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences/preferences.properties"/> <stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences/preferences.properties"/>
<script type="application/javascript" src="chrome://mozapps/content/preferences/fontbuilder.js"/> <script type="application/javascript" src="chrome://mozapps/content/preferences/fontbuilder.js"/>
@@ -297,5 +299,5 @@
</hbox> </hbox>
</hbox> </hbox>
</groupbox> </groupbox>
</prefpane> </vbox>
</prefwindow> </dialog>

View File

@@ -7,14 +7,6 @@
<script type="application/javascript" <script type="application/javascript"
src="chrome://browser/content/preferences/in-content/containers.js"/> src="chrome://browser/content/preferences/in-content/containers.js"/>
<preferences id="containerPreferences" hidden="true" data-category="paneContainer">
<!-- Containers -->
<preference id="privacy.userContext.enabled"
name="privacy.userContext.enabled"
type="bool"/>
</preferences>
<hbox hidden="true" <hbox hidden="true"
class="container-header-links" class="container-header-links"
data-category="paneContainers"> data-category="paneContainers">

View File

@@ -103,6 +103,144 @@ if (AppConstants.MOZ_DEV_EDITION) {
"resource://gre/modules/FxAccounts.jsm"); "resource://gre/modules/FxAccounts.jsm");
} }
Preferences.addAll([
// Startup
{ id: "browser.startup.page", type: "int" },
{ id: "browser.startup.homepage", type: "wstring" },
{ id: "pref.browser.homepage.disable_button.current_page", type: "bool" },
{ id: "pref.browser.homepage.disable_button.bookmark_page", type: "bool" },
{ id: "pref.browser.homepage.disable_button.restore_default", type: "bool" },
{ id: "browser.privatebrowsing.autostart", type: "bool" },
// Downloads
{ id: "browser.download.useDownloadDir", type: "bool" },
{ id: "browser.download.folderList", type: "int" },
{ id: "browser.download.dir", type: "file" },
/* Tab preferences
Preferences:
browser.link.open_newwindow
1 opens such links in the most recent window or tab,
2 opens such links in a new window,
3 opens such links in a new tab
browser.tabs.loadInBackground
- true if display should switch to a new tab which has been opened from a
link, false if display shouldn't switch
browser.tabs.warnOnClose
- true if when closing a window with multiple tabs the user is warned and
allowed to cancel the action, false to just close the window
browser.tabs.warnOnOpen
- true if the user should be warned if he attempts to open a lot of tabs at
once (e.g. a large folder of bookmarks), false otherwise
browser.taskbar.previews.enable
- true if tabs are to be shown in the Windows 7 taskbar
*/
{ id: "browser.link.open_newwindow", type: "int" },
{ id: "browser.tabs.loadInBackground", type: "bool", inverted: true },
{ id: "browser.tabs.warnOnClose", type: "bool" },
{ id: "browser.tabs.warnOnOpen", type: "bool" },
{ id: "browser.sessionstore.restore_on_demand", type: "bool" },
{ id: "browser.ctrlTab.previews", type: "bool" },
// Fonts
{ id: "font.language.group", type: "wstring" },
// Languages
{ id: "browser.translation.detectLanguage", type: "bool" },
// General tab
/* Accessibility
* accessibility.browsewithcaret
- true enables keyboard navigation and selection within web pages using a
visible caret, false uses normal keyboard navigation with no caret
* accessibility.typeaheadfind
- when set to true, typing outside text areas and input boxes will
automatically start searching for what's typed within the current
document; when set to false, no search action happens */
{ id: "accessibility.browsewithcaret", type: "bool" },
{ id: "accessibility.typeaheadfind", type: "bool" },
{ id: "accessibility.blockautorefresh", type: "bool" },
/* Browsing
* general.autoScroll
- when set to true, clicking the scroll wheel on the mouse activates a
mouse mode where moving the mouse down scrolls the document downward with
speed correlated with the distance of the cursor from the original
position at which the click occurred (and likewise with movement upward);
if false, this behavior is disabled
* general.smoothScroll
- set to true to enable finer page scrolling than line-by-line on page-up,
page-down, and other such page movements */
{ id: "general.autoScroll", type: "bool" },
{ id: "general.smoothScroll", type: "bool" },
{ id: "layout.spellcheckDefault", type: "int" },
{ id: "browser.preferences.defaultPerformanceSettings.enabled", type: "bool" },
{ id: "dom.ipc.processCount", type: "int" },
{ id: "dom.ipc.processCount.web", type: "int" },
{ id: "layers.acceleration.disabled", type: "bool", inverted: true },
// Files and Applications
{ id: "browser.feeds.handler", type: "string" },
{ id: "browser.feeds.handler.default", type: "string" },
{ id: "browser.feeds.handlers.application", type: "file" },
{ id: "browser.feeds.handlers.webservice", type: "string" },
{ id: "browser.videoFeeds.handler", type: "string" },
{ id: "browser.videoFeeds.handler.default", type: "string" },
{ id: "browser.videoFeeds.handlers.application", type: "file" },
{ id: "browser.videoFeeds.handlers.webservice", type: "string" },
{ id: "browser.audioFeeds.handler", type: "string" },
{ id: "browser.audioFeeds.handler.default", type: "string" },
{ id: "browser.audioFeeds.handlers.application", type: "file" },
{ id: "browser.audioFeeds.handlers.webservice", type: "string" },
{ id: "pref.downloads.disable_button.edit_actions", type: "bool" },
// DRM content
{ id: "media.eme.enabled", type: "bool" },
// Update
{ id: "browser.preferences.advanced.selectedTabIndex", type: "int" },
{ id: "browser.search.update", type: "bool" },
{ id: "privacy.userContext.enabled", type: "bool" },
]);
if (AppConstants.HAVE_SHELL_SERVICE) {
Preferences.addAll([
{ id: "browser.shell.checkDefaultBrowser", type: "bool" },
{ id: "pref.general.disable_button.default_browser", type: "bool" },
]);
}
if (AppConstants.platform === "win") {
Preferences.addAll([
{ id: "browser.taskbar.previews.enable", type: "bool" },
{ id: "ui.osk.enabled", type: "bool" },
]);
}
if (AppConstants.MOZ_UPDATER) {
Preferences.addAll([
{ id: "app.update.enabled", type: "bool" },
{ id: "app.update.auto", type: "bool" },
{ id: "app.update.disable_button.showUpdateHistory", type: "bool" },
]);
if (AppConstants.MOZ_MAINTENANCE_SERVICE) {
Preferences.addAll([
{ id: "app.update.service.enabled", type: "bool" },
]);
}
}
// A promise that resolves when the list of application handlers is loaded. // A promise that resolves when the list of application handlers is loaded.
// We store this in a global so tests can await it. // We store this in a global so tests can await it.
var promiseLoadHandlersList; var promiseLoadHandlersList;
@@ -208,8 +346,8 @@ var gMainPane = {
this.updateDefaultPerformanceSettingsPref(); this.updateDefaultPerformanceSettingsPref();
let defaultPerformancePref = let defaultPerformancePref =
document.getElementById("browser.preferences.defaultPerformanceSettings.enabled"); Preferences.get("browser.preferences.defaultPerformanceSettings.enabled");
defaultPerformancePref.addEventListener("change", () => { defaultPerformancePref.on("change", () => {
this.updatePerformanceSettingsBox({ duringChangeEvent: true }); this.updatePerformanceSettingsBox({ duringChangeEvent: true });
}); });
this.updatePerformanceSettingsBox({ duringChangeEvent: false }); this.updatePerformanceSettingsBox({ duringChangeEvent: false });
@@ -249,8 +387,8 @@ var gMainPane = {
if (!TransientPrefs.prefShouldBeVisible("browser.tabs.warnOnOpen")) if (!TransientPrefs.prefShouldBeVisible("browser.tabs.warnOnOpen"))
document.getElementById("warnOpenMany").hidden = true; document.getElementById("warnOpenMany").hidden = true;
setEventListener("browser.privatebrowsing.autostart", "change", Preferences.get("browser.privatebrowsing.autostart").on("change",
gMainPane.updateBrowserStartupLastSession); gMainPane.updateBrowserStartupLastSession.bind(gMainPane));
if (AppConstants.HAVE_SHELL_SERVICE) { if (AppConstants.HAVE_SHELL_SERVICE) {
setEventListener("setDefaultButton", "command", setEventListener("setDefaultButton", "command",
gMainPane.setDefaultBrowser); gMainPane.setDefaultBrowser);
@@ -273,14 +411,14 @@ var gMainPane = {
gMainPane.openTranslationProviderAttribution); gMainPane.openTranslationProviderAttribution);
setEventListener("translateButton", "command", setEventListener("translateButton", "command",
gMainPane.showTranslationExceptions); gMainPane.showTranslationExceptions);
setEventListener("font.language.group", "change", Preferences.get("font.language.group").on("change",
gMainPane._rebuildFonts); gMainPane._rebuildFonts.bind(gMainPane));
setEventListener("advancedFonts", "command", setEventListener("advancedFonts", "command",
gMainPane.configureFonts); gMainPane.configureFonts);
setEventListener("colors", "command", setEventListener("colors", "command",
gMainPane.configureColors); gMainPane.configureColors);
setEventListener("layers.acceleration.disabled", "change", Preferences.get("layers.acceleration.disabled").on("change",
gMainPane.updateHardwareAcceleration); gMainPane.updateHardwareAcceleration.bind(gMainPane));
setEventListener("connectionSettings", "command", setEventListener("connectionSettings", "command",
gMainPane.showConnections); gMainPane.showConnections);
setEventListener("browserContainersCheckbox", "command", setEventListener("browserContainersCheckbox", "command",
@@ -420,8 +558,8 @@ var gMainPane = {
setEventListener("typeColumn", "click", gMainPane.sort); setEventListener("typeColumn", "click", gMainPane.sort);
setEventListener("actionColumn", "click", gMainPane.sort); setEventListener("actionColumn", "click", gMainPane.sort);
setEventListener("chooseFolder", "command", gMainPane.chooseFolder); setEventListener("chooseFolder", "command", gMainPane.chooseFolder);
setEventListener("browser.download.dir", "change", gMainPane.displayDownloadDirPref); Preferences.get("browser.download.dir").on("change",
setEventListener("saveWhere", "command", gMainPane.handleSaveToCommand); gMainPane.displayDownloadDirPref.bind(gMainPane));
// Listen for window unload so we can remove our preference observers. // Listen for window unload so we can remove our preference observers.
window.addEventListener("unload", this); window.addEventListener("unload", this);
@@ -484,7 +622,7 @@ var gMainPane = {
* Enables/disables the Settings button used to configure containers * Enables/disables the Settings button used to configure containers
*/ */
readBrowserContainersCheckbox() { readBrowserContainersCheckbox() {
const pref = document.getElementById("privacy.userContext.enabled"); const pref = Preferences.get("privacy.userContext.enabled");
const settings = document.getElementById("browserContainersSettings"); const settings = document.getElementById("browserContainersSettings");
settings.disabled = !pref.value; settings.disabled = !pref.value;
@@ -607,7 +745,7 @@ var gMainPane = {
*/ */
syncFromHomePref() { syncFromHomePref() {
let homePref = document.getElementById("browser.startup.homepage"); let homePref = Preferences.get("browser.startup.homepage");
// Set the "Use Current Page(s)" button's text and enabled state. // Set the "Use Current Page(s)" button's text and enabled state.
this._updateUseCurrentButton(); this._updateUseCurrentButton();
@@ -616,7 +754,7 @@ var gMainPane = {
// Disable or enable the inputs based on if this is controlled by an extension. // Disable or enable the inputs based on if this is controlled by an extension.
document.querySelectorAll("#browserHomePage, .homepage-button") document.querySelectorAll("#browserHomePage, .homepage-button")
.forEach((element) => { .forEach((element) => {
let isLocked = document.getElementById(element.getAttribute("preference")).locked; let isLocked = Preferences.get(element.getAttribute("preference")).locked;
element.disabled = isLocked || isControlled; element.disabled = isLocked || isControlled;
}); });
} }
@@ -668,7 +806,7 @@ var gMainPane = {
* window UI to reflect this. * window UI to reflect this.
*/ */
setHomePageToCurrent() { setHomePageToCurrent() {
let homePage = document.getElementById("browser.startup.homepage"); let homePage = Preferences.get("browser.startup.homepage");
let tabs = this._getTabsForHomePage(); let tabs = this._getTabsForHomePage();
function getTabURI(t) { function getTabURI(t) {
return t.linkedBrowser.currentURI.spec; return t.linkedBrowser.currentURI.spec;
@@ -715,7 +853,7 @@ var gMainPane = {
if (aEvent.detail.button != "accept") if (aEvent.detail.button != "accept")
return; return;
if (rv.urls && rv.names) { if (rv.urls && rv.names) {
var homePage = document.getElementById("browser.startup.homepage"); var homePage = Preferences.get("browser.startup.homepage");
// XXX still using dangerous "|" joiner! // XXX still using dangerous "|" joiner!
homePage.value = rv.urls.join("|"); homePage.value = rv.urls.join("|");
@@ -743,7 +881,7 @@ var gMainPane = {
// In this case, the button's disabled state is set by preferences.xml. // In this case, the button's disabled state is set by preferences.xml.
let prefName = "pref.browser.homepage.disable_button.current_page"; let prefName = "pref.browser.homepage.disable_button.current_page";
if (document.getElementById(prefName).locked) if (Preferences.get(prefName).locked)
return; return;
useCurrent.disabled = !tabs.length; useCurrent.disabled = !tabs.length;
@@ -778,7 +916,7 @@ var gMainPane = {
* Restores the default home page as the user's home page. * Restores the default home page as the user's home page.
*/ */
restoreDefaultHomePage() { restoreDefaultHomePage() {
var homePage = document.getElementById("browser.startup.homepage"); var homePage = Preferences.get("browser.startup.homepage");
homePage.value = homePage.defaultValue; homePage.value = homePage.defaultValue;
}, },
@@ -788,7 +926,7 @@ var gMainPane = {
*/ */
updateButtons(aButtonID, aPreferenceID) { updateButtons(aButtonID, aPreferenceID) {
var button = document.getElementById(aButtonID); var button = document.getElementById(aButtonID);
var preference = document.getElementById(aPreferenceID); var preference = Preferences.get(aPreferenceID);
button.disabled = preference.value != true; button.disabled = preference.value != true;
return undefined; return undefined;
}, },
@@ -798,8 +936,8 @@ var gMainPane = {
* on the value of the browser.privatebrowsing.autostart pref. * on the value of the browser.privatebrowsing.autostart pref.
*/ */
updateBrowserStartupLastSession() { updateBrowserStartupLastSession() {
let pbAutoStartPref = document.getElementById("browser.privatebrowsing.autostart"); let pbAutoStartPref = Preferences.get("browser.privatebrowsing.autostart");
let startupPref = document.getElementById("browser.startup.page"); let startupPref = Preferences.get("browser.startup.page");
let group = document.getElementById("browserStartupPage"); let group = document.getElementById("browserStartupPage");
let option = document.getElementById("browserStartupLastSession"); let option = document.getElementById("browserStartupLastSession");
if (pbAutoStartPref.value) { if (pbAutoStartPref.value) {
@@ -844,7 +982,7 @@ var gMainPane = {
* @returns |true| if such links should be opened in new tabs * @returns |true| if such links should be opened in new tabs
*/ */
readLinkTarget() { readLinkTarget() {
var openNewWindow = document.getElementById("browser.link.open_newwindow"); var openNewWindow = Preferences.get("browser.link.open_newwindow");
return openNewWindow.value != 2; return openNewWindow.value != 2;
}, },
@@ -892,7 +1030,7 @@ var gMainPane = {
*/ */
setDefaultBrowser() { setDefaultBrowser() {
if (AppConstants.HAVE_SHELL_SERVICE) { if (AppConstants.HAVE_SHELL_SERVICE) {
let alwaysCheckPref = document.getElementById("browser.shell.checkDefaultBrowser"); let alwaysCheckPref = Preferences.get("browser.shell.checkDefaultBrowser");
alwaysCheckPref.value = true; alwaysCheckPref.value = true;
// Reset exponential backoff delay time in order to do visual update in pollForDefaultBrowser. // Reset exponential backoff delay time in order to do visual update in pollForDefaultBrowser.
@@ -1024,12 +1162,7 @@ var gMainPane = {
* Populates the default font list in UI. * Populates the default font list in UI.
*/ */
_rebuildFonts() { _rebuildFonts() {
var preferences = document.getElementById("mainPreferences"); var langGroupPref = Preferences.get("font.language.group");
// Ensure preferences are "visible" to ensure bindings work.
preferences.hidden = false;
// Force flush:
preferences.clientHeight;
var langGroupPref = document.getElementById("font.language.group");
var isSerif = this._readDefaultFontTypeForLanguage(langGroupPref.value) == "serif"; var isSerif = this._readDefaultFontTypeForLanguage(langGroupPref.value) == "serif";
this._selectDefaultLanguageGroup(langGroupPref.value, isSerif); this._selectDefaultLanguageGroup(langGroupPref.value, isSerif);
}, },
@@ -1041,14 +1174,10 @@ var gMainPane = {
_readDefaultFontTypeForLanguage(aLanguageGroup) { _readDefaultFontTypeForLanguage(aLanguageGroup) {
const kDefaultFontType = "font.default.%LANG%"; const kDefaultFontType = "font.default.%LANG%";
var defaultFontTypePref = kDefaultFontType.replace(/%LANG%/, aLanguageGroup); var defaultFontTypePref = kDefaultFontType.replace(/%LANG%/, aLanguageGroup);
var preference = document.getElementById(defaultFontTypePref); var preference = Preferences.get(defaultFontTypePref);
if (!preference) { if (!preference) {
preference = document.createElement("preference"); preference = Preferences.add({ id: defaultFontTypePref, type: "string" });
preference.id = defaultFontTypePref; preference.on("change", gMainPane._rebuildFonts.bind(gMainPane));
preference.setAttribute("name", defaultFontTypePref);
preference.setAttribute("type", "string");
preference.setAttribute("onchange", "gMainPane._rebuildFonts();");
document.getElementById("mainPreferences").appendChild(preference);
} }
return preference.value; return preference.value;
}, },
@@ -1072,7 +1201,6 @@ var gMainPane = {
const kFontNameListFmtSansSerif = "font.name-list.sans-serif.%LANG%"; const kFontNameListFmtSansSerif = "font.name-list.sans-serif.%LANG%";
const kFontSizeFmtVariable = "font.size.variable.%LANG%"; const kFontSizeFmtVariable = "font.size.variable.%LANG%";
var preferences = document.getElementById("mainPreferences");
var prefs = [{ var prefs = [{
format: aIsSerif ? kFontNameFmtSerif : kFontNameFmtSansSerif, format: aIsSerif ? kFontNameFmtSerif : kFontNameFmtSansSerif,
type: "fontname", type: "fontname",
@@ -1092,14 +1220,10 @@ var gMainPane = {
fonttype: null fonttype: null
}]; }];
for (var i = 0; i < prefs.length; ++i) { for (var i = 0; i < prefs.length; ++i) {
var preference = document.getElementById(prefs[i].format.replace(/%LANG%/, aLanguageGroup)); var preference = Preferences.get(prefs[i].format.replace(/%LANG%/, aLanguageGroup));
if (!preference) { if (!preference) {
preference = document.createElement("preference");
var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup); var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup);
preference.id = name; preference = Preferences.add({ id: name, type: prefs[i].type });
preference.setAttribute("name", name);
preference.setAttribute("type", prefs[i].type);
preferences.appendChild(preference);
} }
if (!prefs[i].element) if (!prefs[i].element)
@@ -1137,7 +1261,7 @@ var gMainPane = {
* 2 enables spellchecking for all text fields * 2 enables spellchecking for all text fields
*/ */
readCheckSpelling() { readCheckSpelling() {
var pref = document.getElementById("layout.spellcheckDefault"); var pref = Preferences.get("layout.spellcheckDefault");
this._storedSpellCheck = pref.value; this._storedSpellCheck = pref.value;
return (pref.value != 0); return (pref.value != 0);
@@ -1161,9 +1285,9 @@ var gMainPane = {
updateDefaultPerformanceSettingsPref() { updateDefaultPerformanceSettingsPref() {
let defaultPerformancePref = let defaultPerformancePref =
document.getElementById("browser.preferences.defaultPerformanceSettings.enabled"); Preferences.get("browser.preferences.defaultPerformanceSettings.enabled");
let processCountPref = document.getElementById("dom.ipc.processCount"); let processCountPref = Preferences.get("dom.ipc.processCount");
let accelerationPref = document.getElementById("layers.acceleration.disabled"); let accelerationPref = Preferences.get("layers.acceleration.disabled");
if (processCountPref.value != processCountPref.defaultValue || if (processCountPref.value != processCountPref.defaultValue ||
accelerationPref.value != accelerationPref.defaultValue) { accelerationPref.value != accelerationPref.defaultValue) {
defaultPerformancePref.value = false; defaultPerformancePref.value = false;
@@ -1172,11 +1296,11 @@ var gMainPane = {
updatePerformanceSettingsBox({ duringChangeEvent }) { updatePerformanceSettingsBox({ duringChangeEvent }) {
let defaultPerformancePref = let defaultPerformancePref =
document.getElementById("browser.preferences.defaultPerformanceSettings.enabled"); Preferences.get("browser.preferences.defaultPerformanceSettings.enabled");
let performanceSettings = document.getElementById("performanceSettings"); let performanceSettings = document.getElementById("performanceSettings");
let processCountPref = document.getElementById("dom.ipc.processCount"); let processCountPref = Preferences.get("dom.ipc.processCount");
if (defaultPerformancePref.value) { if (defaultPerformancePref.value) {
let accelerationPref = document.getElementById("layers.acceleration.disabled"); let accelerationPref = Preferences.get("layers.acceleration.disabled");
// Unset the value so process count will be decided by the platform. // Unset the value so process count will be decided by the platform.
processCountPref.value = processCountPref.defaultValue; processCountPref.value = processCountPref.defaultValue;
accelerationPref.value = accelerationPref.defaultValue; accelerationPref.value = accelerationPref.defaultValue;
@@ -1188,7 +1312,7 @@ var gMainPane = {
buildContentProcessCountMenuList() { buildContentProcessCountMenuList() {
if (Services.appinfo.browserTabsRemoteAutostart) { if (Services.appinfo.browserTabsRemoteAutostart) {
let processCountPref = document.getElementById("dom.ipc.processCount"); let processCountPref = Preferences.get("dom.ipc.processCount");
let defaultProcessCount = processCountPref.defaultValue; let defaultProcessCount = processCountPref.defaultValue;
let bundlePreferences = document.getElementById("bundlePreferences"); let bundlePreferences = document.getElementById("bundlePreferences");
@@ -1260,8 +1384,8 @@ var gMainPane = {
*/ */
updateReadPrefs() { updateReadPrefs() {
if (AppConstants.MOZ_UPDATER) { if (AppConstants.MOZ_UPDATER) {
var enabledPref = document.getElementById("app.update.enabled"); var enabledPref = Preferences.get("app.update.enabled");
var autoPref = document.getElementById("app.update.auto"); var autoPref = Preferences.get("app.update.auto");
var radiogroup = document.getElementById("updateRadioGroup"); var radiogroup = document.getElementById("updateRadioGroup");
if (!enabledPref.value) // Don't care for autoPref.value in this case. if (!enabledPref.value) // Don't care for autoPref.value in this case.
@@ -1305,8 +1429,8 @@ var gMainPane = {
*/ */
updateWritePrefs() { updateWritePrefs() {
if (AppConstants.MOZ_UPDATER) { if (AppConstants.MOZ_UPDATER) {
var enabledPref = document.getElementById("app.update.enabled"); var enabledPref = Preferences.get("app.update.enabled");
var autoPref = document.getElementById("app.update.auto"); var autoPref = Preferences.get("app.update.auto");
var radiogroup = document.getElementById("updateRadioGroup"); var radiogroup = document.getElementById("updateRadioGroup");
switch (radiogroup.value) { switch (radiogroup.value) {
case "auto": // 1. Automatically install updates for Desktop only case "auto": // 1. Automatically install updates for Desktop only
@@ -2370,7 +2494,7 @@ var gMainPane = {
readUseDownloadDir() { readUseDownloadDir() {
var downloadFolder = document.getElementById("downloadFolder"); var downloadFolder = document.getElementById("downloadFolder");
var chooseFolder = document.getElementById("chooseFolder"); var chooseFolder = document.getElementById("chooseFolder");
var preference = document.getElementById("browser.download.useDownloadDir"); var preference = Preferences.get("browser.download.useDownloadDir");
downloadFolder.disabled = !preference.value || preference.locked; downloadFolder.disabled = !preference.value || preference.locked;
chooseFolder.disabled = !preference.value || preference.locked; chooseFolder.disabled = !preference.value || preference.locked;
@@ -2398,8 +2522,8 @@ var gMainPane = {
[providerDisplayName], 1); [providerDisplayName], 1);
saveToCloudRadio.hidden = false; saveToCloudRadio.hidden = false;
let useDownloadDirPref = document.getElementById("browser.download.useDownloadDir"); let useDownloadDirPref = Preferences.get("browser.download.useDownloadDir");
let folderListPref = document.getElementById("browser.download.folderList"); let folderListPref = Preferences.get("browser.download.folderList");
// Check if useDownloadDir is true and folderListPref is set to Cloud Storage value 3 // Check if useDownloadDir is true and folderListPref is set to Cloud Storage value 3
// before selecting cloudStorageradio button. Disable folder field and Browse button if // before selecting cloudStorageradio button. Disable folder field and Browse button if
@@ -2433,7 +2557,7 @@ var gMainPane = {
// with useDownloadDirPref value true, if selectedIndex is other than // with useDownloadDirPref value true, if selectedIndex is other than
// SaveTo radio button disable downloadFolder filefield and chooseFolder button // SaveTo radio button disable downloadFolder filefield and chooseFolder button
let saveWhere = document.getElementById("saveWhere"); let saveWhere = document.getElementById("saveWhere");
let useDownloadDirPref = document.getElementById("browser.download.useDownloadDir"); let useDownloadDirPref = Preferences.get("browser.download.useDownloadDir");
if (useDownloadDirPref.value) { if (useDownloadDirPref.value) {
let downloadFolder = document.getElementById("downloadFolder"); let downloadFolder = document.getElementById("downloadFolder");
let chooseFolder = document.getElementById("chooseFolder"); let chooseFolder = document.getElementById("chooseFolder");
@@ -2447,12 +2571,12 @@ var gMainPane = {
// default Downloads, check pref 'browser.download.dir' before setting respective // default Downloads, check pref 'browser.download.dir' before setting respective
// folderListPref value. If currentDirPref is unspecified folderList should // folderListPref value. If currentDirPref is unspecified folderList should
// default to 1 // default to 1
let folderListPref = document.getElementById("browser.download.folderList"); let folderListPref = Preferences.get("browser.download.folderList");
let saveTo = document.getElementById("saveTo"); let saveTo = document.getElementById("saveTo");
if (saveWhere.selectedItem == saveToCloudRadio) { if (saveWhere.selectedItem == saveToCloudRadio) {
folderListPref.value = 3; folderListPref.value = 3;
} else if (saveWhere.selectedItem == saveTo) { } else if (saveWhere.selectedItem == saveTo) {
let currentDirPref = document.getElementById("browser.download.dir"); let currentDirPref = Preferences.get("browser.download.dir");
folderListPref.value = currentDirPref.value ? await this._folderToIndex(currentDirPref.value) : 1; folderListPref.value = currentDirPref.value ? await this._folderToIndex(currentDirPref.value) : 1;
} }
} }
@@ -2469,7 +2593,7 @@ var gMainPane = {
async chooseFolderTask() { async chooseFolderTask() {
let bundlePreferences = document.getElementById("bundlePreferences"); let bundlePreferences = document.getElementById("bundlePreferences");
let title = bundlePreferences.getString("chooseDownloadFolderTitle"); let title = bundlePreferences.getString("chooseDownloadFolderTitle");
let folderListPref = document.getElementById("browser.download.folderList"); let folderListPref = Preferences.get("browser.download.folderList");
let currentDirPref = await this._indexToFolder(folderListPref.value); let currentDirPref = await this._indexToFolder(folderListPref.value);
let defDownloads = await this._indexToFolder(1); let defDownloads = await this._indexToFolder(1);
let fp = Components.classes["@mozilla.org/filepicker;1"]. let fp = Components.classes["@mozilla.org/filepicker;1"].
@@ -2493,7 +2617,7 @@ var gMainPane = {
return; return;
} }
let downloadDirPref = document.getElementById("browser.download.dir"); let downloadDirPref = Preferences.get("browser.download.dir");
downloadDirPref.value = fp.file; downloadDirPref.value = fp.file;
folderListPref.value = await this._folderToIndex(fp.file); folderListPref.value = await this._folderToIndex(fp.file);
// Note, the real prefs will not be updated yet, so dnld manager's // Note, the real prefs will not be updated yet, so dnld manager's
@@ -2514,10 +2638,10 @@ var gMainPane = {
}, },
async displayDownloadDirPrefTask() { async displayDownloadDirPrefTask() {
var folderListPref = document.getElementById("browser.download.folderList"); var folderListPref = Preferences.get("browser.download.folderList");
var bundlePreferences = document.getElementById("bundlePreferences"); var bundlePreferences = document.getElementById("bundlePreferences");
var downloadFolder = document.getElementById("downloadFolder"); var downloadFolder = document.getElementById("downloadFolder");
var currentDirPref = document.getElementById("browser.download.dir"); var currentDirPref = Preferences.get("browser.download.dir");
// Used in defining the correct path to the folder icon. // Used in defining the correct path to the folder icon.
var fph = Services.io.getProtocolHandler("file") var fph = Services.io.getProtocolHandler("file")
@@ -2613,7 +2737,7 @@ var gMainPane = {
case 1: case 1:
return this._getDownloadsFolder("Downloads"); return this._getDownloadsFolder("Downloads");
} }
var currentDirPref = document.getElementById("browser.download.dir"); var currentDirPref = Preferences.get("browser.download.dir");
return currentDirPref.value; return currentDirPref.value;
} }
}; };
@@ -3016,16 +3140,16 @@ FeedHandlerInfo.prototype = {
}, },
get preferredApplicationHandler() { get preferredApplicationHandler() {
switch (this.element(this._prefSelectedReader).value) { switch (Preferences.get(this._prefSelectedReader).value) {
case "client": case "client":
var file = this.element(this._prefSelectedApp).value; var file = Preferences.get(this._prefSelectedApp).value;
if (file) if (file)
return getLocalHandlerApp(file); return getLocalHandlerApp(file);
return null; return null;
case "web": case "web":
var uri = this.element(this._prefSelectedWeb).value; var uri = Preferences.get(this._prefSelectedWeb).value;
if (!uri) if (!uri)
return null; return null;
return this._converterSvc.getWebContentHandlerByURI(this.type, uri); return this._converterSvc.getWebContentHandlerByURI(this.type, uri);
@@ -3041,11 +3165,11 @@ FeedHandlerInfo.prototype = {
set preferredApplicationHandler(aNewValue) { set preferredApplicationHandler(aNewValue) {
if (aNewValue instanceof Ci.nsILocalHandlerApp) { if (aNewValue instanceof Ci.nsILocalHandlerApp) {
this.element(this._prefSelectedApp).value = aNewValue.executable; Preferences.get(this._prefSelectedApp).value = aNewValue.executable;
this.element(this._prefSelectedReader).value = "client"; Preferences.get(this._prefSelectedReader).value = "client";
} else if (aNewValue instanceof Ci.nsIWebContentHandlerInfo) { } else if (aNewValue instanceof Ci.nsIWebContentHandlerInfo) {
this.element(this._prefSelectedWeb).value = aNewValue.uri; Preferences.get(this._prefSelectedWeb).value = aNewValue.uri;
this.element(this._prefSelectedReader).value = "web"; Preferences.get(this._prefSelectedReader).value = "web";
// Make the web handler be the new "auto handler" for feeds. // Make the web handler be the new "auto handler" for feeds.
// Note: we don't have to unregister the auto handler when the user picks // Note: we don't have to unregister the auto handler when the user picks
// a non-web handler (local app, Live Bookmarks, etc.) because the service // a non-web handler (local app, Live Bookmarks, etc.) because the service
@@ -3105,7 +3229,7 @@ FeedHandlerInfo.prototype = {
// only a single path. But we display all the local apps the user chooses // only a single path. But we display all the local apps the user chooses
// while the prefpane is open, only dropping the list when the user closes // while the prefpane is open, only dropping the list when the user closes
// the prefpane, for maximum usability and consistency with other types. // the prefpane, for maximum usability and consistency with other types.
var preferredAppFile = this.element(this._prefSelectedApp).value; var preferredAppFile = Preferences.get(this._prefSelectedApp).value;
if (preferredAppFile) { if (preferredAppFile) {
let preferredApp = getLocalHandlerApp(preferredAppFile); let preferredApp = getLocalHandlerApp(preferredAppFile);
let defaultApp = this._defaultApplicationHandler; let defaultApp = this._defaultApplicationHandler;
@@ -3173,7 +3297,7 @@ FeedHandlerInfo.prototype = {
// What to do with content of this type. // What to do with content of this type.
get preferredAction() { get preferredAction() {
switch (this.element(this._prefSelectedAction).value) { switch (Preferences.get(this._prefSelectedAction).value) {
case "bookmarks": case "bookmarks":
return Ci.nsIHandlerInfo.handleInternally; return Ci.nsIHandlerInfo.handleInternally;
@@ -3211,31 +3335,31 @@ FeedHandlerInfo.prototype = {
switch (aNewValue) { switch (aNewValue) {
case Ci.nsIHandlerInfo.handleInternally: case Ci.nsIHandlerInfo.handleInternally:
this.element(this._prefSelectedReader).value = "bookmarks"; Preferences.get(this._prefSelectedReader).value = "bookmarks";
break; break;
case Ci.nsIHandlerInfo.useHelperApp: case Ci.nsIHandlerInfo.useHelperApp:
this.element(this._prefSelectedAction).value = "reader"; Preferences.get(this._prefSelectedAction).value = "reader";
// The controller has already set preferredApplicationHandler // The controller has already set preferredApplicationHandler
// to the new helper app. // to the new helper app.
break; break;
case Ci.nsIHandlerInfo.useSystemDefault: case Ci.nsIHandlerInfo.useSystemDefault:
this.element(this._prefSelectedAction).value = "reader"; Preferences.get(this._prefSelectedAction).value = "reader";
this.preferredApplicationHandler = this._defaultApplicationHandler; this.preferredApplicationHandler = this._defaultApplicationHandler;
break; break;
} }
}, },
get alwaysAskBeforeHandling() { get alwaysAskBeforeHandling() {
return this.element(this._prefSelectedAction).value == "ask"; return Preferences.get(this._prefSelectedAction).value == "ask";
}, },
set alwaysAskBeforeHandling(aNewValue) { set alwaysAskBeforeHandling(aNewValue) {
if (aNewValue == true) if (aNewValue == true)
this.element(this._prefSelectedAction).value = "ask"; Preferences.get(this._prefSelectedAction).value = "ask";
else else
this.element(this._prefSelectedAction).value = "reader"; Preferences.get(this._prefSelectedAction).value = "reader";
}, },
// Whether or not we are currently storing the action selected by the user. // Whether or not we are currently storing the action selected by the user.
@@ -3264,7 +3388,7 @@ FeedHandlerInfo.prototype = {
store() { store() {
for (let app of this._possibleApplicationHandlers._removed) { for (let app of this._possibleApplicationHandlers._removed) {
if (app instanceof Ci.nsILocalHandlerApp) { if (app instanceof Ci.nsILocalHandlerApp) {
let pref = this.element(PREF_FEED_SELECTED_APP); let pref = Preferences.get(PREF_FEED_SELECTED_APP);
var preferredAppFile = pref.value; var preferredAppFile = pref.value;
if (preferredAppFile) { if (preferredAppFile) {
let preferredApp = getLocalHandlerApp(preferredAppFile); let preferredApp = getLocalHandlerApp(preferredAppFile);

View File

@@ -16,245 +16,6 @@
<stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences.properties"/> <stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences.properties"/>
<preferences id="mainPreferences" hidden="true" data-category="paneGeneral">
<!-- Startup -->
<preference id="browser.startup.page"
name="browser.startup.page"
type="int"/>
<preference id="browser.startup.homepage"
name="browser.startup.homepage"
type="wstring"/>
#ifdef HAVE_SHELL_SERVICE
<preference id="browser.shell.checkDefaultBrowser"
name="browser.shell.checkDefaultBrowser"
type="bool"/>
<preference id="pref.general.disable_button.default_browser"
name="pref.general.disable_button.default_browser"
type="bool"/>
#endif
<preference id="pref.browser.homepage.disable_button.current_page"
name="pref.browser.homepage.disable_button.current_page"
type="bool"/>
<preference id="pref.browser.homepage.disable_button.bookmark_page"
name="pref.browser.homepage.disable_button.bookmark_page"
type="bool"/>
<preference id="pref.browser.homepage.disable_button.restore_default"
name="pref.browser.homepage.disable_button.restore_default"
type="bool"/>
<preference id="browser.privatebrowsing.autostart"
name="browser.privatebrowsing.autostart"
type="bool"/>
<!-- Downloads -->
<preference id="browser.download.useDownloadDir"
name="browser.download.useDownloadDir"
type="bool"/>
<preference id="browser.download.folderList"
name="browser.download.folderList"
type="int"/>
<preference id="browser.download.dir"
name="browser.download.dir"
type="file"/>
<!-- Tab preferences
Preferences:
browser.link.open_newwindow
1 opens such links in the most recent window or tab,
2 opens such links in a new window,
3 opens such links in a new tab
browser.tabs.loadInBackground
- true if display should switch to a new tab which has been opened from a
link, false if display shouldn't switch
browser.tabs.warnOnClose
- true if when closing a window with multiple tabs the user is warned and
allowed to cancel the action, false to just close the window
browser.tabs.warnOnOpen
- true if the user should be warned if he attempts to open a lot of tabs at
once (e.g. a large folder of bookmarks), false otherwise
browser.taskbar.previews.enable
- true if tabs are to be shown in the Windows 7 taskbar
-->
<preference id="browser.link.open_newwindow"
name="browser.link.open_newwindow"
type="int"/>
<preference id="browser.tabs.loadInBackground"
name="browser.tabs.loadInBackground"
type="bool"
inverted="true"/>
<preference id="browser.tabs.warnOnClose"
name="browser.tabs.warnOnClose"
type="bool"/>
<preference id="browser.tabs.warnOnOpen"
name="browser.tabs.warnOnOpen"
type="bool"/>
<preference id="browser.sessionstore.restore_on_demand"
name="browser.sessionstore.restore_on_demand"
type="bool"/>
#ifdef XP_WIN
<preference id="browser.taskbar.previews.enable"
name="browser.taskbar.previews.enable"
type="bool"/>
#endif
<preference id="browser.ctrlTab.previews"
name="browser.ctrlTab.previews"
type="bool"/>
<!-- Fonts -->
<preference id="font.language.group"
name="font.language.group"
type="wstring"/>
<!-- Languages -->
<preference id="browser.translation.detectLanguage"
name="browser.translation.detectLanguage"
type="bool"/>
<!-- General tab -->
<!-- Accessibility
* accessibility.browsewithcaret
- true enables keyboard navigation and selection within web pages using a
visible caret, false uses normal keyboard navigation with no caret
* accessibility.typeaheadfind
- when set to true, typing outside text areas and input boxes will
automatically start searching for what's typed within the current
document; when set to false, no search action happens -->
<preference id="accessibility.browsewithcaret"
name="accessibility.browsewithcaret"
type="bool"/>
<preference id="accessibility.typeaheadfind"
name="accessibility.typeaheadfind"
type="bool"/>
<preference id="accessibility.blockautorefresh"
name="accessibility.blockautorefresh"
type="bool"/>
#ifdef XP_WIN
<preference id="ui.osk.enabled"
name="ui.osk.enabled"
type="bool"/>
#endif
<!-- Browsing
* general.autoScroll
- when set to true, clicking the scroll wheel on the mouse activates a
mouse mode where moving the mouse down scrolls the document downward with
speed correlated with the distance of the cursor from the original
position at which the click occurred (and likewise with movement upward);
if false, this behavior is disabled
* general.smoothScroll
- set to true to enable finer page scrolling than line-by-line on page-up,
page-down, and other such page movements -->
<preference id="general.autoScroll"
name="general.autoScroll"
type="bool"/>
<preference id="general.smoothScroll"
name="general.smoothScroll"
type="bool"/>
<preference id="layout.spellcheckDefault"
name="layout.spellcheckDefault"
type="int"/>
<preference id="browser.preferences.defaultPerformanceSettings.enabled"
name="browser.preferences.defaultPerformanceSettings.enabled"
type="bool"/>
<preference id="dom.ipc.processCount"
name="dom.ipc.processCount"
type="int"/>
<preference id="dom.ipc.processCount.web"
name="dom.ipc.processCount.web"
type="int"/>
<preference id="layers.acceleration.disabled"
name="layers.acceleration.disabled"
type="bool"
inverted="true"/>
<!-- Files and Applications -->
<preference id="browser.feeds.handler"
name="browser.feeds.handler"
type="string"/>
<preference id="browser.feeds.handler.default"
name="browser.feeds.handler.default"
type="string"/>
<preference id="browser.feeds.handlers.application"
name="browser.feeds.handlers.application"
type="file"/>
<preference id="browser.feeds.handlers.webservice"
name="browser.feeds.handlers.webservice"
type="string"/>
<preference id="browser.videoFeeds.handler"
name="browser.videoFeeds.handler"
type="string"/>
<preference id="browser.videoFeeds.handler.default"
name="browser.videoFeeds.handler.default"
type="string"/>
<preference id="browser.videoFeeds.handlers.application"
name="browser.videoFeeds.handlers.application"
type="file"/>
<preference id="browser.videoFeeds.handlers.webservice"
name="browser.videoFeeds.handlers.webservice"
type="string"/>
<preference id="browser.audioFeeds.handler"
name="browser.audioFeeds.handler"
type="string"/>
<preference id="browser.audioFeeds.handler.default"
name="browser.audioFeeds.handler.default"
type="string"/>
<preference id="browser.audioFeeds.handlers.application"
name="browser.audioFeeds.handlers.application"
type="file"/>
<preference id="browser.audioFeeds.handlers.webservice"
name="browser.audioFeeds.handlers.webservice"
type="string"/>
<preference id="pref.downloads.disable_button.edit_actions"
name="pref.downloads.disable_button.edit_actions"
type="bool"/>
<!-- DRM content -->
<preference id="media.eme.enabled"
name="media.eme.enabled"
type="bool"/>
<!-- Update -->
<preference id="browser.preferences.advanced.selectedTabIndex"
name="browser.preferences.advanced.selectedTabIndex"
type="int"/>
#ifdef MOZ_UPDATER
<preference id="app.update.enabled"
name="app.update.enabled"
type="bool"/>
<preference id="app.update.auto"
name="app.update.auto"
type="bool"/>
<preference id="app.update.disable_button.showUpdateHistory"
name="app.update.disable_button.showUpdateHistory"
type="bool"/>
#ifdef MOZ_MAINTENANCE_SERVICE
<preference id="app.update.service.enabled"
name="app.update.service.enabled"
type="bool"/>
#endif
#endif
<preference id="browser.search.update"
name="browser.search.update"
type="bool"/>
</preferences>
<hbox id="generalCategory" <hbox id="generalCategory"
class="subcategory" class="subcategory"
hidden="true" hidden="true"

View File

@@ -11,6 +11,7 @@
/* import-globals-from sync.js */ /* import-globals-from sync.js */
/* import-globals-from findInPage.js */ /* import-globals-from findInPage.js */
/* import-globals-from ../../../base/content/utilityOverlay.js */ /* import-globals-from ../../../base/content/utilityOverlay.js */
/* import-globals-from ../../../../toolkit/content/preferencesBindings.js */
"use strict"; "use strict";
@@ -57,7 +58,7 @@ function register_module(categoryName, categoryObject) {
document.addEventListener("DOMContentLoaded", init_all, {once: true}); document.addEventListener("DOMContentLoaded", init_all, {once: true});
function init_all() { function init_all() {
document.documentElement.instantApply = true; Preferences.forceEnableInstantApply();
gSubDialog.init(); gSubDialog.init();
register_module("paneGeneral", gMainPane); register_module("paneGeneral", gMainPane);
@@ -318,14 +319,6 @@ function scrollContentTo(element) {
}); });
} }
function helpButtonCommand() {
let pane = history.state;
let categories = document.getElementById("categories");
let helpTopic = categories.querySelector(".category[value=" + pane + "]")
.getAttribute("helpTopic");
openHelpLink(helpTopic);
}
function friendlyPrefCategoryNameToInternalName(aName) { function friendlyPrefCategoryNameToInternalName(aName) {
if (aName.startsWith("pane")) if (aName.startsWith("pane"))
return aName; return aName;

View File

@@ -104,6 +104,8 @@
<script type="application/javascript" <script type="application/javascript"
src="chrome://browser/content/utilityOverlay.js"/> src="chrome://browser/content/utilityOverlay.js"/>
<script type="application/javascript"
src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript" <script type="application/javascript"
src="chrome://browser/content/preferences/in-content/preferences.js"/> src="chrome://browser/content/preferences/in-content/preferences.js"/>
<script src="chrome://browser/content/preferences/in-content/findInPage.js"/> <script src="chrome://browser/content/preferences/in-content/findInPage.js"/>
@@ -196,14 +198,14 @@
<hbox class="search-container" pack="end"> <hbox class="search-container" pack="end">
<textbox type="search" id="searchInput" style="width: &searchField.width;" hidden="true" clickSelectsAll="true"/> <textbox type="search" id="searchInput" style="width: &searchField.width;" hidden="true" clickSelectsAll="true"/>
</hbox> </hbox>
<prefpane id="mainPrefPane"> <vbox id="mainPrefPane" class="prefpane prefwindow">
#include searchResults.xul #include searchResults.xul
#include main.xul #include main.xul
#include search.xul #include search.xul
#include privacy.xul #include privacy.xul
#include containers.xul #include containers.xul
#include sync.xul #include sync.xul
</prefpane> </vbox>
</vbox> </vbox>
</vbox> </vbox>
</hbox> </hbox>

View File

@@ -34,6 +34,87 @@ XPCOMUtils.defineLazyGetter(this, "AlertsServiceDND", function() {
} }
}); });
Preferences.addAll([
// Tracking
{ id: "privacy.trackingprotection.enabled", type: "bool" },
{ id: "privacy.trackingprotection.pbmode.enabled", type: "bool" },
// Button prefs
{ id: "pref.privacy.disable_button.cookie_exceptions", type: "bool" },
{ id: "pref.privacy.disable_button.view_cookies", type: "bool" },
{ id: "pref.privacy.disable_button.change_blocklist", type: "bool" },
{ id: "pref.privacy.disable_button.tracking_protection_exceptions", type: "bool" },
// Location Bar
{ id: "browser.urlbar.autocomplete.enabled", type: "bool" },
{ id: "browser.urlbar.suggest.bookmark", type: "bool" },
{ id: "browser.urlbar.suggest.history", type: "bool" },
{ id: "browser.urlbar.suggest.openpage", type: "bool" },
// History
{ id: "places.history.enabled", type: "bool" },
{ id: "browser.formfill.enable", type: "bool" },
{ id: "privacy.history.custom", type: "bool" },
// Cookies
{ id: "network.cookie.cookieBehavior", type: "int" },
{ id: "network.cookie.lifetimePolicy", type: "int" },
{ id: "network.cookie.blockFutureCookies", type: "bool" },
// Clear Private Data
{ id: "privacy.sanitize.sanitizeOnShutdown", type: "bool" },
{ id: "privacy.sanitize.timeSpan", type: "int" },
// Do not track
{ id: "privacy.donottrackheader.enabled", type: "bool" },
// Popups
{ id: "dom.disable_open_during_load", type: "bool" },
// Passwords
{ id: "signon.rememberSignons", type: "bool" },
// Buttons
{ id: "pref.privacy.disable_button.view_passwords", type: "bool" },
{ id: "pref.privacy.disable_button.view_passwords_exceptions", type: "bool" },
/* Certificates tab
* security.default_personal_cert
* - a string:
* "Select Automatically" select a certificate automatically when a site
* requests one
* "Ask Every Time" present a dialog to the user so he can select
* the certificate to use on a site which
* requests one
*/
{ id: "security.default_personal_cert", type: "string" },
{ id: "security.disable_button.openCertManager", type: "bool" },
{ id: "security.disable_button.openDeviceManager", type: "bool" },
{ id: "security.OCSP.enabled", type: "int" },
// Add-ons, malware, phishing
{ id: "xpinstall.whitelist.required", type: "bool" },
{ id: "browser.safebrowsing.malware.enabled", type: "bool" },
{ id: "browser.safebrowsing.phishing.enabled", type: "bool" },
{ id: "browser.safebrowsing.downloads.enabled", type: "bool" },
{ id: "urlclassifier.malwareTable", type: "string" },
{ id: "browser.safebrowsing.downloads.remote.block_potentially_unwanted", type: "bool" },
{ id: "browser.safebrowsing.downloads.remote.block_uncommon", type: "bool" },
// Network tab
{ id: "browser.cache.disk.capacity", type: "int" },
{ id: "browser.cache.disk.smart_size.enabled", type: "bool", inverted: "true" },
]);
// Data Choices tab
if (AppConstants.MOZ_CRASHREPORTER) {
Preferences.add({ id: "browser.crashReports.unsubmittedCheck.autoSubmit2", type: "bool" });
}
var gPrivacyPane = { var gPrivacyPane = {
_pane: null, _pane: null,
@@ -104,10 +185,10 @@ var gPrivacyPane = {
this._initTrackingProtectionPBM(); this._initTrackingProtectionPBM();
this._initAutocomplete(); this._initAutocomplete();
setEventListener("privacy.sanitize.sanitizeOnShutdown", "change", Preferences.get("privacy.sanitize.sanitizeOnShutdown").on("change",
gPrivacyPane._updateSanitizeSettingsButton); gPrivacyPane._updateSanitizeSettingsButton.bind(gPrivacyPane));
setEventListener("browser.privatebrowsing.autostart", "change", Preferences.get("browser.privatebrowsing.autostart").on("change",
gPrivacyPane.updatePrivacyMicroControls); gPrivacyPane.updatePrivacyMicroControls.bind(gPrivacyPane));
setEventListener("historyMode", "command", function() { setEventListener("historyMode", "command", function() {
gPrivacyPane.updateHistoryModePane(); gPrivacyPane.updateHistoryModePane();
gPrivacyPane.updateHistoryModePrefs(); gPrivacyPane.updateHistoryModePrefs();
@@ -326,8 +407,8 @@ var gPrivacyPane = {
* Selects the right item of the Tracking Protection radiogroup. * Selects the right item of the Tracking Protection radiogroup.
*/ */
trackingProtectionReadPrefs() { trackingProtectionReadPrefs() {
let enabledPref = document.getElementById("privacy.trackingprotection.enabled"); let enabledPref = Preferences.get("privacy.trackingprotection.enabled");
let pbmPref = document.getElementById("privacy.trackingprotection.pbmode.enabled"); let pbmPref = Preferences.get("privacy.trackingprotection.pbmode.enabled");
let radiogroup = document.getElementById("trackingProtectionRadioGroup"); let radiogroup = document.getElementById("trackingProtectionRadioGroup");
// Global enable takes precedence over enabled in Private Browsing. // Global enable takes precedence over enabled in Private Browsing.
@@ -344,8 +425,8 @@ var gPrivacyPane = {
* Sets the pref values based on the selected item of the radiogroup. * Sets the pref values based on the selected item of the radiogroup.
*/ */
trackingProtectionWritePrefs() { trackingProtectionWritePrefs() {
let enabledPref = document.getElementById("privacy.trackingprotection.enabled"); let enabledPref = Preferences.get("privacy.trackingprotection.enabled");
let pbmPref = document.getElementById("privacy.trackingprotection.pbmode.enabled"); let pbmPref = Preferences.get("privacy.trackingprotection.pbmode.enabled");
let radiogroup = document.getElementById("trackingProtectionRadioGroup"); let radiogroup = document.getElementById("trackingProtectionRadioGroup");
switch (radiogroup.value) { switch (radiogroup.value) {
@@ -411,7 +492,7 @@ var gPrivacyPane = {
*/ */
_checkHistoryValues(aPrefs) { _checkHistoryValues(aPrefs) {
for (let pref of Object.keys(aPrefs)) { for (let pref of Object.keys(aPrefs)) {
if (document.getElementById(pref).value != aPrefs[pref]) if (Preferences.get(pref).value != aPrefs[pref])
return false; return false;
} }
return true; return true;
@@ -422,7 +503,7 @@ var gPrivacyPane = {
*/ */
initializeHistoryMode() { initializeHistoryMode() {
let mode; let mode;
let getVal = aPref => document.getElementById(aPref).value; let getVal = aPref => Preferences.get(aPref).value;
if (getVal("privacy.history.custom")) if (getVal("privacy.history.custom"))
mode = "custom"; mode = "custom";
@@ -454,7 +535,7 @@ var gPrivacyPane = {
break; break;
} }
document.getElementById("historyPane").selectedIndex = selectedIndex; document.getElementById("historyPane").selectedIndex = selectedIndex;
document.getElementById("privacy.history.custom").value = selectedIndex == 2; Preferences.get("privacy.history.custom").value = selectedIndex == 2;
}, },
/** /**
@@ -462,25 +543,25 @@ var gPrivacyPane = {
* micro-management prefs based on the history mode menulist * micro-management prefs based on the history mode menulist
*/ */
updateHistoryModePrefs() { updateHistoryModePrefs() {
let pref = document.getElementById("browser.privatebrowsing.autostart"); let pref = Preferences.get("browser.privatebrowsing.autostart");
switch (document.getElementById("historyMode").value) { switch (document.getElementById("historyMode").value) {
case "remember": case "remember":
if (pref.value) if (pref.value)
pref.value = false; pref.value = false;
// select the remember history option if needed // select the remember history option if needed
document.getElementById("places.history.enabled").value = true; Preferences.get("places.history.enabled").value = true;
// select the remember forms history option // select the remember forms history option
document.getElementById("browser.formfill.enable").value = true; Preferences.get("browser.formfill.enable").value = true;
// select the allow cookies option // select the allow cookies option
document.getElementById("network.cookie.cookieBehavior").value = 0; Preferences.get("network.cookie.cookieBehavior").value = 0;
// select the cookie lifetime policy option // select the cookie lifetime policy option
document.getElementById("network.cookie.lifetimePolicy").value = 0; Preferences.get("network.cookie.lifetimePolicy").value = 0;
// select the clear on close option // select the clear on close option
document.getElementById("privacy.sanitize.sanitizeOnShutdown").value = false; Preferences.get("privacy.sanitize.sanitizeOnShutdown").value = false;
break; break;
case "dontremember": case "dontremember":
if (!pref.value) if (!pref.value)
@@ -496,7 +577,7 @@ var gPrivacyPane = {
updatePrivacyMicroControls() { updatePrivacyMicroControls() {
if (document.getElementById("historyMode").value == "custom") { if (document.getElementById("historyMode").value == "custom") {
let disabled = this._autoStartPrivateBrowsing = let disabled = this._autoStartPrivateBrowsing =
document.getElementById("browser.privatebrowsing.autostart").value; Preferences.get("browser.privatebrowsing.autostart").value;
this.dependentControls.forEach(function(aElement) { this.dependentControls.forEach(function(aElement) {
let control = document.getElementById(aElement); let control = document.getElementById(aElement);
let preferenceId = control.getAttribute("preference"); let preferenceId = control.getAttribute("preference");
@@ -508,13 +589,13 @@ var gPrivacyPane = {
} }
} }
let preference = preferenceId ? document.getElementById(preferenceId) : {}; let preference = preferenceId ? Preferences.get(preferenceId) : {};
control.disabled = disabled || preference.locked; control.disabled = disabled || preference.locked;
}); });
// adjust the cookie controls status // adjust the cookie controls status
this.readAcceptCookies(); this.readAcceptCookies();
let lifetimePolicy = document.getElementById("network.cookie.lifetimePolicy").value; let lifetimePolicy = Preferences.get("network.cookie.lifetimePolicy").value;
if (lifetimePolicy != Ci.nsICookieService.ACCEPT_NORMALLY && if (lifetimePolicy != Ci.nsICookieService.ACCEPT_NORMALLY &&
lifetimePolicy != Ci.nsICookieService.ACCEPT_SESSION && lifetimePolicy != Ci.nsICookieService.ACCEPT_SESSION &&
lifetimePolicy != Ci.nsICookieService.ACCEPT_FOR_N_DAYS) { lifetimePolicy != Ci.nsICookieService.ACCEPT_FOR_N_DAYS) {
@@ -524,13 +605,13 @@ var gPrivacyPane = {
// adjust the checked state of the sanitizeOnShutdown checkbox // adjust the checked state of the sanitizeOnShutdown checkbox
document.getElementById("alwaysClear").checked = disabled ? false : document.getElementById("alwaysClear").checked = disabled ? false :
document.getElementById("privacy.sanitize.sanitizeOnShutdown").value; Preferences.get("privacy.sanitize.sanitizeOnShutdown").value;
// adjust the checked state of the remember history checkboxes // adjust the checked state of the remember history checkboxes
document.getElementById("rememberHistory").checked = disabled ? false : document.getElementById("rememberHistory").checked = disabled ? false :
document.getElementById("places.history.enabled").value; Preferences.get("places.history.enabled").value;
document.getElementById("rememberForms").checked = disabled ? false : document.getElementById("rememberForms").checked = disabled ? false :
document.getElementById("browser.formfill.enable").value; Preferences.get("browser.formfill.enable").value;
if (!disabled) { if (!disabled) {
// adjust the Settings button for sanitizeOnShutdown // adjust the Settings button for sanitizeOnShutdown
@@ -556,7 +637,7 @@ var gPrivacyPane = {
updateAutostart() { updateAutostart() {
let mode = document.getElementById("historyMode"); let mode = document.getElementById("historyMode");
let autoStart = document.getElementById("privateBrowsingAutoStart"); let autoStart = document.getElementById("privateBrowsingAutoStart");
let pref = document.getElementById("browser.privatebrowsing.autostart"); let pref = Preferences.get("browser.privatebrowsing.autostart");
if ((mode.value == "custom" && this._lastCheckState == autoStart.checked) || if ((mode.value == "custom" && this._lastCheckState == autoStart.checked) ||
(mode.value == "remember" && !this._lastCheckState) || (mode.value == "remember" && !this._lastCheckState) ||
(mode.value == "dontremember" && this._lastCheckState)) { (mode.value == "dontremember" && this._lastCheckState)) {
@@ -660,7 +741,7 @@ var gPrivacyPane = {
* if cookies are enabled. * if cookies are enabled.
*/ */
readAcceptCookies() { readAcceptCookies() {
var pref = document.getElementById("network.cookie.cookieBehavior"); var pref = Preferences.get("network.cookie.cookieBehavior");
var acceptThirdPartyLabel = document.getElementById("acceptThirdPartyLabel"); var acceptThirdPartyLabel = document.getElementById("acceptThirdPartyLabel");
var acceptThirdPartyMenu = document.getElementById("acceptThirdPartyMenu"); var acceptThirdPartyMenu = document.getElementById("acceptThirdPartyMenu");
var keepUntil = document.getElementById("keepUntil"); var keepUntil = document.getElementById("keepUntil");
@@ -694,7 +775,7 @@ var gPrivacyPane = {
* Converts between network.cookie.cookieBehavior and the third-party cookie UI * Converts between network.cookie.cookieBehavior and the third-party cookie UI
*/ */
readAcceptThirdPartyCookies() { readAcceptThirdPartyCookies() {
var pref = document.getElementById("network.cookie.cookieBehavior"); var pref = Preferences.get("network.cookie.cookieBehavior");
switch (pref.value) { switch (pref.value) {
case 0: case 0:
return "always"; return "always";
@@ -771,7 +852,7 @@ var gPrivacyPane = {
* cleared. * cleared.
*/ */
clearPrivateDataNow(aClearEverything) { clearPrivateDataNow(aClearEverything) {
var ts = document.getElementById("privacy.sanitize.timeSpan"); var ts = Preferences.get("privacy.sanitize.timeSpan");
var timeSpanOrig = ts.value; var timeSpanOrig = ts.value;
if (aClearEverything) { if (aClearEverything) {
@@ -794,7 +875,7 @@ var gPrivacyPane = {
*/ */
_updateSanitizeSettingsButton() { _updateSanitizeSettingsButton() {
var settingsButton = document.getElementById("clearDataSettings"); var settingsButton = document.getElementById("clearDataSettings");
var sanitizeOnShutdownPref = document.getElementById("privacy.sanitize.sanitizeOnShutdown"); var sanitizeOnShutdownPref = Preferences.get("privacy.sanitize.sanitizeOnShutdown");
settingsButton.disabled = !sanitizeOnShutdownPref.value; settingsButton.disabled = !sanitizeOnShutdownPref.value;
}, },
@@ -900,7 +981,7 @@ var gPrivacyPane = {
*/ */
updateButtons(aButtonID, aPreferenceID) { updateButtons(aButtonID, aPreferenceID) {
var button = document.getElementById(aButtonID); var button = document.getElementById(aButtonID);
var preference = document.getElementById(aPreferenceID); var preference = Preferences.get(aPreferenceID);
button.disabled = preference.value != true; button.disabled = preference.value != true;
return undefined; return undefined;
}, },
@@ -1018,7 +1099,7 @@ var gPrivacyPane = {
* Browsing mode, the "Remember passwords" UI is useless, so we disable it. * Browsing mode, the "Remember passwords" UI is useless, so we disable it.
*/ */
readSavePasswords() { readSavePasswords() {
var pref = document.getElementById("signon.rememberSignons"); var pref = Preferences.get("signon.rememberSignons");
var excepts = document.getElementById("passwordExceptions"); var excepts = document.getElementById("passwordExceptions");
if (PrivateBrowsingUtils.permanentPrivateBrowsing) { if (PrivateBrowsingUtils.permanentPrivateBrowsing) {
@@ -1036,7 +1117,7 @@ var gPrivacyPane = {
* or not add-on installation warnings are displayed. * or not add-on installation warnings are displayed.
*/ */
readWarnAddonInstall() { readWarnAddonInstall() {
var warn = document.getElementById("xpinstall.whitelist.required"); var warn = Preferences.get("xpinstall.whitelist.required");
var exceptions = document.getElementById("addonExceptions"); var exceptions = document.getElementById("addonExceptions");
exceptions.disabled = !warn.value; exceptions.disabled = !warn.value;
@@ -1050,14 +1131,14 @@ var gPrivacyPane = {
let blockDownloads = document.getElementById("blockDownloads"); let blockDownloads = document.getElementById("blockDownloads");
let blockUncommonUnwanted = document.getElementById("blockUncommonUnwanted"); let blockUncommonUnwanted = document.getElementById("blockUncommonUnwanted");
let safeBrowsingPhishingPref = document.getElementById("browser.safebrowsing.phishing.enabled"); let safeBrowsingPhishingPref = Preferences.get("browser.safebrowsing.phishing.enabled");
let safeBrowsingMalwarePref = document.getElementById("browser.safebrowsing.malware.enabled"); let safeBrowsingMalwarePref = Preferences.get("browser.safebrowsing.malware.enabled");
let blockDownloadsPref = document.getElementById("browser.safebrowsing.downloads.enabled"); let blockDownloadsPref = Preferences.get("browser.safebrowsing.downloads.enabled");
let malwareTable = document.getElementById("urlclassifier.malwareTable"); let malwareTable = Preferences.get("urlclassifier.malwareTable");
let blockUnwantedPref = document.getElementById("browser.safebrowsing.downloads.remote.block_potentially_unwanted"); let blockUnwantedPref = Preferences.get("browser.safebrowsing.downloads.remote.block_potentially_unwanted");
let blockUncommonPref = document.getElementById("browser.safebrowsing.downloads.remote.block_uncommon"); let blockUncommonPref = Preferences.get("browser.safebrowsing.downloads.remote.block_uncommon");
let learnMoreLink = document.getElementById("enableSafeBrowsingLearnMore"); let learnMoreLink = document.getElementById("enableSafeBrowsingLearnMore");
let phishingUrl = Services.urlFormatter.formatURLPref("app.support.baseURL") + "phishing-malware"; let phishingUrl = Services.urlFormatter.formatURLPref("app.support.baseURL") + "phishing-malware";
@@ -1191,7 +1272,7 @@ var gPrivacyPane = {
* checked. Otherwise, it should be unchecked. * checked. Otherwise, it should be unchecked.
*/ */
readEnableOCSP() { readEnableOCSP() {
var preference = document.getElementById("security.OCSP.enabled"); var preference = Preferences.get("security.OCSP.enabled");
// This is the case if the preference is the default value. // This is the case if the preference is the default value.
if (preference.value === undefined) { if (preference.value === undefined) {
return true; return true;
@@ -1304,7 +1385,7 @@ var gPrivacyPane = {
readSmartSizeEnabled() { readSmartSizeEnabled() {
// The smart_size.enabled preference element is inverted="true", so its // The smart_size.enabled preference element is inverted="true", so its
// value is the opposite of the actual pref value // value is the opposite of the actual pref value
var disabled = document.getElementById("browser.cache.disk.smart_size.enabled").value; var disabled = Preferences.get("browser.cache.disk.smart_size.enabled").value;
this.updateCacheSizeUI(!disabled); this.updateCacheSizeUI(!disabled);
}, },
@@ -1320,7 +1401,7 @@ var gPrivacyPane = {
*/ */
updateCacheSizeInputField() { updateCacheSizeInputField() {
let cacheSizeElem = document.getElementById("cacheSize"); let cacheSizeElem = document.getElementById("cacheSize");
let cachePref = document.getElementById("browser.cache.disk.capacity"); let cachePref = Preferences.get("browser.cache.disk.capacity");
cacheSizeElem.value = cachePref.value / 1024; cacheSizeElem.value = cachePref.value / 1024;
if (cachePref.locked) if (cachePref.locked)
cacheSizeElem.disabled = true; cacheSizeElem.disabled = true;
@@ -1334,7 +1415,7 @@ var gPrivacyPane = {
*/ */
updateCacheSizePref() { updateCacheSizePref() {
let cacheSizeElem = document.getElementById("cacheSize"); let cacheSizeElem = document.getElementById("cacheSize");
let cachePref = document.getElementById("browser.cache.disk.capacity"); let cachePref = Preferences.get("browser.cache.disk.capacity");
// Converts the cache size as specified in UI (in MB) to KB. // Converts the cache size as specified in UI (in MB) to KB.
let intValue = parseInt(cacheSizeElem.value, 10); let intValue = parseInt(cacheSizeElem.value, 10);
cachePref.value = isNaN(intValue) ? 0 : intValue * 1024; cachePref.value = isNaN(intValue) ? 0 : intValue * 1024;

View File

@@ -6,165 +6,6 @@
<script type="application/javascript" <script type="application/javascript"
src="chrome://browser/content/preferences/in-content/privacy.js"/> src="chrome://browser/content/preferences/in-content/privacy.js"/>
<preferences id="privacyPreferences" hidden="true" data-category="panePrivacy">
<!-- Tracking -->
<preference id="privacy.trackingprotection.enabled"
name="privacy.trackingprotection.enabled"
type="bool"/>
<preference id="privacy.trackingprotection.pbmode.enabled"
name="privacy.trackingprotection.pbmode.enabled"
type="bool"/>
<!-- XXX button prefs -->
<preference id="pref.privacy.disable_button.cookie_exceptions"
name="pref.privacy.disable_button.cookie_exceptions"
type="bool"/>
<preference id="pref.privacy.disable_button.view_cookies"
name="pref.privacy.disable_button.view_cookies"
type="bool"/>
<preference id="pref.privacy.disable_button.change_blocklist"
name="pref.privacy.disable_button.change_blocklist"
type="bool"/>
<preference id="pref.privacy.disable_button.tracking_protection_exceptions"
name="pref.privacy.disable_button.tracking_protection_exceptions"
type="bool"/>
<!-- Location Bar -->
<preference id="browser.urlbar.autocomplete.enabled"
name="browser.urlbar.autocomplete.enabled"
type="bool"/>
<preference id="browser.urlbar.suggest.bookmark"
name="browser.urlbar.suggest.bookmark"
type="bool"/>
<preference id="browser.urlbar.suggest.history"
name="browser.urlbar.suggest.history"
type="bool"/>
<preference id="browser.urlbar.suggest.openpage"
name="browser.urlbar.suggest.openpage"
type="bool"/>
<!-- History -->
<preference id="places.history.enabled"
name="places.history.enabled"
type="bool"/>
<preference id="browser.formfill.enable"
name="browser.formfill.enable"
type="bool"/>
<preference id="privacy.history.custom"
name="privacy.history.custom"
type="bool"/>
<!-- Cookies -->
<preference id="network.cookie.cookieBehavior"
name="network.cookie.cookieBehavior"
type="int"/>
<preference id="network.cookie.lifetimePolicy"
name="network.cookie.lifetimePolicy"
type="int"/>
<preference id="network.cookie.blockFutureCookies"
name="network.cookie.blockFutureCookies"
type="bool"/>
<!-- Clear Private Data -->
<preference id="privacy.sanitize.sanitizeOnShutdown"
name="privacy.sanitize.sanitizeOnShutdown"
type="bool"/>
<preference id="privacy.sanitize.timeSpan"
name="privacy.sanitize.timeSpan"
type="int"/>
<!-- Private Browsing -->
<preference id="browser.privatebrowsing.autostart"
name="browser.privatebrowsing.autostart"
type="bool"/>
<!-- Do not track -->
<preference id="privacy.donottrackheader.enabled"
name="privacy.donottrackheader.enabled"
type="bool"/>
<!-- Popups -->
<preference id="dom.disable_open_during_load"
name="dom.disable_open_during_load"
type="bool"/>
<!-- Passwords -->
<preference id="signon.rememberSignons" name="signon.rememberSignons" type="bool"/>
<!-- XXX buttons -->
<preference id="pref.privacy.disable_button.view_passwords"
name="pref.privacy.disable_button.view_passwords"
type="bool"/>
<preference id="pref.privacy.disable_button.view_passwords_exceptions"
name="pref.privacy.disable_button.view_passwords_exceptions"
type="bool"/>
<!-- Certificates tab
* security.default_personal_cert
- a string:
"Select Automatically" select a certificate automatically when a site
requests one
"Ask Every Time" present a dialog to the user so he can select
the certificate to use on a site which
requests one -->
<preference id="security.default_personal_cert"
name="security.default_personal_cert"
type="string"/>
<preference id="security.disable_button.openCertManager"
name="security.disable_button.openCertManager"
type="bool"/>
<preference id="security.disable_button.openDeviceManager"
name="security.disable_button.openDeviceManager"
type="bool"/>
<preference id="security.OCSP.enabled"
name="security.OCSP.enabled"
type="int"/>
<!-- Add-ons, malware, phishing -->
<preference id="xpinstall.whitelist.required"
name="xpinstall.whitelist.required"
type="bool"/>
<preference id="browser.safebrowsing.malware.enabled"
name="browser.safebrowsing.malware.enabled"
type="bool"/>
<preference id="browser.safebrowsing.phishing.enabled"
name="browser.safebrowsing.phishing.enabled"
type="bool"/>
<preference id="browser.safebrowsing.downloads.enabled"
name="browser.safebrowsing.downloads.enabled"
type="bool"/>
<preference id="urlclassifier.malwareTable"
name="urlclassifier.malwareTable"
type="string"/>
<preference id="browser.safebrowsing.downloads.remote.block_potentially_unwanted"
name="browser.safebrowsing.downloads.remote.block_potentially_unwanted"
type="bool"/>
<preference id="browser.safebrowsing.downloads.remote.block_uncommon"
name="browser.safebrowsing.downloads.remote.block_uncommon"
type="bool"/>
<!-- Network tab -->
<preference id="browser.cache.disk.capacity"
name="browser.cache.disk.capacity"
type="int"/>
<preference id="browser.cache.disk.smart_size.enabled"
name="browser.cache.disk.smart_size.enabled"
inverted="true"
type="bool"/>
<!-- Data Choices tab -->
#ifdef MOZ_CRASHREPORTER
<preference id="browser.crashReports.unsubmittedCheck.autoSubmit2"
name="browser.crashReports.unsubmittedCheck.autoSubmit2"
type="bool"/>
#endif
</preferences>
<stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences/preferences.properties"/> <stringbundle id="bundlePreferences" src="chrome://browser/locale/preferences/preferences.properties"/>
<stringbundle id="signonBundle" src="chrome://passwordmgr/locale/passwordmgr.properties"/> <stringbundle id="signonBundle" src="chrome://passwordmgr/locale/passwordmgr.properties"/>

View File

@@ -10,6 +10,13 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionSettingsStore", XPCOMUtils.defineLazyModuleGetter(this, "ExtensionSettingsStore",
"resource://gre/modules/ExtensionSettingsStore.jsm"); "resource://gre/modules/ExtensionSettingsStore.jsm");
Preferences.addAll([
{ id: "browser.search.suggest.enabled", type: "bool" },
{ id: "browser.urlbar.suggest.searches", type: "bool" },
{ id: "browser.search.hiddenOneOffs", type: "unichar" },
{ id: "browser.search.widget.inNavBar", type: "bool" },
]);
const ENGINE_FLAVOR = "text/x-moz-search-engine"; const ENGINE_FLAVOR = "text/x-moz-search-engine";
const SEARCH_TYPE = "default_search"; const SEARCH_TYPE = "default_search";
const SEARCH_KEY = "defaultSearch"; const SEARCH_KEY = "defaultSearch";
@@ -50,24 +57,19 @@ var gSearchPane = {
this._initAutocomplete(); this._initAutocomplete();
let suggestsPref = let suggestsPref = Preferences.get("browser.search.suggest.enabled");
document.getElementById("browser.search.suggest.enabled"); suggestsPref.on("change", this.updateSuggestsCheckbox.bind(this));
suggestsPref.addEventListener("change", () => {
this.updateSuggestsCheckbox();
});
this.updateSuggestsCheckbox(); this.updateSuggestsCheckbox();
}, },
updateSuggestsCheckbox() { updateSuggestsCheckbox() {
let suggestsPref = let suggestsPref = Preferences.get("browser.search.suggest.enabled");
document.getElementById("browser.search.suggest.enabled");
let permanentPB = let permanentPB =
Services.prefs.getBoolPref("browser.privatebrowsing.autostart"); Services.prefs.getBoolPref("browser.privatebrowsing.autostart");
let urlbarSuggests = document.getElementById("urlBarSuggestion"); let urlbarSuggests = document.getElementById("urlBarSuggestion");
urlbarSuggests.disabled = !suggestsPref.value || permanentPB; urlbarSuggests.disabled = !suggestsPref.value || permanentPB;
let urlbarSuggestsPref = let urlbarSuggestsPref = Preferences.get("browser.urlbar.suggest.searches");
document.getElementById("browser.urlbar.suggest.searches");
urlbarSuggests.checked = urlbarSuggestsPref.value; urlbarSuggests.checked = urlbarSuggestsPref.value;
if (urlbarSuggests.disabled) { if (urlbarSuggests.disabled) {
urlbarSuggests.checked = false; urlbarSuggests.checked = false;
@@ -315,7 +317,7 @@ var gSearchPane = {
if (!engine.shown) if (!engine.shown)
hiddenList.push(engine.name); hiddenList.push(engine.name);
} }
document.getElementById("browser.search.hiddenOneOffs").value = Preferences.get("browser.search.hiddenOneOffs").value =
hiddenList.join(","); hiddenList.join(",");
}, },
@@ -339,7 +341,7 @@ function onDragEngineStart(event) {
function EngineStore() { function EngineStore() {
let pref = document.getElementById("browser.search.hiddenOneOffs").value; let pref = Preferences.get("browser.search.hiddenOneOffs").value;
this.hiddenList = pref ? pref.split(",") : []; this.hiddenList = pref ? pref.split(",") : [];
this._engines = Services.search.getVisibleEngines().map(this._cloneEngine, this); this._engines = Services.search.getVisibleEngines().map(this._cloneEngine, this);

View File

@@ -1,23 +1,3 @@
<preferences id="searchPreferences" hidden="true" data-category="paneSearch">
<preference id="browser.search.suggest.enabled"
name="browser.search.suggest.enabled"
type="bool"/>
<preference id="browser.urlbar.suggest.searches"
name="browser.urlbar.suggest.searches"
type="bool"/>
<preference id="browser.search.hiddenOneOffs"
name="browser.search.hiddenOneOffs"
type="unichar"/>
<preference id="browser.search.widget.inNavBar"
name="browser.search.widget.inNavBar"
type="bool"/>
</preferences>
<script type="application/javascript" <script type="application/javascript"
src="chrome://browser/content/preferences/in-content/search.js"/> src="chrome://browser/content/preferences/in-content/search.js"/>

View File

@@ -28,6 +28,17 @@ const FXA_LOGIN_UNVERIFIED = 1;
// We are logged in locally, but the server rejected our credentials. // We are logged in locally, but the server rejected our credentials.
const FXA_LOGIN_FAILED = 2; const FXA_LOGIN_FAILED = 2;
Preferences.addAll([
{ id: "engine.addons", name: "services.sync.engine.addons", type: "bool" },
{ id: "engine.bookmarks", name: "services.sync.engine.bookmarks", type: "bool" },
{ id: "engine.history", name: "services.sync.engine.history", type: "bool" },
{ id: "engine.tabs", name: "services.sync.engine.tabs", type: "bool" },
{ id: "engine.prefs", name: "services.sync.engine.prefs", type: "bool" },
{ id: "engine.passwords", name: "services.sync.engine.passwords", type: "bool" },
{ id: "engine.addresses", name: "services.sync.engine.addresses", type: "bool" },
{ id: "engine.creditcards", name: "services.sync.engine.creditcards", type: "bool" },
]);
var gSyncPane = { var gSyncPane = {
get page() { get page() {
return document.getElementById("weavePrefsDeck").selectedIndex; return document.getElementById("weavePrefsDeck").selectedIndex;

View File

@@ -4,33 +4,6 @@
<!-- Sync panel --> <!-- Sync panel -->
<preferences id="syncEnginePrefs" hidden="true" data-category="paneSync">
<preference id="engine.addons"
name="services.sync.engine.addons"
type="bool"/>
<preference id="engine.bookmarks"
name="services.sync.engine.bookmarks"
type="bool"/>
<preference id="engine.history"
name="services.sync.engine.history"
type="bool"/>
<preference id="engine.tabs"
name="services.sync.engine.tabs"
type="bool"/>
<preference id="engine.prefs"
name="services.sync.engine.prefs"
type="bool"/>
<preference id="engine.passwords"
name="services.sync.engine.passwords"
type="bool"/>
<preference id="engine.addresses"
name="services.sync.engine.addresses"
type="bool"/>
<preference id="engine.creditcards"
name="services.sync.engine.creditcards"
type="bool"/>
</preferences>
<script type="application/javascript" <script type="application/javascript"
src="chrome://browser/content/preferences/in-content/sync.js"/> src="chrome://browser/content/preferences/in-content/sync.js"/>

View File

@@ -10,8 +10,10 @@ add_task(async function() {
await gBrowser.contentWindow.gMainPane._selectDefaultLanguageGroupPromise; await gBrowser.contentWindow.gMainPane._selectDefaultLanguageGroupPromise;
// eslint-disable-next-line mozilla/no-cpows-in-tests // eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = gBrowser.contentDocument; let doc = gBrowser.contentDocument;
// eslint-disable-next-line mozilla/no-cpows-in-tests
let contentWindow = gBrowser.contentWindow;
var langGroup = Services.prefs.getComplexValue("font.language.group", Ci.nsIPrefLocalizedString).data; var langGroup = Services.prefs.getComplexValue("font.language.group", Ci.nsIPrefLocalizedString).data;
is(doc.getElementById("font.language.group").value, langGroup, is(contentWindow.Preferences.get("font.language.group").value, langGroup,
"Language group should be set correctly."); "Language group should be set correctly.");
let defaultFontType = Services.prefs.getCharPref("font.default." + langGroup); let defaultFontType = Services.prefs.getCharPref("font.default." + langGroup);
@@ -44,7 +46,7 @@ add_task(async function() {
win.FontBuilder._allFonts = null; win.FontBuilder._allFonts = null;
win.FontBuilder._langGroupSupported = false; win.FontBuilder._langGroupSupported = false;
let langGroupElement = doc.getElementById("font.language.group"); let langGroupElement = win.Preferences.get("font.language.group");
let selectLangsField = doc.getElementById("selectLangs"); let selectLangsField = doc.getElementById("selectLangs");
let serifField = doc.getElementById("serif"); let serifField = doc.getElementById("serif");
let armenian = "x-armn"; let armenian = "x-armn";
@@ -63,7 +65,7 @@ add_task(async function() {
selectLangsField.value = armenian; selectLangsField.value = armenian;
is(serifField.value, "", "Font family should not be set."); is(serifField.value, "", "Font family should not be set.");
let armenianSerifElement = doc.getElementById("font.name.serif.x-armn"); let armenianSerifElement = win.Preferences.get("font.name.serif.x-armn");
langGroupElement.value = western; langGroupElement.value = western;
await fontListsRebuilt(); await fontListsRebuilt();

View File

@@ -16,10 +16,9 @@ var gElements;
function checkElements(expectedPane) { function checkElements(expectedPane) {
for (let element of gElements) { for (let element of gElements) {
// keyset and preferences elements fail is_element_visible checks because they are never visible. // keyset elements fail is_element_visible checks because they are never visible.
// special-case the drmGroup item because its visibility depends on pref + OS version // special-case the drmGroup item because its visibility depends on pref + OS version
if (element.nodeName == "keyset" || if (element.nodeName == "keyset" ||
element.nodeName == "preferences" ||
element.id === "drmGroup") { element.id === "drmGroup") {
continue; continue;
} }

View File

@@ -34,9 +34,6 @@ function runTest(win) {
// Test if privacy pane is opened correctly // Test if privacy pane is opened correctly
win.gotoPref("panePrivacy"); win.gotoPref("panePrivacy");
for (let element of elements) { for (let element of elements) {
if (element.nodeName == "preferences") {
continue;
}
let attributeValue = element.getAttribute("data-category"); let attributeValue = element.getAttribute("data-category");
if (attributeValue == "panePrivacy") { if (attributeValue == "panePrivacy") {
is_element_visible(element, `Privacy element of id=${element.id} should be visible`); is_element_visible(element, `Privacy element of id=${element.id} should be visible`);

View File

@@ -48,8 +48,8 @@ function test() {
function runConnectionTests(win) { function runConnectionTests(win) {
let doc = win.document; let doc = win.document;
let networkProxyNone = doc.getElementById("networkProxyNone"); let networkProxyNone = doc.getElementById("networkProxyNone");
let networkProxyNonePref = doc.getElementById("network.proxy.no_proxies_on"); let networkProxyNonePref = win.Preferences.get("network.proxy.no_proxies_on");
let networkProxyTypePref = doc.getElementById("network.proxy.type"); let networkProxyTypePref = win.Preferences.get("network.proxy.type");
// make sure the networkProxyNone textbox is formatted properly // make sure the networkProxyNone textbox is formatted properly
is(networkProxyNone.getAttribute("multiline"), "true", is(networkProxyNone.getAttribute("multiline"), "true",

View File

@@ -53,12 +53,12 @@ function test() {
dialogClosingPromise = waitForEvent(dialog.document.documentElement, "dialogclosing"); dialogClosingPromise = waitForEvent(dialog.document.documentElement, "dialogclosing");
doc = dialog.document; doc = dialog.document;
proxyTypePref = doc.getElementById("network.proxy.type"); proxyTypePref = dialog.Preferences.get("network.proxy.type");
sharePref = doc.getElementById("network.proxy.share_proxy_settings"); sharePref = dialog.Preferences.get("network.proxy.share_proxy_settings");
httpPref = doc.getElementById("network.proxy.http"); httpPref = dialog.Preferences.get("network.proxy.http");
httpPortPref = doc.getElementById("network.proxy.http_port"); httpPortPref = dialog.Preferences.get("network.proxy.http_port");
ftpPref = doc.getElementById("network.proxy.ftp"); ftpPref = dialog.Preferences.get("network.proxy.ftp");
ftpPortPref = doc.getElementById("network.proxy.ftp_port"); ftpPortPref = dialog.Preferences.get("network.proxy.ftp_port");
} }
// This batch of tests should not close the dialog // This batch of tests should not close the dialog

View File

@@ -25,9 +25,10 @@ add_task(async function() {
]); ]);
let doc = gBrowser.contentDocument; let doc = gBrowser.contentDocument;
let win = gBrowser.contentWindow;
await doc.l10n.ready; await doc.l10n.ready;
let processCountPref = doc.getElementById("dom.ipc.processCount"); let processCountPref = win.Preferences.get("dom.ipc.processCount");
let defaultProcessCount = processCountPref.defaultValue; let defaultProcessCount = processCountPref.defaultValue;
let [ msg ] = await doc.l10n.formatMessages([ let [ msg ] = await doc.l10n.formatMessages([

View File

@@ -14,7 +14,7 @@ function testPrefStateMatchesLockedState() {
switchToCustomHistoryMode(doc); switchToCustomHistoryMode(doc);
let checkbox = doc.getElementById("alwaysClear"); let checkbox = doc.getElementById("alwaysClear");
let preference = doc.getElementById("privacy.sanitize.sanitizeOnShutdown"); let preference = win.Preferences.get("privacy.sanitize.sanitizeOnShutdown");
is(checkbox.disabled, preference.locked, "Always Clear checkbox should be enabled when preference is not locked."); is(checkbox.disabled, preference.locked, "Always Clear checkbox should be enabled when preference is not locked.");
Services.prefs.clearUserPref("privacy.history.custom"); Services.prefs.clearUserPref("privacy.history.custom");

View File

@@ -220,7 +220,7 @@ function test_dependent_prefs(win) {
function expect_checked(checked) { function expect_checked(checked) {
controls.forEach(function(control) { controls.forEach(function(control) {
is(control.checked, checked, is(control.checked, checked,
control.getAttribute("id") + " should " + (checked ? "not " : "") + "be checked"); control.getAttribute("id") + " should " + (checked ? "" : "not ") + "be checked");
}); });
is(thirdPartyCookieMenu.value == "always" || thirdPartyCookieMenu.value == "visited", checked, "third-party cookies should " + (checked ? "not " : "") + "be limited"); is(thirdPartyCookieMenu.value == "always" || thirdPartyCookieMenu.value == "visited", checked, "third-party cookies should " + (checked ? "not " : "") + "be limited");
@@ -311,13 +311,13 @@ function test_locbar_suggestion_retention(suggestion, autocomplete) {
const gPrefCache = new Map(); const gPrefCache = new Map();
function cache_preferences(win) { function cache_preferences(win) {
let prefs = win.document.querySelectorAll("#privacyPreferences > preference"); let prefs = win.Preferences.getAll();
for (let pref of prefs) for (let pref of prefs)
gPrefCache.set(pref.name, pref.value); gPrefCache.set(pref.name, pref.value);
} }
function reset_preferences(win) { function reset_preferences(win) {
let prefs = win.document.querySelectorAll("#privacyPreferences > preference"); let prefs = win.Preferences.getAll();
for (let pref of prefs) for (let pref of prefs)
pref.value = gPrefCache.get(pref.name); pref.value = gPrefCache.get(pref.name);
} }

View File

@@ -8,15 +8,16 @@ browser.jar:
content/browser/preferences/blocklists.xul content/browser/preferences/blocklists.xul
content/browser/preferences/blocklists.js content/browser/preferences/blocklists.js
* content/browser/preferences/colors.xul * content/browser/preferences/colors.xul
content/browser/preferences/colors.js
* content/browser/preferences/cookies.xul * content/browser/preferences/cookies.xul
content/browser/preferences/cookies.js content/browser/preferences/cookies.js
* content/browser/preferences/connection.xul * content/browser/preferences/connection.xul
content/browser/preferences/connection.js content/browser/preferences/connection.js
* content/browser/preferences/fonts.xul content/browser/preferences/fonts.xul
content/browser/preferences/fonts.js content/browser/preferences/fonts.js
content/browser/preferences/handlers.xml content/browser/preferences/handlers.xml
content/browser/preferences/handlers.css content/browser/preferences/handlers.css
* content/browser/preferences/languages.xul content/browser/preferences/languages.xul
content/browser/preferences/languages.js content/browser/preferences/languages.js
content/browser/preferences/permissions.xul content/browser/preferences/permissions.xul
content/browser/preferences/sitePermissions.xul content/browser/preferences/sitePermissions.xul

View File

@@ -3,8 +3,18 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from ../../../toolkit/content/preferencesBindings.js */
Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/Services.jsm");
Preferences.addAll([
{ id: "intl.accept_languages", type: "wstring" },
{ id: "pref.browser.language.disable_button.up", type: "bool" },
{ id: "pref.browser.language.disable_button.down", type: "bool" },
{ id: "pref.browser.language.disable_button.remove", type: "bool" },
{ id: "privacy.spoof_english", type: "int" },
]);
var gLanguagesDialog = { var gLanguagesDialog = {
_availableLanguagesList: [], _availableLanguagesList: [],
@@ -126,7 +136,7 @@ var gLanguagesDialog = {
this._activeLanguages.firstChild.remove(); this._activeLanguages.firstChild.remove();
var selectedIndex = 0; var selectedIndex = 0;
var preference = document.getElementById("intl.accept_languages"); var preference = Preferences.get("intl.accept_languages");
if (preference.value == "") if (preference.value == "")
return undefined; return undefined;
var languages = preference.value.toLowerCase().split(/\s*,\s*/); var languages = preference.value.toLowerCase().split(/\s*,\s*/);
@@ -173,7 +183,7 @@ var gLanguagesDialog = {
addLanguage() { addLanguage() {
var selectedID = this._availableLanguages.selectedItem.id; var selectedID = this._availableLanguages.selectedItem.id;
var preference = document.getElementById("intl.accept_languages"); var preference = Preferences.get("intl.accept_languages");
var arrayOfPrefs = preference.value.toLowerCase().split(/\s*,\s*/); var arrayOfPrefs = preference.value.toLowerCase().split(/\s*,\s*/);
for (var i = 0; i < arrayOfPrefs.length; ++i ) { for (var i = 0; i < arrayOfPrefs.length; ++i ) {
if (arrayOfPrefs[i] == selectedID) if (arrayOfPrefs[i] == selectedID)
@@ -219,7 +229,7 @@ var gLanguagesDialog = {
this._selectedItemID = selectItem; this._selectedItemID = selectItem;
// Update the preference and force a UI rebuild // Update the preference and force a UI rebuild
var preference = document.getElementById("intl.accept_languages"); var preference = Preferences.get("intl.accept_languages");
preference.value = string; preference.value = string;
this._buildAvailableLanguageList(); this._buildAvailableLanguageList();
@@ -254,7 +264,7 @@ var gLanguagesDialog = {
this._selectedItemID = selectedItem.id; this._selectedItemID = selectedItem.id;
// Update the preference and force a UI rebuild // Update the preference and force a UI rebuild
var preference = document.getElementById("intl.accept_languages"); var preference = Preferences.get("intl.accept_languages");
preference.value = string; preference.value = string;
}, },
@@ -277,7 +287,7 @@ var gLanguagesDialog = {
this._selectedItemID = selectedItem.id; this._selectedItemID = selectedItem.id;
// Update the preference and force a UI rebuild // Update the preference and force a UI rebuild
var preference = document.getElementById("intl.accept_languages"); var preference = Preferences.get("intl.accept_languages");
preference.value = string; preference.value = string;
}, },
@@ -335,4 +345,3 @@ var gLanguagesDialog = {
return document.getElementById("spoofEnglish").checked ? 2 : 1; return document.getElementById("spoofEnglish").checked ? 2 : 1;
} }
}; };

View File

@@ -1,51 +1,47 @@
<?xml version="1.0"?> <?xml version="1.0"?>
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- <!-- -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -->
# This Source Code Form is subject to the terms of the Mozilla Public <!-- This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE prefwindow SYSTEM "chrome://browser/locale/preferences/languages.dtd"> <!DOCTYPE dialog [
<!ENTITY % preferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
%preferencesDTD;
<!ENTITY % languagesDTD SYSTEM "chrome://browser/locale/preferences/languages.dtd">
%languagesDTD;
]>
<?xml-stylesheet href="chrome://global/skin/"?> <?xml-stylesheet href="chrome://global/skin/"?>
#ifdef XP_MACOSX
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?> <?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
#endif
<prefwindow id="LanguagesDialog" type="child" <dialog id="LanguagesDialog" type="child" class="prefwindow"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&languages.customize.Header;" title="&languages.customize.Header;"
dlgbuttons="accept,cancel,help" buttons="accept,cancel,help"
ondialoghelp="openPrefsHelp()" persist="lastSelected screenX screenY"
style="width: &window.width;" closebuttonlabel="&preferencesCloseButton.label;"
# hack around XUL bug 1194844 by triggering extra reflow (see bug 1194346): closebuttonaccesskey="&preferencesCloseButton.accesskey;"
onfocus="gLanguagesDialog.forceReflow()" role="dialog"
onresize="gLanguagesDialog.forceReflow()"> onload="gLanguagesDialog.init();"
helpTopic="prefs-languages"
ondialoghelp="openPrefsHelp()"
style="width: &window.width;"
onfocus="gLanguagesDialog.forceReflow()"
onresize="gLanguagesDialog.forceReflow()">
<!-- The onfocus and onresize handlers above hack around XUL bug 1194844
- by triggering extra reflow (see bug 1194346). -->
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/> <script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript" src="chrome://browser/content/preferences/languages.js"/>
<prefpane id="LanguagesDialogPane" <keyset>
class="largeDialogContainer" <key key="&windowClose.key;" modifiers="accel" oncommand="Preferences.close(event)"/>
onpaneload="gLanguagesDialog.init();" </keyset>
helpTopic="prefs-languages">
<preferences> <vbox id="LanguagesDialogPane" class="prefpane largeDialogContainer">
<preference id="intl.accept_languages" name="intl.accept_languages" type="wstring"/>
<preference id="pref.browser.language.disable_button.up"
name="pref.browser.language.disable_button.up"
type="bool"/>
<preference id="pref.browser.language.disable_button.down"
name="pref.browser.language.disable_button.down"
type="bool"/>
<preference id="pref.browser.language.disable_button.remove"
name="pref.browser.language.disable_button.remove"
type="bool"/>
<preference id="privacy.spoof_english"
name="privacy.spoof_english"
type="int"/>
</preferences>
<script type="application/javascript" src="chrome://browser/content/preferences/languages.js"/>
<stringbundleset id="languageSet"> <stringbundleset id="languageSet">
<stringbundle id="bundleRegions" src="chrome://global/locale/regionNames.properties"/> <stringbundle id="bundleRegions" src="chrome://global/locale/regionNames.properties"/>
@@ -107,6 +103,5 @@
</grid> </grid>
<separator/> <separator/>
<separator/> <separator/>
</prefpane> </vbox>
</prefwindow> </dialog>

View File

@@ -3,14 +3,29 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from ../../../toolkit/content/preferencesBindings.js */
Preferences.addAll([
{ id: "privacy.clearOnShutdown.history", type: "bool" },
{ id: "privacy.clearOnShutdown.formdata", type: "bool" },
{ id: "privacy.clearOnShutdown.downloads", type: "bool" },
{ id: "privacy.clearOnShutdown.cookies", type: "bool" },
{ id: "privacy.clearOnShutdown.cache", type: "bool" },
{ id: "privacy.clearOnShutdown.offlineApps", type: "bool" },
{ id: "privacy.clearOnShutdown.sessions", type: "bool" },
{ id: "privacy.clearOnShutdown.siteSettings", type: "bool" },
]);
var gSanitizeDialog = Object.freeze({ var gSanitizeDialog = Object.freeze({
init() { init() {
this.onClearHistoryChanged(); this.onClearHistoryChanged();
Preferences.get("privacy.clearOnShutdown.history").on("change", this.onClearHistoryChanged.bind(this));
}, },
onClearHistoryChanged() { onClearHistoryChanged() {
let downloadsPref = document.getElementById("privacy.clearOnShutdown.downloads"); let downloadsPref = Preferences.get("privacy.clearOnShutdown.downloads");
let historyPref = document.getElementById("privacy.clearOnShutdown.history"); let historyPref = Preferences.get("privacy.clearOnShutdown.history");
downloadsPref.value = historyPref.value; downloadsPref.value = historyPref.value;
} }
}); });

View File

@@ -6,40 +6,40 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<?xml-stylesheet href="chrome://global/skin/"?> <?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?> <?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css"?>
<!DOCTYPE dialog [ <!DOCTYPE dialog [
<!ENTITY % preferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
%preferencesDTD;
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd"> <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
<!ENTITY % sanitizeDTD SYSTEM "chrome://browser/locale/sanitize.dtd">
%brandDTD; %brandDTD;
<!ENTITY % sanitizeDTD SYSTEM "chrome://browser/locale/sanitize.dtd">
%sanitizeDTD; %sanitizeDTD;
]> ]>
<prefwindow id="SanitizeDialog" type="child" <dialog id="SanitizeDialog" type="child" class="prefwindow"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
dlgbuttons="accept,cancel,help" buttons="accept,cancel,help"
ondialoghelp="openPrefsHelp()" persist="lastSelected screenX screenY"
style="width: &sanitizePrefs2.modal.width;" closebuttonlabel="&preferencesCloseButton.label;"
title="&sanitizePrefs2.title;" closebuttonaccesskey="&preferencesCloseButton.accesskey;"
onload="gSanitizeDialog.init();"> role="dialog"
ondialoghelp="openPrefsHelp()"
style="width: &sanitizePrefs2.modal.width;"
title="&sanitizePrefs2.title;"
helpTopic="prefs-clear-private-data"
onload="gSanitizeDialog.init();">
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/> <script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
<script type="application/javascript" src="chrome://browser/content/preferences/sanitize.js"/> <script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<prefpane id="SanitizeDialogPane" <keyset>
helpTopic="prefs-clear-private-data"> <key key="&windowClose.key;" modifiers="accel" oncommand="Preferences.close(event)"/>
</keyset>
<preferences> <vbox id="SanitizeDialogPane" class="prefpane">
<preference id="privacy.clearOnShutdown.history" name="privacy.clearOnShutdown.history" type="bool"
onchange="return gSanitizeDialog.onClearHistoryChanged();"/> <script type="application/javascript" src="chrome://browser/content/preferences/sanitize.js"/>
<preference id="privacy.clearOnShutdown.formdata" name="privacy.clearOnShutdown.formdata" type="bool"/>
<preference id="privacy.clearOnShutdown.downloads" name="privacy.clearOnShutdown.downloads" type="bool"/>
<preference id="privacy.clearOnShutdown.cookies" name="privacy.clearOnShutdown.cookies" type="bool"/>
<preference id="privacy.clearOnShutdown.cache" name="privacy.clearOnShutdown.cache" type="bool"/>
<preference id="privacy.clearOnShutdown.offlineApps" name="privacy.clearOnShutdown.offlineApps" type="bool"/>
<preference id="privacy.clearOnShutdown.sessions" name="privacy.clearOnShutdown.sessions" type="bool"/>
<preference id="privacy.clearOnShutdown.siteSettings" name="privacy.clearOnShutdown.siteSettings" type="bool"/>
</preferences>
<description>&clearDataSettings3.label;</description> <description>&clearDataSettings3.label;</description>
@@ -94,5 +94,5 @@
</rows> </rows>
</grid> </grid>
</groupbox> </groupbox>
</prefpane> </vbox>
</prefwindow> </dialog>

View File

@@ -120,18 +120,17 @@ this.ShieldPreferences = {
viewStudies.classList.add("learnMore", "text-link"); viewStudies.classList.add("learnMore", "text-link");
hContainer.appendChild(viewStudies); hContainer.appendChild(viewStudies);
// <prefrence> elements for prefs that we need to monitor while the page is open.
const optOutPref = doc.createElementNS(XUL_NS, "preference"); const optOutPref = doc.createElementNS(XUL_NS, "preference");
optOutPref.setAttribute("id", OPT_OUT_STUDIES_ENABLED_PREF); optOutPref.setAttribute("id", OPT_OUT_STUDIES_ENABLED_PREF);
optOutPref.setAttribute("name", OPT_OUT_STUDIES_ENABLED_PREF); optOutPref.setAttribute("name", OPT_OUT_STUDIES_ENABLED_PREF);
optOutPref.setAttribute("type", "bool"); optOutPref.setAttribute("type", "bool");
// Preference instances for prefs that we need to monitor while the page is open.
doc.defaultView.Preferences.add({ id: OPT_OUT_STUDIES_ENABLED_PREF, type: "bool" });
// Weirdly, FHR doesn't have a <preference> element on the page, so we create it. // Weirdly, FHR doesn't have a <preference> element on the page, so we create it.
const fhrPref = doc.createElementNS(XUL_NS, "preference"); const fhrPref = doc.defaultView.Preferences.add({ id: FHR_UPLOAD_ENABLED_PREF, type: "bool" });
fhrPref.setAttribute("id", FHR_UPLOAD_ENABLED_PREF); fhrPref.on("change", function(event) {
fhrPref.setAttribute("name", FHR_UPLOAD_ENABLED_PREF);
fhrPref.setAttribute("type", "bool");
fhrPref.addEventListener("change", function(event) {
// Avoid reference to the document directly, to avoid leaks. // Avoid reference to the document directly, to avoid leaks.
const eventTargetCheckbox = event.target.ownerDocument.getElementById("optOutStudiesEnabled"); const eventTargetCheckbox = event.target.ownerDocument.getElementById("optOutStudiesEnabled");
eventTargetCheckbox.disabled = !Services.prefs.getBoolPref(FHR_UPLOAD_ENABLED_PREF); eventTargetCheckbox.disabled = !Services.prefs.getBoolPref(FHR_UPLOAD_ENABLED_PREF);
@@ -140,9 +139,5 @@ this.ShieldPreferences = {
// Actually inject the elements we've created. // Actually inject the elements we've created.
const parent = doc.getElementById("submitHealthReportBox").closest("vbox"); const parent = doc.getElementById("submitHealthReportBox").closest("vbox");
parent.appendChild(container); parent.appendChild(container);
const preferences = doc.getElementById("privacyPreferences");
preferences.appendChild(optOutPref);
preferences.appendChild(fhrPref);
}, },
}; };

View File

@@ -5,6 +5,33 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
/* Pref Window & Pane */
.prefwindow {
padding: 0px;
}
.prefwindow[type="child"] {
padding: 8px;
}
.prefpane {
padding: 8px;
}
.prefwindow[type="child"] > .prefpane {
padding: 0px;
}
.dialog-button-box {
padding-bottom: 8px;
padding-inline-start: 8px;
padding-inline-end: 8px;
}
.prefwindow[type="child"] .dialog-button-box {
padding: 0px;
}
/* General Pane */ /* General Pane */
#useFirefoxSync, #useFirefoxSync,
#getStarted { #getStarted {
@@ -23,7 +50,7 @@
/* Modeless Window Dialogs */ /* Modeless Window Dialogs */
.windowDialog, .windowDialog,
.windowDialog prefpane { .windowDialog .prefpane {
padding: 0px; padding: 0px;
} }

View File

@@ -99,7 +99,7 @@
/* Align the last dialog button with the end of the warning box */ /* Align the last dialog button with the end of the warning box */
.prefWindow-dlgbuttons { .dialog-button-box {
margin-inline-end: 0; margin-inline-end: 0;
} }
.dialog-button[dlgtype="accept"] { .dialog-button[dlgtype="accept"] {

View File

@@ -4,7 +4,7 @@
%include ../../../shared/incontentprefs/dialog.inc.css %include ../../../shared/incontentprefs/dialog.inc.css
prefwindow, .prefwindow,
.windowDialog { .windowDialog {
font: message-box !important; font: message-box !important;
} }
@@ -12,7 +12,3 @@ prefwindow,
:root > * { :root > * {
font-size: 1.18em; font-size: 1.18em;
} }
.prefWindow-dlgbuttons {
margin: 0;
}

View File

@@ -12,12 +12,40 @@
font: -moz-dialog; font: -moz-dialog;
} }
/* ----- APPLICATIONS PREFPANE ----- */ .prefwindow {
padding: 0;
font: -moz-dialog !important;
}
.prefwindow[type="child"] {
padding-top: 18px;
padding-bottom: 15px;
padding-inline-start: 18px;
padding-inline-end: 20px;
}
.dialog-button-box {
margin: 0 12px 12px;
padding-top: 0 !important;
}
description { description {
margin-bottom: 4px !important; margin-bottom: 4px !important;
} }
prefpane .groupbox-body { .prefpane {
padding-top: 12px;
padding-bottom: 12px;
padding-inline-start: 0;
padding-inline-end: 12px;
}
.prefwindow[type="child"] > .prefpane {
padding: 0;
}
.prefpane .groupbox-body,
.prefpane .groupbox-body {
-moz-appearance: none; -moz-appearance: none;
padding: 8px 4px 4px 4px; padding: 8px 4px 4px 4px;
} }

View File

@@ -83,7 +83,7 @@
/* Align the last dialog button with the end of the warning box */ /* Align the last dialog button with the end of the warning box */
.prefWindow-dlgbuttons { .dialog-button-box {
margin-inline-end: 0; margin-inline-end: 0;
} }
.dialog-button[dlgtype="accept"] { .dialog-button[dlgtype="accept"] {

View File

@@ -6,8 +6,7 @@
dialog, dialog,
window, window,
prefpane, .prefpane,
prefwindow,
.windowDialog { .windowDialog {
-moz-appearance: none; -moz-appearance: none;
background-color: #fbfbfb; background-color: #fbfbfb;
@@ -57,7 +56,7 @@ groupbox {
padding-bottom: 5px; padding-bottom: 5px;
} }
prefpane .groupbox-body { .prefpane .groupbox-body {
padding: 0 0 5px; padding: 0 0 5px;
} }

View File

@@ -28,7 +28,12 @@
padding: 0; padding: 0;
} }
prefpane > groupbox + groupbox { .prefwindow[type="child"] > .prefpane {
-moz-box-flex: 1;
overflow: -moz-hidden-unscrollable;
}
.prefpane > groupbox + groupbox {
margin-top: 16px; margin-top: 16px;
} }

View File

@@ -5,6 +5,39 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
/* Pref Window & Pane */
.prefwindow {
padding: 0px;
}
.prefwindow[type="child"] {
padding-top: 8px;
padding-bottom: 10px;
padding-inline-start: 8px;
padding-inline-end: 10px;
}
.prefpane {
padding-top: 8px;
padding-bottom: 10px;
padding-inline-start: 8px;
padding-inline-end: 10px;
}
.prefwindow[type="child"] > .prefpane {
padding: 0px;
}
.dialog-button-box {
padding-bottom: 10px;
padding-inline-start: 8px;
padding-inline-end: 10px;
}
.prefwindow[type="child"] .dialog-button-box {
padding: 0px;
}
/* General Pane */ /* General Pane */
#useFirefoxSync, #useFirefoxSync,
@@ -23,8 +56,7 @@
} }
/* Modeless Window Dialogs */ /* Modeless Window Dialogs */
.windowDialog, .windowDialog {
.windowDialog prefpane {
padding: 0; padding: 0;
} }

View File

@@ -85,7 +85,7 @@
/* Align the last dialog button with the end of the warning box */ /* Align the last dialog button with the end of the warning box */
.prefWindow-dlgbuttons { .dialog-button-box {
margin-inline-end: 0; margin-inline-end: 0;
} }
.dialog-button[dlgtype="cancel"] { .dialog-button[dlgtype="cancel"] {

View File

@@ -82,7 +82,7 @@ class TestAnonymousNodes(WindowManagerMixin, MarionetteTestCase):
def test_find_anonymous_children(self): def test_find_anonymous_children(self):
self.assertEquals(HTMLElement, type(self.marionette.find_element(By.ANON, None))) self.assertEquals(HTMLElement, type(self.marionette.find_element(By.ANON, None)))
self.assertEquals(2, len(self.marionette.find_elements(By.ANON, None))) self.assertEquals(3, len(self.marionette.find_elements(By.ANON, None)))
frame = self.marionette.find_element(By.ID, "framebox") frame = self.marionette.find_element(By.ID, "framebox")
with self.assertRaises(NoSuchElementException): with self.assertRaises(NoSuchElementException):

View File

@@ -53,6 +53,7 @@ toolkit.jar:
content/global/filepicker.properties content/global/filepicker.properties
content/global/globalOverlay.js content/global/globalOverlay.js
content/global/mozilla.xhtml content/global/mozilla.xhtml
content/global/preferencesBindings.js
content/global/process-content.js content/global/process-content.js
content/global/resetProfile.css content/global/resetProfile.css
content/global/resetProfile.js content/global/resetProfile.js
@@ -87,7 +88,6 @@ toolkit.jar:
content/global/bindings/notification.xml (widgets/notification.xml) content/global/bindings/notification.xml (widgets/notification.xml)
content/global/bindings/numberbox.xml (widgets/numberbox.xml) content/global/bindings/numberbox.xml (widgets/numberbox.xml)
content/global/bindings/popup.xml (widgets/popup.xml) content/global/bindings/popup.xml (widgets/popup.xml)
* content/global/bindings/preferences.xml (widgets/preferences.xml)
content/global/bindings/progressmeter.xml (widgets/progressmeter.xml) content/global/bindings/progressmeter.xml (widgets/progressmeter.xml)
content/global/bindings/radio.xml (widgets/radio.xml) content/global/bindings/radio.xml (widgets/radio.xml)
content/global/bindings/remote-browser.xml (widgets/remote-browser.xml) content/global/bindings/remote-browser.xml (widgets/remote-browser.xml)

View File

@@ -0,0 +1,615 @@
/* - This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this file,
- You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
// We attach Preferences to the window object so other contexts (tests, JSMs)
// have access to it.
const Preferences = window.Preferences = (function() {
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
Cu.import("resource://gre/modules/EventEmitter.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DeferredTask",
"resource://gre/modules/DeferredTask.jsm");
function getElementsByAttribute(name, value) {
// If we needed to defend against arbitrary values, we would escape
// double quotes (") and escape characters (\) in them, i.e.:
// ${value.replace(/["\\]/g, '\\$&')}
return value ? document.querySelectorAll(`[${name}="${value}"]`)
: document.querySelectorAll(`[${name}]`);
}
const domContentLoadedPromise = new Promise(resolve => {
window.addEventListener("DOMContentLoaded", resolve, { capture: true, once: true });
});
const Preferences = {
_all: {},
_add(prefInfo) {
if (this._all[prefInfo.id]) {
throw new Error(`preference with id '${prefInfo.id}' already added`);
}
const pref = new Preference(prefInfo);
this._all[pref.id] = pref;
domContentLoadedPromise.then(() => { pref.updateElements(); });
return pref;
},
add(prefInfo) {
const pref = this._add(prefInfo);
return pref;
},
addAll(prefInfos) {
prefInfos.map(prefInfo => this._add(prefInfo));
},
get(id) {
return this._all[id] || null;
},
getAll() {
return Object.values(this._all);
},
defaultBranch: Services.prefs.getDefaultBranch(""),
get type() {
return document.documentElement.getAttribute("type") || "";
},
get instantApply() {
// The about:preferences page forces instantApply.
if (this._instantApplyForceEnabled) {
return true;
}
// Dialogs of type="child" are never instantApply.
if (this.type === "child") {
return false;
}
// All other pref windows observe the value of the instantApply
// preference. Note that, as of this writing, the only such windows
// are in tests, so it should be possible to remove the pref
// (and forceEnableInstantApply) in favor of always applying in a parent
// and never applying in a child.
return Services.prefs.getBoolPref("browser.preferences.instantApply");
},
_instantApplyForceEnabled: false,
// Override the computed value of instantApply for this window.
forceEnableInstantApply() {
this._instantApplyForceEnabled = true;
},
observe(subject, topic, data) {
const pref = this._all[data];
if (pref) {
pref.value = pref.valueFromPreferences;
}
},
onDOMContentLoaded() {
// Iterate elements with a "preference" attribute and log an error
// if there isn't a corresponding Preference object in order to catch
// any cases of elements referencing preferences that haven't (yet?)
// been registered.
//
// TODO: remove this code once we determine that there are no such
// elements (or resolve any bugs that cause this behavior).
//
const elements = getElementsByAttribute("preference");
for (const element of elements) {
const id = element.getAttribute("preference");
const pref = this.get(id);
if (!pref) {
console.error(`Missing preference for ID ${id}`);
}
}
},
onUnload() {
Services.prefs.removeObserver("", this);
},
QueryInterface: XPCOMUtils.generateQI([
Ci.nsITimerCallback,
Ci.nsIObserver,
]),
_deferredValueUpdateElements: new Set(),
writePreferences(aFlushToDisk) {
// Write all values to preferences.
if (this._deferredValueUpdateElements.size) {
this._finalizeDeferredElements();
}
const preferences = Preferences.getAll();
for (const preference of preferences) {
preference.batching = true;
preference.valueFromPreferences = preference.value;
preference.batching = false;
}
if (aFlushToDisk) {
Services.prefs.savePrefFile(null);
}
},
getPreferenceElement(aStartElement) {
let temp = aStartElement;
while (temp && temp.nodeType == Node.ELEMENT_NODE &&
!temp.hasAttribute("preference"))
temp = temp.parentNode;
return temp && temp.nodeType == Node.ELEMENT_NODE ?
temp : aStartElement;
},
_deferredValueUpdate(aElement) {
delete aElement._deferredValueUpdateTask;
const prefID = aElement.getAttribute("preference");
const preference = Preferences.get(prefID);
const prefVal = preference.getElementValue(aElement);
preference.value = prefVal;
this._deferredValueUpdateElements.delete(aElement);
},
_finalizeDeferredElements() {
for (const el of this._deferredValueUpdateElements) {
if (el._deferredValueUpdateTask) {
el._deferredValueUpdateTask.finalize();
}
}
},
userChangedValue(aElement) {
const element = this.getPreferenceElement(aElement);
if (element.hasAttribute("preference")) {
if (element.getAttribute("delayprefsave") != "true") {
const preference = Preferences.get(element.getAttribute("preference"));
const prefVal = preference.getElementValue(element);
preference.value = prefVal;
} else {
if (!element._deferredValueUpdateTask) {
element._deferredValueUpdateTask =
new DeferredTask(this._deferredValueUpdate.bind(this, element), 1000);
this._deferredValueUpdateElements.add(element);
} else {
// Each time the preference is changed, restart the delay.
element._deferredValueUpdateTask.disarm();
}
element._deferredValueUpdateTask.arm();
}
}
},
onCommand(event) {
// This "command" event handler tracks changes made to preferences by
// the user in this window.
if (event.sourceEvent)
event = event.sourceEvent;
this.userChangedValue(event.target);
},
onSelect(event) {
// This "select" event handler tracks changes made to colorpicker
// preferences by the user in this window.
if (event.target.localName == "colorpicker")
this.userChangedValue(event.target);
},
onChange(event) {
// This "change" event handler tracks changes made to preferences by
// the user in this window.
this.userChangedValue(event.target);
},
onInput(event) {
// This "input" event handler tracks changes made to preferences by
// the user in this window.
this.userChangedValue(event.target);
},
_fireEvent(aEventName, aTarget) {
// Panel loaded, synthesize a load event.
try {
const event = document.createEvent("Events");
event.initEvent(aEventName, true, true);
let cancel = !aTarget.dispatchEvent(event);
if (aTarget.hasAttribute("on" + aEventName)) {
const fn = new Function("event", aTarget.getAttribute("on" + aEventName));
const rv = fn.call(aTarget, event);
if (rv == false)
cancel = true;
}
return !cancel;
} catch (e) {
Cu.reportError(e);
}
return false;
},
onDialogAccept(event) {
if (!this._fireEvent("beforeaccept", document.documentElement)) {
event.preventDefault();
return false;
}
this.writePreferences(true);
return true;
},
close(event) {
if (Preferences.instantApply)
window.close();
event.stopPropagation();
event.preventDefault();
},
handleEvent(event) {
switch (event.type) {
case "change": return this.onChange(event);
case "command": return this.onCommand(event);
case "dialogaccept": return this.onDialogAccept(event);
case "input": return this.onInput(event);
case "select": return this.onSelect(event);
case "unload": return this.onUnload(event);
default: return undefined;
}
},
};
Services.prefs.addObserver("", Preferences);
domContentLoadedPromise.then(result => Preferences.onDOMContentLoaded(result));
window.addEventListener("change", Preferences);
window.addEventListener("command", Preferences);
window.addEventListener("dialogaccept", Preferences);
window.addEventListener("input", Preferences);
window.addEventListener("select", Preferences);
window.addEventListener("unload", Preferences, { once: true });
class Preference extends EventEmitter {
constructor({ id, name, type, inverted, disabled }) {
super();
this.on("change", this.onChange.bind(this));
this._value = null;
this.readonly = false;
this._useDefault = false;
this.batching = false;
this.id = id;
this._name = name || this.id;
this.type = type;
this.inverted = !!inverted;
this._disabled = !!disabled;
// if the element has been inserted without the name attribute set,
// we have nothing to do here
if (!this.name) {
throw new Error(`preference with id '${id}' doesn't have name`);
}
// In non-instant apply mode, we must try and use the last saved state
// from any previous opens of a child dialog instead of the value from
// preferences, to pick up any edits a user may have made.
if (Preferences.type == "child" && window.opener &&
Services.scriptSecurityManager.isSystemPrincipal(window.opener.document.nodePrincipal)) {
// Try to find the preference in the parent window.
const preference = window.opener.Preferences.get(this.name);
// Don't use the value setter here, we don't want updateElements to be
// prematurely fired.
this._value = preference ? preference.value : this.valueFromPreferences;
} else
this._value = this.valueFromPreferences;
}
reset() {
// defer reset until preference update
this.value = undefined;
}
_reportUnknownType() {
const msg = `Preference with id=${this.id} and name=${this.name} has unknown type ${this.type}.`;
Services.console.logStringMessage(msg);
}
setElementValue(aElement) {
if (this.locked)
aElement.disabled = true;
if (!this.isElementEditable(aElement))
return;
let rv = undefined;
if (aElement.hasAttribute("onsyncfrompreference")) {
// Value changed, synthesize an event
try {
const event = document.createEvent("Events");
event.initEvent("syncfrompreference", true, true);
const f = new Function("event",
aElement.getAttribute("onsyncfrompreference"));
rv = f.call(aElement, event);
} catch (e) {
Cu.reportError(e);
}
}
let val = rv;
if (val === undefined)
val = Preferences.instantApply ? this.valueFromPreferences : this.value;
// if the preference is marked for reset, show default value in UI
if (val === undefined)
val = this.defaultValue;
/**
* Initialize a UI element property with a value. Handles the case
* where an element has not yet had a XBL binding attached for it and
* the property setter does not yet exist by setting the same attribute
* on the XUL element using DOM apis and assuming the element's
* constructor or property getters appropriately handle this state.
*/
function setValue(element, attribute, value) {
if (attribute in element)
element[attribute] = value;
else
element.setAttribute(attribute, value);
}
if (aElement.localName == "checkbox" ||
aElement.localName == "listitem")
setValue(aElement, "checked", val);
else if (aElement.localName == "colorpicker")
setValue(aElement, "color", val);
else if (aElement.localName == "textbox") {
// XXXmano Bug 303998: Avoid a caret placement issue if either the
// preference observer or its setter calls updateElements as a result
// of the input event handler.
if (aElement.value !== val)
setValue(aElement, "value", val);
} else
setValue(aElement, "value", val);
}
getElementValue(aElement) {
if (aElement.hasAttribute("onsynctopreference")) {
// Value changed, synthesize an event
try {
const event = document.createEvent("Events");
event.initEvent("synctopreference", true, true);
const f = new Function("event",
aElement.getAttribute("onsynctopreference"));
const rv = f.call(aElement, event);
if (rv !== undefined)
return rv;
} catch (e) {
Cu.reportError(e);
}
}
/**
* Read the value of an attribute from an element, assuming the
* attribute is a property on the element's node API. If the property
* is not present in the API, then assume its value is contained in
* an attribute, as is the case before a binding has been attached.
*/
function getValue(element, attribute) {
if (attribute in element)
return element[attribute];
return element.getAttribute(attribute);
}
let value;
if (aElement.localName == "checkbox" ||
aElement.localName == "listitem")
value = getValue(aElement, "checked");
else if (aElement.localName == "colorpicker")
value = getValue(aElement, "color");
else
value = getValue(aElement, "value");
switch (this.type) {
case "int":
return parseInt(value, 10) || 0;
case "bool":
return typeof(value) == "boolean" ? value : value == "true";
}
return value;
}
isElementEditable(aElement) {
switch (aElement.localName) {
case "checkbox":
case "colorpicker":
case "radiogroup":
case "textbox":
case "listitem":
case "listbox":
case "menulist":
return true;
}
return aElement.getAttribute("preference-editable") == "true";
}
updateElements() {
if (!this.id)
return;
// This "change" event handler tracks changes made to preferences by
// sources other than the user in this window.
const elements = getElementsByAttribute("preference", this.id);
for (const element of elements)
this.setElementValue(element);
}
onChange() {
this.updateElements();
}
get name() {
return this._name;
}
set name(val) {
if (val == this.name)
return val;
this._name = val;
return val;
}
get value() {
return this._value;
}
set value(val) {
if (this.value !== val) {
this._value = val;
if (Preferences.instantApply)
this.valueFromPreferences = val;
this.emit("change");
}
return val;
}
get locked() {
return Services.prefs.prefIsLocked(this.name);
}
get disabled() {
return this._disabled;
}
set disabled(val) {
this._disabled = !!val;
if (!this.id)
return val;
const elements = getElementsByAttribute("preference", this.id);
for (const element of elements) {
element.disabled = val;
const labels = getElementsByAttribute("control", element.id);
for (const label of labels)
label.disabled = val;
}
return val;
}
get hasUserValue() {
return Services.prefs.prefHasUserValue(this.name) &&
this.value !== undefined;
}
get defaultValue() {
this._useDefault = true;
const val = this.valueFromPreferences;
this._useDefault = false;
return val;
}
get _branch() {
return this._useDefault ? Preferences.defaultBranch : Services.prefs;
}
get valueFromPreferences() {
try {
// Force a resync of value with preferences.
switch (this.type) {
case "int":
return this._branch.getIntPref(this.name);
case "bool": {
const val = this._branch.getBoolPref(this.name);
return this.inverted ? !val : val;
}
case "wstring":
return this._branch
.getComplexValue(this.name, Ci.nsIPrefLocalizedString)
.data;
case "string":
case "unichar":
return this._branch.getStringPref(this.name);
case "fontname": {
const family = this._branch.getStringPref(this.name);
const fontEnumerator = Cc["@mozilla.org/gfx/fontenumerator;1"]
.createInstance(Ci.nsIFontEnumerator);
return fontEnumerator.getStandardFamilyName(family);
}
case "file": {
const f = this._branch
.getComplexValue(this.name, Ci.nsIFile);
return f;
}
default:
this._reportUnknownType();
}
} catch (e) { }
return null;
}
set valueFromPreferences(val) {
// Exit early if nothing to do.
if (this.readonly || this.valueFromPreferences == val)
return val;
// The special value undefined means 'reset preference to default'.
if (val === undefined) {
Services.prefs.clearUserPref(this.name);
return val;
}
// Force a resync of preferences with value.
switch (this.type) {
case "int":
Services.prefs.setIntPref(this.name, val);
break;
case "bool":
Services.prefs.setBoolPref(this.name, this.inverted ? !val : val);
break;
case "wstring": {
const pls = Cc["@mozilla.org/pref-localizedstring;1"]
.createInstance(Ci.nsIPrefLocalizedString);
pls.data = val;
Services.prefs
.setComplexValue(this.name, Ci.nsIPrefLocalizedString, pls);
break;
}
case "string":
case "unichar":
case "fontname":
Services.prefs.setStringPref(this.name, val);
break;
case "file": {
let lf;
if (typeof(val) == "string") {
lf = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
lf.persistentDescriptor = val;
if (!lf.exists())
lf.initWithPath(val);
} else
lf = val.QueryInterface(Ci.nsIFile);
Services.prefs
.setComplexValue(this.name, Ci.nsIFile, lf);
break;
}
default:
this._reportUnknownType();
}
if (!this.batching) {
Services.prefs.savePrefFile(null);
}
return val;
}
}
return Preferences;
}.bind({})());

View File

@@ -4,7 +4,7 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE prefwindow [ <!DOCTYPE dialog [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" > <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
%brandDTD; %brandDTD;
<!ENTITY % resetProfileDTD SYSTEM "chrome://global/locale/resetProfile.dtd" > <!ENTITY % resetProfileDTD SYSTEM "chrome://global/locale/resetProfile.dtd" >

View File

@@ -128,28 +128,33 @@
return aPrefWindow.document.getElementById(aID); return aPrefWindow.document.getElementById(aID);
} }
function GetPreference(aPrefWindow, aID)
{
return aPrefWindow.Preferences.get(aID);
}
function WritePrefsToPreferences(aPrefWindow, aPrefValueSet) function WritePrefsToPreferences(aPrefWindow, aPrefValueSet)
{ {
// write preference data into <preference>s // write preference data into Preference instances
GetXULElement(aPrefWindow, "tests.static_preference_int" ).value = aPrefValueSet.int; GetPreference(aPrefWindow, "tests.static_preference_int" ).value = aPrefValueSet.int;
GetXULElement(aPrefWindow, "tests.static_preference_bool" ).value = aPrefValueSet.bool; GetPreference(aPrefWindow, "tests.static_preference_bool" ).value = aPrefValueSet.bool;
GetXULElement(aPrefWindow, "tests.static_preference_string" ).value = aPrefValueSet.string; GetPreference(aPrefWindow, "tests.static_preference_string" ).value = aPrefValueSet.string;
GetXULElement(aPrefWindow, "tests.static_preference_unichar").value = aPrefValueSet.unichar; GetPreference(aPrefWindow, "tests.static_preference_unichar").value = aPrefValueSet.unichar;
GetXULElement(aPrefWindow, "tests.static_preference_wstring").value = aPrefValueSet.wstring_data; GetPreference(aPrefWindow, "tests.static_preference_wstring").value = aPrefValueSet.wstring_data;
GetXULElement(aPrefWindow, "tests.static_preference_file" ).value = aPrefValueSet.file_data; GetPreference(aPrefWindow, "tests.static_preference_file" ).value = aPrefValueSet.file_data;
} }
function ReadPrefsFromPreferences(aPrefWindow) function ReadPrefsFromPreferences(aPrefWindow)
{ {
// read preference data from <preference>s // read preference data from Preference instances
var result = var result =
{ {
int: GetXULElement(aPrefWindow, "tests.static_preference_int" ).value, int: GetPreference(aPrefWindow, "tests.static_preference_int" ).value,
bool: GetXULElement(aPrefWindow, "tests.static_preference_bool" ).value, bool: GetPreference(aPrefWindow, "tests.static_preference_bool" ).value,
string: GetXULElement(aPrefWindow, "tests.static_preference_string" ).value, string: GetPreference(aPrefWindow, "tests.static_preference_string" ).value,
unichar: GetXULElement(aPrefWindow, "tests.static_preference_unichar").value, unichar: GetPreference(aPrefWindow, "tests.static_preference_unichar").value,
wstring_data: GetXULElement(aPrefWindow, "tests.static_preference_wstring").value, wstring_data: GetPreference(aPrefWindow, "tests.static_preference_wstring").value,
file_data: GetXULElement(aPrefWindow, "tests.static_preference_file" ).value, file_data: GetPreference(aPrefWindow, "tests.static_preference_file" ).value,
wstring: Components.classes["@mozilla.org/pref-localizedstring;1"] wstring: Components.classes["@mozilla.org/pref-localizedstring;1"]
.createInstance(Components.interfaces.nsIPrefLocalizedString), .createInstance(Components.interfaces.nsIPrefLocalizedString),
file: Components.classes["@mozilla.org/file/local;1"] file: Components.classes["@mozilla.org/file/local;1"]
@@ -173,7 +178,7 @@
function ReadPrefsFromUI(aPrefWindow) function ReadPrefsFromUI(aPrefWindow)
{ {
// read preference data from <preference>s // read preference data from Preference instances
var result = var result =
{ {
int: GetXULElement(aPrefWindow, "static_element_int" ).value, int: GetXULElement(aPrefWindow, "static_element_int" ).value,
@@ -197,7 +202,7 @@
{ {
// remark: there's currently no UI element binding for files // remark: there's currently no UI element binding for files
// were all <preferences> correctly initialized? // were all Preference instances correctly initialized?
var expected = kPrefValueSet1; var expected = kPrefValueSet1;
var found = ReadPrefsFromPreferences(aPrefWindow); var found = ReadPrefsFromPreferences(aPrefWindow);
ok(found.int === expected.int, "instant pref init int" ); ok(found.int === expected.int, "instant pref init int" );
@@ -220,7 +225,7 @@
expected = kPrefValueSet2; expected = kPrefValueSet2;
WritePrefsToUI(aPrefWindow, expected); WritePrefsToUI(aPrefWindow, expected);
// UI changes should get passed to the <preference>s, // UI changes should get passed to the Preference instances,
// but currently they aren't if the changes are made programmatically // but currently they aren't if the changes are made programmatically
// (the handlers preference.change/prefpane.input and prefpane.change // (the handlers preference.change/prefpane.input and prefpane.change
// are called for manual changes, though). // are called for manual changes, though).
@@ -243,12 +248,12 @@
todo(found.file_data === expected.file_data, "instant change element file" ); todo(found.file_data === expected.file_data, "instant change element file" );
// try resetting the prefs to default values (which should be empty here) // try resetting the prefs to default values (which should be empty here)
GetXULElement(aPrefWindow, "tests.static_preference_int" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_int" ).reset();
GetXULElement(aPrefWindow, "tests.static_preference_bool" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_bool" ).reset();
GetXULElement(aPrefWindow, "tests.static_preference_string" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_string" ).reset();
GetXULElement(aPrefWindow, "tests.static_preference_unichar").reset(); GetPreference(aPrefWindow, "tests.static_preference_unichar").reset();
GetXULElement(aPrefWindow, "tests.static_preference_wstring").reset(); GetPreference(aPrefWindow, "tests.static_preference_wstring").reset();
GetXULElement(aPrefWindow, "tests.static_preference_file" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_file" ).reset();
// check system // check system
expected = CreateEmptyPrefValueSet(); expected = CreateEmptyPrefValueSet();
@@ -283,12 +288,12 @@
// ok(found.file_data === expected.file_data, "instant reset element file" ); // ok(found.file_data === expected.file_data, "instant reset element file" );
// check hasUserValue // check hasUserValue
ok(GetXULElement(aPrefWindow, "tests.static_preference_int" ).hasUserValue === false, "instant reset hasUserValue int" ); ok(GetPreference(aPrefWindow, "tests.static_preference_int" ).hasUserValue === false, "instant reset hasUserValue int" );
ok(GetXULElement(aPrefWindow, "tests.static_preference_bool" ).hasUserValue === false, "instant reset hasUserValue bool" ); ok(GetPreference(aPrefWindow, "tests.static_preference_bool" ).hasUserValue === false, "instant reset hasUserValue bool" );
ok(GetXULElement(aPrefWindow, "tests.static_preference_string" ).hasUserValue === false, "instant reset hasUserValue string" ); ok(GetPreference(aPrefWindow, "tests.static_preference_string" ).hasUserValue === false, "instant reset hasUserValue string" );
ok(GetXULElement(aPrefWindow, "tests.static_preference_unichar").hasUserValue === false, "instant reset hasUserValue unichar"); ok(GetPreference(aPrefWindow, "tests.static_preference_unichar").hasUserValue === false, "instant reset hasUserValue unichar");
ok(GetXULElement(aPrefWindow, "tests.static_preference_wstring").hasUserValue === false, "instant reset hasUserValue wstring"); ok(GetPreference(aPrefWindow, "tests.static_preference_wstring").hasUserValue === false, "instant reset hasUserValue wstring");
ok(GetXULElement(aPrefWindow, "tests.static_preference_file" ).hasUserValue === false, "instant reset hasUserValue file" ); ok(GetPreference(aPrefWindow, "tests.static_preference_file" ).hasUserValue === false, "instant reset hasUserValue file" );
// done with instant apply checks // done with instant apply checks
} }
@@ -301,7 +306,7 @@
// remark: there's currently no UI element binding for files // remark: there's currently no UI element binding for files
// were all <preferences> correctly initialized? // were all Preference instances correctly initialized?
var expected = kPrefValueSet1; var expected = kPrefValueSet1;
var found = ReadPrefsFromPreferences(aPrefWindow); var found = ReadPrefsFromPreferences(aPrefWindow);
ok(found.int === expected.int, "non-instant pref init int" ); ok(found.int === expected.int, "non-instant pref init int" );
@@ -324,7 +329,7 @@
expected = kPrefValueSet2; expected = kPrefValueSet2;
WritePrefsToUI(aPrefWindow, expected); WritePrefsToUI(aPrefWindow, expected);
// UI changes should get passed to the <preference>s, // UI changes should get passed to the Preference instances,
// but currently they aren't if the changes are made programmatically // but currently they aren't if the changes are made programmatically
// (the handlers preference.change/prefpane.input and prefpane.change // (the handlers preference.change/prefpane.input and prefpane.change
// are called for manual changes, though). // are called for manual changes, though).
@@ -348,12 +353,12 @@
todo(found.file_data === expected.file_data, "non-instant change element file" ); todo(found.file_data === expected.file_data, "non-instant change element file" );
// try resetting the prefs to default values (which should be empty here) // try resetting the prefs to default values (which should be empty here)
GetXULElement(aPrefWindow, "tests.static_preference_int" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_int" ).reset();
GetXULElement(aPrefWindow, "tests.static_preference_bool" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_bool" ).reset();
GetXULElement(aPrefWindow, "tests.static_preference_string" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_string" ).reset();
GetXULElement(aPrefWindow, "tests.static_preference_unichar").reset(); GetPreference(aPrefWindow, "tests.static_preference_unichar").reset();
GetXULElement(aPrefWindow, "tests.static_preference_wstring").reset(); GetPreference(aPrefWindow, "tests.static_preference_wstring").reset();
GetXULElement(aPrefWindow, "tests.static_preference_file" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_file" ).reset();
// check system: the current values *MUST NOT* change // check system: the current values *MUST NOT* change
expected = kPrefValueSet1; expected = kPrefValueSet1;
@@ -388,12 +393,12 @@
// ok(found.file_data === expected.file_data, "non-instant reset element file" ); // ok(found.file_data === expected.file_data, "non-instant reset element file" );
// check hasUserValue // check hasUserValue
ok(GetXULElement(aPrefWindow, "tests.static_preference_int" ).hasUserValue === false, "non-instant reset hasUserValue int" ); ok(GetPreference(aPrefWindow, "tests.static_preference_int" ).hasUserValue === false, "non-instant reset hasUserValue int" );
ok(GetXULElement(aPrefWindow, "tests.static_preference_bool" ).hasUserValue === false, "non-instant reset hasUserValue bool" ); ok(GetPreference(aPrefWindow, "tests.static_preference_bool" ).hasUserValue === false, "non-instant reset hasUserValue bool" );
ok(GetXULElement(aPrefWindow, "tests.static_preference_string" ).hasUserValue === false, "non-instant reset hasUserValue string" ); ok(GetPreference(aPrefWindow, "tests.static_preference_string" ).hasUserValue === false, "non-instant reset hasUserValue string" );
ok(GetXULElement(aPrefWindow, "tests.static_preference_unichar").hasUserValue === false, "non-instant reset hasUserValue unichar"); ok(GetPreference(aPrefWindow, "tests.static_preference_unichar").hasUserValue === false, "non-instant reset hasUserValue unichar");
ok(GetXULElement(aPrefWindow, "tests.static_preference_wstring").hasUserValue === false, "non-instant reset hasUserValue wstring"); ok(GetPreference(aPrefWindow, "tests.static_preference_wstring").hasUserValue === false, "non-instant reset hasUserValue wstring");
ok(GetXULElement(aPrefWindow, "tests.static_preference_file" ).hasUserValue === false, "non-instant reset hasUserValue file" ); ok(GetPreference(aPrefWindow, "tests.static_preference_file" ).hasUserValue === false, "non-instant reset hasUserValue file" );
} }
function RunNonInstantPrefTestClose(aPrefWindow) function RunNonInstantPrefTestClose(aPrefWindow)
@@ -404,20 +409,20 @@
function RunCheckCommandRedirect(aPrefWindow) function RunCheckCommandRedirect(aPrefWindow)
{ {
GetXULElement(aPrefWindow, "checkbox").click(); GetXULElement(aPrefWindow, "checkbox").click();
ok(GetXULElement(aPrefWindow, "tests.static_preference_bool").value, "redirected command bool"); ok(GetPreference(aPrefWindow, "tests.static_preference_bool").value, "redirected command bool");
GetXULElement(aPrefWindow, "checkbox").click(); GetXULElement(aPrefWindow, "checkbox").click();
ok(!GetXULElement(aPrefWindow, "tests.static_preference_bool").value, "redirected command bool"); ok(!GetPreference(aPrefWindow, "tests.static_preference_bool").value, "redirected command bool");
} }
function RunResetPrefTest(aPrefWindow) function RunResetPrefTest(aPrefWindow)
{ {
// try resetting the prefs to default values // try resetting the prefs to default values
GetXULElement(aPrefWindow, "tests.static_preference_int" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_int" ).reset();
GetXULElement(aPrefWindow, "tests.static_preference_bool" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_bool" ).reset();
GetXULElement(aPrefWindow, "tests.static_preference_string" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_string" ).reset();
GetXULElement(aPrefWindow, "tests.static_preference_unichar").reset(); GetPreference(aPrefWindow, "tests.static_preference_unichar").reset();
GetXULElement(aPrefWindow, "tests.static_preference_wstring").reset(); GetPreference(aPrefWindow, "tests.static_preference_wstring").reset();
GetXULElement(aPrefWindow, "tests.static_preference_file" ).reset(); GetPreference(aPrefWindow, "tests.static_preference_file" ).reset();
} }
function InitTestPrefs(aInstantApply) function InitTestPrefs(aInstantApply)

View File

@@ -17,8 +17,8 @@
var prefWindow = openDialog("window_preferences_beforeaccept.xul", "", "", windowOnload); var prefWindow = openDialog("window_preferences_beforeaccept.xul", "", "", windowOnload);
function windowOnload() { function windowOnload() {
var dialogShown = prefWindow.document.getElementById("tests.beforeaccept.dialogShown"); var dialogShown = prefWindow.Preferences.get("tests.beforeaccept.dialogShown");
var called = prefWindow.document.getElementById("tests.beforeaccept.called"); var called = prefWindow.Preferences.get("tests.beforeaccept.called");
is(dialogShown.value, true, "dialog opened, shown pref set"); is(dialogShown.value, true, "dialog opened, shown pref set");
is(dialogShown.valueFromPreferences, null, "shown pref not committed"); is(dialogShown.valueFromPreferences, null, "shown pref not committed");
is(called.value, null, "beforeaccept not yet called"); is(called.value, null, "beforeaccept not yet called");

View File

@@ -37,7 +37,7 @@
for (let pref of PREFS) { for (let pref of PREFS) {
// The `value` field of each <preference> element should be initialized by now. // The `value` field of each <preference> element should be initialized by now.
is(SpecialPowers.getIntPref(pref), prefWindow.document.getElementById(pref).value, is(SpecialPowers.getIntPref(pref), prefWindow.Preferences.get(pref).value,
"Pref constructor was called correctly") "Pref constructor was called correctly")
} }

View File

@@ -3,12 +3,14 @@
<!-- <!--
XUL Widget Test for preferences window XUL Widget Test for preferences window
--> -->
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="preferences window" class="prefwindow"
windowtype="test:preferences" title="preferences window"
buttons="accept,cancel" windowtype="test:preferences"
onload="RunTest(window.arguments)" buttons="accept,cancel"
onload="RunTest(window.arguments)"
> >
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript"> <script type="application/javascript">
<![CDATA[ <![CDATA[
function RunTest(aArgs) function RunTest(aArgs)
@@ -18,31 +20,20 @@
// close dialog // close dialog
document.documentElement[aArgs[1] ? "acceptDialog" : "cancelDialog"](); document.documentElement[aArgs[1] ? "acceptDialog" : "cancelDialog"]();
} }
Preferences.addAll([
// one of each type known to Preference.valueFromPreferences
{ id: "tests.static_preference_int", type: "int" },
{ id: "tests.static_preference_bool", type: "bool" },
{ id: "tests.static_preference_string", type: "string" },
{ id: "tests.static_preference_wstring", type: "wstring" },
{ id: "tests.static_preference_unichar", type: "unichar" },
{ id: "tests.static_preference_file", type: "file" },
]);
]]> ]]>
</script> </script>
<prefpane id="sample_pane" label="Sample Prefpane"> <vbox id="sample_pane" class="prefpane" label="Sample Prefpane">
<preferences id="sample_preferences">
<!-- one of each type known to <preferences>.valueFromPreferences -->
<preference id ="tests.static_preference_int"
name="tests.static_preference_int"
type="int"/>
<preference id ="tests.static_preference_bool"
name="tests.static_preference_bool"
type="bool"/>
<preference id ="tests.static_preference_string"
name="tests.static_preference_string"
type="string"/>
<preference id ="tests.static_preference_wstring"
name="tests.static_preference_wstring"
type="wstring"/>
<preference id ="tests.static_preference_unichar"
name="tests.static_preference_unichar"
type="unichar"/>
<preference id ="tests.static_preference_file"
name="tests.static_preference_file"
type="file"/>
</preferences>
<!-- one element for each preference type above --> <!-- one element for each preference type above -->
<hbox> <hbox>
@@ -69,5 +60,5 @@
<label flex="1" value="file"/> <label flex="1" value="file"/>
<textbox id="static_element_file" preference="tests.static_preference_file"/> <textbox id="static_element_file" preference="tests.static_preference_file"/>
</hbox> </hbox>
</prefpane> </vbox>
</prefwindow> </dialog>

View File

@@ -3,23 +3,25 @@
<!-- <!--
XUL Widget Test for preferences window XUL Widget Test for preferences window
--> -->
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="preferences window" class="prefwindow"
windowtype="test:preferences2" title="preferences window"
buttons="accept,cancel" windowtype="test:preferences2"
onload="RunTest(window.arguments)" buttons="accept,cancel"
onload="RunTest(window.arguments)"
> >
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript"> <script type="application/javascript">
<![CDATA[ <![CDATA[
function RunTest(aArgs) function RunTest(aArgs)
{ {
// open child // open child
document.documentElement.openSubDialog("window_preferences3.xul", "", {test: aArgs[0], accept: aArgs[1]}); openDialog("window_preferences3.xul", "", "modal,centerscreen,resizable=no", {test: aArgs[0], accept: aArgs[1]});
// close dialog // close dialog
document.documentElement[aArgs[1] ? "acceptDialog" : "cancelDialog"](); document.documentElement[aArgs[1] ? "acceptDialog" : "cancelDialog"]();
} }
]]> ]]>
</script> </script>
<prefpane id="sample_pane" label="Sample Prefpane"/> <vbox id="sample_pane" class="prefpane" label="Sample Prefpane"/>
</prefwindow> </dialog>

View File

@@ -3,13 +3,15 @@
<!-- <!--
XUL Widget Test for preferences window XUL Widget Test for preferences window
--> -->
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="preferences window" class="prefwindow"
windowtype="test:preferences3" title="preferences window"
buttons="accept,cancel" windowtype="test:preferences3"
onload="RunTest(window.arguments)" buttons="accept,cancel"
type="child" onload="RunTest(window.arguments)"
type="child"
> >
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript"> <script type="application/javascript">
<![CDATA[ <![CDATA[
function RunTest(aArgs) function RunTest(aArgs)
@@ -19,32 +21,20 @@
// close dialog // close dialog
document.documentElement[aArgs[0].accept ? "acceptDialog" : "cancelDialog"](); document.documentElement[aArgs[0].accept ? "acceptDialog" : "cancelDialog"]();
} }
Preferences.addAll([
// one of each type known to Preference.valueFromPreferences
{ id: "tests.static_preference_int", type: "int" },
{ id: "tests.static_preference_bool", type: "bool" },
{ id: "tests.static_preference_string", type: "string" },
{ id: "tests.static_preference_wstring", type: "wstring" },
{ id: "tests.static_preference_unichar", type: "unichar" },
{ id: "tests.static_preference_file", type: "file" },
]);
]]> ]]>
</script> </script>
<prefpane id="sample_pane" label="Sample Prefpane"> <vbox id="sample_pane" class="prefpane" label="Sample Prefpane">
<preferences id="sample_preferences">
<!-- one of each type known to <preferences>.valueFromPreferences -->
<preference id ="tests.static_preference_int"
name="tests.static_preference_int"
type="int"/>
<preference id ="tests.static_preference_bool"
name="tests.static_preference_bool"
type="bool"/>
<preference id ="tests.static_preference_string"
name="tests.static_preference_string"
type="string"/>
<preference id ="tests.static_preference_wstring"
name="tests.static_preference_wstring"
type="wstring"/>
<preference id ="tests.static_preference_unichar"
name="tests.static_preference_unichar"
type="unichar"/>
<preference id ="tests.static_preference_file"
name="tests.static_preference_file"
type="file"/>
</preferences>
<!-- one element for each preference type above --> <!-- one element for each preference type above -->
<hbox> <hbox>
<label flex="1" value="int"/> <label flex="1" value="int"/>
@@ -70,5 +60,5 @@
<label flex="1" value="file"/> <label flex="1" value="file"/>
<textbox id="static_element_file" preference="tests.static_preference_file"/> <textbox id="static_element_file" preference="tests.static_preference_file"/>
</hbox> </hbox>
</prefpane> </vbox>
</prefwindow> </dialog>

View File

@@ -3,18 +3,20 @@
<!-- <!--
XUL Widget Test for preferences window with beforeaccept XUL Widget Test for preferences window with beforeaccept
--> -->
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="preferences window" class="prefwindow"
width="300" height="300" title="preferences window"
windowtype="test:preferences" width="300" height="300"
buttons="accept,cancel" windowtype="test:preferences"
onbeforeaccept="return beforeAccept();" buttons="accept,cancel"
onload="onDialogLoad();" onbeforeaccept="return beforeAccept();"
onload="onDialogLoad();"
> >
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript"> <script type="application/javascript">
<![CDATA[ <![CDATA[
function onDialogLoad() { function onDialogLoad() {
var pref = document.getElementById("tests.beforeaccept.dialogShown"); var pref = Preferences.get("tests.beforeaccept.dialogShown");
pref.value = true; pref.value = true;
// call the onload handler we were passed // call the onload handler we were passed
@@ -22,24 +24,21 @@
} }
function beforeAccept() { function beforeAccept() {
var beforeAcceptPref = document.getElementById("tests.beforeaccept.called"); var beforeAcceptPref = Preferences.get("tests.beforeaccept.called");
var oldValue = beforeAcceptPref.value; var oldValue = beforeAcceptPref.value;
beforeAcceptPref.value = true; beforeAcceptPref.value = true;
return !!oldValue; return !!oldValue;
} }
Preferences.addAll([
{ id: "tests.beforeaccept.called", type: "bool" },
{ id: "tests.beforeaccept.dialogShown", type: "bool" },
]);
]]> ]]>
</script> </script>
<prefpane id="sample_pane" label="Sample Prefpane"> <vbox id="sample_pane" class="prefpane" label="Sample Prefpane">
<preferences id="sample_preferences"> </vbox>
<preference id="tests.beforeaccept.called"
name="tests.beforeaccept.called"
type="bool"/>
<preference id="tests.beforeaccept.dialogShown"
name="tests.beforeaccept.dialogShown"
type="bool"/>
</preferences>
</prefpane>
<label>Test Prefpane</label> <label>Test Prefpane</label>
</prefwindow> </dialog>

View File

@@ -5,11 +5,13 @@
a checkbox with a command attribute properly updates even though the command a checkbox with a command attribute properly updates even though the command
event gets retargeted. event gets retargeted.
--> -->
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="preferences window" class="prefwindow"
windowtype="test:preferences" title="preferences window"
buttons="accept,cancel" windowtype="test:preferences"
onload="RunTest(window.arguments)"> buttons="accept,cancel"
onload="RunTest(window.arguments)">
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<script type="application/javascript"> <script type="application/javascript">
<![CDATA[ <![CDATA[
function RunTest(aArgs) function RunTest(aArgs)
@@ -17,20 +19,18 @@
aArgs[0](this); aArgs[0](this);
document.documentElement.cancelDialog(); document.documentElement.cancelDialog();
} }
Preferences.addAll([
{ id: "tests.static_preference_bool", type: "bool" },
]);
]]> ]]>
</script> </script>
<prefpane id="sample_pane" label="Sample Prefpane"> <vbox id="sample_pane" class="prefpane" label="Sample Prefpane">
<preferences id="sample_preferences">
<preference id="tests.static_preference_bool"
name="tests.static_preference_bool"
type="bool"/>
</preferences>
<commandset> <commandset>
<command id="cmd_test" preference="tests.static_preference_bool"/> <command id="cmd_test" preference="tests.static_preference_bool"/>
</commandset> </commandset>
<checkbox id="checkbox" label="Enable Option" preference="tests.static_preference_bool" command="cmd_test"/> <checkbox id="checkbox" label="Enable Option" preference="tests.static_preference_bool" command="cmd_test"/>
</prefpane> </vbox>
</prefwindow> </dialog>

View File

@@ -8,24 +8,24 @@
This test ensures that onsyncfrompreference handlers are called after all the This test ensures that onsyncfrompreference handlers are called after all the
values of the corresponding preference element have been set correctly values of the corresponding preference element have been set correctly
--> -->
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" <dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="preferences window" class="prefwindow"
width="300" height="300" title="preferences window"
windowtype="test:preferences"> width="300" height="300"
windowtype="test:preferences">
<prefpane id="sample_pane" label="Sample Prefpane"> <script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
<preferences id="sample_preferences"> <script type="application/javascript">
<preference id="tests.onsyncfrompreference.pref1" <![CDATA[
name="tests.onsyncfrompreference.pref1" Preferences.addAll([
type="int"/> { id: "tests.onsyncfrompreference.pref1", type: "int" },
<preference id="tests.onsyncfrompreference.pref2" { id: "tests.onsyncfrompreference.pref2", type: "int" },
name="tests.onsyncfrompreference.pref2" { id: "tests.onsyncfrompreference.pref3", type: "int" },
type="int"/> ]);
<preference id="tests.onsyncfrompreference.pref3" ]]>
name="tests.onsyncfrompreference.pref3" </script>
type="int"/> <vbox id="sample_pane" class="prefpane" label="Sample Prefpane">
</preferences> </vbox>
</prefpane>
<label>Test Prefpane</label> <label>Test Prefpane</label>
<checkbox id="check1" label="Label1" <checkbox id="check1" label="Label1"
preference="tests.onsyncfrompreference.pref1" preference="tests.onsyncfrompreference.pref1"
@@ -39,4 +39,4 @@
preference="tests.onsyncfrompreference.pref3" preference="tests.onsyncfrompreference.pref3"
onsyncfrompreference="return window.arguments[0]();" onsyncfrompreference="return window.arguments[0]();"
onsynctopreference="return 1;"/> onsynctopreference="return 1;"/>
</prefwindow> </dialog>

View File

@@ -3,6 +3,10 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this - License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE bindings [
<!ENTITY % globalKeysDTD SYSTEM "chrome://global/locale/globalKeys.dtd">
%globalKeysDTD;
]>
<bindings id="dialogBindings" <bindings id="dialogBindings"
xmlns="http://www.mozilla.org/xbl" xmlns="http://www.mozilla.org/xbl"
@@ -40,6 +44,16 @@
<xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/> <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
#endif #endif
</xul:hbox> </xul:hbox>
<xul:keyset>
<xul:key phase="capturing" oncommand="document.documentElement.openHelp(event)"
#ifdef XP_MACOSX
key="&openHelpMac.commandkey;" modifiers="accel"/>
#else
keycode="&openHelp.commandkey;"/>
#endif
</xul:keyset>
</content> </content>
<implementation> <implementation>
@@ -209,6 +223,20 @@
</body> </body>
</method> </method>
<method name="openHelp">
<parameter name="event"/>
<body>
<![CDATA[
var helpButton = document.documentElement.getButton("help");
if (helpButton.disabled || helpButton.hidden)
return;
this._fireButtonEvent("help");
event.stopPropagation();
event.preventDefault();
]]>
</body>
</method>
<property name="mStrBundle"> <property name="mStrBundle">
<getter> <getter>
<![CDATA[ <![CDATA[

File diff suppressed because it is too large Load Diff

View File

@@ -1015,56 +1015,6 @@ wizardpage {
-moz-binding: url("chrome://global/content/bindings/wizard.xml#wizard-buttons"); -moz-binding: url("chrome://global/content/bindings/wizard.xml#wizard-buttons");
} }
/********** preferences ********/
prefwindow,
prefwindow:root /* override :root from above */ {
-moz-binding: url("chrome://global/content/bindings/preferences.xml#prefwindow");
-moz-box-orient: vertical;
}
prefpane {
-moz-binding: url("chrome://global/content/bindings/preferences.xml#prefpane");
-moz-box-orient: vertical;
}
prefwindow > .paneDeckContainer {
overflow: hidden;
}
prefpane > .content-box {
overflow: hidden;
}
prefwindow[type="child"] > .paneDeckContainer {
overflow: -moz-hidden-unscrollable;
}
prefwindow[type="child"] > prefpane > .content-box {
-moz-box-flex: 1;
overflow: -moz-hidden-unscrollable;
}
preferences {
-moz-binding: url("chrome://global/content/bindings/preferences.xml#preferences");
visibility: collapse;
}
preference {
-moz-binding: url("chrome://global/content/bindings/preferences.xml#preference");
visibility: collapse;
}
radio[pane] {
-moz-binding: url("chrome://global/content/bindings/preferences.xml#panebutton") !important;
-moz-box-orient: vertical;
-moz-box-align: center;
}
prefwindow[chromehidden~="toolbar"] .chromeclass-toolbar {
display: none;
}
/********** expander ********/ /********** expander ********/
expander { expander {

View File

@@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from ../../content/preferencesBindings.js */
var FontBuilder = { var FontBuilder = {
_enumerator: null, _enumerator: null,
get enumerator() { get enumerator() {
@@ -91,7 +93,7 @@ var FontBuilder = {
// - there is no setting // - there is no setting
// - the font selected by the user is no longer present (e.g. deleted from // - the font selected by the user is no longer present (e.g. deleted from
// fonts folder) // fonts folder)
const preference = document.getElementById(aElement.getAttribute("preference")); const preference = Preferences.get(aElement.getAttribute("preference"));
if (preference.value) { if (preference.value) {
const fontItems = aElement.getElementsByAttribute("value", preference.value); const fontItems = aElement.getElementsByAttribute("value", preference.value);

View File

@@ -41,8 +41,7 @@ progressmeter[mode="undetermined"] {
window, window,
page, page,
dialog, dialog,
wizard, wizard {
prefwindow {
-moz-appearance: window; -moz-appearance: window;
background-color: -moz-Dialog; background-color: -moz-Dialog;
color: -moz-DialogText; color: -moz-DialogText;

View File

@@ -23,7 +23,6 @@ toolkit.jar:
* skin/classic/global/notification.css * skin/classic/global/notification.css
skin/classic/global/numberbox.css skin/classic/global/numberbox.css
skin/classic/global/popup.css skin/classic/global/popup.css
skin/classic/global/preferences.css
skin/classic/global/printPreview.css skin/classic/global/printPreview.css
skin/classic/global/radio.css skin/classic/global/radio.css
skin/classic/global/scrollbox.css skin/classic/global/scrollbox.css

View File

@@ -1,62 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* ===== preferences.css =====================================================
== Styles used by the XUL prefwindow element.
======================================================================= */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* ::::: dialog ::::: */
prefwindow {
padding: 0px;
}
prefpane {
padding: 8px;
}
prefwindow[type="child"] {
padding: 8px;
}
prefwindow[type="child"] > prefpane {
padding: 0px;
}
.prefWindow-dlgbuttons {
padding-bottom: 8px;
padding-inline-start: 8px;
padding-inline-end: 8px;
}
prefwindow[type="child"] .prefWindow-dlgbuttons {
padding: 0px;
}
radio[pane] {
-moz-appearance: none;
min-width: 4.5em;
margin: 0;
padding: 3px;
color: -moz-FieldText;
}
.paneSelector {
-moz-appearance: listbox;
margin: 8px 8px 0 8px;
padding: 0;
}
.paneButtonIcon {
width: 32px;
height: 32px;
}
radio[pane][selected="true"] {
background-color: Highlight;
color: HighlightText;
}

View File

@@ -17,7 +17,6 @@ toolkit.jar:
skin/classic/global/menulist.css (global/empty.css) skin/classic/global/menulist.css (global/empty.css)
skin/classic/global/numberbox.css (global/empty.css) skin/classic/global/numberbox.css (global/empty.css)
skin/classic/global/popup.css (global/empty.css) skin/classic/global/popup.css (global/empty.css)
skin/classic/global/preferences.css (global/empty.css)
skin/classic/global/progressmeter.css (global/empty.css) skin/classic/global/progressmeter.css (global/empty.css)
skin/classic/global/radio.css (global/empty.css) skin/classic/global/radio.css (global/empty.css)
skin/classic/global/resizer.css (global/empty.css) skin/classic/global/resizer.css (global/empty.css)

View File

@@ -30,21 +30,13 @@ menulist > menupopup {
window, window,
page, page,
dialog, dialog,
wizard, wizard {
prefwindow {
-moz-appearance: dialog; -moz-appearance: dialog;
background-color: #FFFFFF; background-color: #FFFFFF;
color: -moz-DialogText; color: -moz-DialogText;
font: message-box; font: message-box;
} }
prefwindow[type="child"] {
padding-top: 18px;
padding-bottom: 15px;
padding-inline-start: 18px;
padding-inline-end: 20px;
}
/* deprecated */ /* deprecated */
window.dialog { window.dialog {
padding-top: 8px; padding-top: 8px;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

View File

@@ -25,7 +25,6 @@ toolkit.jar:
skin/classic/global/netError.css skin/classic/global/netError.css
skin/classic/global/numberbox.css skin/classic/global/numberbox.css
skin/classic/global/popup.css skin/classic/global/popup.css
skin/classic/global/preferences.css
skin/classic/global/progressmeter.css skin/classic/global/progressmeter.css
skin/classic/global/radio.css skin/classic/global/radio.css
skin/classic/global/resizer.css skin/classic/global/resizer.css
@@ -71,8 +70,6 @@ toolkit.jar:
skin/classic/global/icons/glyph-dropdown.png (icons/glyph-dropdown.png) skin/classic/global/icons/glyph-dropdown.png (icons/glyph-dropdown.png)
skin/classic/global/icons/glyph-dropdown@2x.png (icons/glyph-dropdown@2x.png) skin/classic/global/icons/glyph-dropdown@2x.png (icons/glyph-dropdown@2x.png)
skin/classic/global/icons/notfound.png (icons/notfound.png) skin/classic/global/icons/notfound.png (icons/notfound.png)
skin/classic/global/icons/panebutton-active.png (icons/panebutton-active.png)
skin/classic/global/icons/panebutton-inactive.png (icons/panebutton-inactive.png)
skin/classic/global/icons/panel-dropmarker.png (icons/panel-dropmarker.png) skin/classic/global/icons/panel-dropmarker.png (icons/panel-dropmarker.png)
skin/classic/global/icons/resizer.png (icons/resizer.png) skin/classic/global/icons/resizer.png (icons/resizer.png)
skin/classic/global/icons/resizer@2x.png (icons/resizer@2x.png) skin/classic/global/icons/resizer@2x.png (icons/resizer@2x.png)

View File

@@ -1,59 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
prefwindow {
padding: 0;
font: -moz-dialog !important;
}
prefpane {
padding: 12px 12px 0 12px;
}
prefwindow[type="child"] > prefpane {
padding: 0;
}
.prefWindow-dlgbuttons {
margin: 0 12px 12px;
padding-top: 0 !important;
}
.paneSelector {
font: message-box;
padding: 1px 4px;
-moz-appearance: toolbar;
margin: 0;
}
radio[pane] {
border: solid transparent;
border-width: 0 2px;
padding: 5px 4px 3px;
margin: 0;
-moz-appearance: none;
text-shadow: rgba(255, 255, 255, 0.4) 0 1px;
}
radio[pane]:active:hover {
text-shadow: none;
}
radio[pane]:active:hover > .paneButtonIcon {
filter: brightness(0.55);
}
radio[pane][selected="true"] {
-moz-border-image: url("chrome://global/skin/icons/panebutton-active.png") 0 2 fill repeat stretch;
}
radio[pane][selected="true"]:-moz-window-inactive {
-moz-border-image: url("chrome://global/skin/icons/panebutton-inactive.png") 0 2 fill repeat stretch;
}
.paneButtonLabel {
margin: 0 !important;
}

View File

@@ -94,10 +94,6 @@ xul|caption xul|label {
overflow: auto; overflow: auto;
} }
xul|prefpane > xul|*.content-box {
overflow: visible;
}
/* groupboxes */ /* groupboxes */
xul|groupbox { xul|groupbox {

View File

@@ -37,8 +37,7 @@ menulist > menupopup {
window, window,
page, page,
dialog, dialog,
wizard, wizard {
prefwindow {
-moz-appearance: window; -moz-appearance: window;
background-color: -moz-Dialog; background-color: -moz-Dialog;
color: -moz-DialogText; color: -moz-DialogText;

View File

@@ -24,7 +24,6 @@ toolkit.jar:
skin/classic/global/netError.css skin/classic/global/netError.css
skin/classic/global/numberbox.css skin/classic/global/numberbox.css
* skin/classic/global/notification.css * skin/classic/global/notification.css
skin/classic/global/preferences.css
skin/classic/global/printPageSetup.css skin/classic/global/printPageSetup.css
skin/classic/global/printPreview.css skin/classic/global/printPreview.css
skin/classic/global/scrollbox.css skin/classic/global/scrollbox.css

View File

@@ -1,76 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* ===== preferences.css =====================================================
== Styles used by the XUL prefwindow element.
======================================================================= */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* ::::: dialog ::::: */
prefwindow {
padding: 0px;
}
prefpane {
padding-top: 8px;
padding-bottom: 10px;
padding-inline-start: 8px;
padding-inline-end: 10px;
}
prefwindow[type="child"] {
padding-top: 8px;
padding-bottom: 10px;
padding-inline-start: 8px;
padding-inline-end: 10px;
}
prefwindow[type="child"] > prefpane {
padding: 0px;
}
.prefWindow-dlgbuttons {
padding-bottom: 10px;
padding-inline-start: 8px;
padding-inline-end: 10px;
}
prefwindow[type="child"] .prefWindow-dlgbuttons {
padding: 0px;
}
radio[pane] {
-moz-appearance: none;
margin: 0px 1px 0px 1px;
padding: 1px 3px 1px 3px;
min-width: 4.5em;
}
.paneSelector {
border-bottom: 2px groove ThreeDFace;
margin: 0px;
padding-inline-start: 10px;
background-color: -moz-Field;
color: -moz-FieldText;
}
.paneButtonIcon {
width: 32px;
height: 32px;
}
radio[pane]:hover {
background-color: #E0E8F6;
color: black;
-moz-appearance: none;
}
radio[pane][selected="true"] {
background-color: #C1D2EE;
color: black;
-moz-appearance: none;
}