diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/telemetry/tests/unit/test_TelemetryUtils.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/telemetry/tests/unit/test_TelemetryUtils.js')
-rw-r--r-- | toolkit/components/telemetry/tests/unit/test_TelemetryUtils.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryUtils.js b/toolkit/components/telemetry/tests/unit/test_TelemetryUtils.js new file mode 100644 index 0000000000..6ac7944a0a --- /dev/null +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryUtils.js @@ -0,0 +1,46 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const { TelemetryUtils } = ChromeUtils.importESModule( + "resource://gre/modules/TelemetryUtils.sys.mjs" +); +const { UpdateUtils } = ChromeUtils.importESModule( + "resource://gre/modules/UpdateUtils.sys.mjs" +); + +add_task(async function testUpdateChannelOverride() { + if ( + Services.prefs.prefHasDefaultValue( + TelemetryUtils.Preferences.OverrideUpdateChannel + ) || + Services.prefs.prefHasUserValue( + TelemetryUtils.Preferences.OverrideUpdateChannel + ) + ) { + // If the pref is already set at this point, the test is running in a build + // that makes use of the override pref. For testing purposes, unset the pref. + Services.prefs.setStringPref( + TelemetryUtils.Preferences.OverrideUpdateChannel, + "" + ); + } + + // Check that we return the same channel as UpdateUtils, by default + Assert.equal( + TelemetryUtils.getUpdateChannel(), + UpdateUtils.getUpdateChannel(false), + "The telemetry reported channel must match the one from UpdateChannel, by default." + ); + + // Now set the override pref and check that we return the correct channel + const OVERRIDE_TEST_CHANNEL = "nightly-test"; + Services.prefs.setStringPref( + TelemetryUtils.Preferences.OverrideUpdateChannel, + OVERRIDE_TEST_CHANNEL + ); + Assert.equal( + TelemetryUtils.getUpdateChannel(), + OVERRIDE_TEST_CHANNEL, + "The telemetry reported channel must match the override pref when pref is set." + ); +}); |