summaryrefslogtreecommitdiffstats
path: root/browser/components/enterprisepolicies
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:12:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:12:12 +0000
commita7c14e2f29831f4bc5eb18e23e55eb6f7a4e3431 (patch)
tree54617b4f5f04ee87a2c9e3b97cc88b8626859124 /browser/components/enterprisepolicies
parentReleasing progress-linux version 115.7.0esr-1~deb12u1progress7u1. (diff)
downloadfirefox-esr-a7c14e2f29831f4bc5eb18e23e55eb6f7a4e3431.tar.xz
firefox-esr-a7c14e2f29831f4bc5eb18e23e55eb6f7a4e3431.zip
Merging upstream version 115.8.0esr.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/enterprisepolicies')
-rw-r--r--browser/components/enterprisepolicies/Policies.sys.mjs31
-rw-r--r--browser/components/enterprisepolicies/schemas/policies-schema.json4
-rw-r--r--browser/components/enterprisepolicies/tests/xpcshell/head.js5
-rw-r--r--browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js11
4 files changed, 41 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)
) {
diff --git a/browser/components/enterprisepolicies/schemas/policies-schema.json b/browser/components/enterprisepolicies/schemas/policies-schema.json
index 62885837b9..8ff88935dd 100644
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -1131,6 +1131,10 @@
"Status": {
"type": "string",
"enum": ["default", "locked", "user", "clear"]
+ },
+ "Type": {
+ "type": "string",
+ "enum": ["number", "boolean", "string"]
}
}
}
diff --git a/browser/components/enterprisepolicies/tests/xpcshell/head.js b/browser/components/enterprisepolicies/tests/xpcshell/head.js
index 0680e7ece7..1c7c8844fa 100644
--- a/browser/components/enterprisepolicies/tests/xpcshell/head.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/head.js
@@ -132,6 +132,11 @@ function checkDefaultPref(prefName, prefValue) {
Services.prefs.PREF_INVALID,
`Pref ${prefName} is set on the default branch`
);
+ strictEqual(
+ Preferences.get(prefName),
+ prefValue,
+ `Pref ${prefName} has the correct value`
+ );
}
function checkUnsetPref(prefName) {
diff --git a/browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js b/browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js
index 44b77ddc63..eb13fe24ae 100644
--- a/browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js
@@ -64,12 +64,23 @@ const NEW_PREFERENCES_TESTS = [
Value: 11,
Status: "user",
},
+ "browser.policies.test.default.number.implicit": {
+ Value: 0,
+ Status: "default",
+ },
+ "browser.policies.test.default.number.explicit": {
+ Value: 0,
+ Status: "default",
+ Type: "number",
+ },
},
},
defaultPrefs: {
"browser.policies.test.default.boolean": true,
"browser.policies.test.default.string": "string",
"browser.policies.test.default.number": 11,
+ "browser.policies.test.default.number.implicit": false,
+ "browser.policies.test.default.number.explicit": 0,
},
lockedPrefs: {
"browser.policies.test.locked.boolean": true,