1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
//
// Simple WebTransport test
//
// keep eslint happy until it knows about WebTransport
/* global WebTransport:false */
"use strict";
var h3Port;
var host;
registerCleanupFunction(async () => {
Services.prefs.clearUserPref("network.dns.localDomains");
});
var { NetUtil } = ChromeUtils.importESModule(
"resource://gre/modules/NetUtil.sys.mjs"
);
function readFile(file) {
let fstream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(
Ci.nsIFileInputStream
);
fstream.init(file, -1, 0, 0);
let data = NetUtil.readInputStreamToString(fstream, fstream.available());
fstream.close();
return data;
}
function addCertFromFile(certdb, filename, trustString) {
let certFile = do_get_file(filename, false);
let pem = readFile(certFile)
.replace(/-----BEGIN CERTIFICATE-----/, "")
.replace(/-----END CERTIFICATE-----/, "")
.replace(/[\r\n]/g, "");
certdb.addCertFromBase64(pem, trustString);
}
add_task(async function setup() {
Services.prefs.setCharPref("network.dns.localDomains", "foo.example.com");
h3Port = Services.env.get("MOZHTTP3_PORT");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");
host = "foo.example.com:" + h3Port;
do_get_profile();
let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
Ci.nsIX509CertDB
);
// `../unit/` so that unit_ipc tests can use as well
addCertFromFile(
certdb,
"../../../../netwerk/test/unit/http2-ca.pem",
"CTu,u,u"
);
});
add_task(async function test_webtransport_create() {
Services.prefs.setBoolPref("network.webtransport.enabled", true);
const wt = new WebTransport("https://" + host + "/success");
await wt.ready;
dump("**** ready\n");
wt.close();
});
// bug 1840626 - cancel and then close
add_task(async function test_wt_stream_create_bidi_cancel_close() {
let wt = new WebTransport("https://" + host + "/success");
await wt.ready;
await wt.createBidirectionalStream();
await wt.incomingBidirectionalStreams.cancel(undefined);
wt.close();
});
|