commit 7f7c96f16bc5e6f045bcd1bb3cfdf7974f30903e
parent 66b92d074cc35c9b5b2a1e311908faf46c74b1e1
Author: Tom Ritter <tom@mozilla.com>
Date: Mon, 29 Dec 2025 20:28:58 +0000
Bug 2005865: Add a test for the linux distro metric r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D276928
Diffstat:
2 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser.toml b/toolkit/components/resistfingerprinting/tests/browser/browser.toml
@@ -82,6 +82,9 @@ support-files = ["file_pdf.pdf"]
["browser_usercharacteristics_gamepads.js"]
+["browser_usercharacteristics_linux_distro.js"]
+skip-if = ["os != 'linux'"]
+
["browser_worker_granular_overrides.js"]
["browser_worker_overrides.js"]
diff --git a/toolkit/components/resistfingerprinting/tests/browser/browser_usercharacteristics_linux_distro.js b/toolkit/components/resistfingerprinting/tests/browser/browser_usercharacteristics_linux_distro.js
@@ -0,0 +1,55 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+const emptyPage =
+ getRootDirectory(gTestPath).replace(
+ "chrome://mochitests/content",
+ "https://example.com"
+ ) + "empty.html";
+
+add_task(async function test_linux_distro_metrics() {
+ info("Testing Linux distribution metrics");
+
+ await BrowserTestUtils.withNewTab({ gBrowser, url: emptyPage }, () =>
+ GleanPings.userCharacteristics.testSubmission(
+ () => {
+ // Test os_distro metric
+ const osDistro = Glean.characteristics.osDistro.testGetValue();
+ Assert.ok(osDistro, "os_distro should have a value on Linux");
+ Assert.notEqual(osDistro, "", "os_distro should not be empty on Linux");
+ info(`os_distro: ${osDistro}`);
+
+ // Test os_distro_version metric
+ const osDistroVersion =
+ Glean.characteristics.osDistroVersion.testGetValue();
+ Assert.ok(
+ osDistroVersion,
+ "os_distro_version should have a value on Linux"
+ );
+ Assert.notEqual(
+ osDistroVersion,
+ "",
+ "os_distro_version should not be empty on Linux"
+ );
+ info(`os_distro_version: ${osDistroVersion}`);
+
+ // Test os_distro_id metric (may be empty if MOZ_DISTRIBUTION_ID not set)
+ const osDistroId = Glean.characteristics.osDistroId.testGetValue();
+ info(`os_distro_id: ${osDistroId || "(not set)"}`);
+ },
+ async () => {
+ const populated = TestUtils.topicObserved(
+ "user-characteristics-populating-data-done",
+ () => true
+ );
+ Services.obs.notifyObservers(
+ null,
+ "user-characteristics-testing-please-populate-data"
+ );
+ await populated;
+ GleanPings.userCharacteristics.submit();
+ }
+ )
+ );
+});