From f3bcaf9f88aad2c423ebcd61121562f9834187d4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 8 Apr 2024 17:11:27 +0200 Subject: Merging upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- .../components/enterprisepolicies/Policies.sys.mjs | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'browser/components/enterprisepolicies/Policies.sys.mjs') 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) ) { -- cgit v1.2.3