diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /toolkit/components/utils/test/browser/browser_ClientEnvironment.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/utils/test/browser/browser_ClientEnvironment.js')
-rw-r--r-- | toolkit/components/utils/test/browser/browser_ClientEnvironment.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/toolkit/components/utils/test/browser/browser_ClientEnvironment.js b/toolkit/components/utils/test/browser/browser_ClientEnvironment.js new file mode 100644 index 0000000000..a5f252a13f --- /dev/null +++ b/toolkit/components/utils/test/browser/browser_ClientEnvironment.js @@ -0,0 +1,50 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/* + * This can't be an xpcshell-test because not all applications implement + * nsIXULAppInfo (e.g. xpcshell doesn't). + */ +const { ClientEnvironmentBase } = ChromeUtils.import( + "resource://gre/modules/components-utils/ClientEnvironment.jsm" +); + +const { NormandyTestUtils } = ChromeUtils.import( + "resource://testing-common/NormandyTestUtils.jsm" +); + +add_task(function testBuildId() { + ok( + ClientEnvironmentBase.appinfo !== undefined, + "appinfo should be available in the context" + ); + ok( + typeof ClientEnvironmentBase.appinfo === "object", + "appinfo should be an object" + ); + ok( + typeof ClientEnvironmentBase.appinfo.appBuildID === "string", + "buildId should be a string" + ); +}); + +add_task(async function testRandomizationId() { + // Should generate an id if none is set + await SpecialPowers.clearUserPref("app.normandy.user_id"); + ok( + NormandyTestUtils.isUuid(ClientEnvironmentBase.randomizationId), + "randomizationId should be available" + ); + + // Should read the right preference + await SpecialPowers.pushPrefEnv({ + set: [["app.normandy.user_id", "fake id"]], + }); + is( + ClientEnvironmentBase.randomizationId, + "fake id", + "randomizationId should read from preferences" + ); +}); |