summaryrefslogtreecommitdiffstats
path: root/netwerk/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /netwerk/test
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test')
-rw-r--r--netwerk/test/browser/browser.toml4
-rw-r--r--netwerk/test/browser/browser_bug1629307.js4
-rw-r--r--netwerk/test/browser/browser_cookie_filtering_insecure.js8
-rw-r--r--netwerk/test/browser/browser_cookie_filtering_subdomain.js8
-rw-r--r--netwerk/test/browser/browser_post_auth.js2
-rw-r--r--netwerk/test/gtest/TestIDNA.cpp77
-rw-r--r--netwerk/test/gtest/TestStandardURL.cpp28
-rw-r--r--netwerk/test/gtest/moz.build1
-rw-r--r--netwerk/test/http3server/Cargo.toml10
-rw-r--r--netwerk/test/http3server/src/main.rs2
-rw-r--r--netwerk/test/mochitests/test_different_domain_in_hierarchy.html2
-rw-r--r--netwerk/test/mochitests/test_rel_preconnect.html5
-rw-r--r--netwerk/test/unit/test_NetUtil.js2
-rw-r--r--netwerk/test/unit/test_brotli_http.js2
-rw-r--r--netwerk/test/unit/test_bug526789.js2
-rw-r--r--netwerk/test/unit/test_connection_coalescing.js194
-rw-r--r--netwerk/test/unit/test_default_uri_bypass.js67
-rw-r--r--netwerk/test/unit/test_dns_service.js33
-rw-r--r--netwerk/test/unit/test_http3_prio_disabled.js5
-rw-r--r--netwerk/test/unit/test_http3_prio_enabled.js5
-rw-r--r--netwerk/test/unit/test_multipart_set_cookie.js4
-rw-r--r--netwerk/test/unit/test_standardurl.js10
-rw-r--r--netwerk/test/unit/xpcshell.toml5
-rw-r--r--netwerk/test/unit_ipc/test_default_uri_bypass_wrap.js13
-rw-r--r--netwerk/test/unit_ipc/test_http3_prio_disabled_wrap.js2
-rw-r--r--netwerk/test/unit_ipc/test_http3_prio_enabled_wrap.js2
-rw-r--r--netwerk/test/unit_ipc/xpcshell.toml4
27 files changed, 483 insertions, 18 deletions
diff --git a/netwerk/test/browser/browser.toml b/netwerk/test/browser/browser.toml
index 9a470d8c59..002bd2769d 100644
--- a/netwerk/test/browser/browser.toml
+++ b/netwerk/test/browser/browser.toml
@@ -74,6 +74,10 @@ support-files = [
"file_link_header.sjs",
]
+prefs = [
+ "network.fetch.systemDefaultsToOmittingCredentials=false"
+]
+
["browser_103_assets.js"]
["browser_103_assets_extension.js"]
diff --git a/netwerk/test/browser/browser_bug1629307.js b/netwerk/test/browser/browser_bug1629307.js
index 03ea2476e2..1cab7bc101 100644
--- a/netwerk/test/browser/browser_bug1629307.js
+++ b/netwerk/test/browser/browser_bug1629307.js
@@ -24,7 +24,7 @@ add_task(async function () {
PromptTestUtils.handleNextPrompt(
window,
{
- modalType: Services.prefs.getIntPref("prompts.modalType.httpAuth"),
+ modalType: Ci.nsIPrompt.MODAL_TYPE_TAB,
promptType: "promptUserAndPass",
},
{ buttonNumClick: 1 }
@@ -59,7 +59,7 @@ add_task(async function () {
PromptTestUtils.handleNextPrompt(
window,
{
- modalType: Services.prefs.getIntPref("prompts.modalType.httpAuth"),
+ modalType: Ci.nsIPrompt.MODAL_TYPE_TAB,
promptType: "promptUserAndPass",
},
{ buttonNumClick: 1 }
diff --git a/netwerk/test/browser/browser_cookie_filtering_insecure.js b/netwerk/test/browser/browser_cookie_filtering_insecure.js
index 679bfc5a56..4f46773675 100644
--- a/netwerk/test/browser/browser_cookie_filtering_insecure.js
+++ b/netwerk/test/browser/browser_cookie_filtering_insecure.js
@@ -4,6 +4,14 @@
*/
"use strict";
+// performing http and https testing within this file,
+// and we do not want https-first to interfere with that test
+Services.prefs.setBoolPref("dom.security.https_first", false);
+
+registerCleanupFunction(function () {
+ Services.prefs.clearUserPref("dom.security.https_first");
+});
+
const {
HTTPS_EXAMPLE_ORG,
HTTPS_EXAMPLE_COM,
diff --git a/netwerk/test/browser/browser_cookie_filtering_subdomain.js b/netwerk/test/browser/browser_cookie_filtering_subdomain.js
index 78fcdb07dd..4a27eea1e8 100644
--- a/netwerk/test/browser/browser_cookie_filtering_subdomain.js
+++ b/netwerk/test/browser/browser_cookie_filtering_subdomain.js
@@ -5,6 +5,14 @@
"use strict";
+// performing http and https testing within this file,
+// and we do not want https-first to interfere with that test
+Services.prefs.setBoolPref("dom.security.https_first", false);
+
+registerCleanupFunction(function () {
+ Services.prefs.clearUserPref("dom.security.https_first");
+});
+
const {
HTTPS_EXAMPLE_ORG,
HTTPS_EXAMPLE_COM,
diff --git a/netwerk/test/browser/browser_post_auth.js b/netwerk/test/browser/browser_post_auth.js
index 24104f96d6..1168cdabb1 100644
--- a/netwerk/test/browser/browser_post_auth.js
+++ b/netwerk/test/browser/browser_post_auth.js
@@ -43,7 +43,7 @@ add_task(async function () {
let promptPromise = PromptTestUtils.handleNextPrompt(
tab.linkedBrowser,
{
- modalType: Services.prefs.getIntPref("prompts.modalType.httpAuth"),
+ modalType: Ci.nsIPrompt.MODAL_TYPE_TAB,
promptType: "promptUserAndPass",
},
{ buttonNumClick: 0, loginInput: "user", passwordInput: "pass" }
diff --git a/netwerk/test/gtest/TestIDNA.cpp b/netwerk/test/gtest/TestIDNA.cpp
new file mode 100644
index 0000000000..544debbd43
--- /dev/null
+++ b/netwerk/test/gtest/TestIDNA.cpp
@@ -0,0 +1,77 @@
+#include "gtest/gtest.h"
+#include "gtest/MozGTestBench.h" // For MOZ_GTEST_BENCH
+#include "gtest/BlackBox.h"
+
+#include "nsNetUtil.h"
+
+#define TEST_COUNT 10000
+
+class TestIDNA : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ // Intentionally Assign and not AssignLiteral
+ // to simulate the usual heap case.
+ mPlainASCII.Assign("example.com");
+ mLeadingDigitASCII.Assign("1test.example");
+ mUnicodeMixed.Assign("مثال.example");
+ mPunycodeMixed.Assign("xn--mgbh0fb.example");
+ mUnicodeLTR.Assign("නම.උදාහරණ");
+ mPunycodeLTR.Assign("xn--r0co.xn--ozc8dl2c3bxd");
+ mUnicodeRTL.Assign("الاسم.مثال");
+ mPunycodeRTL.Assign("xn--mgba0b1dh.xn--mgbh0fb");
+ // Intentionally not assigning to mEmpty
+ }
+
+ public:
+ nsCString mPlainASCII;
+ nsCString mLeadingDigitASCII;
+ nsCString mUnicodeMixed;
+ nsCString mPunycodeMixed;
+ nsCString mUnicodeLTR;
+ nsCString mPunycodeLTR;
+ nsCString mUnicodeRTL;
+ nsCString mPunycodeRTL;
+ nsCString mEmpty; // Extremely suspicious measurement!
+};
+
+#define IDNA_ITERATIONS 50000
+
+#define IDNA_BENCH(name, func, src) \
+ MOZ_GTEST_BENCH_F(TestIDNA, name, [this] { \
+ for (int i = 0; i < IDNA_ITERATIONS; i++) { \
+ nsCString dst; \
+ func(*mozilla::BlackBox(&src), *mozilla::BlackBox(&dst)); \
+ } \
+ });
+
+IDNA_BENCH(BenchToASCIIPlainASCII, NS_DomainToASCII, mPlainASCII);
+IDNA_BENCH(BenchToASCIILeadingDigitASCII, NS_DomainToASCII, mLeadingDigitASCII);
+IDNA_BENCH(BenchToASCIIUnicodeMixed, NS_DomainToASCII, mUnicodeMixed);
+IDNA_BENCH(BenchToASCIIPunycodeMixed, NS_DomainToASCII, mPunycodeMixed);
+IDNA_BENCH(BenchToASCIIUnicodeLTR, NS_DomainToASCII, mUnicodeLTR);
+IDNA_BENCH(BenchToASCIIPunycodeLTR, NS_DomainToASCII, mPunycodeLTR);
+IDNA_BENCH(BenchToASCIIUnicodeRTL, NS_DomainToASCII, mUnicodeRTL);
+IDNA_BENCH(BenchToASCIIPunycodeRTL, NS_DomainToASCII, mPunycodeRTL);
+IDNA_BENCH(BenchToASCIIEmpty, NS_DomainToASCII, mEmpty);
+
+IDNA_BENCH(BenchToDisplayPlainASCII, NS_DomainToDisplay, mPlainASCII);
+IDNA_BENCH(BenchToDisplayLeadingDigitASCII, NS_DomainToDisplay,
+ mLeadingDigitASCII);
+IDNA_BENCH(BenchToDisplayUnicodeMixed, NS_DomainToDisplay, mUnicodeMixed);
+IDNA_BENCH(BenchToDisplayPunycodeMixed, NS_DomainToDisplay, mPunycodeMixed);
+IDNA_BENCH(BenchToDisplayUnicodeLTR, NS_DomainToDisplay, mUnicodeLTR);
+IDNA_BENCH(BenchToDisplayPunycodeLTR, NS_DomainToDisplay, mPunycodeLTR);
+IDNA_BENCH(BenchToDisplayUnicodeRTL, NS_DomainToDisplay, mUnicodeRTL);
+IDNA_BENCH(BenchToDisplayPunycodeRTL, NS_DomainToDisplay, mPunycodeRTL);
+IDNA_BENCH(BenchToDisplayEmpty, NS_DomainToDisplay, mEmpty);
+
+IDNA_BENCH(BenchToUnicodePlainASCII, NS_DomainToUnicode, mPlainASCII);
+IDNA_BENCH(BenchToUnicodeLeadingDigitASCII, NS_DomainToUnicode,
+ mLeadingDigitASCII);
+IDNA_BENCH(BenchToUnicodeUnicodeMixed, NS_DomainToUnicode, mUnicodeMixed);
+IDNA_BENCH(BenchToUnicodePunycodeMixed, NS_DomainToUnicode, mPunycodeMixed);
+IDNA_BENCH(BenchToUnicodeUnicodeLTR, NS_DomainToUnicode, mUnicodeLTR);
+IDNA_BENCH(BenchToUnicodePunycodeLTR, NS_DomainToUnicode, mPunycodeLTR);
+IDNA_BENCH(BenchToUnicodeUnicodeRTL, NS_DomainToUnicode, mUnicodeRTL);
+IDNA_BENCH(BenchToUnicodePunycodeRTL, NS_DomainToUnicode, mPunycodeRTL);
+IDNA_BENCH(BenchToUnicodeEmpty, NS_DomainToUnicode, mEmpty);
diff --git a/netwerk/test/gtest/TestStandardURL.cpp b/netwerk/test/gtest/TestStandardURL.cpp
index 035c92fcc2..64a57ed7fb 100644
--- a/netwerk/test/gtest/TestStandardURL.cpp
+++ b/netwerk/test/gtest/TestStandardURL.cpp
@@ -14,6 +14,7 @@
#include "nsSerializationHelper.h"
#include "mozilla/Base64.h"
#include "nsEscape.h"
+#include "nsURLHelper.h"
using namespace mozilla;
@@ -439,3 +440,30 @@ TEST(TestStandardURL, ParseIPv4Num)
Test_ParseIPv4Number("0x10"_ns, 16, number, 255);
ASSERT_EQ(number, (uint32_t)16);
}
+
+TEST(TestStandardURL, CoalescePath)
+{
+ auto testCoalescing = [](const char* input, const char* expected) {
+ nsAutoCString buf(input);
+ net_CoalesceDirs(NET_COALESCE_NORMAL, buf.BeginWriting());
+ ASSERT_EQ(nsCString(buf.get()), nsCString(expected));
+ };
+
+ testCoalescing("/.", "/");
+ testCoalescing("/..", "/");
+ testCoalescing("/foo/foo1/.", "/foo/foo1/");
+ testCoalescing("/foo/../foo1", "/foo1");
+ testCoalescing("/foo/./foo1", "/foo/foo1");
+ testCoalescing("/foo/foo1/..", "/foo/");
+
+ // Bug 1890346
+ testCoalescing("/..?/..", "/?/..");
+
+ testCoalescing("/.?/..", "/?/..");
+ testCoalescing("/./../?", "/?");
+ testCoalescing("/.abc", "/.abc");
+ testCoalescing("//", "//");
+ testCoalescing("/../", "/");
+ testCoalescing("/./", "/");
+ testCoalescing("/.../", "/.../");
+}
diff --git a/netwerk/test/gtest/moz.build b/netwerk/test/gtest/moz.build
index 571c908707..8e0d66f4e2 100644
--- a/netwerk/test/gtest/moz.build
+++ b/netwerk/test/gtest/moz.build
@@ -17,6 +17,7 @@ UNIFIED_SOURCES += [
"TestHttpAuthUtils.cpp",
"TestHttpChannel.cpp",
"TestHttpResponseHead.cpp",
+ "TestIDNA.cpp",
"TestInputStreamTransport.cpp",
"TestIsValidIp.cpp",
"TestLinkHeader.cpp",
diff --git a/netwerk/test/http3server/Cargo.toml b/netwerk/test/http3server/Cargo.toml
index 60ff22c530..4905760d3d 100644
--- a/netwerk/test/http3server/Cargo.toml
+++ b/netwerk/test/http3server/Cargo.toml
@@ -6,10 +6,10 @@ edition = "2018"
license = "MPL-2.0"
[dependencies]
-neqo-transport = { tag = "v0.7.2", git = "https://github.com/mozilla/neqo" }
-neqo-common = { tag = "v0.7.2", git = "https://github.com/mozilla/neqo" }
-neqo-http3 = { tag = "v0.7.2", git = "https://github.com/mozilla/neqo" }
-neqo-qpack = { tag = "v0.7.2", git = "https://github.com/mozilla/neqo" }
+neqo-transport = { tag = "v0.7.5", git = "https://github.com/mozilla/neqo" }
+neqo-common = { tag = "v0.7.5", git = "https://github.com/mozilla/neqo" }
+neqo-http3 = { tag = "v0.7.5", git = "https://github.com/mozilla/neqo" }
+neqo-qpack = { tag = "v0.7.5", git = "https://github.com/mozilla/neqo" }
mio = "0.6.17"
mio-extras = "2.0.5"
log = "0.4.0"
@@ -21,7 +21,7 @@ tokio = { version = "1", features = ["rt-multi-thread"] }
mozilla-central-workspace-hack = { version = "0.1", features = ["http3server"], optional = true }
[dependencies.neqo-crypto]
-tag = "v0.7.2"
+tag = "v0.7.5"
git = "https://github.com/mozilla/neqo"
default-features = false
features = ["gecko"]
diff --git a/netwerk/test/http3server/src/main.rs b/netwerk/test/http3server/src/main.rs
index a308f56442..1543e3aeb3 100644
--- a/netwerk/test/http3server/src/main.rs
+++ b/netwerk/test/http3server/src/main.rs
@@ -1378,7 +1378,7 @@ fn main() -> Result<(), io::Error> {
}
});
- init_db(PathBuf::from(args[1].clone()));
+ init_db(PathBuf::from(args[1].clone())).unwrap();
let mut servers_runner = ServersRunner::new()?;
servers_runner.init();
diff --git a/netwerk/test/mochitests/test_different_domain_in_hierarchy.html b/netwerk/test/mochitests/test_different_domain_in_hierarchy.html
index 0ec6d35d4d..1a4abad676 100644
--- a/netwerk/test/mochitests/test_different_domain_in_hierarchy.html
+++ b/netwerk/test/mochitests/test_different_domain_in_hierarchy.html
@@ -5,7 +5,7 @@
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
-<body onload="setupTest('https://example.org/tests/netwerk/test/mochitests/file_domain_hierarchy_inner.html', 4, 3)">
+<body onload="setupTest('https://example.org/tests/netwerk/test/mochitests/file_domain_hierarchy_inner.html', 3, 3)">
<p id="display"></p>
<pre id="test">
<script class="testbody" type="text/javascript" src="file_testcommon.js">
diff --git a/netwerk/test/mochitests/test_rel_preconnect.html b/netwerk/test/mochitests/test_rel_preconnect.html
index a0c3309954..fd3d0cf311 100644
--- a/netwerk/test/mochitests/test_rel_preconnect.html
+++ b/netwerk/test/mochitests/test_rel_preconnect.html
@@ -19,12 +19,15 @@ async function doTest()
{
await SpecialPowers.setBoolPref("network.http.debug-observations", true);
+ SimpleTest.registerCleanupFunction(async () => {
+ await SpecialPowers.setBoolPref("network.http.debug-observations", false);
+ });
+
observer = SpecialPowers.wrapCallback(function() {
remainder--;
ok(true, "observed remainder = " + remainder);
if (!remainder) {
SpecialPowers.removeObserver(observer, "speculative-connect-request");
- SpecialPowers.setBoolPref("network.http.debug-observations", false);
SimpleTest.finish();
}
});
diff --git a/netwerk/test/unit/test_NetUtil.js b/netwerk/test/unit/test_NetUtil.js
index 624e35f30e..211f60ac6a 100644
--- a/netwerk/test/unit/test_NetUtil.js
+++ b/netwerk/test/unit/test_NetUtil.js
@@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
- * This file tests the methods on NetUtil.jsm.
+ * This file tests the methods on NetUtil.sys.mjs.
*/
"use strict";
diff --git a/netwerk/test/unit/test_brotli_http.js b/netwerk/test/unit/test_brotli_http.js
index 1207c95012..adf5915b76 100644
--- a/netwerk/test/unit/test_brotli_http.js
+++ b/netwerk/test/unit/test_brotli_http.js
@@ -100,7 +100,7 @@ add_task(
});
equal(
Services.prefs.getCharPref("network.http.accept-encoding.secure"),
- "gzip, deflate, br"
+ "gzip, deflate, br, zstd"
);
let { req, buff } = await new Promise(resolve => {
let chan = NetUtil.newChannel({
diff --git a/netwerk/test/unit/test_bug526789.js b/netwerk/test/unit/test_bug526789.js
index ec80249a3c..ba0714801f 100644
--- a/netwerk/test/unit/test_bug526789.js
+++ b/netwerk/test/unit/test_bug526789.js
@@ -239,6 +239,7 @@ add_task(async () => {
await testTrailingDotCookie("http://foo.com/", "foo.com");
cm.removeAll();
+ Services.prefs.clearUserPref("dom.security.https_first");
});
function getCookieCount() {
@@ -285,5 +286,4 @@ async function testTrailingDotCookie(uriString, domain) {
Assert.equal(cm.countCookiesFromHost(domain), 0);
Assert.equal(cm.countCookiesFromHost(domain + "."), 0);
cm.removeAll();
- Services.prefs.clearUserPref("dom.security.https_first");
}
diff --git a/netwerk/test/unit/test_connection_coalescing.js b/netwerk/test/unit/test_connection_coalescing.js
new file mode 100644
index 0000000000..a61098e73e
--- /dev/null
+++ b/netwerk/test/unit/test_connection_coalescing.js
@@ -0,0 +1,194 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* 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/. */
+
+"use strict";
+
+const override = Cc["@mozilla.org/network/native-dns-override;1"].getService(
+ Ci.nsINativeDNSResolverOverride
+);
+
+let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
+ Ci.nsIX509CertDB
+);
+addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u");
+
+async function createServer() {
+ let server = new NodeHTTP2Server();
+ await server.start();
+ registerCleanupFunction(async () => {
+ await server.stop();
+ });
+ await server.registerPathHandler("/", (req, resp) => {
+ let content = `hello from ${req.authority} | ${req.socket.remotePort}`;
+ resp.writeHead(200, {
+ "Content-Type": "text/plain",
+ "Content-Length": `${content.length}`,
+ });
+ resp.end(content);
+ });
+ return server;
+}
+
+let IP1 = "127.0.0.1";
+let IP2 = "127.0.0.2";
+if (AppConstants.platform == "macosx") {
+ // OSX doesn't use 127.0.0.2 as a local interface
+ IP2 = "::1";
+} else if (AppConstants.platform == "android") {
+ IP2 = "10.0.2.2";
+}
+
+async function openChan(uri) {
+ let chan = NetUtil.newChannel({
+ uri,
+ loadUsingSystemPrincipal: true,
+ }).QueryInterface(Ci.nsIHttpChannel);
+ chan.loadFlags = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
+
+ let { req, buffer } = await new Promise(resolve => {
+ function finish(r, b) {
+ resolve({ req: r, buffer: b });
+ }
+ chan.asyncOpen(new ChannelListener(finish, null, CL_ALLOW_UNKNOWN_CL));
+ });
+
+ return {
+ buffer,
+ port: buffer.split("|")[1],
+ addr: req.QueryInterface(Ci.nsIHttpChannelInternal).remoteAddress,
+ status: req.QueryInterface(Ci.nsIHttpChannel).responseStatus,
+ };
+}
+
+add_task(async function test_dontCoalesce() {
+ let server = await createServer();
+ Services.prefs.setBoolPref("network.http.http2.aggressive_coalescing", false);
+ override.clearOverrides();
+ Services.dns.clearCache(true);
+
+ override.addIPOverride("foo.example.com", IP1);
+ override.addIPOverride("foo.example.com", IP2);
+ override.addIPOverride("alt1.example.com", IP2);
+
+ let { addr: addr1 } = await openChan(
+ `https://foo.example.com:${server.port()}/`
+ );
+ let { addr: addr2 } = await openChan(
+ `https://alt1.example.com:${server.port()}/`
+ );
+
+ Assert.notEqual(addr1, addr2);
+ await server.stop();
+});
+
+add_task(async function test_doCoalesce() {
+ let server = await createServer();
+ Services.prefs.setBoolPref("network.http.http2.aggressive_coalescing", false);
+ override.clearOverrides();
+ Services.dns.clearCache(true);
+
+ override.addIPOverride("foo.example.com", IP1);
+ override.addIPOverride("foo.example.com", IP2);
+ override.addIPOverride("alt2.example.com", IP1);
+ override.addIPOverride("alt2.example.com", IP2);
+
+ let { port: port1, addr: addr1 } = await openChan(
+ `https://foo.example.com:${server.port()}/`
+ );
+ let { port: port2, addr: addr2 } = await openChan(
+ `https://alt2.example.com:${server.port()}/`
+ );
+
+ Assert.equal(addr1, addr2);
+ Assert.equal(port1, port2);
+ await server.stop();
+});
+
+add_task(async function test_doCoalesceAggresive() {
+ let server = await createServer();
+
+ Services.prefs.setBoolPref("network.http.http2.aggressive_coalescing", true);
+ override.clearOverrides();
+ Services.dns.clearCache(true);
+
+ override.addIPOverride("foo.example.com", IP1);
+ override.addIPOverride("foo.example.com", IP2);
+ override.addIPOverride("alt1.example.com", IP2);
+
+ let { port: port1, addr: addr1 } = await openChan(
+ `https://foo.example.com:${server.port()}/`
+ );
+ let { port: port2, addr: addr2 } = await openChan(
+ `https://alt1.example.com:${server.port()}/`
+ );
+
+ Assert.equal(addr1, addr2);
+ Assert.equal(port1, port2);
+ await server.stop();
+});
+
+// On android because of the way networking is set up the
+// localAddress is always ::ffff:127.0.0.1 so it can't be
+// used to make a decision.
+add_task(
+ { skip_if: () => AppConstants.platform == "android" },
+ async function test_doCoalesceAggresive421() {
+ let server = await createServer();
+
+ await server.execute(`global.rightIP = "${IP2}"`);
+
+ await server.registerPathHandler("/", (req, resp) => {
+ let content = `hello from ${req.authority} | ${req.socket.remotePort}`;
+ // Check that returning 421 when aggresively coalescing
+ // makes Firefox not coalesce the connections.
+ if (
+ req.authority.startsWith("alt1.example.com") &&
+ req.socket.localAddress != global.rightIP &&
+ req.socket.localAddress != `::ffff:${global.rightIP}`
+ ) {
+ resp.writeHead(421, {
+ "Content-Type": "text/plain",
+ "Content-Length": `${content.length}`,
+ });
+ resp.end(content);
+ return;
+ }
+ resp.writeHead(200, {
+ "Content-Type": "text/plain",
+ "Content-Length": `${content.length}`,
+ });
+ resp.end(content);
+ });
+
+ Services.prefs.setBoolPref(
+ "network.http.http2.aggressive_coalescing",
+ true
+ );
+ override.clearOverrides();
+ Services.dns.clearCache(true);
+
+ override.addIPOverride("foo.example.com", IP1);
+ override.addIPOverride("foo.example.com", IP2);
+ override.addIPOverride("alt1.example.com", IP2);
+
+ let {
+ addr: addr1,
+ status: status1,
+ port: port1,
+ } = await openChan(`https://foo.example.com:${server.port()}/`);
+ Assert.equal(status1, 200);
+ Assert.equal(addr1, IP1);
+ let {
+ addr: addr2,
+ status: status2,
+ port: port2,
+ } = await openChan(`https://alt1.example.com:${server.port()}/`);
+
+ Assert.equal(status2, 200);
+ Assert.equal(addr2, IP2);
+ Assert.notEqual(port1, port2);
+ await server.stop();
+ }
+);
diff --git a/netwerk/test/unit/test_default_uri_bypass.js b/netwerk/test/unit/test_default_uri_bypass.js
new file mode 100644
index 0000000000..d3ceac5d8c
--- /dev/null
+++ b/netwerk/test/unit/test_default_uri_bypass.js
@@ -0,0 +1,67 @@
+/* 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 that default uri is bypassable by an unknown protocol that is
+ * present in the bypass list (and the pref is enabled)
+ */
+"use strict";
+
+function inChildProcess() {
+ return Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
+}
+
+function run_test() {
+ // In-Parent-only process pref setup
+ if (!inChildProcess()) {
+ Services.prefs.setBoolPref("network.url.useDefaultURI", true);
+ Services.prefs.setBoolPref(
+ "network.url.some_schemes_bypass_defaultURI_fallback",
+ true
+ );
+
+ Services.prefs.setCharPref(
+ "network.url.simple_uri_schemes",
+ "simpleprotocol,otherproto"
+ );
+ }
+
+ // check valid url is fine
+ let uri = NetUtil.newURI("https://example.com/");
+ Assert.equal(uri.spec, "https://example.com/"); // same
+
+ // nsStandardURL removes second colon when nesting protocols
+ let uri1 = NetUtil.newURI("https://https://example.com/");
+ Assert.equal(uri1.spec, "https://https//example.com/");
+
+ // defaultUri removes second colon
+ // no-bypass protocol uses defaultURI
+ let uri2 = NetUtil.newURI("nonsimpleprotocol://https://example.com");
+ Assert.equal(uri2.spec, "nonsimpleprotocol://https//example.com");
+
+ // simpleURI keeps the second colon
+ // an unknown protocol in the bypass list will use simpleURI
+ // despite network.url.useDefaultURI being enabled
+ let same = "simpleprotocol://https://example.com";
+ let uri3 = NetUtil.newURI(same);
+ Assert.equal(uri3.spec, same); // simple uri keeps second colon
+
+ // setCharPref not accessible from child process
+ if (!inChildProcess()) {
+ // check that pref update removes simpleprotocol from bypass list
+ Services.prefs.setCharPref("network.url.simple_uri_schemes", "otherproto");
+ let uri4 = NetUtil.newURI("simpleprotocol://https://example.com");
+ Assert.equal(uri4.spec, "simpleprotocol://https//example.com"); // default uri removes second colon
+
+ // check that spaces are parsed out
+ Services.prefs.setCharPref(
+ "network.url.simple_uri_schemes",
+ " simpleprotocol , otherproto "
+ );
+ let uri5 = NetUtil.newURI("simpleprotocol://https://example.com");
+ Assert.equal(uri5.spec, "simpleprotocol://https://example.com"); // simple uri keeps second colon
+ let uri6 = NetUtil.newURI("otherproto://https://example.com");
+ Assert.equal(uri6.spec, "otherproto://https://example.com"); // simple uri keeps second colon
+ }
+}
diff --git a/netwerk/test/unit/test_dns_service.js b/netwerk/test/unit/test_dns_service.js
index da404c1e7d..a4c167a6c3 100644
--- a/netwerk/test/unit/test_dns_service.js
+++ b/netwerk/test/unit/test_dns_service.js
@@ -121,3 +121,36 @@ add_task(
}
}
);
+
+add_task(
+ {
+ skip_if: () =>
+ Services.appinfo.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT,
+ },
+ async function test_sort_family() {
+ Services.prefs.setBoolPref("network.dns.preferIPv6", true);
+ overrideService.clearOverrides();
+ overrideService.addIPOverride("example.com", "1.2.3.4");
+ overrideService.addIPOverride("example.com", "3.4.5.6");
+ overrideService.addIPOverride("example.com", "::1");
+ overrideService.addIPOverride("example.com", "::2");
+
+ let listener = new Listener();
+ Services.dns.asyncResolve(
+ "example.com",
+ Ci.nsIDNSService.RESOLVE_TYPE_DEFAULT,
+ Ci.nsIDNSService.RESOLVE_CANONICAL_NAME,
+ null, // resolverInfo
+ listener,
+ mainThread,
+ defaultOriginAttributes
+ );
+
+ let [, inRecord] = await listener;
+ inRecord.QueryInterface(Ci.nsIDNSAddrRecord);
+ Assert.equal(inRecord.getNextAddrAsString(), "::1");
+ Assert.equal(inRecord.getNextAddrAsString(), "::2");
+ Assert.equal(inRecord.getNextAddrAsString(), "1.2.3.4");
+ Assert.equal(inRecord.getNextAddrAsString(), "3.4.5.6");
+ }
+);
diff --git a/netwerk/test/unit/test_http3_prio_disabled.js b/netwerk/test/unit/test_http3_prio_disabled.js
index b73ca98709..44c7a20833 100644
--- a/netwerk/test/unit/test_http3_prio_disabled.js
+++ b/netwerk/test/unit/test_http3_prio_disabled.js
@@ -16,6 +16,7 @@ load("../unit/test_http3_prio_helpers.js");
if (!inChildProcess()) {
registerCleanupFunction(async () => {
Services.prefs.clearUserPref("network.http.http3.priority");
+ Services.prefs.clearUserPref("network.http.priority_header.enabled");
http3_clear_prefs();
});
}
@@ -75,7 +76,7 @@ async function test_http3_prio_disabled(incremental) {
null
);
await test_flag_priority(
- "disabled (background)",
+ "disabled (tail)",
Ci.nsIClassOfService.Tail,
null,
incremental,
@@ -91,6 +92,7 @@ add_task(async function test_http3_prio_disabled_inc_true() {
// wrapper handles when testing as content process for pref change
if (!inChildProcess()) {
Services.prefs.setBoolPref("network.http.http3.priority", false);
+ Services.prefs.setBoolPref("network.http.priority_header.enabled", false);
}
await test_http3_prio_disabled(true);
});
@@ -101,6 +103,7 @@ add_task(async function test_http3_prio_disabled_inc_false() {
// wrapper handles when testing as content process for pref change
if (!inChildProcess()) {
Services.prefs.setBoolPref("network.http.http3.priority", false);
+ Services.prefs.setBoolPref("network.http.priority_header.enabled", false);
}
await test_http3_prio_disabled(false);
});
diff --git a/netwerk/test/unit/test_http3_prio_enabled.js b/netwerk/test/unit/test_http3_prio_enabled.js
index 6dd30c590a..0dcb4aba6f 100644
--- a/netwerk/test/unit/test_http3_prio_enabled.js
+++ b/netwerk/test/unit/test_http3_prio_enabled.js
@@ -16,6 +16,7 @@ load("../unit/test_http3_prio_helpers.js");
if (!inChildProcess()) {
registerCleanupFunction(async () => {
Services.prefs.clearUserPref("network.http.http3.priority");
+ Services.prefs.clearUserPref("network.http.priority_header.enabled");
http3_clear_prefs();
});
}
@@ -82,7 +83,7 @@ async function test_http3_prio_enabled(incremental) {
incremental
);
await test_flag_priority(
- "enabled (background)",
+ "enabled (tail)",
Ci.nsIClassOfService.Tail,
"u=6",
incremental,
@@ -95,6 +96,7 @@ add_task(async function test_http3_prio_enabled_incremental_true() {
// wrapper handles when testing as content process for pref change
if (!inChildProcess()) {
Services.prefs.setBoolPref("network.http.http3.priority", true);
+ Services.prefs.setBoolPref("network.http.priority_header.enabled", true);
}
await test_http3_prio_enabled(true);
});
@@ -103,6 +105,7 @@ add_task(async function test_http3_prio_enabled_incremental_false() {
// wrapper handles when testing as content process for pref change
if (!inChildProcess()) {
Services.prefs.setBoolPref("network.http.http3.priority", true);
+ Services.prefs.setBoolPref("network.http.priority_header.enabled", true);
}
await test_http3_prio_enabled(false);
});
diff --git a/netwerk/test/unit/test_multipart_set_cookie.js b/netwerk/test/unit/test_multipart_set_cookie.js
index c8943cf3cc..e7ea715355 100644
--- a/netwerk/test/unit/test_multipart_set_cookie.js
+++ b/netwerk/test/unit/test_multipart_set_cookie.js
@@ -63,7 +63,7 @@ var multipartListener = {
"nsIRequestObserver",
]),
- onStartRequest(request) {
+ onStartRequest() {
this._buffer = "";
},
@@ -76,7 +76,7 @@ var multipartListener = {
}
},
- onStopRequest(request, status) {
+ onStopRequest(request) {
try {
responseHandler(request, this._buffer);
} catch (ex) {
diff --git a/netwerk/test/unit/test_standardurl.js b/netwerk/test/unit/test_standardurl.js
index cf3f736929..b44289f2e6 100644
--- a/netwerk/test/unit/test_standardurl.js
+++ b/netwerk/test/unit/test_standardurl.js
@@ -1051,3 +1051,13 @@ add_task(async function test_bug1648493() {
equal(url.spec, "t://%C3%83%C2%A7:%C3%83%C2%AA@example.com/");
equal(url.username, "%C3%83%C2%A7");
});
+
+add_task(async function test_bug1873976() {
+ let url = Services.io.newURI("file:.");
+ equal(url.spec, "file:///");
+});
+
+add_task(async function test_bug1890346() {
+ let url = Services.io.newURI("file:..?/..");
+ equal(url.spec, "file:///?/..");
+});
diff --git a/netwerk/test/unit/xpcshell.toml b/netwerk/test/unit/xpcshell.toml
index fb3791963d..c86a1759e7 100644
--- a/netwerk/test/unit/xpcshell.toml
+++ b/netwerk/test/unit/xpcshell.toml
@@ -484,6 +484,7 @@ skip-if = ["os == 'linux' && bits == 64 && !debug"] #Bug 1553353
["test_cookies_partition_counting.js"]
["test_cookies_privatebrowsing.js"]
+skip-if = ["os == 'android' && fission"] # Bug 1888227
["test_cookies_profile_close.js"]
skip-if = ["os == 'android'"] # Bug 1700483
@@ -1275,3 +1276,7 @@ skip-if = [
]
["test_xmlhttprequest.js"]
+
+["test_connection_coalescing.js"]
+
+["test_default_uri_bypass.js"]
diff --git a/netwerk/test/unit_ipc/test_default_uri_bypass_wrap.js b/netwerk/test/unit_ipc/test_default_uri_bypass_wrap.js
new file mode 100644
index 0000000000..82c8e730f8
--- /dev/null
+++ b/netwerk/test/unit_ipc/test_default_uri_bypass_wrap.js
@@ -0,0 +1,13 @@
+function run_test() {
+ Services.prefs.setBoolPref("network.url.useDefaultURI", true);
+ Services.prefs.setBoolPref(
+ "network.url.some_schemes_bypass_defaultURI_fallback",
+ true
+ );
+ Services.prefs.setCharPref(
+ "network.url.simple_uri_schemes",
+ "simpleprotocol,otherproto"
+ );
+
+ run_test_in_child("../unit/test_default_uri_bypass.js");
+}
diff --git a/netwerk/test/unit_ipc/test_http3_prio_disabled_wrap.js b/netwerk/test/unit_ipc/test_http3_prio_disabled_wrap.js
index 38988cd450..8704484d13 100644
--- a/netwerk/test/unit_ipc/test_http3_prio_disabled_wrap.js
+++ b/netwerk/test/unit_ipc/test_http3_prio_disabled_wrap.js
@@ -4,6 +4,7 @@
registerCleanupFunction(async () => {
Services.prefs.clearUserPref("network.http.http3.priority");
+ Services.prefs.clearUserPref("network.http.priority_header.enabled");
http3_clear_prefs();
});
@@ -15,6 +16,7 @@ add_task(async function setup() {
async function run_test() {
// test priority urgency and incremental with priority disabled
Services.prefs.setBoolPref("network.http.http3.priority", false);
+ Services.prefs.setBoolPref("network.http.priority_header.enabled", false);
run_test_in_child("../unit/test_http3_prio_disabled.js");
run_next_test(); // only pumps next async task from this file
}
diff --git a/netwerk/test/unit_ipc/test_http3_prio_enabled_wrap.js b/netwerk/test/unit_ipc/test_http3_prio_enabled_wrap.js
index dcff09fcba..664869f2f5 100644
--- a/netwerk/test/unit_ipc/test_http3_prio_enabled_wrap.js
+++ b/netwerk/test/unit_ipc/test_http3_prio_enabled_wrap.js
@@ -4,6 +4,7 @@
registerCleanupFunction(async () => {
Services.prefs.clearUserPref("network.http.http3.priority");
+ Services.prefs.clearUserPref("network.http.priority_header.enabled");
http3_clear_prefs();
});
@@ -15,6 +16,7 @@ add_task(async function setup() {
async function run_test() {
// test priority urgency and incremental with priority enabled
Services.prefs.setBoolPref("network.http.http3.priority", true);
+ Services.prefs.setBoolPref("network.http.priority_header.enabled", true);
run_test_in_child("../unit/test_http3_prio_enabled.js");
run_next_test(); // only pumps next async task from this file
}
diff --git a/netwerk/test/unit_ipc/xpcshell.toml b/netwerk/test/unit_ipc/xpcshell.toml
index 24c84d745d..bc53e4ce74 100644
--- a/netwerk/test/unit_ipc/xpcshell.toml
+++ b/netwerk/test/unit_ipc/xpcshell.toml
@@ -70,6 +70,7 @@ support-files = [
"!/netwerk/test/unit/test_http3_prio_helpers.js",
"!/netwerk/test/unit/http2-ca.pem",
"!/netwerk/test/unit/test_orb_empty_header.js",
+ "!/netwerk/test/unit/test_default_uri_bypass.js",
"child_is_proxy_used.js",
"child_cookie_header.js",
"child_dns_by_type_resolve.js",
@@ -239,3 +240,6 @@ skip-if = ["os == 'android'"]
["test_xmlhttprequest_wrap.js"]
prefs = ["network.allow_raw_sockets_in_content_processes=true"]
+
+["test_default_uri_bypass_wrap.js"]
+prefs = ["network.allow_raw_sockets_in_content_processes=true"]