diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/net/proxy_resolution | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/net/proxy_resolution')
7 files changed, 65 insertions, 130 deletions
diff --git a/chromium/net/proxy_resolution/configured_proxy_resolution_service.cc b/chromium/net/proxy_resolution/configured_proxy_resolution_service.cc index c699df2bb33..68fc89b5455 100644 --- a/chromium/net/proxy_resolution/configured_proxy_resolution_service.cc +++ b/chromium/net/proxy_resolution/configured_proxy_resolution_service.cc @@ -391,34 +391,6 @@ GURL SanitizeUrl(const GURL& url) { return url.ReplaceComponents(replacements); } -// Do not change the enumerated value as it is relied on by histograms. -enum class PacUrlSchemeForHistogram { - kOther = 0, - - kHttp = 1, - kHttps = 2, - kFtp = 3, - kFile = 4, - kData = 5, - - kMaxValue = kData, -}; - -PacUrlSchemeForHistogram GetPacUrlScheme(const GURL& pac_url) { - if (pac_url.SchemeIs("http")) - return PacUrlSchemeForHistogram::kHttp; - if (pac_url.SchemeIs("https")) - return PacUrlSchemeForHistogram::kHttps; - if (pac_url.SchemeIs("data")) - return PacUrlSchemeForHistogram::kData; - if (pac_url.SchemeIs("ftp")) - return PacUrlSchemeForHistogram::kFtp; - if (pac_url.SchemeIs("file")) - return PacUrlSchemeForHistogram::kFile; - - return PacUrlSchemeForHistogram::kOther; -} - } // namespace // ConfiguredProxyResolutionService::InitProxyResolver @@ -1511,11 +1483,6 @@ void ConfiguredProxyResolutionService::OnProxyConfigChanged( }); } - if (config.value().has_pac_url()) { - UMA_HISTOGRAM_ENUMERATION("Net.ProxyResolutionService.PacUrlScheme", - GetPacUrlScheme(config.value().pac_url())); - } - // Set the new configuration as the most recently fetched one. fetched_config_ = effective_config; diff --git a/chromium/net/proxy_resolution/configured_proxy_resolution_service_unittest.cc b/chromium/net/proxy_resolution/configured_proxy_resolution_service_unittest.cc index 9b129ee2e81..c9a5fb01269 100644 --- a/chromium/net/proxy_resolution/configured_proxy_resolution_service_unittest.cc +++ b/chromium/net/proxy_resolution/configured_proxy_resolution_service_unittest.cc @@ -346,42 +346,6 @@ JobMap GetCancelledJobsForURLs(const MockAsyncProxyResolver& resolver, return GetJobsForURLs(map, urls); } -// Helper class to verify the bucket counts for PacUrlScheme histogram. -class PacUrlSchemeHistogramTester { - public: - void VerifyHistogram() const { - const char kPacUrlSchemeHistogram[] = - "Net.ProxyResolutionService.PacUrlScheme"; - - int total = GetTotal(); - - histograms_.ExpectTotalCount(kPacUrlSchemeHistogram, total); - - if (total > 0) { - histograms_.ExpectBucketCount(kPacUrlSchemeHistogram, 0, num_other); - histograms_.ExpectBucketCount(kPacUrlSchemeHistogram, 1, num_http); - histograms_.ExpectBucketCount(kPacUrlSchemeHistogram, 2, num_https); - histograms_.ExpectBucketCount(kPacUrlSchemeHistogram, 3, num_ftp); - histograms_.ExpectBucketCount(kPacUrlSchemeHistogram, 4, num_file); - histograms_.ExpectBucketCount(kPacUrlSchemeHistogram, 5, num_data); - } - } - - int num_http = 0; - int num_https = 0; - int num_ftp = 0; - int num_data = 0; - int num_file = 0; - int num_other = 0; - - private: - int GetTotal() const { - return num_http + num_https + num_ftp + num_data + num_file + num_other; - } - - base::HistogramTester histograms_; -}; - } // namespace TEST_F(ConfiguredProxyResolutionServiceTest, Direct) { @@ -3999,61 +3963,6 @@ TEST_F(ConfiguredProxyResolutionServiceTest, OnShutdownFollowedByRequest) { EXPECT_TRUE(info.is_direct()); } -// Tests that the URL scheme for PAC files gets output to the histogram. -TEST_F(ConfiguredProxyResolutionServiceTest, PacUrlSchemeHistogram) { - PacUrlSchemeHistogramTester pac_histogram; - - MockProxyConfigService* config_service = - new MockProxyConfigService(ProxyConfig::CreateDirect()); - - ConfiguredProxyResolutionService service( - base::WrapUnique(config_service), - std::make_unique<MockAsyncProxyResolverFactory>(false), nullptr, - /*quick_check_enabled=*/true); - - pac_histogram.VerifyHistogram(); - - // Set an http:// PAC. - config_service->SetPacUrlConfig("http://example.test/"); - pac_histogram.num_http++; - pac_histogram.VerifyHistogram(); - - // Set an https:// PAC. - config_service->SetPacUrlConfig("hTTps://example.test/wpad.dat"); - pac_histogram.num_https++; - pac_histogram.VerifyHistogram(); - - // Set an ftp:// PAC. - config_service->SetPacUrlConfig("ftp://example.test/pac.js"); - pac_histogram.num_ftp++; - pac_histogram.VerifyHistogram(); - - // Set an file:// PAC. - config_service->SetPacUrlConfig("file://example.test/boo"); - pac_histogram.num_file++; - pac_histogram.VerifyHistogram(); - - // Set an mailto: PAC. - config_service->SetPacUrlConfig("mailto:foo@example.test"); - pac_histogram.num_other++; - pac_histogram.VerifyHistogram(); - - // Set an data: PAC. - config_service->SetPacUrlConfig("data:,Hello%2C%20World!"); - pac_histogram.num_data++; - pac_histogram.VerifyHistogram(); - - // Set an filesystem: PAC. - config_service->SetPacUrlConfig("filesystem:http://example.test/pac.js"); - pac_histogram.num_other++; - pac_histogram.VerifyHistogram(); - - // Set another https:// as PAC. - config_service->SetPacUrlConfig("https://example2.test/wpad.dat"); - pac_histogram.num_https++; - pac_histogram.VerifyHistogram(); -} - const char* kImplicityBypassedHosts[] = { "localhost", "localhost.", diff --git a/chromium/net/proxy_resolution/network_delegate_error_observer_unittest.cc b/chromium/net/proxy_resolution/network_delegate_error_observer_unittest.cc index dff170e9e55..b0c9ff4322c 100644 --- a/chromium/net/proxy_resolution/network_delegate_error_observer_unittest.cc +++ b/chromium/net/proxy_resolution/network_delegate_error_observer_unittest.cc @@ -59,7 +59,6 @@ class TestNetworkDelegate : public NetworkDelegateImpl { got_pac_error_ = true; } bool OnCanGetCookies(const URLRequest& request, - const CookieList& cookie_list, bool allowed_from_caller) override { return allowed_from_caller; } diff --git a/chromium/net/proxy_resolution/pac_file_fetcher_impl.cc b/chromium/net/proxy_resolution/pac_file_fetcher_impl.cc index cedd67874ce..f31ae9a7b22 100644 --- a/chromium/net/proxy_resolution/pac_file_fetcher_impl.cc +++ b/chromium/net/proxy_resolution/pac_file_fetcher_impl.cc @@ -175,6 +175,8 @@ int PacFileFetcherImpl::Fetch( cur_request_ = url_request_context_->CreateRequest(url, MAXIMUM_PRIORITY, this, traffic_annotation); + cur_request_->set_isolation_info(isolation_info_); + // Make sure that the PAC script is downloaded using a direct connection, // to avoid circular dependencies (fetching is a part of proxy resolution). // Also disable the use of the disk cache. The cache is disabled so that if @@ -316,6 +318,7 @@ void PacFileFetcherImpl::OnReadCompleted(URLRequest* request, int num_bytes) { PacFileFetcherImpl::PacFileFetcherImpl(URLRequestContext* url_request_context) : url_request_context_(url_request_context), + isolation_info_(IsolationInfo::CreateTransient()), buf_(base::MakeRefCounted<IOBuffer>(kBufSize)), next_id_(0), cur_request_id_(0), diff --git a/chromium/net/proxy_resolution/pac_file_fetcher_impl.h b/chromium/net/proxy_resolution/pac_file_fetcher_impl.h index efbba739f5c..0ceea27f615 100644 --- a/chromium/net/proxy_resolution/pac_file_fetcher_impl.h +++ b/chromium/net/proxy_resolution/pac_file_fetcher_impl.h @@ -17,6 +17,7 @@ #include "base/strings/string16.h" #include "base/time/time.h" #include "net/base/completion_once_callback.h" +#include "net/base/isolation_info.h" #include "net/base/net_export.h" #include "net/proxy_resolution/pac_file_fetcher.h" #include "net/traffic_annotation/network_traffic_annotation.h" @@ -80,6 +81,8 @@ class NET_EXPORT PacFileFetcherImpl : public PacFileFetcher, void OnResponseStarted(URLRequest* request, int net_error) override; void OnReadCompleted(URLRequest* request, int num_bytes) override; + const IsolationInfo& isolation_info_for_testing() { return isolation_info_; } + private: enum { kBufSize = 4096 }; @@ -110,6 +113,9 @@ class NET_EXPORT PacFileFetcherImpl : public PacFileFetcher, // OnShutdown. URLRequestContext* url_request_context_; + // Transient IsolationInfo used to fetch PAC scripts. + const IsolationInfo isolation_info_; + // Buffer that URLRequest writes into. scoped_refptr<IOBuffer> buf_; diff --git a/chromium/net/proxy_resolution/pac_file_fetcher_impl_unittest.cc b/chromium/net/proxy_resolution/pac_file_fetcher_impl_unittest.cc index d5c60af6869..34095ea5147 100644 --- a/chromium/net/proxy_resolution/pac_file_fetcher_impl_unittest.cc +++ b/chromium/net/proxy_resolution/pac_file_fetcher_impl_unittest.cc @@ -18,8 +18,10 @@ #include "base/single_thread_task_runner.h" #include "base/stl_util.h" #include "base/strings/utf_string_conversions.h" +#include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" #include "base/threading/thread_task_runner_handle.h" +#include "net/base/features.h" #include "net/base/filename_util.h" #include "net/base/load_flags.h" #include "net/base/network_delegate_impl.h" @@ -73,13 +75,12 @@ struct FetchResult { base::string16 text; }; -// A non-mock URL request which can access http:// and file:// urls, in the case -// the tests were built with file support. +// A non-mock URL request which can access http:// urls. class RequestContext : public URLRequestContext { public: RequestContext() : storage_(this) { ProxyConfig no_proxy; - storage_.set_host_resolver(std::make_unique<MockHostResolver>()); + storage_.set_host_resolver(std::make_unique<MockCachingHostResolver>()); storage_.set_cert_verifier(std::make_unique<MockCertVerifier>()); storage_.set_transport_security_state( std::make_unique<TransportSecurityState>()); @@ -179,7 +180,6 @@ class BasicNetworkDelegate : public NetworkDelegateImpl { } bool OnCanGetCookies(const URLRequest& request, - const CookieList& cookie_list, bool allowed_from_caller) override { return allowed_from_caller; } @@ -321,6 +321,58 @@ TEST_F(PacFileFetcherImplTest, ContentDisposition) { EXPECT_EQ(ASCIIToUTF16("-downloadable.pac-\n"), text); } +// Verifies that fetches are made using the fetcher's IsolationInfo, by checking +// the DNS cache. +TEST_F(PacFileFetcherImplTest, IsolationInfo) { + base::test::ScopedFeatureList feature_list; + feature_list.InitWithFeatures( + // enabled_features + {features::kPartitionConnectionsByNetworkIsolationKey, + features::kSplitHostCacheByNetworkIsolationKey}, + // disabled_features + {}); + const char kHost[] = "foo.test"; + + ASSERT_TRUE(test_server_.Start()); + + auto pac_fetcher = PacFileFetcherImpl::Create(&context_); + + GURL url(test_server_.GetURL(kHost, "/downloadable.pac")); + base::string16 text; + TestCompletionCallback callback; + int result = pac_fetcher->Fetch(url, &text, callback.callback(), + TRAFFIC_ANNOTATION_FOR_TESTS); + EXPECT_THAT(callback.GetResult(result), IsOk()); + EXPECT_EQ(ASCIIToUTF16("-downloadable.pac-\n"), text); + + // Check that the URL in kDestination is in the HostCache, with + // the fetcher's IsolationInfo / NetworkIsolationKey, and no others. + const net::HostPortPair kHostPortPair = + net::HostPortPair(kHost, 0 /* port */); + net::HostResolver::ResolveHostParameters params; + params.source = net::HostResolverSource::LOCAL_ONLY; + std::unique_ptr<net::HostResolver::ResolveHostRequest> host_request = + context_.host_resolver()->CreateRequest( + kHostPortPair, + pac_fetcher->isolation_info_for_testing().network_isolation_key(), + net::NetLogWithSource(), params); + net::TestCompletionCallback callback2; + result = host_request->Start(callback2.callback()); + EXPECT_EQ(net::OK, callback2.GetResult(result)); + + // Make sure there are no other entries in the HostCache (which would + // potentially be associated with other NetworkIsolationKeys). + EXPECT_EQ(1u, context_.host_resolver()->GetHostCache()->size()); + + // Make sure the cache is actually returning different results based on + // NetworkIsolationKey. + host_request = context_.host_resolver()->CreateRequest( + kHostPortPair, NetworkIsolationKey(), net::NetLogWithSource(), params); + net::TestCompletionCallback callback3; + result = host_request->Start(callback3.callback()); + EXPECT_EQ(net::ERR_NAME_NOT_RESOLVED, callback3.GetResult(result)); +} + // Verifies that PAC scripts are not being cached. TEST_F(PacFileFetcherImplTest, NoCache) { ASSERT_TRUE(test_server_.Start()); diff --git a/chromium/net/proxy_resolution/proxy_resolver.h b/chromium/net/proxy_resolution/proxy_resolver.h index 6cfdb32859b..5b7e65c5ca4 100644 --- a/chromium/net/proxy_resolution/proxy_resolver.h +++ b/chromium/net/proxy_resolution/proxy_resolver.h @@ -6,7 +6,6 @@ #define NET_PROXY_RESOLUTION_PROXY_RESOLVER_H_ #include "base/callback_forward.h" -#include "base/logging.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/strings/string16.h" |