From da4c7e7ed675c3bf405668739c3012d140856109 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:42 +0200 Subject: Adding upstream version 126.0. Signed-off-by: Daniel Baumann --- netwerk/test/browser/browser.toml | 4 + netwerk/test/browser/browser_bug1629307.js | 4 +- .../browser/browser_cookie_filtering_insecure.js | 8 + .../browser/browser_cookie_filtering_subdomain.js | 8 + netwerk/test/browser/browser_post_auth.js | 2 +- netwerk/test/gtest/TestIDNA.cpp | 77 ++++++++ netwerk/test/gtest/TestStandardURL.cpp | 28 +++ netwerk/test/gtest/moz.build | 1 + netwerk/test/http3server/Cargo.toml | 10 +- netwerk/test/http3server/src/main.rs | 2 +- .../test_different_domain_in_hierarchy.html | 2 +- netwerk/test/mochitests/test_rel_preconnect.html | 5 +- netwerk/test/unit/test_NetUtil.js | 2 +- netwerk/test/unit/test_brotli_http.js | 2 +- netwerk/test/unit/test_bug526789.js | 2 +- netwerk/test/unit/test_connection_coalescing.js | 194 +++++++++++++++++++++ netwerk/test/unit/test_default_uri_bypass.js | 67 +++++++ netwerk/test/unit/test_dns_service.js | 33 ++++ netwerk/test/unit/test_http3_prio_disabled.js | 5 +- netwerk/test/unit/test_http3_prio_enabled.js | 5 +- netwerk/test/unit/test_multipart_set_cookie.js | 4 +- netwerk/test/unit/test_standardurl.js | 10 ++ netwerk/test/unit/xpcshell.toml | 5 + .../test/unit_ipc/test_default_uri_bypass_wrap.js | 13 ++ .../test/unit_ipc/test_http3_prio_disabled_wrap.js | 2 + .../test/unit_ipc/test_http3_prio_enabled_wrap.js | 2 + netwerk/test/unit_ipc/xpcshell.toml | 4 + 27 files changed, 483 insertions(+), 18 deletions(-) create mode 100644 netwerk/test/gtest/TestIDNA.cpp create mode 100644 netwerk/test/unit/test_connection_coalescing.js create mode 100644 netwerk/test/unit/test_default_uri_bypass.js create mode 100644 netwerk/test/unit_ipc/test_default_uri_bypass_wrap.js (limited to 'netwerk/test') 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 @@ - +