/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Test if we can fallback to the last record sucessfully.
add_task(async function testFallbackToTheLastRecord() {
trrServer = new TRRServer();
await trrServer.start();
await new TRRDNSListener("test.fallback.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
port: h2Port,
});
let chan = makeChan(`https://test.fallback.com:${h2Port}/server-timing`);
let [req] = await channelOpenPromise(chan); // Test if this request is done by h2. Assert.equal(req.getResponseHeader("x-connection-http2"), "yes");
await trrServer.stop();
});
add_task(async function testFallbackToTheOrigin() {
trrServer = new TRRServer();
await trrServer.start();
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setBoolPref( "network.dns.echconfig.fallback_to_origin_when_all_failed", true
);
Services.prefs.setCharPref( "network.trr.uri",
`https://foo.example.com:${trrServer.port()}/dns-query`
);
await new TRRDNSListener("test.foo.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
});
let chan = makeChan(`https://test.foo.com:${h2Port}/server-timing`);
let [req] = await channelOpenPromise(chan); // Test if this request is done by h2. Assert.equal(req.getResponseHeader("x-connection-http2"), "yes");
await trrServer.stop();
});
// Test when all records are failed and network.dns.echconfig.fallback_to_origin // is false. In this case, the connection is always failed.
add_task(async function testAllRecordsFailed() {
trrServer = new TRRServer();
await trrServer.start();
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref( "network.trr.uri",
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref( "network.dns.echconfig.fallback_to_origin_when_all_failed", false
);
await new TRRDNSListener("test.bar.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
});
// This channel should be failed.
let chan = makeChan(`https://test.bar.com:${h2Port}/server-timing`);
await channelOpenPromise(chan, CL_EXPECT_LATE_FAILURE | CL_ALLOW_UNKNOWN_CL);
await trrServer.stop();
});
// Test when all records have no echConfig, we directly fallback to the origin // one.
add_task(async function testFallbackToTheOrigin2() {
trrServer = new TRRServer();
await trrServer.start();
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref( "network.trr.uri",
`https://foo.example.com:${trrServer.port()}/dns-query`
);
// Test when some records have echConfig and some not, we directly fallback to // the origin one.
add_task(async function testFallbackToTheOrigin3() {
Services.dns.clearCache(true);
await new TRRDNSListener("test.reset.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
port: h2Port,
});
// After this request, test.reset1.com and test.reset2.com should be both in // the exclusion list.
let chan = makeChan(`https://test.reset.com:${h2Port}/server-timing`);
await channelOpenPromise(chan, CL_EXPECT_LATE_FAILURE | CL_ALLOW_UNKNOWN_CL);
// This request should be also failed, because all records are excluded.
chan = makeChan(`https://test.reset.com:${h2Port}/server-timing`);
await channelOpenPromise(chan, CL_EXPECT_LATE_FAILURE | CL_ALLOW_UNKNOWN_CL);
// After enable network.dns.httpssvc.reset_exclustion_list and register // A record for test.reset1.com, this request should be succeeded.
chan = makeChan(`https://test.reset.com:${h2Port}/server-timing`);
await channelOpenPromise(chan);
await trrServer.stop();
});
// Simply test if we can connect to H3 server.
add_task(async function testH3Connection() {
trrServer = new TRRServer();
await trrServer.start();
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref( "network.trr.uri",
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
await new TRRDNSListener("test.h3.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
});
let chan = makeChan(`https://test.h3.com`);
let [req] = await channelOpenPromise(chan); Assert.equal(req.protocolVersion, "h3");
let internal = req.QueryInterface(Ci.nsIHttpChannelInternal); Assert.equal(internal.remotePort, h3Port);
await trrServer.stop();
});
add_task(async function testFastfallbackToH2() {
trrServer = new TRRServer();
await trrServer.start();
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref( "network.trr.uri",
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true); // Use a short timeout to make sure the fast fallback timer will be triggered.
Services.prefs.setIntPref( "network.dns.httpssvc.http3_fast_fallback_timeout",
1
);
Services.prefs.setCharPref( "network.dns.localDomains", "test.fastfallback1.com"
);
await new TRRDNSListener("test.fastfallback.com", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
});
let chan = makeChan(`https://test.fastfallback.com/server-timing`);
let [req] = await channelOpenPromise(chan); Assert.equal(req.protocolVersion, "h2");
let internal = req.QueryInterface(Ci.nsIHttpChannelInternal); Assert.equal(internal.remotePort, h2Port);
// Use a longer timeout to test the case that the timer is canceled.
Services.prefs.setIntPref( "network.dns.httpssvc.http3_fast_fallback_timeout",
5000
);
await new TRRDNSListener("test.h3.org", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
});
let chan = makeChan(`https://test.h3.org`);
await channelOpenPromise(chan, CL_EXPECT_LATE_FAILURE | CL_ALLOW_UNKNOWN_CL);
await trrServer.stop();
});
// Test we don't use the service mode record whose domain is in // http3 excluded list.
add_task(async function testHttp3ExcludedList() {
trrServer = new TRRServer();
await trrServer.start();
Services.dns.clearCache(true);
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref( "network.trr.uri",
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
Services.prefs.setIntPref( "network.dns.httpssvc.http3_fast_fallback_timeout",
0
);
// This will fail because there is no address record for www.h3_fail.org.
let chan = makeChan(`https://www.h3_fail.org`);
await channelOpenPromise(chan, CL_EXPECT_LATE_FAILURE | CL_ALLOW_UNKNOWN_CL);
// Test we can connect to www.h3_all_excluded.org sucessfully.
let chan = makeChan(
`https://www.h3_all_excluded.org:${h2Port}/server-timing`
);
let [req] = await channelOpenPromise(chan);
// Test if this request is done by h2. Assert.equal(req.getResponseHeader("x-connection-http2"), "yes");
// This will fail because there is no address record for www.h3_fail1.org.
chan = makeChan(`https://www.h3_fail1.org`);
await channelOpenPromise(chan, CL_EXPECT_LATE_FAILURE | CL_ALLOW_UNKNOWN_CL);
// This will fail because there is no address record for www.h3_fail2.org.
chan = makeChan(`https://www.h3_fail2.org`);
await channelOpenPromise(chan, CL_EXPECT_LATE_FAILURE | CL_ALLOW_UNKNOWN_CL);
// All HTTPS RRs are in http3 excluded list and all records are failed to // connect, so don't fallback to the origin one.
chan = makeChan(`https://www.h3_all_excluded.org:${h2Port}/server-timing`);
await channelOpenPromise(chan, CL_EXPECT_LATE_FAILURE | CL_ALLOW_UNKNOWN_CL);
// The the case that when all records are in http3 excluded list, we still // give the first record one more shot.
chan = makeChan(`https://www.h3_all_excluded.org:${h2Port}`);
[req] = await channelOpenPromise(chan); Assert.equal(req.protocolVersion, "h3");
let internal = req.QueryInterface(Ci.nsIHttpChannelInternal); Assert.equal(internal.remotePort, h3Port);
var uri = Services.io.newURI(wssUri); var wsListener = new WebSocketListener();
certOverrideService.setDisableAllSecurityChecksAndLetAttackersInterceptMyData( false
);
await new Promise(resolve => {
wsListener.finish = resolve;
chan.asyncOpen(uri, wssUri, {}, 0, wsListener, null);
certOverrideService.setDisableAllSecurityChecksAndLetAttackersInterceptMyData( true
);
});
await trrServer.stop();
});
// Test if we fallback to h2 with echConfig.
add_task(async function testFallbackToH2WithEchConfig() {
trrServer = new TRRServer();
await trrServer.start();
Services.dns.clearCache(true);
Services.prefs.setIntPref("network.trr.mode", 3);
Services.prefs.setCharPref( "network.trr.uri",
`https://foo.example.com:${trrServer.port()}/dns-query`
);
Services.prefs.setBoolPref("network.http.http3.enable", true);
Services.prefs.setIntPref( "network.dns.httpssvc.http3_fast_fallback_timeout",
0
);
await new TRRDNSListener("test.fallback.org", {
type: Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC,
});
await new TRRDNSListener("test.fallback.org", "127.0.0.1");
let chan = makeChan(`https://test.fallback.org/server-timing`);
let [req] = await channelOpenPromise(chan); // Test if this request is done by h2. Assert.equal(req.getResponseHeader("x-connection-http2"), "yes");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.