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_RDDScalars.js | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 toolkit/components/telemetry/tests/unit/test_RDDScalars.js (limited to 'toolkit/components/telemetry/tests/unit/test_RDDScalars.js') diff --git a/toolkit/components/telemetry/tests/unit/test_RDDScalars.js b/toolkit/components/telemetry/tests/unit/test_RDDScalars.js new file mode 100644 index 0000000000..e7078012d2 --- /dev/null +++ b/toolkit/components/telemetry/tests/unit/test_RDDScalars.js @@ -0,0 +1,53 @@ +/* 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 RDD_ONLY_UINT_SCALAR = "telemetry.test.rdd_only_uint"; + +const rddProcessTest = () => { + return Cc["@mozilla.org/rdd-process-test;1"].createInstance( + Ci.nsIRddProcessTest + ); +}; + +/** + * This function waits until rdd scalars are reported into the + * scalar snapshot. + */ +async function waitForRddScalars() { + await ContentTaskUtils.waitForCondition(() => { + const scalars = Telemetry.getSnapshotForScalars("main", false); + return Object.keys(scalars).includes("rdd"); + }, "Waiting for rdd scalars to have been set"); +} + +add_setup(async function setup_telemetry_rdd() { + do_get_profile(true); + await TelemetryController.testSetup(); +}); + +add_task(async function test_scalars_in_rdd_process() { + Telemetry.clearScalars(); + const pid = await rddProcessTest().testTelemetryProbes(); + info(`Started some RDD: ${pid}`); + + // Once scalars are set by the rdd 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. + await waitForRddScalars(); + + Assert.equal( + Telemetry.getSnapshotForScalars("main", false).rdd[RDD_ONLY_UINT_SCALAR], + 42, + `${RDD_ONLY_UINT_SCALAR} must have the correct value (rdd process).` + ); + + await rddProcessTest().stopProcess(); +}); -- cgit v1.2.3