test_startupTelemetry_launchMethod.js (1239B)
1 /* Any copyright is dedicated to the Public Domain. 2 https://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const { StartupTelemetry } = ChromeUtils.importESModule( 7 "moz-src:///browser/components/StartupTelemetry.sys.mjs" 8 ); 9 10 const ENV_VAR = "FIREFOX_LAUNCHED_BY_DESKTOP_LAUNCHER"; 11 12 add_setup(function test_setup() { 13 // FOG needs a profile directory to put its data in. 14 do_get_profile(); 15 16 // FOG needs to be initialized in order for data to flow. 17 Services.fog.initializeFOG(); 18 }); 19 20 add_task(async function test_not_launched_from_desktop_launcher() { 21 // This test ensures that if the env variable isn't set, we don't mistakenly categorize 22 // startup through desktop launcher 23 await StartupTelemetry.pinningStatus(); 24 25 Assert.notEqual( 26 "DesktopLauncher", 27 Glean.osEnvironment.launchMethod.testGetValue() 28 ); 29 }); 30 31 add_task(async function test_launched_from_desktop_launcher() { 32 // Let's assume that the desktop launcher sets the environment variable correctly. 33 // Set it manually in the test to simulate that behaviour 34 Services.env.set(ENV_VAR, "TRUE"); 35 36 await StartupTelemetry.pinningStatus(); 37 38 Assert.equal( 39 "DesktopLauncher", 40 Glean.osEnvironment.launchMethod.testGetValue() 41 ); 42 });