From def92d1b8e9d373e2f6f27c366d578d97d8960c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:50 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- .../components/nimbus/lib/ExperimentManager.sys.mjs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'toolkit/components/nimbus/lib/ExperimentManager.sys.mjs') diff --git a/toolkit/components/nimbus/lib/ExperimentManager.sys.mjs b/toolkit/components/nimbus/lib/ExperimentManager.sys.mjs index d0f313a2ae..8bd847b067 100644 --- a/toolkit/components/nimbus/lib/ExperimentManager.sys.mjs +++ b/toolkit/components/nimbus/lib/ExperimentManager.sys.mjs @@ -95,8 +95,8 @@ export class _ExperimentManager { get studiesEnabled() { return ( - Services.prefs.getBoolPref(UPLOAD_ENABLED_PREF) && - Services.prefs.getBoolPref(STUDIES_OPT_OUT_PREF) + Services.prefs.getBoolPref(UPLOAD_ENABLED_PREF, false) && + Services.prefs.getBoolPref(STUDIES_OPT_OUT_PREF, false) ); } @@ -974,7 +974,7 @@ export class _ExperimentManager { // need to check if we have another enrollment for the same feature. const conflictingEnrollment = getConflictingEnrollment(featureId); - for (const [variable, value] of Object.entries(featureValue)) { + for (let [variable, value] of Object.entries(featureValue)) { const setPref = feature.getSetPref(variable); if (setPref) { @@ -1012,6 +1012,13 @@ export class _ExperimentManager { // An experiment takes precedence if there is already a pref set. if (!isRollout || !conflictingPref) { + if ( + lazy.NimbusFeatures[featureId].manifest.variables[variable] + .type === "json" + ) { + value = JSON.stringify(value); + } + prefsToSet.push({ name: prefName, value, @@ -1250,7 +1257,13 @@ export class _ExperimentManager { } } - const value = featuresById[featureId].value[variable]; + let value = featuresById[featureId].value[variable]; + if ( + lazy.NimbusFeatures[featureId].manifest.variables[variable].type === + "json" + ) { + value = JSON.stringify(value); + } if (prefBranch !== "user") { lazy.PrefUtils.setPref(name, value, { branch: prefBranch }); -- cgit v1.2.3