3 /* import-globals-from trr_common.js */
5 // Allow telemetry probes which may otherwise be disabled for some
6 // applications (e.g. Thunderbird).
7 Services
.prefs
.setBoolPref(
8 "toolkit.telemetry.testing.overrideProductsCheck",
12 const { TelemetryTestUtils
} = ChromeUtils
.importESModule(
13 "resource://testing-common/TelemetryTestUtils.sys.mjs"
17 h2Port
= trr_test_setup();
21 registerCleanupFunction(async () => {
25 async
function trrLookup(mode
, rolloutMode
) {
26 let hist
= TelemetryTestUtils
.getAndClearKeyedHistogram(
27 "TRR_SKIP_REASON_TRR_FIRST2"
31 info("Testing doh-rollout.mode");
32 setModeAndURI(0, "doh?responseIP=2.2.2.2");
33 Services
.prefs
.setIntPref("doh-rollout.mode", rolloutMode
);
35 setModeAndURI(mode
, "doh?responseIP=2.2.2.2");
38 Services
.dns
.clearCache(true);
39 await
new TRRDNSListener("test.example.com", "2.2.2.2");
40 let expectedKey
= `(other)_${mode}`;
42 expectedKey
= "(other)";
45 let snapshot
= hist
.snapshot();
46 await TestUtils
.waitForCondition(() => {
47 snapshot
= hist
.snapshot();
48 info("snapshot:" + JSON
.stringify(snapshot
));
51 TelemetryTestUtils
.assertKeyedHistogramValue(
54 Ci
.nsITRRSkipReason
.TRR_OK
,
59 add_task(async
function test_trr_lookup_mode_2() {
60 await
trrLookup(Ci
.nsIDNSService
.MODE_TRRFIRST
);
63 add_task(async
function test_trr_lookup_mode_3() {
64 await
trrLookup(Ci
.nsIDNSService
.MODE_TRRONLY
);
67 add_task(async
function test_trr_lookup_mode_0() {
69 Ci
.nsIDNSService
.MODE_NATIVEONLY
,
70 Ci
.nsIDNSService
.MODE_TRRFIRST
74 async
function trrByTypeLookup(trrURI
, expectedSuccess
, expectedSkipReason
) {
75 Services
.prefs
.setIntPref(
77 Ci
.nsIDNSService
.MODE_NATIVEONLY
80 let hist
= TelemetryTestUtils
.getAndClearKeyedHistogram(
81 "TRR_RELEVANT_SKIP_REASON_TRR_FIRST_TYPE_REC"
84 setModeAndURI(Ci
.nsIDNSService
.MODE_TRRFIRST
, trrURI
);
86 Services
.dns
.clearCache(true);
87 await
new TRRDNSListener("test.httpssvc.com", {
88 type
: Ci
.nsIDNSService
.RESOLVE_TYPE_HTTPSSVC
,
91 let expectedKey
= `(other)_2`;
93 let snapshot
= hist
.snapshot();
94 await TestUtils
.waitForCondition(() => {
95 snapshot
= hist
.snapshot();
96 info("snapshot:" + JSON
.stringify(snapshot
));
100 TelemetryTestUtils
.assertKeyedHistogramValue(
108 add_task(async
function test_trr_by_type_lookup_success() {
109 await
trrByTypeLookup("httpssvc", true, Ci
.nsITRRSkipReason
.TRR_OK
);
112 add_task(async
function test_trr_by_type_lookup_fail() {
113 await
trrByTypeLookup(
114 "doh?responseIP=none",
116 Ci
.nsITRRSkipReason
.TRR_NO_ANSWERS