Bug 1566998 - Improve awaiting new TRRDNSListener by returning an object r=necko-reviewers,kershaw

It's nicer to destructure the response using
`let {inRecord, inStatus} = await new TRRDNSListener(...)`
instead of
`let [,inRecord,inStatus] = await new TRRDNSListener(...)`

Differential Revision: https://phabricator.services.mozilla.com/D130042
This commit is contained in:
Valentin Gosu 2021-11-09 16:41:44 +00:00
Родитель 272f24ea0c
Коммит 37f236afbe
18 изменённых файлов: 92 добавлений и 96 удалений

Просмотреть файл

@ -153,7 +153,7 @@ class TRRDNSListener {
Assert.ok(!this.options.expectEarlyFail); Assert.ok(!this.options.expectEarlyFail);
} catch (e) { } catch (e) {
Assert.ok(this.options.expectEarlyFail); Assert.ok(this.options.expectEarlyFail);
this.resolve([e]); this.resolve({ error: e });
} }
} }
@ -166,14 +166,14 @@ class TRRDNSListener {
// If we don't expect success here, just resolve and the caller will // If we don't expect success here, just resolve and the caller will
// decide what to do with the results. // decide what to do with the results.
if (!this.expectedSuccess) { if (!this.expectedSuccess) {
this.resolve([inRequest, inRecord, inStatus]); this.resolve({ inRequest, inRecord, inStatus });
return; return;
} }
Assert.equal(inStatus, Cr.NS_OK, "Checking status"); Assert.equal(inStatus, Cr.NS_OK, "Checking status");
if (this.type != Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT) { if (this.type != Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT) {
this.resolve([inRequest, inRecord, inStatus]); this.resolve({ inRequest, inRecord, inStatus });
return; return;
} }
@ -215,7 +215,7 @@ class TRRDNSListener {
} }
} }
this.resolve([inRequest, inRecord, inStatus]); this.resolve({ inRequest, inRecord, inStatus });
} }
QueryInterface(aIID) { QueryInterface(aIID) {

Просмотреть файл

@ -39,7 +39,7 @@ add_task(async function testTXTResolve() {
"https://foo.example.com:" + h2Port + "/doh" "https://foo.example.com:" + h2Port + "/doh"
); );
let [, inRecord] = await new TRRDNSListener("_esni.example.com", { let { inRecord } = await new TRRDNSListener("_esni.example.com", {
type: dns.RESOLVE_TYPE_TXT, type: dns.RESOLVE_TYPE_TXT,
}); });
@ -55,7 +55,7 @@ add_task(async function testTXTRecordPushPart1() {
"network.trr.uri", "network.trr.uri",
"https://foo.example.com:" + h2Port + "/txt-dns-push" "https://foo.example.com:" + h2Port + "/txt-dns-push"
); );
let [, inRecord] = await new TRRDNSListener("_esni_push.example.com", { let { inRecord } = await new TRRDNSListener("_esni_push.example.com", {
type: dns.RESOLVE_TYPE_DEFAULT, type: dns.RESOLVE_TYPE_DEFAULT,
expectedAnswer: "127.0.0.1", expectedAnswer: "127.0.0.1",
}); });
@ -73,7 +73,7 @@ add_task(async function testTXTRecordPushPart2() {
"network.trr.uri", "network.trr.uri",
"https://foo.example.com:" + h2Port + "/404" "https://foo.example.com:" + h2Port + "/404"
); );
let [, inRecord] = await new TRRDNSListener("_esni_push.example.com", { let { inRecord } = await new TRRDNSListener("_esni_push.example.com", {
type: dns.RESOLVE_TYPE_TXT, type: dns.RESOLVE_TYPE_TXT,
}); });

Просмотреть файл

@ -101,7 +101,7 @@ add_task(async function testEchConfigEnabled() {
], ],
}); });
let [, inRecord] = await new TRRDNSListener("test.bar.com", { let { inRecord } = await new TRRDNSListener("test.bar.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); });
@ -125,9 +125,9 @@ add_task(async function testEchConfigEnabled() {
Services.prefs.setBoolPref("network.dns.echconfig.enabled", true); Services.prefs.setBoolPref("network.dns.echconfig.enabled", true);
dns.clearCache(true); dns.clearCache(true);
[, inRecord] = await new TRRDNSListener("test.bar.com", { ({ inRecord } = await new TRRDNSListener("test.bar.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); }));
checkResult(inRecord, false, false, { checkResult(inRecord, false, false, {
expectedPriority: 2, expectedPriority: 2,
@ -203,7 +203,7 @@ add_task(async function testTwoRecordsHaveEchConfig() {
], ],
}); });
let [, inRecord] = await new TRRDNSListener("test.foo.com", { let { inRecord } = await new TRRDNSListener("test.foo.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); });
@ -226,9 +226,9 @@ add_task(async function testTwoRecordsHaveEchConfig() {
Services.prefs.setBoolPref("network.dns.http3_echconfig.enabled", true); Services.prefs.setBoolPref("network.dns.http3_echconfig.enabled", true);
dns.clearCache(true); dns.clearCache(true);
[, inRecord] = await new TRRDNSListener("test.foo.com", { ({ inRecord } = await new TRRDNSListener("test.foo.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); }));
checkResult(inRecord, false, false, { checkResult(inRecord, false, false, {
expectedPriority: 1, expectedPriority: 1,
@ -302,7 +302,7 @@ add_task(async function testTwoRecordsHaveEchConfig1() {
], ],
}); });
let [, inRecord] = await new TRRDNSListener("test.foo.com", { let { inRecord } = await new TRRDNSListener("test.foo.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); });
@ -329,9 +329,9 @@ add_task(async function testTwoRecordsHaveEchConfig1() {
Services.prefs.setBoolPref("network.dns.http3_echconfig.enabled", true); Services.prefs.setBoolPref("network.dns.http3_echconfig.enabled", true);
dns.clearCache(true); dns.clearCache(true);
[, inRecord] = await new TRRDNSListener("test.foo.com", { ({ inRecord } = await new TRRDNSListener("test.foo.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); }));
checkResult(inRecord, false, false, { checkResult(inRecord, false, false, {
expectedPriority: 1, expectedPriority: 1,
@ -405,7 +405,7 @@ add_task(async function testOneRecordsHasEchConfig() {
], ],
}); });
let [, inRecord] = await new TRRDNSListener("test.foo.com", { let { inRecord } = await new TRRDNSListener("test.foo.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); });
@ -428,9 +428,9 @@ add_task(async function testOneRecordsHasEchConfig() {
Services.prefs.setBoolPref("network.dns.http3_echconfig.enabled", true); Services.prefs.setBoolPref("network.dns.http3_echconfig.enabled", true);
dns.clearCache(true); dns.clearCache(true);
[, inRecord] = await new TRRDNSListener("test.foo.com", { ({ inRecord } = await new TRRDNSListener("test.foo.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); }));
checkResult(inRecord, false, false, { checkResult(inRecord, false, false, {
expectedPriority: 1, expectedPriority: 1,
@ -503,7 +503,7 @@ add_task(async function testHttp3AndHttp2Pref() {
], ],
}); });
let [, inRecord] = await new TRRDNSListener("test.foo.com", { let { inRecord } = await new TRRDNSListener("test.foo.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); });

Просмотреть файл

@ -80,7 +80,7 @@ add_task(async function testStoreIPHint() {
], ],
}); });
let [, inRecord] = await new TRRDNSListener("test.IPHint.com", { let { inRecord } = await new TRRDNSListener("test.IPHint.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC, type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
}); });
@ -124,7 +124,7 @@ add_task(async function testStoreIPHint() {
); );
async function verifyAnswer(flags, answer) { async function verifyAnswer(flags, answer) {
let [, inRecord] = await new TRRDNSListener("test.IPHint.com", { let { inRecord } = await new TRRDNSListener("test.IPHint.com", {
flags, flags,
expectedSuccess: false, expectedSuccess: false,
}); });
@ -186,7 +186,7 @@ add_task(async function testConnectionWithIPHint() {
); );
// Resolving test.iphint.com should be failed. // Resolving test.iphint.com should be failed.
let [, , inStatus] = await new TRRDNSListener("test.iphint.com", { let { inStatus } = await new TRRDNSListener("test.iphint.com", {
expectedSuccess: false, expectedSuccess: false,
}); });
Assert.equal( Assert.equal(
@ -265,7 +265,7 @@ add_task(async function testIPHintWithFreshDNS() {
], ],
}); });
let [, inRecord] = await new TRRDNSListener("test.iphint.org", { let { inRecord } = await new TRRDNSListener("test.iphint.org", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); });

Просмотреть файл

@ -79,7 +79,7 @@ add_task(async function testPriorityAndECHConfig() {
], ],
}); });
let [, inRecord] = await new TRRDNSListener("test.priority.com", { let { inRecord } = await new TRRDNSListener("test.priority.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC, type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
}); });
@ -100,9 +100,9 @@ add_task(async function testPriorityAndECHConfig() {
Services.prefs.setBoolPref("network.dns.echconfig.enabled", true); Services.prefs.setBoolPref("network.dns.echconfig.enabled", true);
dns.clearCache(true); dns.clearCache(true);
[, inRecord] = await new TRRDNSListener("test.priority.com", { ({ inRecord } = await new TRRDNSListener("test.priority.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC, type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
}); }));
answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records; answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records;
Assert.equal(answer.length, 4); Assert.equal(answer.length, 4);

Просмотреть файл

@ -61,7 +61,7 @@ add_task(async function testODoHConfig() {
"https://foo.example.com:" + h2Port + "/odohconfig" "https://foo.example.com:" + h2Port + "/odohconfig"
); );
let [, inRecord] = await new TRRDNSListener("odoh_host.example.com", { let { inRecord } = await new TRRDNSListener("odoh_host.example.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC, type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
}); });
let answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records; let answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records;

Просмотреть файл

@ -26,7 +26,7 @@ async function waitForConfirmation(expectedResponseIP, confirmationShouldFail) {
// because of the increased delay between the emulator and host. // because of the increased delay between the emulator and host.
await new Promise(resolve => do_timeout(100 * (100 / count), resolve)); await new Promise(resolve => do_timeout(100 * (100 / count), resolve));
} }
let [, inRecord] = await new TRRDNSListener( let { inRecord } = await new TRRDNSListener(
`ip${count}.example.org`, `ip${count}.example.org`,
undefined, undefined,
false false
@ -341,7 +341,7 @@ add_task(async function test_async_resolve_with_trr_server() {
dns.clearCache(true); dns.clearCache(true);
setModeAndURI(2, "doh?responseIP=2.2.2.2"); setModeAndURI(2, "doh?responseIP=2.2.2.2");
let [, , inStatus] = await new TRRDNSListener( let { inStatus } = await new TRRDNSListener(
"bar_with_trr6.example.com", "bar_with_trr6.example.com",
undefined, undefined,
false, false,
@ -406,13 +406,13 @@ add_task(async function test_async_resolve_with_trr_server() {
dns.clearCache(true); dns.clearCache(true);
setModeAndURI(2, "doh?responseIP=2.2.2.2"); setModeAndURI(2, "doh?responseIP=2.2.2.2");
[, , inStatus] = await new TRRDNSListener( ({ inStatus } = await new TRRDNSListener(
"only_once.example.com", "only_once.example.com",
undefined, undefined,
false, false,
undefined, undefined,
`https://target.example.com:666/404` `https://target.example.com:666/404`
); ));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`

Просмотреть файл

@ -239,7 +239,7 @@ add_task(async function test_parse_additional_section() {
], ],
}); });
let [, inRecord] = await new TRRDNSListener("multiple.foo", { let { inRecord } = await new TRRDNSListener("multiple.foo", {
expectedAnswer: "9.9.9.9", expectedAnswer: "9.9.9.9",
}); });
let IPs = []; let IPs = [];
@ -251,9 +251,9 @@ add_task(async function test_parse_additional_section() {
equal(IPs.length, 1); equal(IPs.length, 1);
equal(IPs[0], "9.9.9.9"); equal(IPs[0], "9.9.9.9");
IPs = []; IPs = [];
[, inRecord] = await new TRRDNSListener("yuiop.foo", { ({ inRecord } = await new TRRDNSListener("yuiop.foo", {
expectedSuccess: false, expectedSuccess: false,
}); }));
inRecord.QueryInterface(Ci.nsIDNSAddrRecord); inRecord.QueryInterface(Ci.nsIDNSAddrRecord);
inRecord.rewind(); inRecord.rewind();
while (inRecord.hasMore()) { while (inRecord.hasMore()) {

Просмотреть файл

@ -57,11 +57,11 @@ add_task(async function unspec_first() {
flags: Ci.nsIDNSService.RESOLVE_DISABLE_IPV6, flags: Ci.nsIDNSService.RESOLVE_DISABLE_IPV6,
expectedAnswer: "1.2.3.4", expectedAnswer: "1.2.3.4",
}); });
let [, , status] = await new TRRDNSListener("example.org", { let { inStatus } = await new TRRDNSListener("example.org", {
flags: Ci.nsIDNSService.RESOLVE_DISABLE_IPV4, flags: Ci.nsIDNSService.RESOLVE_DISABLE_IPV4,
expectedSuccess: false, expectedSuccess: false,
}); });
equal(status, Cr.NS_ERROR_UNKNOWN_HOST); equal(inStatus, Cr.NS_ERROR_UNKNOWN_HOST);
}); });
add_task(async function A_then_AAAA_fails() { add_task(async function A_then_AAAA_fails() {
@ -87,11 +87,11 @@ add_task(async function A_then_AAAA_fails() {
flags: Ci.nsIDNSService.RESOLVE_DISABLE_IPV6, flags: Ci.nsIDNSService.RESOLVE_DISABLE_IPV6,
expectedAnswer: "1.2.3.4", expectedAnswer: "1.2.3.4",
}); });
let [, , status] = await new TRRDNSListener("example.org", { let { inStatus } = await new TRRDNSListener("example.org", {
flags: Ci.nsIDNSService.RESOLVE_DISABLE_IPV4, flags: Ci.nsIDNSService.RESOLVE_DISABLE_IPV4,
expectedSuccess: false, expectedSuccess: false,
}); });
equal(status, Cr.NS_ERROR_UNKNOWN_HOST); equal(inStatus, Cr.NS_ERROR_UNKNOWN_HOST);
}); });
add_task(async function just_AAAA_fails() { add_task(async function just_AAAA_fails() {
@ -113,9 +113,9 @@ add_task(async function just_AAAA_fails() {
], ],
}); });
// We only do an IPv6 req - we expect IPv6 not to fallback to Do53 because we have an IPv4 record // We only do an IPv6 req - we expect IPv6 not to fallback to Do53 because we have an IPv4 record
let [, , status] = await new TRRDNSListener("example.org", { let { inStatus } = await new TRRDNSListener("example.org", {
flags: Ci.nsIDNSService.RESOLVE_DISABLE_IPV4, flags: Ci.nsIDNSService.RESOLVE_DISABLE_IPV4,
expectedSuccess: false, expectedSuccess: false,
}); });
equal(status, Cr.NS_ERROR_UNKNOWN_HOST); equal(inStatus, Cr.NS_ERROR_UNKNOWN_HOST);
}); });

Просмотреть файл

@ -63,7 +63,7 @@ add_task(async function cancel_immediately() {
let r1 = new TRRDNSListener("example.org", { expectedSuccess: false }); let r1 = new TRRDNSListener("example.org", { expectedSuccess: false });
let r2 = new TRRDNSListener("example.org", { expectedAnswer: "2.3.4.5" }); let r2 = new TRRDNSListener("example.org", { expectedAnswer: "2.3.4.5" });
r1.cancel(); r1.cancel();
let [, , inStatus] = await r1; let { inStatus } = await r1;
equal(inStatus, Cr.NS_ERROR_ABORT); equal(inStatus, Cr.NS_ERROR_ABORT);
await r2; await r2;
equal(await trrServer.requestCount("example.org", "A"), 1); equal(await trrServer.requestCount("example.org", "A"), 1);
@ -74,9 +74,9 @@ add_task(async function cancel_immediately() {
r2 = new TRRDNSListener("example.org", { expectedSuccess: false }); r2 = new TRRDNSListener("example.org", { expectedSuccess: false });
r1.cancel(); r1.cancel();
r2.cancel(); r2.cancel();
[, , inStatus] = await r1; ({ inStatus } = await r1);
equal(inStatus, Cr.NS_ERROR_ABORT); equal(inStatus, Cr.NS_ERROR_ABORT);
[, , inStatus] = await r2; ({ inStatus } = await r2);
equal(inStatus, Cr.NS_ERROR_ABORT); equal(inStatus, Cr.NS_ERROR_ABORT);
await new Promise(resolve => do_timeout(50, resolve)); await new Promise(resolve => do_timeout(50, resolve));
equal(await trrServer.requestCount("example.org", "A"), 2); equal(await trrServer.requestCount("example.org", "A"), 2);
@ -100,7 +100,7 @@ add_task(async function cancel_delayed() {
let r2 = new TRRDNSListener("example.com", { expectedAnswer: "1.1.1.1" }); let r2 = new TRRDNSListener("example.com", { expectedAnswer: "1.1.1.1" });
await new Promise(resolve => do_timeout(50, resolve)); await new Promise(resolve => do_timeout(50, resolve));
r1.cancel(); r1.cancel();
let [, , inStatus] = await r1; let { inStatus } = await r1;
equal(inStatus, Cr.NS_ERROR_ABORT); equal(inStatus, Cr.NS_ERROR_ABORT);
await r2; await r2;
}); });

Просмотреть файл

@ -82,7 +82,7 @@ add_task(async function test_follow_cnames_same_response() {
}, },
], ],
}); });
let [, inRecord] = await new TRRDNSListener("something.foo", { let { inRecord } = await new TRRDNSListener("something.foo", {
expectedAnswer: "1.2.3.4", expectedAnswer: "1.2.3.4",
flags: Ci.nsIDNSService.RESOLVE_CANONICAL_NAME, flags: Ci.nsIDNSService.RESOLVE_CANONICAL_NAME,
}); });

Просмотреть файл

@ -54,7 +54,7 @@ add_task(async function intermittent_dns_mode3() {
}, },
], ],
}); });
let [, , inStatus] = await new TRRDNSListener("example.com", { let { inStatus } = await new TRRDNSListener("example.com", {
expectedSuccess: false, expectedSuccess: false,
}); });
equal(inStatus, Cr.NS_ERROR_UNKNOWN_HOST); equal(inStatus, Cr.NS_ERROR_UNKNOWN_HOST);

Просмотреть файл

@ -87,7 +87,7 @@ add_task(async function test_extended_error_bogus() {
}); });
// Check that we don't fall back to DNS // Check that we don't fall back to DNS
let [, , inStatus] = await new TRRDNSListener("a.foo", { let { inStatus } = await new TRRDNSListener("a.foo", {
expectedSuccess: false, expectedSuccess: false,
}); });
Assert.ok( Assert.ok(
@ -116,7 +116,7 @@ add_task(async function test_extended_error_filtered() {
}); });
// Check that we don't fall back to DNS // Check that we don't fall back to DNS
let [, , inStatus] = await new TRRDNSListener("b.foo", { let { inStatus } = await new TRRDNSListener("b.foo", {
expectedSuccess: false, expectedSuccess: false,
}); });
Assert.ok( Assert.ok(
@ -315,7 +315,7 @@ add_task(async function test_only_ipv4_extended_error() {
}, },
], ],
}); });
let [, , inStatus] = await new TRRDNSListener("only.com", { let { inStatus } = await new TRRDNSListener("only.com", {
expectedSuccess: false, expectedSuccess: false,
}); });
Assert.ok( Assert.ok(

Просмотреть файл

@ -49,7 +49,7 @@ add_task(async function testHTTPSSVC() {
); );
} }
let [, inRecord] = await new TRRDNSListener("test.httpssvc.com", { let { inRecord } = await new TRRDNSListener("test.httpssvc.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); });
let answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records; let answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records;
@ -266,7 +266,7 @@ add_task(async function test_aliasform() {
], ],
}); });
let [, , inStatus] = await new TRRDNSListener("no-ip-host.com", { let { inStatus } = await new TRRDNSListener("no-ip-host.com", {
expectedSuccess: false, expectedSuccess: false,
}); });
Assert.ok( Assert.ok(
@ -303,9 +303,9 @@ add_task(async function test_aliasform() {
], ],
}); });
[, , inStatus] = await new TRRDNSListener("loop.com", { ({ inStatus } = await new TRRDNSListener("loop.com", {
expectedSuccess: false, expectedSuccess: false,
}); }));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`
@ -328,9 +328,9 @@ add_task(async function test_aliasform() {
], ],
}); });
[, , inStatus] = await new TRRDNSListener("empty.com", { ({ inStatus } = await new TRRDNSListener("empty.com", {
expectedSuccess: false, expectedSuccess: false,
}); }));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`
@ -371,7 +371,7 @@ add_task(async function test_aliasform() {
], ],
}); });
let [, , inStatus2] = await new TRRDNSListener("multi.com", { let { inStatus: inStatus2 } = await new TRRDNSListener("multi.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false, expectedSuccess: false,
}); });
@ -404,10 +404,10 @@ add_task(async function test_aliasform() {
], ],
}); });
[, , inStatus2] = await new TRRDNSListener("order.com", { ({ inStatus: inStatus2 } = await new TRRDNSListener("order.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false, expectedSuccess: false,
}); }));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus2), !Components.isSuccessCode(inStatus2),
`${inStatus2} should be an error code` `${inStatus2} should be an error code`
@ -433,10 +433,10 @@ add_task(async function test_aliasform() {
], ],
}); });
[, , inStatus2] = await new TRRDNSListener("duplicate.com", { ({ inStatus: inStatus2 } = await new TRRDNSListener("duplicate.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false, expectedSuccess: false,
}); }));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus2), !Components.isSuccessCode(inStatus2),
`${inStatus2} should be an error code` `${inStatus2} should be an error code`
@ -463,10 +463,10 @@ add_task(async function test_aliasform() {
], ],
}); });
[, , inStatus2] = await new TRRDNSListener("mandatory.com", { ({ inStatus: inStatus2 } = await new TRRDNSListener("mandatory.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false, expectedSuccess: false,
}); }));
Assert.ok(!Components.isSuccessCode(inStatus2), `${inStatus2} should fail`); Assert.ok(!Components.isSuccessCode(inStatus2), `${inStatus2} should fail`);
// mandatory svcparam // mandatory svcparam
@ -504,9 +504,9 @@ add_task(async function test_aliasform() {
], ],
}); });
[, , inStatus2] = await new TRRDNSListener("mandatory2.com", { ({ inStatus: inStatus2 } = await new TRRDNSListener("mandatory2.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); }));
Assert.ok(Components.isSuccessCode(inStatus2), `${inStatus2} should succeed`); Assert.ok(Components.isSuccessCode(inStatus2), `${inStatus2} should succeed`);
@ -527,10 +527,10 @@ add_task(async function test_aliasform() {
], ],
}); });
[, , inStatus2] = await new TRRDNSListener("no-alias.com", { ({ inStatus: inStatus2 } = await new TRRDNSListener("no-alias.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false, expectedSuccess: false,
}); }));
Assert.ok(!Components.isSuccessCode(inStatus2), `${inStatus2} should fail`); Assert.ok(!Components.isSuccessCode(inStatus2), `${inStatus2} should fail`);
@ -552,9 +552,9 @@ add_task(async function test_aliasform() {
}); });
let inRecord; let inRecord;
[, inRecord, inStatus2] = await new TRRDNSListener("service.com", { ({ inRecord, inStatus: inStatus2 } = await new TRRDNSListener("service.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); }));
Assert.ok(Components.isSuccessCode(inStatus2), `${inStatus2} should work`); Assert.ok(Components.isSuccessCode(inStatus2), `${inStatus2} should work`);
let answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records; let answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records;
Assert.equal(answer[0].priority, 1); Assert.equal(answer[0].priority, 1);
@ -562,7 +562,7 @@ add_task(async function test_aliasform() {
}); });
add_task(async function testNegativeResponse() { add_task(async function testNegativeResponse() {
let [, , inStatus] = await new TRRDNSListener("negative_test.com", { let { inStatus } = await new TRRDNSListener("negative_test.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false, expectedSuccess: false,
}); });
@ -588,10 +588,10 @@ add_task(async function testNegativeResponse() {
}); });
// Should still be failed because a negative response is from DNS cache. // Should still be failed because a negative response is from DNS cache.
[, , inStatus] = await new TRRDNSListener("negative_test.com", { ({ inStatus } = await new TRRDNSListener("negative_test.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
expectedSuccess: false, expectedSuccess: false,
}); }));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`
@ -605,9 +605,9 @@ add_task(async function testNegativeResponse() {
} }
let inRecord; let inRecord;
[, inRecord, inStatus] = await new TRRDNSListener("negative_test.com", { ({ inRecord, inStatus } = await new TRRDNSListener("negative_test.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); }));
Assert.ok(Components.isSuccessCode(inStatus), `${inStatus} should work`); Assert.ok(Components.isSuccessCode(inStatus), `${inStatus} should work`);
let answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records; let answer = inRecord.QueryInterface(Ci.nsIDNSHTTPSSVCRecord).records;
Assert.equal(answer[0].priority, 1); Assert.equal(answer[0].priority, 1);

Просмотреть файл

@ -96,7 +96,7 @@ add_task(async function test_add_nat64_prefix_to_trr() {
}, },
], ],
}); });
let [, inRecord] = await new TRRDNSListener("xyz.foo", { let { inRecord } = await new TRRDNSListener("xyz.foo", {
expectedSuccess: false, expectedSuccess: false,
}); });

Просмотреть файл

@ -212,7 +212,7 @@ add_task(async function testFallback() {
], ],
}); });
let [, inRecord] = await new TRRDNSListener("test.fallback.com", { let { inRecord } = await new TRRDNSListener("test.fallback.com", {
type: dns.RESOLVE_TYPE_HTTPSSVC, type: dns.RESOLVE_TYPE_HTTPSSVC,
}); });

Просмотреть файл

@ -102,7 +102,7 @@ async function test_A_record() {
setModeAndURI(3, "doh?responseIP=4.4.4.4&auth=true"); setModeAndURI(3, "doh?responseIP=4.4.4.4&auth=true");
Services.prefs.setCharPref("network.trr.credentials", "evil:person"); Services.prefs.setCharPref("network.trr.credentials", "evil:person");
let [, , inStatus] = await new TRRDNSListener( let { inStatus } = await new TRRDNSListener(
"wrong.example.com", "wrong.example.com",
undefined, undefined,
false false
@ -139,7 +139,7 @@ async function test_RFC1918() {
dns.clearCache(true); dns.clearCache(true);
setModeAndURI(3, "doh?responseIP=192.168.0.1"); setModeAndURI(3, "doh?responseIP=192.168.0.1");
let [, , inStatus] = await new TRRDNSListener( let { inStatus } = await new TRRDNSListener(
"rfc1918.example.com", "rfc1918.example.com",
undefined, undefined,
false false
@ -150,11 +150,11 @@ async function test_RFC1918() {
`${inStatus} should be an error code` `${inStatus} should be an error code`
); );
setModeAndURI(3, "doh?responseIP=::ffff:192.168.0.1"); setModeAndURI(3, "doh?responseIP=::ffff:192.168.0.1");
[, , inStatus] = await new TRRDNSListener( ({ inStatus } = await new TRRDNSListener(
"rfc1918-ipv6.example.com", "rfc1918-ipv6.example.com",
undefined, undefined,
false false
); ));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`
@ -209,7 +209,7 @@ async function test_timeout_mode3() {
Services.prefs.setIntPref("network.trr.request_timeout_ms", 10); Services.prefs.setIntPref("network.trr.request_timeout_ms", 10);
Services.prefs.setIntPref("network.trr.request_timeout_mode_trronly_ms", 10); Services.prefs.setIntPref("network.trr.request_timeout_mode_trronly_ms", 10);
let [, , inStatus] = await new TRRDNSListener( let { inStatus } = await new TRRDNSListener(
"timeout.example.com", "timeout.example.com",
undefined, undefined,
false false
@ -238,7 +238,7 @@ async function test_strict_native_fallback() {
Services.prefs.setIntPref("network.trr.request_timeout_ms", 10); Services.prefs.setIntPref("network.trr.request_timeout_ms", 10);
Services.prefs.setIntPref("network.trr.request_timeout_mode_trronly_ms", 10); Services.prefs.setIntPref("network.trr.request_timeout_mode_trronly_ms", 10);
let [, , inStatus] = await new TRRDNSListener( let { inStatus } = await new TRRDNSListener(
"timeout.example.com", "timeout.example.com",
undefined, undefined,
false false
@ -253,7 +253,7 @@ async function test_strict_native_fallback() {
setModeAndURI(2, "doh?responseIP=2.2.2.2"); setModeAndURI(2, "doh?responseIP=2.2.2.2");
Services.prefs.clearUserPref("network.trr.request_timeout_ms"); Services.prefs.clearUserPref("network.trr.request_timeout_ms");
Services.prefs.clearUserPref("network.trr.request_timeout_mode_trronly_ms"); Services.prefs.clearUserPref("network.trr.request_timeout_mode_trronly_ms");
[, , inStatus] = await new TRRDNSListener("closeme.com", undefined, false); ({ inStatus } = await new TRRDNSListener("closeme.com", undefined, false));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`
@ -262,11 +262,11 @@ async function test_strict_native_fallback() {
info("Now a decode error"); info("Now a decode error");
dns.clearCache(true); dns.clearCache(true);
setModeAndURI(2, "doh?responseIP=2.2.2.2&corruptedAnswer=true"); setModeAndURI(2, "doh?responseIP=2.2.2.2&corruptedAnswer=true");
[, , inStatus] = await new TRRDNSListener( ({ inStatus } = await new TRRDNSListener(
"bar.example.com", "bar.example.com",
undefined, undefined,
false false
); ));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`
@ -400,7 +400,7 @@ async function test_CNAME() {
setModeAndURI(3, "doh?responseIP=none&cnameloop=true"); setModeAndURI(3, "doh?responseIP=none&cnameloop=true");
} }
let [, , inStatus] = await new TRRDNSListener( let { inStatus } = await new TRRDNSListener(
"test18.example.com", "test18.example.com",
undefined, undefined,
false false
@ -439,7 +439,7 @@ async function test_name_mismatch() {
// regardless of what was requested. // regardless of what was requested.
setModeAndURI(3, "doh?hostname=mismatch.example.com"); setModeAndURI(3, "doh?hostname=mismatch.example.com");
let [, , inStatus] = await new TRRDNSListener( let { inStatus } = await new TRRDNSListener(
"bar.example.com", "bar.example.com",
undefined, undefined,
false false
@ -718,11 +718,7 @@ async function test_connection_closed() {
await new TRRDNSListener("bar.example.com", "2.2.2.2"); await new TRRDNSListener("bar.example.com", "2.2.2.2");
// makes the TRR connection shut down. // makes the TRR connection shut down.
let [, , inStatus] = await new TRRDNSListener( let { inStatus } = await new TRRDNSListener("closeme.com", undefined, false);
"closeme.com",
undefined,
false
);
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`
@ -739,7 +735,7 @@ async function test_connection_closed() {
await new TRRDNSListener("bar.example.com", "2.2.2.2"); await new TRRDNSListener("bar.example.com", "2.2.2.2");
// makes the TRR connection shut down. // makes the TRR connection shut down.
[, , inStatus] = await new TRRDNSListener("closeme.com", undefined, false); ({ inStatus } = await new TRRDNSListener("closeme.com", undefined, false));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`
@ -755,7 +751,7 @@ async function test_connection_closed() {
await new TRRDNSListener("bar.example.com", "2.2.2.2"); await new TRRDNSListener("bar.example.com", "2.2.2.2");
// makes the TRR connection shut down. // makes the TRR connection shut down.
[, , inStatus] = await new TRRDNSListener("closeme.com", undefined, false); ({ inStatus } = await new TRRDNSListener("closeme.com", undefined, false));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`
@ -774,7 +770,7 @@ async function test_connection_closed() {
await new TRRDNSListener("bar.example.com", "2.2.2.2"); await new TRRDNSListener("bar.example.com", "2.2.2.2");
// makes the TRR connection shut down. // makes the TRR connection shut down.
[, , inStatus] = await new TRRDNSListener("closeme.com", undefined, false); ({ inStatus } = await new TRRDNSListener("closeme.com", undefined, false));
Assert.ok( Assert.ok(
!Components.isSuccessCode(inStatus), !Components.isSuccessCode(inStatus),
`${inStatus} should be an error code` `${inStatus} should be an error code`

Просмотреть файл

@ -15,7 +15,7 @@ let test_answer_addr = "127.0.0.1";
add_task(async function testTXTResolve() { add_task(async function testTXTResolve() {
// use the h2 server as DOH provider // use the h2 server as DOH provider
let [, inRecord, inStatus] = await new TRRDNSListener("_esni.example.com", { let { inRecord, inStatus } = await new TRRDNSListener("_esni.example.com", {
type: dns.RESOLVE_TYPE_TXT, type: dns.RESOLVE_TYPE_TXT,
}); });
Assert.equal(inStatus, Cr.NS_OK, "status OK"); Assert.equal(inStatus, Cr.NS_OK, "status OK");