summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/test_trr_telemetry.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /netwerk/test/unit/test_trr_telemetry.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/unit/test_trr_telemetry.js')
-rw-r--r--netwerk/test/unit/test_trr_telemetry.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_trr_telemetry.js b/netwerk/test/unit/test_trr_telemetry.js
new file mode 100644
index 0000000000..69f5d59201
--- /dev/null
+++ b/netwerk/test/unit/test_trr_telemetry.js
@@ -0,0 +1,59 @@
+"use strict";
+
+/* import-globals-from trr_common.js */
+
+// Allow telemetry probes which may otherwise be disabled for some
+// applications (e.g. Thunderbird).
+Services.prefs.setBoolPref(
+ "toolkit.telemetry.testing.overrideProductsCheck",
+ true
+);
+
+const { TelemetryTestUtils } = ChromeUtils.importESModule(
+ "resource://testing-common/TelemetryTestUtils.sys.mjs"
+);
+
+function setup() {
+ h2Port = trr_test_setup();
+}
+
+let TRR_OK = 1;
+
+setup();
+registerCleanupFunction(async () => {
+ trr_clear_prefs();
+});
+
+async function trrLookup(mode, rolloutMode) {
+ let hist = TelemetryTestUtils.getAndClearKeyedHistogram(
+ "TRR_SKIP_REASON_TRR_FIRST2"
+ );
+
+ if (rolloutMode) {
+ info("Testing doh-rollout.mode");
+ setModeAndURI(0, "doh?responseIP=2.2.2.2");
+ Services.prefs.setIntPref("doh-rollout.mode", rolloutMode);
+ } else {
+ setModeAndURI(mode, "doh?responseIP=2.2.2.2");
+ }
+
+ Services.dns.clearCache(true);
+ await new TRRDNSListener("test.example.com", "2.2.2.2");
+ let expectedKey = `(other)_${mode}`;
+ if (mode == 0) {
+ expectedKey = "(other)";
+ }
+ TelemetryTestUtils.assertKeyedHistogramValue(hist, expectedKey, TRR_OK, 1);
+}
+
+add_task(async function test_trr_lookup_mode_2() {
+ await trrLookup(2);
+});
+
+add_task(async function test_trr_lookup_mode_3() {
+ await trrLookup(3);
+});
+
+add_task(async function test_trr_lookup_mode_0() {
+ await trrLookup(0, 2);
+});