From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- netwerk/test/unit/test_http3_alt_svc.js | 37 +++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'netwerk/test/unit/test_http3_alt_svc.js') diff --git a/netwerk/test/unit/test_http3_alt_svc.js b/netwerk/test/unit/test_http3_alt_svc.js index 201101eb19..46488525ae 100644 --- a/netwerk/test/unit/test_http3_alt_svc.js +++ b/netwerk/test/unit/test_http3_alt_svc.js @@ -5,7 +5,7 @@ let h3AltSvc; let h3Route; let prefs; -let tests = [test_https_alt_svc, testsDone]; +let tests = [test_https_alt_svc, test_https_alt_svc_1, testsDone]; let current_test = 0; @@ -68,7 +68,9 @@ function makeChan(uri) { return chan; } -let WaitForHttp3Listener = function () {}; +let WaitForHttp3Listener = function (expectedH3Version) { + this._expectedH3Version = expectedH3Version; +}; WaitForHttp3Listener.prototype = { onDataAvailableFired: false, @@ -84,7 +86,7 @@ WaitForHttp3Listener.prototype = { read_stream(stream, cnt); }, - onStopRequest: function testOnStopRequest(request, status) { + onStopRequest: function testOnStopRequest(request) { let routed = "NA"; try { routed = request.getRequestHeader("Alt-Used"); @@ -96,13 +98,18 @@ WaitForHttp3Listener.prototype = { try { httpVersion = request.protocolVersion; } catch (e) {} - Assert.equal(httpVersion, "h3-29"); + Assert.equal(httpVersion, this._expectedH3Version); run_next_test(); } else { dump("poll later for alt svc mapping\n"); do_test_pending(); do_timeout(500, () => { - doTest(this.uri, this.expectedRoute, this.h3AltSvc); + doTest( + this.uri, + this.expectedRoute, + this.h3AltSvc, + this._expectedH3Version + ); }); } @@ -110,9 +117,9 @@ WaitForHttp3Listener.prototype = { }, }; -function doTest(uri, expectedRoute, altSvc) { +function doTest(uri, expectedRoute, altSvc, expectedH3Version) { let chan = makeChan(uri); - let listener = new WaitForHttp3Listener(); + let listener = new WaitForHttp3Listener(expectedH3Version); listener.uri = uri; listener.expectedRoute = expectedRoute; listener.h3AltSvc = altSvc; @@ -121,11 +128,23 @@ function doTest(uri, expectedRoute, altSvc) { } // Test Alt-Svc for http3. -// H2 server returns alt-svc=h2=foo2.example.com:8000,h3-29=:h3port,h3-30=foo2.example.com:8443 +// H2 server returns alt-svc=h2=foo2.example.com:8000,h3-29=:h3port function test_https_alt_svc() { dump("test_https_alt_svc()\n"); do_test_pending(); - doTest(httpsOrigin + "http3-test2", h3Route, h3AltSvc); + doTest(httpsOrigin + "http3-test2", h3Route, h3AltSvc, "h3-29"); +} + +// Test if we use the latest version of HTTP/3. +// H2 server returns alt-svc=h3-29=:h3port,h3=:h3port +function test_https_alt_svc_1() { + // Close the previous connection and clear alt-svc mappings. + Services.obs.notifyObservers(null, "last-pb-context-exited"); + Services.obs.notifyObservers(null, "net:cancel-all-connections"); + do_test_pending(); + do_timeout(1000, () => { + doTest(httpsOrigin + "http3-test3", h3Route, h3AltSvc, "h3"); + }); } function testsDone() { -- cgit v1.2.3