1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* import-globals-from head_cache.js */
8 /* import-globals-from head_cookies.js */
9 /* import-globals-from head_channels.js */
10 /* import-globals-from head_servers.js */
11 /* import-globals-from head_websocket.js */
13 let certdb
= Cc
["@mozilla.org/security/x509certdb;1"].getService(
18 Services
.prefs
.setBoolPref("network.http.http2.websockets", true);
21 registerCleanupFunction(() => {
22 Services
.prefs
.clearUserPref("network.http.http2.websockets");
25 // TLS handshake to the end server fails with proxy
26 async
function test_tls_fail_on_ws_server_over_proxy() {
27 // we are expecting a timeout, so lets shorten how long we must wait
28 Services
.prefs
.setIntPref("network.websocket.timeout.open", 1);
30 // no cert to ws server
31 addCertFromFile(certdb
, "proxy-ca.pem", "CTu,u,u");
33 let proxy
= new NodeHTTPSProxyServer();
36 let wss
= new NodeWebSocketServer();
39 registerCleanupFunction(async () => {
42 Services
.prefs
.clearUserPref("network.websocket.timeout.open");
45 Assert
.notEqual(wss
.port(), null);
46 await wss
.registerMessageHandler((data
, ws
) => {
50 let chan
= makeWebSocketChan();
51 let url
= `wss://localhost:${wss.port()}`;
52 const msg
= "test tls fail on ws server over proxy";
53 let [status
] = await
openWebSocketChannelPromise(chan
, url
, msg
);
55 Assert
.equal(status
, Cr
.NS_ERROR_NET_TIMEOUT_EXTERNAL
);
57 add_task(test_tls_fail_on_ws_server_over_proxy
);