diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /netwerk/test | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test')
-rw-r--r-- | netwerk/test/browser/browser.toml | 3 | ||||
-rw-r--r-- | netwerk/test/browser/browser_dns_prefetch_link_header.js | 282 | ||||
-rw-r--r-- | netwerk/test/browser/file_link_dns_prefetch.sjs | 25 | ||||
-rw-r--r-- | netwerk/test/gtest/TestCommon.h | 8 | ||||
-rw-r--r-- | netwerk/test/gtest/TestCookie.cpp | 4 | ||||
-rw-r--r-- | netwerk/test/gtest/TestIDNA.cpp | 43 | ||||
-rw-r--r-- | netwerk/test/gtest/TestInputStreamTransport.cpp | 2 | ||||
-rw-r--r-- | netwerk/test/gtest/TestNamedPipeService.cpp | 2 | ||||
-rw-r--r-- | netwerk/test/gtest/moz.build | 14 | ||||
-rw-r--r-- | netwerk/test/http3server/Cargo.toml | 10 | ||||
-rw-r--r-- | netwerk/test/unit/head_channels.js | 2 | ||||
-rw-r--r-- | netwerk/test/unit/test_cookies_privatebrowsing.js | 13 | ||||
-rw-r--r-- | netwerk/test/unit/test_dns_override.js | 25 | ||||
-rw-r--r-- | netwerk/test/unit/test_httpssvc_iphint.js | 4 | ||||
-rw-r--r-- | netwerk/test/unit/test_verify_traffic.js | 39 | ||||
-rw-r--r-- | netwerk/test/unit/xpcshell.toml | 2 |
16 files changed, 447 insertions, 31 deletions
diff --git a/netwerk/test/browser/browser.toml b/netwerk/test/browser/browser.toml index 002bd2769d..a12ffed212 100644 --- a/netwerk/test/browser/browser.toml +++ b/netwerk/test/browser/browser.toml @@ -72,6 +72,7 @@ support-files = [ "x_frame_options.html^headers^", "test_1629307.html", "file_link_header.sjs", + "file_link_dns_prefetch.sjs", ] prefs = [ @@ -156,6 +157,8 @@ skip-if = ["os == 'win'"] # Bug 1775761 ["browser_cookie_sync_across_tabs.js"] +["browser_dns_prefetch_link_header.js"] + ["browser_fetch_lnk.js"] run-if = ["os == 'win'"] support-files = ["file_lnk.lnk",] diff --git a/netwerk/test/browser/browser_dns_prefetch_link_header.js b/netwerk/test/browser/browser_dns_prefetch_link_header.js new file mode 100644 index 0000000000..a7954cadb5 --- /dev/null +++ b/netwerk/test/browser/browser_dns_prefetch_link_header.js @@ -0,0 +1,282 @@ +/* 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 steps: +// 1. Load file_link_dns_prefetch.sjs +// 2.`<link rel="dns-prefetch" href="https://example.org">` is in +// the server-side sjs, so we will make the dns-request. +// 3. We verify that the dns request was made + +const gDashboard = Cc["@mozilla.org/network/dashboard;1"].getService( + Ci.nsIDashboard +); + +///////////////////////////////////////////////////////////////////////////// +// To observe DNS requests when running via the mochitest proxy we must first take a few steps: +// +// 1. Update the mochitest proxy pac file to include dns resolution. +// We do this by injecting "dnsResolve(host);" into the `FindProxyForURL()` pac function. +let existingPACScript = Services.prefs.getCharPref( + "network.proxy.autoconfig_url" +); + +let findProxyForURLFunction = "function FindProxyForURL(url, host){"; +let directDnsPacScript = existingPACScript.replace( + findProxyForURLFunction, + `${findProxyForURLFunction} + dnsResolve(host); + ` +); +Services.prefs.setStringPref( + "network.proxy.autoconfig_url", + directDnsPacScript +); + +// 2. Ensure we don't disable dns prefetch despite using a proxy (this would otherwise happen after every request that the proxy completed) +Services.prefs.setBoolPref("network.dns.prefetch_via_proxy", true); + +// 3. And finally enable dns prefetching via the private dns service api (generally disabled in mochitest proxy) +Services.dns.QueryInterface(Ci.nsPIDNSService).prefetchEnabled = true; +///////////////////////////////////////////////////////////////////////////// + +registerCleanupFunction(function () { + // Restore proxy pac and dns prefetch behaviour via proxy + Services.prefs.setCharPref("network.proxy.autoconfig_url", existingPACScript); + Services.prefs.clearUserPref("network.dns.prefetch_via_proxy"); + Services.dns.QueryInterface(Ci.nsPIDNSService).prefetchEnabled = false; +}); + +async function isRecordFound(hostname) { + return new Promise(resolve => { + gDashboard.requestDNSInfo(function (data) { + let found = false; + for (let i = 0; i < data.entries.length; i++) { + if (data.entries[i].hostname == hostname) { + found = true; + break; + } + } + resolve(found); + }); + }); +} + +let https_requestUrl = `https://example.com/browser/netwerk/test/browser/file_link_dns_prefetch.sjs`; +let http_requestUrl = `http://example.com/browser/netwerk/test/browser/file_link_dns_prefetch.sjs`; // eslint-disable-line @microsoft/sdl/no-insecure-url + +// Test dns-prefetch on https +add_task(async function test_https_dns_prefetch() { + Services.dns.clearCache(true); + + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: https_requestUrl, + waitForLoad: true, + }, + async function () {} + ); + + Assert.ok( + await TestUtils.waitForCondition(() => { + return isRecordFound("example.org"); + }), + "Record from link rel=dns-prefetch element should be found" + ); + Assert.ok(await isRecordFound("example.com"), "Host record should be found"); +}); + +// Test dns-prefetch on http +add_task(async function test_http_dns_prefetch() { + Services.dns.clearCache(true); + + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: http_requestUrl, + waitForLoad: true, + }, + async function () {} + ); + + Assert.ok( + await TestUtils.waitForCondition(() => { + return isRecordFound("example.org"); + }), + "Record from link rel=dns-prefetch element should be found" + ); + Assert.ok(await isRecordFound("example.com"), "Host record should be found"); +}); + +// Test dns-prefetch on https with the feature disabled +add_task(async function test_https_dns_prefetch_disabled() { + Services.dns.clearCache(true); + + // Disable the feature to verify that it will not prefetch + Services.prefs.setBoolPref("network.dns.disablePrefetchFromHTTPS", true); + + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: https_requestUrl, + waitForLoad: true, + }, + async function () {} + ); + + Assert.ok(await isRecordFound("example.com"), "Host record should be found"); + Assert.ok( + !(await isRecordFound("example.org")), + "Record from link rel=dns-prefetch element should not be found with disablePrefetchFromHTTPS set" + ); + + Services.prefs.clearUserPref("network.dns.disablePrefetchFromHTTPS"); +}); + +// Test dns-prefetch on http with the feature disabled +add_task(async function test_http_dns_prefetch_disabled() { + Services.dns.clearCache(true); + + // Disable the feature to verify, but this test is http, and so prefetch will execute + Services.prefs.setBoolPref("network.dns.disablePrefetchFromHTTPS", true); + + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: http_requestUrl, + waitForLoad: true, + }, + async function () {} + ); + + Assert.ok( + await TestUtils.waitForCondition(() => { + return isRecordFound("example.org"); + }), + "Record from link rel=dns-prefetch element should be found on http page with disablePrefetchFromHTTPS set" + ); + Assert.ok(await isRecordFound("example.com"), "Host record should be found"); + + Services.prefs.clearUserPref("network.dns.disablePrefetchFromHTTPS"); +}); + +// Test if we speculatively prefetch dns for anchor elements on https documents +add_task(async function test_https_anchor_speculative_dns_prefetch() { + Services.dns.clearCache(true); + + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: https_requestUrl, + waitForLoad: true, + }, + async function () { + Assert.ok( + await isRecordFound("example.com"), + "Host record should be found" + ); + Assert.ok( + !(await isRecordFound("www.mozilla.org")), + "By default we do not speculatively prefetch dns for anchor elements on https documents" + ); + } + ); + + // And enable the pref to verify that it works + Services.prefs.setBoolPref( + "dom.prefetch_dns_for_anchor_https_document", + true + ); + Services.dns.clearCache(true); + + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: https_requestUrl, + waitForLoad: true, + }, + async function () { + // The anchor element prefetchs are sent after pageload event; wait for them + Assert.ok( + await TestUtils.waitForCondition(() => { + return isRecordFound("www.mozilla.org"); + }), + "Speculatively prefetch dns for anchor elements on https documents" + ); + Assert.ok( + await isRecordFound("example.com"), + "Host record should be found" + ); + } + ); + + Services.prefs.clearUserPref("dom.prefetch_dns_for_anchor_https_document"); +}); + +// Test that we speculatively prefetch dns for anchor elements on http documents +add_task(async function test_http_anchor_speculative_dns_prefetch() { + Services.dns.clearCache(true); + + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: http_requestUrl, + waitForLoad: true, + }, + async function () { + Assert.ok( + await TestUtils.waitForCondition(() => { + return isRecordFound("example.org"); + }), + "Record from link rel=dns-prefetch element should be found" + ); + + // The anchor element prefetchs are sent after pageload event; wait for them + Assert.ok( + await TestUtils.waitForCondition(() => { + return isRecordFound("www.mozilla.org"); + }), + "By default we speculatively prefetch dns for anchor elements on http documents" + ); + + Assert.ok( + await isRecordFound("example.com"), + "Host record should be found" + ); + } + ); + + // And disable the pref to verify that we no longer make the requests + Services.prefs.setBoolPref( + "dom.prefetch_dns_for_anchor_http_document", + false + ); + Services.dns.clearCache(true); + + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: http_requestUrl, + waitForLoad: true, + }, + async function () { + Assert.ok( + await TestUtils.waitForCondition(() => { + return isRecordFound("example.org"); + }), + "Record from link rel=dns-prefetch element should be found" + ); + Assert.ok( + !(await isRecordFound("www.mozilla.org")), + "We disabled speculative prefetch dns for anchor elements on http documents" + ); + Assert.ok( + await isRecordFound("example.com"), + "Host record should be found" + ); + } + ); + + Services.prefs.clearUserPref("dom.prefetch_dns_for_anchor_http_document"); +}); diff --git a/netwerk/test/browser/file_link_dns_prefetch.sjs b/netwerk/test/browser/file_link_dns_prefetch.sjs new file mode 100644 index 0000000000..6ca959bda1 --- /dev/null +++ b/netwerk/test/browser/file_link_dns_prefetch.sjs @@ -0,0 +1,25 @@ +"use strict"; + +function handleRequest(request, response) { + // write to raw socket + response.seizePower(); + let body = `<!DOCTYPE html> + <html> + <head> + <link rel="dns-prefetch" href="https://example.org"> + </head> + <body> + <h1>Test rel=dns-prefetch<h1> + <a href="https://www.mozilla.org"> Test link </a> + </body> + </html>`; + + response.write("HTTP/1.1 200 OK\r\n"); + response.write("Content-Type: text/html;charset=utf-8\r\n"); + response.write("Cache-Control: no-cache\r\n"); + response.write(`Content-Length: ${body.length}\r\n`); + response.write("\r\n"); + response.write(body); + + response.finish(); +} diff --git a/netwerk/test/gtest/TestCommon.h b/netwerk/test/gtest/TestCommon.h index 0d2fd74e5b..76620fbb44 100644 --- a/netwerk/test/gtest/TestCommon.h +++ b/netwerk/test/gtest/TestCommon.h @@ -17,8 +17,8 @@ class WaitForCondition final : public nsIRunnable { NS_DECL_THREADSAFE_ISUPPORTS void Wait(int pending) { - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(mPending == 0); + MOZ_RELEASE_ASSERT(NS_IsMainThread()); + MOZ_RELEASE_ASSERT(mPending == 0); mPending = pending; mozilla::SpinEventLoopUntil("TestCommon.h:WaitForCondition::Wait"_ns, @@ -32,8 +32,8 @@ class WaitForCondition final : public nsIRunnable { virtual ~WaitForCondition() = default; NS_IMETHOD Run() override { - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(mPending); + MOZ_RELEASE_ASSERT(NS_IsMainThread()); + MOZ_RELEASE_ASSERT(mPending); --mPending; return NS_OK; diff --git a/netwerk/test/gtest/TestCookie.cpp b/netwerk/test/gtest/TestCookie.cpp index 4812ee47f1..e99e9f6332 100644 --- a/netwerk/test/gtest/TestCookie.cpp +++ b/netwerk/test/gtest/TestCookie.cpp @@ -95,7 +95,7 @@ void SetACookieInternal(nsICookieService* aCookieService, const char* aSpec, /* shouldResistFingerprinting */ false) : CookieJarSettings::GetBlockingAll( /* shouldResistFingerprinting */ false); - MOZ_ASSERT(cookieJarSettings); + MOZ_RELEASE_ASSERT(cookieJarSettings); nsCOMPtr<nsILoadInfo> loadInfo = dummyChannel->LoadInfo(); loadInfo->SetCookieJarSettings(cookieJarSettings); @@ -140,7 +140,7 @@ void GetACookieNoHttp(nsICookieService* aCookieService, const char* aSpec, RefPtr<BasePrincipal> principal = BasePrincipal::CreateContentPrincipal(uri, OriginAttributes()); - MOZ_ASSERT(principal); + MOZ_RELEASE_ASSERT(principal); nsCOMPtr<mozilla::dom::Document> document; nsresult rv = NS_NewDOMDocument(getter_AddRefs(document), diff --git a/netwerk/test/gtest/TestIDNA.cpp b/netwerk/test/gtest/TestIDNA.cpp index 544debbd43..56b05025d7 100644 --- a/netwerk/test/gtest/TestIDNA.cpp +++ b/netwerk/test/gtest/TestIDNA.cpp @@ -3,6 +3,9 @@ #include "gtest/BlackBox.h" #include "nsNetUtil.h" +#include "nsIURI.h" +#include "nsCOMPtr.h" +#include "mozilla/Encoding.h" #define TEST_COUNT 10000 @@ -10,7 +13,7 @@ class TestIDNA : public ::testing::Test { protected: void SetUp() override { // Intentionally Assign and not AssignLiteral - // to simulate the usual heap case. + // to simulate the heap case. mPlainASCII.Assign("example.com"); mLeadingDigitASCII.Assign("1test.example"); mUnicodeMixed.Assign("مثال.example"); @@ -20,6 +23,16 @@ class TestIDNA : public ::testing::Test { mUnicodeRTL.Assign("الاسم.مثال"); mPunycodeRTL.Assign("xn--mgba0b1dh.xn--mgbh0fb"); // Intentionally not assigning to mEmpty + + // For measuring the case inside nsStandardURL + mUrlPlainASCII.Assign("https://example.com/"); + mUrlLeadingDigitASCII.Assign("https://1test.example/"); + mUrlUnicodeMixed.Assign("https://مثال.example/"); + mUrlPunycodeMixed.Assign("https://xn--mgbh0fb.example/"); + mUrlUnicodeLTR.Assign("https://නම.උදාහරණ/"); + mUrlPunycodeLTR.Assign("https://xn--r0co.xn--ozc8dl2c3bxd/"); + mUrlUnicodeRTL.Assign("https://الاسم.مثال/"); + mUrlPunycodeRTL.Assign("https://xn--mgba0b1dh.xn--mgbh0fb/"); } public: @@ -32,6 +45,14 @@ class TestIDNA : public ::testing::Test { nsCString mUnicodeRTL; nsCString mPunycodeRTL; nsCString mEmpty; // Extremely suspicious measurement! + nsCString mUrlPlainASCII; + nsCString mUrlLeadingDigitASCII; + nsCString mUrlUnicodeMixed; + nsCString mUrlPunycodeMixed; + nsCString mUrlUnicodeLTR; + nsCString mUrlPunycodeLTR; + nsCString mUrlUnicodeRTL; + nsCString mUrlPunycodeRTL; }; #define IDNA_ITERATIONS 50000 @@ -44,6 +65,17 @@ class TestIDNA : public ::testing::Test { } \ }); +#define IDNA_URL_BENCH(name, src) \ + MOZ_GTEST_BENCH_F(TestIDNA, name, [this] { \ + for (int i = 0; i < IDNA_ITERATIONS; i++) { \ + nsCOMPtr<nsIURI> dst; \ + nsresult rv = NS_NewURI(getter_AddRefs(dst), *mozilla::BlackBox(&src), \ + UTF_8_ENCODING); \ + ASSERT_EQ(NS_OK, rv); \ + mozilla::BlackBox(&dst); \ + } \ + }); + IDNA_BENCH(BenchToASCIIPlainASCII, NS_DomainToASCII, mPlainASCII); IDNA_BENCH(BenchToASCIILeadingDigitASCII, NS_DomainToASCII, mLeadingDigitASCII); IDNA_BENCH(BenchToASCIIUnicodeMixed, NS_DomainToASCII, mUnicodeMixed); @@ -75,3 +107,12 @@ IDNA_BENCH(BenchToUnicodePunycodeLTR, NS_DomainToUnicode, mPunycodeLTR); IDNA_BENCH(BenchToUnicodeUnicodeRTL, NS_DomainToUnicode, mUnicodeRTL); IDNA_BENCH(BenchToUnicodePunycodeRTL, NS_DomainToUnicode, mPunycodeRTL); IDNA_BENCH(BenchToUnicodeEmpty, NS_DomainToUnicode, mEmpty); + +IDNA_URL_BENCH(BenchUrlPlainASCII, mUrlPlainASCII); +IDNA_URL_BENCH(BenchUrlLeadingDigitASCII, mUrlLeadingDigitASCII); +IDNA_URL_BENCH(BenchUrlUnicodeMixed, mUrlUnicodeMixed); +IDNA_URL_BENCH(BenchUrlPunycodeMixed, mUrlPunycodeMixed); +IDNA_URL_BENCH(BenchUrlUnicodeLTR, mUrlUnicodeLTR); +IDNA_URL_BENCH(BenchUrlPunycodeLTR, mUrlPunycodeLTR); +IDNA_URL_BENCH(BenchUrlUnicodeRTL, mUrlUnicodeRTL); +IDNA_URL_BENCH(BenchUrlPunycodeRTL, mUrlPunycodeRTL); diff --git a/netwerk/test/gtest/TestInputStreamTransport.cpp b/netwerk/test/gtest/TestInputStreamTransport.cpp index 43df0e193a..de19f48147 100644 --- a/netwerk/test/gtest/TestInputStreamTransport.cpp +++ b/netwerk/test/gtest/TestInputStreamTransport.cpp @@ -29,7 +29,7 @@ void CreateStream(already_AddRefed<nsIInputStream> aSource, ASSERT_EQ(NS_OK, rv); nsCOMPtr<nsIAsyncInputStream> asyncStream = do_QueryInterface(wrapper); - MOZ_ASSERT(asyncStream); + MOZ_RELEASE_ASSERT(asyncStream); asyncStream.forget(aStream); } diff --git a/netwerk/test/gtest/TestNamedPipeService.cpp b/netwerk/test/gtest/TestNamedPipeService.cpp index b91a17a93e..ef764dde13 100644 --- a/netwerk/test/gtest/TestNamedPipeService.cpp +++ b/netwerk/test/gtest/TestNamedPipeService.cpp @@ -31,7 +31,7 @@ class Event { void Set() { MonitorAutoLock lock(mMonitor); - MOZ_ASSERT(!mSignaled); + MOZ_RELEASE_ASSERT(!mSignaled); mSignaled = true; mMonitor.Notify(); } diff --git a/netwerk/test/gtest/moz.build b/netwerk/test/gtest/moz.build index 8e0d66f4e2..a0333ecde7 100644 --- a/netwerk/test/gtest/moz.build +++ b/netwerk/test/gtest/moz.build @@ -23,6 +23,7 @@ UNIFIED_SOURCES += [ "TestLinkHeader.cpp", "TestMIMEInputStream.cpp", "TestMozURL.cpp", + "TestPACMan.cpp", "TestProtocolProxyService.cpp", "TestReadStreamToString.cpp", "TestServerTimingHeader.cpp", @@ -30,24 +31,15 @@ UNIFIED_SOURCES += [ "TestSSLTokensCache.cpp", "TestStandardURL.cpp", "TestUDPSocket.cpp", + "TestURIMutator.cpp", ] if CONFIG["OS_TARGET"] == "WINNT": UNIFIED_SOURCES += [ "TestNamedPipeService.cpp", + "TestNetworkLinkIdHashingWindows.cpp", ] -# skip the test on windows10-aarch64 -if not (CONFIG["OS_TARGET"] == "WINNT" and CONFIG["TARGET_CPU"] == "aarch64"): - UNIFIED_SOURCES += [ - "TestPACMan.cpp", - "TestURIMutator.cpp", - ] - -# run the test on windows only -if CONFIG["OS_TARGET"] == "WINNT": - UNIFIED_SOURCES += ["TestNetworkLinkIdHashingWindows.cpp"] - # run the test on mac only if CONFIG["TARGET_OS"] == "OSX": UNIFIED_SOURCES += ["TestNetworkLinkIdHashingDarwin.cpp"] diff --git a/netwerk/test/http3server/Cargo.toml b/netwerk/test/http3server/Cargo.toml index 4905760d3d..d2413636f7 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.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" } +neqo-transport = { tag = "v0.7.7", git = "https://github.com/mozilla/neqo" } +neqo-common = { tag = "v0.7.7", git = "https://github.com/mozilla/neqo" } +neqo-http3 = { tag = "v0.7.7", git = "https://github.com/mozilla/neqo" } +neqo-qpack = { tag = "v0.7.7", 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.5" +tag = "v0.7.7" git = "https://github.com/mozilla/neqo" default-features = false features = ["gecko"] diff --git a/netwerk/test/unit/head_channels.js b/netwerk/test/unit/head_channels.js index ca16bd2835..94a20b0a3d 100644 --- a/netwerk/test/unit/head_channels.js +++ b/netwerk/test/unit/head_channels.js @@ -480,7 +480,7 @@ function bytesToString(bytes) { function check_http_info(request, expected_httpVersion, expected_proxy) { let httpVersion = ""; try { - httpVersion = request.protocolVersion; + httpVersion = request.QueryInterface(Ci.nsIHttpChannel).protocolVersion; } catch (e) {} request.QueryInterface(Ci.nsIProxiedChannel); diff --git a/netwerk/test/unit/test_cookies_privatebrowsing.js b/netwerk/test/unit/test_cookies_privatebrowsing.js index 9d3528440a..dab719954e 100644 --- a/netwerk/test/unit/test_cookies_privatebrowsing.js +++ b/netwerk/test/unit/test_cookies_privatebrowsing.js @@ -96,10 +96,21 @@ add_task(async () => { Services.cookies.setCookieStringFromHttp(uri2, "oh=hai; max-age=1000", chan2); Assert.equal(await getCookieStringFromPrivateDocument(uri2.spec), "oh=hai"); + // on android fission the privateBrowsingHolder prevents + // the cookies on the content process from being updated + // Let's release the last PB window. + await privateBrowsingHolder.close(); + // Fake a profile change. await promise_close_profile(); do_load_profile(); + // keep the private browsing window open again + const privateBrowsingHolder2 = await CookieXPCShellUtils.loadContentPage( + "http://bar.com/", + { privateBrowsing: true } + ); + // We're still in private browsing mode, but should have a new session. // Check counts. Assert.equal(await getCookieStringFromPrivateDocument(uri1.spec), ""); @@ -127,6 +138,6 @@ add_task(async () => { Assert.equal(Services.cookies.countCookiesFromHost(uri2.host), 0); // Let's release the last PB window. - privateBrowsingHolder.close(); + await privateBrowsingHolder2.close(); Services.prefs.clearUserPref("dom.security.https_first"); }); diff --git a/netwerk/test/unit/test_dns_override.js b/netwerk/test/unit/test_dns_override.js index f092dd531c..75fc69c289 100644 --- a/netwerk/test/unit/test_dns_override.js +++ b/netwerk/test/unit/test_dns_override.js @@ -353,7 +353,10 @@ function hexToUint8Array(hex) { add_task( { - skip_if: () => mozinfo.os == "win" || mozinfo.os == "android", + skip_if: () => + mozinfo.os == "win" || + mozinfo.os == "android" || + mozinfo.socketprocess_networking, }, async function test_https_record_override() { let trrServer = new TRRServer(); @@ -414,6 +417,7 @@ add_task( Services.prefs.setBoolPref("network.dns.native_https_query", true); registerCleanupFunction(async () => { Services.prefs.clearUserPref("network.dns.native_https_query"); + Services.prefs.clearUserPref("network.trr.excluded-domains"); }); let listener = new Listener(); @@ -511,5 +515,24 @@ add_task( "def...", "got correct answer" ); + + // Adding "service.com" into excluded-domains should fail + // native HTTPS query. + Services.prefs.setCharPref("network.trr.excluded-domains", "service.com"); + listener = new Listener(); + try { + Services.dns.asyncResolve( + "service.com", + Ci.nsIDNSService.RESOLVE_TYPE_HTTPSSVC, + 0, + null, + listener, + mainThread, + defaultOriginAttributes + ); + Assert.ok(false, "asyncResolve should fail"); + } catch (e) { + Assert.equal(e.result, Cr.NS_ERROR_UNKNOWN_HOST); + } } ); diff --git a/netwerk/test/unit/test_httpssvc_iphint.js b/netwerk/test/unit/test_httpssvc_iphint.js index 13d9a7e648..40f6727e08 100644 --- a/netwerk/test/unit/test_httpssvc_iphint.js +++ b/netwerk/test/unit/test_httpssvc_iphint.js @@ -316,7 +316,7 @@ add_task(async function testIPHintWithFreshDNS() { ); let chan = makeChan(`https://test.iphint.org/server-timing`); - chan.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE; + chan.loadFlags |= Ci.nsIRequest.LOAD_FRESH_CONNECTION; let [req] = await channelOpenPromise( chan, CL_EXPECT_FAILURE | CL_ALLOW_UNKNOWN_CL @@ -337,7 +337,7 @@ add_task(async function testIPHintWithFreshDNS() { }); chan = makeChan(`https://test.iphint.org/server-timing`); - chan.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE; + chan.loadFlags |= Ci.nsIRequest.LOAD_FRESH_CONNECTION; [req] = await channelOpenPromise(chan); Assert.equal(req.protocolVersion, "h2"); let internal = req.QueryInterface(Ci.nsIHttpChannelInternal); diff --git a/netwerk/test/unit/test_verify_traffic.js b/netwerk/test/unit/test_verify_traffic.js index be41223642..2b806332c9 100644 --- a/netwerk/test/unit/test_verify_traffic.js +++ b/netwerk/test/unit/test_verify_traffic.js @@ -9,6 +9,14 @@ /* import-globals-from head_channels.js */ /* import-globals-from head_servers.js */ +const gDashboard = Cc["@mozilla.org/network/dashboard;1"].getService( + Ci.nsIDashboard +); + +const { TestUtils } = ChromeUtils.importESModule( + "resource://testing-common/TestUtils.sys.mjs" +); + function makeChan(uri) { let chan = NetUtil.newChannel({ uri, @@ -106,5 +114,36 @@ add_task(async function test_verify_traffic_for_http2() { sessionCount = await server.sessionCount(); Assert.equal(sessionCount, 2); + // Create another request and trigger the network change event again. + // The second network change event is to put the second connection into the + // pending list. + res = await new Promise(resolve => { + // Create a request that takes 8s to finish. + let chan = makeChan(`https://localhost:${server.port()}/longDelay`); + chan.asyncOpen(new ChannelListener(resolve, null, CL_ALLOW_UNKNOWN_CL)); + + Services.obs.notifyObservers( + null, + "network:link-status-changed", + "changed" + ); + }); + + Assert.equal(res.status, Cr.NS_OK); + Assert.equal(res.QueryInterface(Ci.nsIHttpChannel).responseStatus, 200); + + async function getSocketCount() { + return new Promise(resolve => { + gDashboard.requestSockets(function (data) { + resolve(data.sockets.length); + }); + }); + } + + await TestUtils.waitForCondition(async () => { + const socketCount = await getSocketCount(); + return socketCount === 0; + }, "Socket count should be 0"); + await server.stop(); }); diff --git a/netwerk/test/unit/xpcshell.toml b/netwerk/test/unit/xpcshell.toml index c86a1759e7..a2c09da498 100644 --- a/netwerk/test/unit/xpcshell.toml +++ b/netwerk/test/unit/xpcshell.toml @@ -113,6 +113,7 @@ skip-if = [ ["test_auth_proxy.js"] ["test_authentication.js"] +requesttimeoutfactor = 2 ["test_authpromptwrapper.js"] @@ -484,7 +485,6 @@ 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 |