diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/components/telemetry/tests/unit/test_SocketScalars.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/telemetry/tests/unit/test_SocketScalars.js')
-rw-r--r-- | toolkit/components/telemetry/tests/unit/test_SocketScalars.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/toolkit/components/telemetry/tests/unit/test_SocketScalars.js b/toolkit/components/telemetry/tests/unit/test_SocketScalars.js new file mode 100644 index 0000000000..a685a611b2 --- /dev/null +++ b/toolkit/components/telemetry/tests/unit/test_SocketScalars.js @@ -0,0 +1,49 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ +*/ + +const { TelemetryController } = ChromeUtils.importESModule( + "resource://gre/modules/TelemetryController.sys.mjs" +); +const { ContentTaskUtils } = ChromeUtils.importESModule( + "resource://testing-common/ContentTaskUtils.sys.mjs" +); + +const SOCKET_ONLY_UINT_SCALAR = "telemetry.test.socket_only_uint"; + +/** + * This function waits until socket scalars are reported into the + * scalar snapshot. + */ +async function waitForSocketScalars() { + await ContentTaskUtils.waitForCondition(() => { + const scalars = Telemetry.getSnapshotForScalars("main", false); + return Object.keys(scalars).includes("socket"); + }, "Waiting for socket scalars to have been set"); +} + +add_task(async function test_scalars_in_socket_process() { + Assert.ok( + Services.prefs.getBoolPref("network.process.enabled"), + "Socket process should be enabled" + ); + + do_get_profile(true); + await TelemetryController.testSetup(); + + Services.io.socketProcessTelemetryPing(); + + // Once scalars are set by the socket process, they don't immediately get + // sent to the parent process. Wait for the Telemetry IPC Timer to trigger + // and batch send the data back to the parent process. + // Note: this requires the socket process to be enabled (see bug 1716307). + await waitForSocketScalars(); + + Assert.equal( + Telemetry.getSnapshotForScalars("main", false).socket[ + SOCKET_ONLY_UINT_SCALAR + ], + 42, + `${SOCKET_ONLY_UINT_SCALAR} must have the correct value (socket process).` + ); +}); |