From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../telemetry/tests/unit/test_TelemetryUtils.js | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 toolkit/components/telemetry/tests/unit/test_TelemetryUtils.js (limited to 'toolkit/components/telemetry/tests/unit/test_TelemetryUtils.js') 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..fd4cf5304f --- /dev/null +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryUtils.js @@ -0,0 +1,39 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const { Preferences } = ChromeUtils.importESModule( + "resource://gre/modules/Preferences.sys.mjs" +); +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 (Preferences.has(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. + Preferences.set(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"; + Preferences.set( + 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." + ); +}); -- cgit v1.2.3