summaryrefslogtreecommitdiffstats
path: root/browser/components/enterprisepolicies/Policies.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/enterprisepolicies/Policies.sys.mjs')
-rw-r--r--browser/components/enterprisepolicies/Policies.sys.mjs31
1 files changed, 21 insertions, 10 deletions
diff --git a/browser/components/enterprisepolicies/Policies.sys.mjs b/browser/components/enterprisepolicies/Policies.sys.mjs
index cb15d441a6..21c5bfaa67 100644
--- a/browser/components/enterprisepolicies/Policies.sys.mjs
+++ b/browser/components/enterprisepolicies/Policies.sys.mjs
@@ -1797,7 +1797,9 @@ export var Policies = {
Services.prefs.unlockPref(preference);
}
try {
- switch (typeof param[preference].Value) {
+ let prefType =
+ param[preference].Type || typeof param[preference].Value;
+ switch (prefType) {
case "boolean":
prefBranch.setBoolPref(preference, param[preference].Value);
break;
@@ -1807,14 +1809,9 @@ export var Policies = {
throw new Error(`Non-integer value for ${preference}`);
}
- // This is ugly, but necessary. On Windows GPO and macOS
- // configs, booleans are converted to 0/1. In the previous
- // Preferences implementation, the schema took care of
- // automatically converting these values to booleans.
- // Since we allow arbitrary prefs now, we have to do
- // something different. See bug 1666836.
- // Even uglier, because pdfjs prefs are set async, we need
- // to get their type from PdfJsDefaultPreferences.
+ // Because pdfjs prefs are set async, we can't check the
+ // default pref branch to see if they are int or bool, so we
+ // have to get their type from PdfJsDefaultPreferences.
if (preference.startsWith("pdfjs.")) {
let preferenceTail = preference.replace("pdfjs.", "");
if (
@@ -1829,7 +1826,21 @@ export var Policies = {
!!param[preference].Value
);
}
- } else if (
+ break;
+ }
+
+ // This is ugly, but necessary. On Windows GPO and macOS
+ // configs, booleans are converted to 0/1. In the previous
+ // Preferences implementation, the schema took care of
+ // automatically converting these values to booleans.
+ // Since we allow arbitrary prefs now, we have to do
+ // something different. See bug 1666836, 1668374, and 1872267.
+
+ // We only set something as int if it was explicit in policy,
+ // the same type as the default pref, or NOT 0/1. Otherwise
+ // we set it as bool.
+ if (
+ param[preference].Type == "number" ||
prefBranch.getPrefType(preference) == prefBranch.PREF_INT ||
![0, 1].includes(param[preference].Value)
) {