commit 108e1f9c56e95071f7cb719b12672fa30e58541d
parent 9785718795ad1b98525e8efbc1b1a603d2f92cef
Author: Valentin Gosu <valentin.gosu@gmail.com>
Date: Tue, 16 Dec 2025 08:47:58 +0000
Bug 2005731 - Fix doh/ tests r=necko-reviewers,sunil
Differential Revision: https://phabricator.services.mozilla.com/D276319
Diffstat:
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/toolkit/components/doh/test/unit/head.js b/toolkit/components/doh/test/unit/head.js
@@ -4,6 +4,8 @@
"use strict";
+/* globals TRRServer */
+
const { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
@@ -11,7 +13,7 @@ const { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
-let h2Port, trrServer1, trrServer2, trrList;
+let trrServer, trrServer1, trrServer2, trrList;
let DNSLookup, LookupAggregator, TRRRacer;
function readFile(file) {
@@ -42,19 +44,18 @@ async function ensureNoTelemetry() {
);
}
-function setup() {
- h2Port = Services.env.get("MOZHTTP2_PORT");
- Assert.notEqual(h2Port, null);
- Assert.notEqual(h2Port, "");
-
+async function setup() {
// Set to allow the cert presented by our H2 server
do_get_profile();
+ trrServer = new TRRServer();
+ await trrServer.start();
+
Services.prefs.setBoolPref("network.http.http2.enabled", true);
// use the h2 server as DOH provider
- trrServer1 = `https://foo.example.com:${h2Port}/doh?responseIP=1.1.1.1`;
- trrServer2 = `https://foo.example.com:${h2Port}/doh?responseIP=2.2.2.2`;
+ trrServer1 = `https://foo.example.com:${trrServer.port()}/doh?responseIP=1.1.1.1`;
+ trrServer2 = `https://foo.example.com:${trrServer.port()}/doh?responseIP=2.2.2.2`;
trrList = [trrServer1, trrServer2];
// make all native resolve calls "secretly" resolve localhost instead
Services.prefs.setBoolPref("network.dns.native-is-localhost", true);
@@ -89,10 +90,14 @@ function setup() {
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
- registerCleanupFunction(() => {
+ registerCleanupFunction(async () => {
Services.prefs.clearUserPref("network.http.http2.enabled");
Services.prefs.clearUserPref("network.dns.native-is-localhost");
Services.telemetry.canRecordExtended = oldCanRecord;
+
+ if (trrServer) {
+ await trrServer.stop();
+ }
});
}
diff --git a/toolkit/components/doh/test/unit/test_DNSLookup.js b/toolkit/components/doh/test/unit/test_DNSLookup.js
@@ -48,7 +48,7 @@ add_task(async function test_FailedDNSLookup() {
let deferred = Promise.withResolvers();
let lookup = new DNSLookup(
null,
- `https://foo.example.com:${h2Port}/doh?responseIP=none`,
+ `https://foo.example.com:${trrServer.port()}/doh?responseIP=none`,
(request, record, status, usedDomain, retryCount) => {
deferred.resolve({ request, record, status, usedDomain, retryCount });
}
diff --git a/toolkit/components/doh/test/unit/xpcshell.toml b/toolkit/components/doh/test/unit/xpcshell.toml
@@ -1,5 +1,5 @@
[DEFAULT]
-head = "head.js"
+head = "../../../../../netwerk/test/unit/head_trr.js head.js"
firefox-appdir = "browser"
support-files = ["../../../../../netwerk/test/unit/http2-ca.pem"]