From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- netwerk/test/unit/test_http3_direct_proxy.js | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 netwerk/test/unit/test_http3_direct_proxy.js (limited to 'netwerk/test/unit/test_http3_direct_proxy.js') diff --git a/netwerk/test/unit/test_http3_direct_proxy.js b/netwerk/test/unit/test_http3_direct_proxy.js new file mode 100644 index 0000000000..74d2b11fc1 --- /dev/null +++ b/netwerk/test/unit/test_http3_direct_proxy.js @@ -0,0 +1,54 @@ +/* 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 a HTTP3 connection can be established when a proxy info says +// to use direct connection + +"use strict"; + +registerCleanupFunction(async () => { + http3_clear_prefs(); + Services.prefs.clearUserPref("network.proxy.type"); + Services.prefs.clearUserPref("network.proxy.autoconfig_url"); +}); + +add_task(async function setup() { + await http3_setup_tests("h3-29"); +}); + +function makeChan(url) { + let chan = NetUtil.newChannel({ + uri: url, + loadUsingSystemPrincipal: true, + contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT, + }).QueryInterface(Ci.nsIHttpChannel); + chan.loadFlags = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI; + return chan; +} + +function channelOpenPromise(chan, flags) { + return new Promise(resolve => { + function finish(req, buffer) { + resolve([req, buffer]); + } + chan.asyncOpen(new ChannelListener(finish, null, flags)); + }); +} + +add_task(async function testHttp3WithDirectProxy() { + var pac = + "data:text/plain," + + "function FindProxyForURL(url, host) {" + + ' return "DIRECT; PROXY foopy:8080;"' + + "}"; + + // Configure PAC + Services.prefs.setIntPref("network.proxy.type", 2); + Services.prefs.setCharPref("network.proxy.autoconfig_url", pac); + + let chan = makeChan(`https://foo.example.com`); + let [req] = await channelOpenPromise(chan, CL_ALLOW_UNKNOWN_CL); + req.QueryInterface(Ci.nsIHttpChannel); + Assert.equal(req.protocolVersion, "h3-29"); +}); -- cgit v1.2.3