diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/webtransport/test | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dom/webtransport/test/moz.build | 9 | ||||
-rw-r--r-- | dom/webtransport/test/xpcshell/moz.build | 9 | ||||
-rw-r--r-- | dom/webtransport/test/xpcshell/test_close.js | 64 | ||||
-rw-r--r-- | dom/webtransport/test/xpcshell/xpcshell.ini | 11 |
4 files changed, 93 insertions, 0 deletions
diff --git a/dom/webtransport/test/moz.build b/dom/webtransport/test/moz.build new file mode 100644 index 0000000000..ddf7e1f9a9 --- /dev/null +++ b/dom/webtransport/test/moz.build @@ -0,0 +1,9 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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_DIRS += [ + "xpcshell", +] diff --git a/dom/webtransport/test/xpcshell/moz.build b/dom/webtransport/test/xpcshell/moz.build new file mode 100644 index 0000000000..3d85532034 --- /dev/null +++ b/dom/webtransport/test/xpcshell/moz.build @@ -0,0 +1,9 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + +XPCSHELL_TESTS_MANIFESTS += [ + "xpcshell.ini", +] diff --git a/dom/webtransport/test/xpcshell/test_close.js b/dom/webtransport/test/xpcshell/test_close.js new file mode 100644 index 0000000000..458b933ff3 --- /dev/null +++ b/dom/webtransport/test/xpcshell/test_close.js @@ -0,0 +1,64 @@ +// +// 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.import("resource://gre/modules/NetUtil.jsm"); + +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; + + wt.close(); +}); diff --git a/dom/webtransport/test/xpcshell/xpcshell.ini b/dom/webtransport/test/xpcshell/xpcshell.ini new file mode 100644 index 0000000000..816e096aa0 --- /dev/null +++ b/dom/webtransport/test/xpcshell/xpcshell.ini @@ -0,0 +1,11 @@ +# 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/. + +[DEFAULT] + +# XXX figure out why android doesn't get MOZHTTP3_PORT +[test_close.js] +skip-if = + os == 'android' || socketprocess_networking + os == 'win' && msix # https://bugzilla.mozilla.org/show_bug.cgi?id=1807925 |