blob: 3478267321da04bf228aeed082a2769149914592 [file] [log] [blame]
xunjielif24ee5f2015-11-23 18:05:261// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "components/cronet/url_request_context_config.h"
6
Gyuyoung Kim6afb5082018-01-19 13:35:577#include <memory>
8
Eric Orthe1cdd902019-02-26 02:52:469#include "base/bind.h"
Julia Tuttle3cc27a4a2018-04-25 15:57:0610#include "base/json/json_writer.h"
Eric Orthe1cdd902019-02-26 02:52:4611#include "base/logging.h"
Douglas Creagera220947e2018-08-23 20:08:5312#include "base/strings/string_piece.h"
mmenke51629db12017-06-28 13:34:1213#include "base/test/scoped_task_environment.h"
Douglas Creagera220947e2018-08-23 20:08:5314#include "base/test/values_test_util.h"
tfhef3618f2016-01-11 23:07:0815#include "base/values.h"
Zhongyi Shiaa518c22018-06-15 04:37:3616#include "build/build_config.h"
Eric Orthe1cdd902019-02-26 02:52:4617#include "net/base/host_port_pair.h"
Matt Menked732ea42019-03-08 12:05:0018#include "net/base/http_user_agent_settings.h"
Eric Orthe1cdd902019-02-26 02:52:4619#include "net/base/net_errors.h"
pauljensen9041eb3c2015-12-09 12:29:0120#include "net/cert/cert_verifier.h"
Eric Orthe1cdd902019-02-26 02:52:4621#include "net/dns/host_resolver.h"
Eric Orth607b6d82019-05-08 16:43:3222#include "net/dns/host_resolver_manager.h"
xunjielif24ee5f2015-11-23 18:05:2623#include "net/http/http_network_session.h"
mikecironef22f9812016-10-04 03:40:1924#include "net/log/net_log.h"
25#include "net/log/net_log_with_source.h"
Lily Houghton582d4622018-01-22 22:43:4026#include "net/proxy_resolution/proxy_config.h"
27#include "net/proxy_resolution/proxy_config_service_fixed.h"
xunjielif24ee5f2015-11-23 18:05:2628#include "net/url_request/url_request_context.h"
29#include "net/url_request/url_request_context_builder.h"
30#include "testing/gtest/include/gtest/gtest.h"
31
Douglas Creagera220947e2018-08-23 20:08:5332#if BUILDFLAG(ENABLE_REPORTING)
33#include "net/network_error_logging/network_error_logging_service.h"
34#include "net/reporting/reporting_service.h"
35#endif // BUILDFLAG(ENABLE_REPORTING)
36
xunjielif24ee5f2015-11-23 18:05:2637namespace cronet {
38
Douglas Creagera220947e2018-08-23 20:08:5339namespace {
40
Douglas Creagera220947e2018-08-23 20:08:5341std::string WrapJsonHeader(base::StringPiece value) {
42 std::string result;
43 result.reserve(value.size() + 2);
44 result.push_back('[');
45 value.AppendToString(&result);
46 result.push_back(']');
47 return result;
48}
49
50// Returns whether two JSON-encoded headers contain the same content, ignoring
51// irrelevant encoding issues like whitespace and map element ordering.
52bool JsonHeaderEquals(base::StringPiece expected, base::StringPiece actual) {
Lei Zhang9b9d5792019-02-20 07:24:4253 return base::test::ParseJson(WrapJsonHeader(expected)) ==
54 base::test::ParseJson(WrapJsonHeader(actual));
Douglas Creagera220947e2018-08-23 20:08:5355}
56
57} // namespace
58
mmenke51629db12017-06-28 13:34:1259TEST(URLRequestContextConfigTest, TestExperimentalOptionParsing) {
60 base::test::ScopedTaskEnvironment scoped_task_environment_(
61 base::test::ScopedTaskEnvironment::MainThreadType::IO);
62
Julia Tuttle3cc27a4a2018-04-25 15:57:0663 // Create JSON for experimental options.
64 base::DictionaryValue options;
65 options.SetPath({"QUIC", "max_server_configs_stored_in_properties"},
66 base::Value(2));
67 options.SetPath({"QUIC", "user_agent_id"}, base::Value("Custom QUIC UAID"));
68 options.SetPath({"QUIC", "idle_connection_timeout_seconds"},
69 base::Value(300));
70 options.SetPath({"QUIC", "close_sessions_on_ip_change"}, base::Value(true));
71 options.SetPath({"QUIC", "race_cert_verification"}, base::Value(true));
72 options.SetPath({"QUIC", "connection_options"}, base::Value("TIME,TBBR,REJ"));
73 options.SetPath({"AsyncDNS", "enable"}, base::Value(true));
74 options.SetPath({"NetworkErrorLogging", "enable"}, base::Value(true));
Douglas Creagera220947e2018-08-23 20:08:5375 options.SetPath({"NetworkErrorLogging", "preloaded_report_to_headers"},
Lei Zhang9b9d5792019-02-20 07:24:4276 base::test::ParseJson(R"json(
Douglas Creagera220947e2018-08-23 20:08:5377 [
78 {
79 "origin": "https://test-origin/",
80 "value": {
81 "group": "test-group",
82 "max_age": 86400,
83 "endpoints": [
84 {"url": "https://test-endpoint/"},
85 ],
86 },
87 },
88 {
89 "origin": "https://test-origin-2/",
90 "value": [
91 {
92 "group": "test-group-2",
93 "max_age": 86400,
94 "endpoints": [
95 {"url": "https://test-endpoint-2/"},
96 ],
97 },
98 {
99 "group": "test-group-3",
100 "max_age": 86400,
101 "endpoints": [
102 {"url": "https://test-endpoint-3/"},
103 ],
104 },
105 ],
106 },
107 {
108 "origin": "https://value-is-missing/",
109 },
110 {
111 "value": "origin is missing",
112 },
113 {
114 "origin": 123,
115 "value": "origin is not a string",
116 },
117 {
118 "origin": "this is not a URL",
119 "value": "origin not a URL",
120 },
121 ]
122 )json"));
123 options.SetPath({"NetworkErrorLogging", "preloaded_nel_headers"},
Lei Zhang9b9d5792019-02-20 07:24:42124 base::test::ParseJson(R"json(
Douglas Creagera220947e2018-08-23 20:08:53125 [
126 {
127 "origin": "https://test-origin/",
128 "value": {
129 "report_to": "test-group",
130 "max_age": 86400,
131 },
132 },
133 ]
134 )json"));
Julia Tuttle3cc27a4a2018-04-25 15:57:06135 options.SetPath({"UnknownOption", "foo"}, base::Value(true));
136 options.SetPath({"HostResolverRules", "host_resolver_rules"},
137 base::Value("MAP * 127.0.0.1"));
138 // See http://crbug.com/696569.
139 options.SetKey("disable_ipv6_on_wifi", base::Value(true));
140 std::string options_json;
141 EXPECT_TRUE(base::JSONWriter::Write(options, &options_json));
142
pauljensen9041eb3c2015-12-09 12:29:01143 URLRequestContextConfig config(
144 // Enable QUIC.
145 true,
mefc5da5712016-02-09 20:14:23146 // QUIC User Agent ID.
147 "Default QUIC User Agent ID",
pauljensen9041eb3c2015-12-09 12:29:01148 // Enable SPDY.
149 true,
xunjieli186d2bf2017-04-18 13:45:47150 // Enable Brotli.
151 false,
pauljensen9041eb3c2015-12-09 12:29:01152 // Type of http cache.
153 URLRequestContextConfig::HttpCacheType::DISK,
154 // Max size of http cache in bytes.
155 1024000,
156 // Disable caching for HTTP responses. Other information may be stored in
157 // the cache.
158 false,
159 // Storage path for http cache and cookie storage.
160 "/data/data/org.chromium.net/app_cronet_test/test_storage",
Misha Efimovd4ab38302018-01-30 23:56:42161 // Accept-Language request header field.
162 "foreign-language",
pauljensen9041eb3c2015-12-09 12:29:01163 // User-Agent request header field.
164 "fake agent",
165 // JSON encoded experimental options.
Julia Tuttle3cc27a4a2018-04-25 15:57:06166 options_json,
pauljensen9041eb3c2015-12-09 12:29:01167 // MockCertVerifier to use for testing purposes.
tbansal7018e2a2016-06-25 00:40:39168 std::unique_ptr<net::CertVerifier>(),
169 // Enable network quality estimator.
kapishnikov385aa422016-07-01 20:53:02170 false,
171 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41172 true,
173 // Optional network thread priority.
174 base::Optional<double>(42.0));
xunjielif24ee5f2015-11-23 18:05:26175
xunjielif24ee5f2015-11-23 18:05:26176 net::URLRequestContextBuilder builder;
pauljensene92c4092015-12-09 19:13:48177 net::NetLog net_log;
David Benjamindc2f4b02017-07-27 23:59:02178 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
xunjielid67295e2017-03-16 21:05:41179 EXPECT_FALSE(config.effective_experimental_options->HasKey("UnknownOption"));
xunjielif24ee5f2015-11-23 18:05:26180 // Set a ProxyConfigService to avoid DCHECK failure when building.
ricea85ec57952016-08-31 09:34:10181 builder.set_proxy_config_service(
Lily Houghtonef028852017-12-06 20:52:30182 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49183 net::ProxyConfigWithAnnotation::CreateDirect()));
dchengfe3745e6242016-04-21 23:49:58184 std::unique_ptr<net::URLRequestContext> context(builder.Build());
xunjielif24ee5f2015-11-23 18:05:26185 const net::HttpNetworkSession::Params* params =
186 context->GetNetworkSessionParams();
187 // Check Quic Connection options.
Ryan Hamilton8d9ee76e2018-05-29 23:52:52188 quic::QuicTagVector quic_connection_options;
189 quic_connection_options.push_back(quic::kTIME);
190 quic_connection_options.push_back(quic::kTBBR);
191 quic_connection_options.push_back(quic::kREJ);
Nick Harper72ade192019-07-17 03:30:42192 EXPECT_EQ(quic_connection_options, params->quic_params.connection_options);
xunjielif24ee5f2015-11-23 18:05:26193
mefc5da5712016-02-09 20:14:23194 // Check Custom QUIC User Agent Id.
Nick Harper72ade192019-07-17 03:30:42195 EXPECT_EQ("Custom QUIC UAID", params->quic_params.user_agent_id);
mefc5da5712016-02-09 20:14:23196
rtenneti6971c172016-01-15 20:12:10197 // Check max_server_configs_stored_in_properties.
Nick Harper72ade192019-07-17 03:30:42198 EXPECT_EQ(2u, params->quic_params.max_server_configs_stored_in_properties);
xunjielif24ee5f2015-11-23 18:05:26199
rtenneti64e809d02015-12-11 00:26:20200 // Check idle_connection_timeout_seconds.
Nick Harper72ade192019-07-17 03:30:42201 EXPECT_EQ(300, params->quic_params.idle_connection_timeout_seconds);
rtenneti64e809d02015-12-11 00:26:20202
Nick Harper72ade192019-07-17 03:30:42203 EXPECT_TRUE(params->quic_params.close_sessions_on_ip_change);
204 EXPECT_FALSE(params->quic_params.goaway_sessions_on_ip_change);
205 EXPECT_FALSE(params->quic_params.allow_server_migration);
206 EXPECT_FALSE(params->quic_params.migrate_sessions_on_network_change_v2);
207 EXPECT_FALSE(params->quic_params.migrate_sessions_early_v2);
208 EXPECT_FALSE(params->quic_params.migrate_idle_sessions);
209 EXPECT_FALSE(params->quic_params.retry_on_alternate_network_before_handshake);
210 EXPECT_FALSE(params->quic_params.race_stale_dns_on_connection);
jrid26566952016-02-04 21:06:42211
rtennetid073dd22016-08-04 01:58:33212 // Check race_cert_verification.
Nick Harper72ade192019-07-17 03:30:42213 EXPECT_TRUE(params->quic_params.race_cert_verification);
rtennetid073dd22016-08-04 01:58:33214
Misha Efimov63957912017-12-06 07:13:26215#if defined(ENABLE_BUILT_IN_DNS)
216 // Check AsyncDNS resolver is enabled (not supported on iOS).
tfhef3618f2016-01-11 23:07:08217 EXPECT_TRUE(context->host_resolver()->GetDnsConfigAsValue());
Misha Efimov63957912017-12-06 07:13:26218#endif // defined(ENABLE_BUILT_IN_DNS)
mgershaf2c12c2016-08-22 16:33:54219
Julia Tuttle9715d1642018-01-29 17:02:26220#if BUILDFLAG(ENABLE_REPORTING)
221 // Check Reporting and Network Error Logging are enabled (can be disabled at
222 // build time).
223 EXPECT_TRUE(context->reporting_service());
Julia Tuttlecba7d222018-02-23 19:37:27224 EXPECT_TRUE(context->network_error_logging_service());
Julia Tuttle9715d1642018-01-29 17:02:26225#endif // BUILDFLAG(ENABLE_REPORTING)
226
Douglas Creagera220947e2018-08-23 20:08:53227 ASSERT_EQ(2u, config.preloaded_report_to_headers.size());
228 EXPECT_EQ(url::Origin::CreateFromNormalizedTuple("https", "test-origin", 443),
229 config.preloaded_report_to_headers[0].origin);
230 EXPECT_TRUE(JsonHeaderEquals( //
231 R"json(
232 {
233 "group": "test-group",
234 "max_age": 86400,
235 "endpoints": [
236 {"url": "https://test-endpoint/"},
237 ],
238 }
239 )json",
240 config.preloaded_report_to_headers[0].value));
241 EXPECT_EQ(
242 url::Origin::CreateFromNormalizedTuple("https", "test-origin-2", 443),
243 config.preloaded_report_to_headers[1].origin);
244 EXPECT_TRUE(JsonHeaderEquals( //
245 R"json(
246 {
247 "group": "test-group-2",
248 "max_age": 86400,
249 "endpoints": [
250 {"url": "https://test-endpoint-2/"},
251 ],
252 },
253 {
254 "group": "test-group-3",
255 "max_age": 86400,
256 "endpoints": [
257 {"url": "https://test-endpoint-3/"},
258 ],
259 }
260 )json",
261 config.preloaded_report_to_headers[1].value));
262
263 ASSERT_EQ(1u, config.preloaded_nel_headers.size());
264 EXPECT_EQ(url::Origin::CreateFromNormalizedTuple("https", "test-origin", 443),
265 config.preloaded_nel_headers[0].origin);
266 EXPECT_TRUE(JsonHeaderEquals( //
267 R"json(
268 {
269 "report_to": "test-group",
270 "max_age": 86400,
271 }
272 )json",
273 config.preloaded_nel_headers[0].value));
274
mgershaf9a9232017-04-13 20:19:03275 // Check IPv6 is disabled when on wifi.
Eric Orth607b6d82019-05-08 16:43:32276 EXPECT_FALSE(context->host_resolver()
277 ->GetManagerForTesting()
278 ->check_ipv6_on_wifi_for_testing());
mgershb3fe8082017-02-28 20:09:20279
Eric Orthe1cdd902019-02-26 02:52:46280 // All host resolution expected to be mapped to an immediately-resolvable IP.
281 std::unique_ptr<net::HostResolver::ResolveHostRequest> resolve_request =
282 context->host_resolver()->CreateRequest(net::HostPortPair("abcde", 80),
283 net::NetLogWithSource(),
284 base::nullopt);
285 EXPECT_EQ(net::OK, resolve_request->Start(
286 base::BindOnce([](int error) { NOTREACHED(); })));
Paul Jensen6a1ea3a2018-08-24 14:46:41287
288 EXPECT_TRUE(config.network_thread_priority);
289 EXPECT_EQ(42.0, config.network_thread_priority.value());
xunjielif24ee5f2015-11-23 18:05:26290}
291
Zhongyi Shi57247962018-11-05 20:03:52292TEST(URLRequestContextConfigTest, SetSupportedQuicVersion) {
293 base::test::ScopedTaskEnvironment scoped_task_environment_(
294 base::test::ScopedTaskEnvironment::MainThreadType::IO);
295
296 URLRequestContextConfig config(
297 // Enable QUIC.
298 true,
299 // QUIC User Agent ID.
300 "Default QUIC User Agent ID",
301 // Enable SPDY.
302 true,
303 // Enable Brotli.
304 false,
305 // Type of http cache.
306 URLRequestContextConfig::HttpCacheType::DISK,
307 // Max size of http cache in bytes.
308 1024000,
309 // Disable caching for HTTP responses. Other information may be stored in
310 // the cache.
311 false,
312 // Storage path for http cache and cookie storage.
313 "/data/data/org.chromium.net/app_cronet_test/test_storage",
314 // Accept-Language request header field.
315 "foreign-language",
316 // User-Agent request header field.
317 "fake agent",
318 // JSON encoded experimental options.
Ryan Hamilton8380c652019-06-04 02:25:06319 "{\"QUIC\":{\"quic_version\":\"QUIC_VERSION_46\"}}",
Zhongyi Shi57247962018-11-05 20:03:52320 // MockCertVerifier to use for testing purposes.
321 std::unique_ptr<net::CertVerifier>(),
322 // Enable network quality estimator.
323 false,
324 // Enable Public Key Pinning bypass for local trust anchors.
325 true,
326 // Optional network thread priority.
327 base::Optional<double>());
328
329 net::URLRequestContextBuilder builder;
330 net::NetLog net_log;
331 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
332 // Set a ProxyConfigService to avoid DCHECK failure when building.
333 builder.set_proxy_config_service(
334 std::make_unique<net::ProxyConfigServiceFixed>(
335 net::ProxyConfigWithAnnotation::CreateDirect()));
336 std::unique_ptr<net::URLRequestContext> context(builder.Build());
337 const net::HttpNetworkSession::Params* params =
338 context->GetNetworkSessionParams();
Nick Harper72ade192019-07-17 03:30:42339 EXPECT_EQ(params->quic_params.supported_versions.size(), 1u);
340 EXPECT_EQ(params->quic_params.supported_versions[0],
Nick Harper23290b82019-05-02 00:02:56341 quic::ParsedQuicVersion(quic::PROTOCOL_QUIC_CRYPTO,
Ryan Hamilton8380c652019-06-04 02:25:06342 quic::QUIC_VERSION_46));
Zhongyi Shi57247962018-11-05 20:03:52343}
344
345TEST(URLRequestContextConfigTest, SetUnsupportedQuicVersion) {
346 base::test::ScopedTaskEnvironment scoped_task_environment_(
347 base::test::ScopedTaskEnvironment::MainThreadType::IO);
348
349 URLRequestContextConfig config(
350 // Enable QUIC.
351 true,
352 // QUIC User Agent ID.
353 "Default QUIC User Agent ID",
354 // Enable SPDY.
355 true,
356 // Enable Brotli.
357 false,
358 // Type of http cache.
359 URLRequestContextConfig::HttpCacheType::DISK,
360 // Max size of http cache in bytes.
361 1024000,
362 // Disable caching for HTTP responses. Other information may be stored in
363 // the cache.
364 false,
365 // Storage path for http cache and cookie storage.
366 "/data/data/org.chromium.net/app_cronet_test/test_storage",
367 // Accept-Language request header field.
368 "foreign-language",
369 // User-Agent request header field.
370 "fake agent",
371 // JSON encoded experimental options.
372 "{\"QUIC\":{\"quic_version\":\"QUIC_VERSION_33\"}}",
373 // MockCertVerifier to use for testing purposes.
374 std::unique_ptr<net::CertVerifier>(),
375 // Enable network quality estimator.
376 false,
377 // Enable Public Key Pinning bypass for local trust anchors.
378 true,
379 // Optional network thread priority.
380 base::Optional<double>());
381
382 net::URLRequestContextBuilder builder;
383 net::NetLog net_log;
384 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
385 // Set a ProxyConfigService to avoid DCHECK failure when building.
386 builder.set_proxy_config_service(
387 std::make_unique<net::ProxyConfigServiceFixed>(
388 net::ProxyConfigWithAnnotation::CreateDirect()));
389 std::unique_ptr<net::URLRequestContext> context(builder.Build());
390 const net::HttpNetworkSession::Params* params =
391 context->GetNetworkSessionParams();
Nick Harper72ade192019-07-17 03:30:42392 EXPECT_EQ(params->quic_params.supported_versions.size(), 1u);
393 EXPECT_EQ(params->quic_params.supported_versions[0],
Nick Harper23290b82019-05-02 00:02:56394 quic::ParsedQuicVersion(quic::PROTOCOL_QUIC_CRYPTO,
Ryan Hamilton3cbc5632019-05-20 17:16:29395 quic::QUIC_VERSION_46));
Zhongyi Shi57247962018-11-05 20:03:52396}
397
Zhongyi Shi8ff38c12018-02-22 00:02:30398TEST(URLRequestContextConfigTest, SetQuicServerMigrationOptions) {
399 base::test::ScopedTaskEnvironment scoped_task_environment_(
400 base::test::ScopedTaskEnvironment::MainThreadType::IO);
401
402 URLRequestContextConfig config(
403 // Enable QUIC.
404 true,
405 // QUIC User Agent ID.
406 "Default QUIC User Agent ID",
407 // Enable SPDY.
408 true,
409 // Enable Brotli.
410 false,
411 // Type of http cache.
412 URLRequestContextConfig::HttpCacheType::DISK,
413 // Max size of http cache in bytes.
414 1024000,
415 // Disable caching for HTTP responses. Other information may be stored in
416 // the cache.
417 false,
418 // Storage path for http cache and cookie storage.
419 "/data/data/org.chromium.net/app_cronet_test/test_storage",
420 // Accept-Language request header field.
421 "foreign-language",
422 // User-Agent request header field.
423 "fake agent",
424 // JSON encoded experimental options.
425 "{\"QUIC\":{\"allow_server_migration\":true}}",
426 // MockCertVerifier to use for testing purposes.
427 std::unique_ptr<net::CertVerifier>(),
428 // Enable network quality estimator.
429 false,
430 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41431 true,
432 // Optional network thread priority.
433 base::Optional<double>());
Zhongyi Shi8ff38c12018-02-22 00:02:30434
435 net::URLRequestContextBuilder builder;
436 net::NetLog net_log;
437 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
438 // Set a ProxyConfigService to avoid DCHECK failure when building.
439 builder.set_proxy_config_service(
440 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49441 net::ProxyConfigWithAnnotation::CreateDirect()));
Zhongyi Shi8ff38c12018-02-22 00:02:30442 std::unique_ptr<net::URLRequestContext> context(builder.Build());
443 const net::HttpNetworkSession::Params* params =
444 context->GetNetworkSessionParams();
445
Nick Harper72ade192019-07-17 03:30:42446 EXPECT_FALSE(params->quic_params.close_sessions_on_ip_change);
447 EXPECT_TRUE(params->quic_params.allow_server_migration);
Zhongyi Shi8ff38c12018-02-22 00:02:30448}
449
Zhongyi Shiaa518c22018-06-15 04:37:36450// Test that goaway_sessions_on_ip_change is set on by default for iOS.
451#if defined(OS_IOS)
452#define MAYBE_SetQuicGoAwaySessionsOnIPChangeByDefault \
453 SetQuicGoAwaySessionsOnIPChangeByDefault
454#else
455#define MAYBE_SetQuicGoAwaySessionsOnIPChangeByDefault \
456 DISABLED_SetQuicGoAwaySessionsOnIPChangeByDefault
457#endif
458TEST(URLRequestContextConfigTest,
459 MAYBE_SetQuicGoAwaySessionsOnIPChangeByDefault) {
460 base::test::ScopedTaskEnvironment scoped_task_environment_(
461 base::test::ScopedTaskEnvironment::MainThreadType::IO);
462
463 URLRequestContextConfig config(
464 // Enable QUIC.
465 true,
466 // QUIC User Agent ID.
467 "Default QUIC User Agent ID",
468 // Enable SPDY.
469 true,
470 // Enable Brotli.
471 false,
472 // Type of http cache.
473 URLRequestContextConfig::HttpCacheType::DISK,
474 // Max size of http cache in bytes.
475 1024000,
476 // Disable caching for HTTP responses. Other information may be stored in
477 // the cache.
478 false,
479 // Storage path for http cache and cookie storage.
480 "/data/data/org.chromium.net/app_cronet_test/test_storage",
481 // Accept-Language request header field.
482 "foreign-language",
483 // User-Agent request header field.
484 "fake agent",
485 // JSON encoded experimental options.
486 "{\"QUIC\":{}}",
487 // MockCertVerifier to use for testing purposes.
488 std::unique_ptr<net::CertVerifier>(),
489 // Enable network quality estimator.
490 false,
491 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41492 true,
493 // Optional network thread priority.
494 base::Optional<double>());
Zhongyi Shiaa518c22018-06-15 04:37:36495
496 net::URLRequestContextBuilder builder;
497 net::NetLog net_log;
498 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
499 // Set a ProxyConfigService to avoid DCHECK failure when building.
500 builder.set_proxy_config_service(
501 std::make_unique<net::ProxyConfigServiceFixed>(
502 net::ProxyConfigWithAnnotation::CreateDirect()));
503 std::unique_ptr<net::URLRequestContext> context(builder.Build());
504 const net::HttpNetworkSession::Params* params =
505 context->GetNetworkSessionParams();
506
Nick Harper72ade192019-07-17 03:30:42507 EXPECT_FALSE(params->quic_params.close_sessions_on_ip_change);
508 EXPECT_TRUE(params->quic_params.goaway_sessions_on_ip_change);
Zhongyi Shiaa518c22018-06-15 04:37:36509}
510
511// Tests that goaway_sessions_on_ip_changes can be set on via
512// experimental options on non-iOS.
513#if !defined(OS_IOS)
514#define MAYBE_SetQuicGoAwaySessionsOnIPChangeViaExperimentOptions \
515 SetQuicGoAwaySessionsOnIPChangeViaExperimentOptions
516#else
517#define MAYBE_SetQuicGoAwaySessionsOnIPChangeViaExperimentOptions \
518 DISABLED_SetQuicGoAwaySessionsOnIPChangeViaExperimentOptions
519#endif
520TEST(URLRequestContextConfigTest,
521 MAYBE_SetQuicGoAwaySessionsOnIPChangeViaExperimentOptions) {
Zhongyi Shi63574b72018-06-01 20:22:25522 base::test::ScopedTaskEnvironment scoped_task_environment_(
523 base::test::ScopedTaskEnvironment::MainThreadType::IO);
524
525 URLRequestContextConfig config(
526 // Enable QUIC.
527 true,
528 // QUIC User Agent ID.
529 "Default QUIC User Agent ID",
530 // Enable SPDY.
531 true,
532 // Enable Brotli.
533 false,
534 // Type of http cache.
535 URLRequestContextConfig::HttpCacheType::DISK,
536 // Max size of http cache in bytes.
537 1024000,
538 // Disable caching for HTTP responses. Other information may be stored in
539 // the cache.
540 false,
541 // Storage path for http cache and cookie storage.
542 "/data/data/org.chromium.net/app_cronet_test/test_storage",
543 // Accept-Language request header field.
544 "foreign-language",
545 // User-Agent request header field.
546 "fake agent",
547 // JSON encoded experimental options.
548 "{\"QUIC\":{\"goaway_sessions_on_ip_change\":true}}",
549 // MockCertVerifier to use for testing purposes.
550 std::unique_ptr<net::CertVerifier>(),
551 // Enable network quality estimator.
552 false,
553 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41554 true,
555 // Optional network thread priority.
556 base::Optional<double>());
Zhongyi Shi63574b72018-06-01 20:22:25557
558 net::URLRequestContextBuilder builder;
559 net::NetLog net_log;
560 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
561 // Set a ProxyConfigService to avoid DCHECK failure when building.
562 builder.set_proxy_config_service(
563 std::make_unique<net::ProxyConfigServiceFixed>(
564 net::ProxyConfigWithAnnotation::CreateDirect()));
565 std::unique_ptr<net::URLRequestContext> context(builder.Build());
566 const net::HttpNetworkSession::Params* params =
567 context->GetNetworkSessionParams();
568
Nick Harper72ade192019-07-17 03:30:42569 EXPECT_FALSE(params->quic_params.close_sessions_on_ip_change);
570 EXPECT_TRUE(params->quic_params.goaway_sessions_on_ip_change);
Zhongyi Shi63574b72018-06-01 20:22:25571}
572
Zhongyi Shiaa518c22018-06-15 04:37:36573// Test that goaway_sessions_on_ip_change can be set to false via
574// exprimental options on iOS.
575#if defined(OS_IOS)
576#define MAYBE_DisableQuicGoAwaySessionsOnIPChangeViaExperimentOptions \
577 DisableQuicGoAwaySessionsOnIPChangeViaExperimentOptions
578#else
579#define MAYBE_DisableQuicGoAwaySessionsOnIPChangeViaExperimentOptions \
580 DISABLED_DisableQuicGoAwaySessionsOnIPChangeViaExperimentOptions
581#endif
582TEST(URLRequestContextConfigTest,
583 MAYBE_DisableQuicGoAwaySessionsOnIPChangeViaExperimentOptions) {
584 base::test::ScopedTaskEnvironment scoped_task_environment_(
585 base::test::ScopedTaskEnvironment::MainThreadType::IO);
586
587 URLRequestContextConfig config(
588 // Enable QUIC.
589 true,
590 // QUIC User Agent ID.
591 "Default QUIC User Agent ID",
592 // Enable SPDY.
593 true,
594 // Enable Brotli.
595 false,
596 // Type of http cache.
597 URLRequestContextConfig::HttpCacheType::DISK,
598 // Max size of http cache in bytes.
599 1024000,
600 // Disable caching for HTTP responses. Other information may be stored in
601 // the cache.
602 false,
603 // Storage path for http cache and cookie storage.
604 "/data/data/org.chromium.net/app_cronet_test/test_storage",
605 // Accept-Language request header field.
606 "foreign-language",
607 // User-Agent request header field.
608 "fake agent",
609 // JSON encoded experimental options.
610 "{\"QUIC\":{\"goaway_sessions_on_ip_change\":false}}",
611 // MockCertVerifier to use for testing purposes.
612 std::unique_ptr<net::CertVerifier>(),
613 // Enable network quality estimator.
614 false,
615 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41616 true,
617 // Optional network thread priority.
618 base::Optional<double>());
Zhongyi Shiaa518c22018-06-15 04:37:36619
620 net::URLRequestContextBuilder builder;
621 net::NetLog net_log;
622 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
623 // Set a ProxyConfigService to avoid DCHECK failure when building.
624 builder.set_proxy_config_service(
625 std::make_unique<net::ProxyConfigServiceFixed>(
626 net::ProxyConfigWithAnnotation::CreateDirect()));
627 std::unique_ptr<net::URLRequestContext> context(builder.Build());
628 const net::HttpNetworkSession::Params* params =
629 context->GetNetworkSessionParams();
630
Nick Harper72ade192019-07-17 03:30:42631 EXPECT_FALSE(params->quic_params.close_sessions_on_ip_change);
632 EXPECT_FALSE(params->quic_params.goaway_sessions_on_ip_change);
Zhongyi Shiaa518c22018-06-15 04:37:36633}
634
Yixin Wang10f477ed2017-11-21 04:20:20635TEST(URLRequestContextConfigTest, SetQuicConnectionMigrationV2Options) {
Zhongyi Shi64795622017-11-20 02:21:49636 base::test::ScopedTaskEnvironment scoped_task_environment_(
637 base::test::ScopedTaskEnvironment::MainThreadType::IO);
638
639 URLRequestContextConfig config(
640 // Enable QUIC.
641 true,
642 // QUIC User Agent ID.
643 "Default QUIC User Agent ID",
644 // Enable SPDY.
645 true,
646 // Enable Brotli.
647 false,
648 // Type of http cache.
649 URLRequestContextConfig::HttpCacheType::DISK,
650 // Max size of http cache in bytes.
651 1024000,
652 // Disable caching for HTTP responses. Other information may be stored in
653 // the cache.
654 false,
655 // Storage path for http cache and cookie storage.
656 "/data/data/org.chromium.net/app_cronet_test/test_storage",
Misha Efimovd4ab38302018-01-30 23:56:42657 // Accept-Language request header field.
658 "foreign-language",
Zhongyi Shi64795622017-11-20 02:21:49659 // User-Agent request header field.
660 "fake agent",
661 // JSON encoded experimental options.
Zhongyi Shif4683a32017-12-01 00:03:28662 "{\"QUIC\":{\"migrate_sessions_on_network_change_v2\":true,"
Zhongyi Shi73f23ca872017-12-13 18:37:13663 "\"migrate_sessions_early_v2\":true,"
Zhongyi Shiff359581bc2018-09-26 18:11:48664 "\"retry_on_alternate_network_before_handshake\":true,"
Zhongyi Shi32fe14d42019-02-28 00:25:36665 "\"migrate_idle_sessions\":true,"
Zhongyi Shie01f2db2019-02-22 19:53:23666 "\"retransmittable_on_wire_timeout_milliseconds\":1000,"
Zhongyi Shibc85e3e2019-02-12 19:34:42667 "\"idle_session_migration_period_seconds\":15,"
Zhongyi Shi8b1e43f2017-12-13 20:46:30668 "\"max_time_on_non_default_network_seconds\":10,"
Zhongyi Shiee760762018-08-01 00:54:29669 "\"max_migrations_to_non_default_network_on_write_error\":3,"
Zhongyi Shi8b1e43f2017-12-13 20:46:30670 "\"max_migrations_to_non_default_network_on_path_degrading\":4}}",
Zhongyi Shi64795622017-11-20 02:21:49671 // MockCertVerifier to use for testing purposes.
672 std::unique_ptr<net::CertVerifier>(),
673 // Enable network quality estimator.
674 false,
675 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41676 true,
677 // Optional network thread priority.
678 base::Optional<double>());
Zhongyi Shi64795622017-11-20 02:21:49679
680 net::URLRequestContextBuilder builder;
681 net::NetLog net_log;
682 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
683 // Set a ProxyConfigService to avoid DCHECK failure when building.
684 builder.set_proxy_config_service(
Lily Houghtonef028852017-12-06 20:52:30685 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49686 net::ProxyConfigWithAnnotation::CreateDirect()));
Zhongyi Shi64795622017-11-20 02:21:49687 std::unique_ptr<net::URLRequestContext> context(builder.Build());
688 const net::HttpNetworkSession::Params* params =
689 context->GetNetworkSessionParams();
690
Nick Harper72ade192019-07-17 03:30:42691 EXPECT_TRUE(params->quic_params.migrate_sessions_on_network_change_v2);
692 EXPECT_TRUE(params->quic_params.migrate_sessions_early_v2);
693 EXPECT_TRUE(params->quic_params.retry_on_alternate_network_before_handshake);
694 EXPECT_EQ(1000,
695 params->quic_params.retransmittable_on_wire_timeout_milliseconds);
696 EXPECT_TRUE(params->quic_params.migrate_idle_sessions);
Zhongyi Shibc85e3e2019-02-12 19:34:42697 EXPECT_EQ(base::TimeDelta::FromSeconds(15),
Nick Harper72ade192019-07-17 03:30:42698 params->quic_params.idle_session_migration_period);
Zhongyi Shi73f23ca872017-12-13 18:37:13699 EXPECT_EQ(base::TimeDelta::FromSeconds(10),
Nick Harper72ade192019-07-17 03:30:42700 params->quic_params.max_time_on_non_default_network);
Zhongyi Shi8b1e43f2017-12-13 20:46:30701 EXPECT_EQ(
Nick Harper72ade192019-07-17 03:30:42702 3,
703 params->quic_params.max_migrations_to_non_default_network_on_write_error);
704 EXPECT_EQ(4, params->quic_params
705 .max_migrations_to_non_default_network_on_path_degrading);
Zhongyi Shi64795622017-11-20 02:21:49706}
707
Renjie94b90712018-10-18 21:03:19708TEST(URLRequestContextConfigTest, SetQuicStaleDNSracing) {
709 base::test::ScopedTaskEnvironment scoped_task_environment_(
710 base::test::ScopedTaskEnvironment::MainThreadType::IO);
711
712 URLRequestContextConfig config(
713 // Enable QUIC.
714 true,
715 // QUIC User Agent ID.
716 "Default QUIC User Agent ID",
717 // Enable SPDY.
718 true,
719 // Enable Brotli.
720 false,
721 // Type of http cache.
722 URLRequestContextConfig::HttpCacheType::DISK,
723 // Max size of http cache in bytes.
724 1024000,
725 // Disable caching for HTTP responses. Other information may be stored in
726 // the cache.
727 false,
728 // Storage path for http cache and cookie storage.
729 "/data/data/org.chromium.net/app_cronet_test/test_storage",
730 // Accept-Language request header field.
731 "foreign-language",
732 // User-Agent request header field.
733 "fake agent",
734 // JSON encoded experimental options.
735 "{\"QUIC\":{\"race_stale_dns_on_connection\":true}}",
736 // MockCertVerifier to use for testing purposes.
737 std::unique_ptr<net::CertVerifier>(),
738 // Enable network quality estimator.
739 false,
740 // Enable Public Key Pinning bypass for local trust anchors.
741 true,
742 // Optional network thread priority.
743 base::Optional<double>());
744
745 net::URLRequestContextBuilder builder;
746 net::NetLog net_log;
747 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
748 // Set a ProxyConfigService to avoid DCHECK failure when building.
749 builder.set_proxy_config_service(
750 std::make_unique<net::ProxyConfigServiceFixed>(
751 net::ProxyConfigWithAnnotation::CreateDirect()));
752 std::unique_ptr<net::URLRequestContext> context(builder.Build());
753 const net::HttpNetworkSession::Params* params =
754 context->GetNetworkSessionParams();
755
Nick Harper72ade192019-07-17 03:30:42756 EXPECT_TRUE(params->quic_params.race_stale_dns_on_connection);
Renjie94b90712018-10-18 21:03:19757}
758
Yixin Wang10f477ed2017-11-21 04:20:20759TEST(URLRequestContextConfigTest, SetQuicHostWhitelist) {
760 base::test::ScopedTaskEnvironment scoped_task_environment_(
761 base::test::ScopedTaskEnvironment::MainThreadType::IO);
762
763 URLRequestContextConfig config(
764 // Enable QUIC.
765 true,
766 // QUIC User Agent ID.
767 "Default QUIC User Agent ID",
768 // Enable SPDY.
769 true,
770 // Enable Brotli.
771 false,
772 // Type of http cache.
773 URLRequestContextConfig::HttpCacheType::DISK,
774 // Max size of http cache in bytes.
775 1024000,
776 // Disable caching for HTTP responses. Other information may be stored in
777 // the cache.
778 false,
779 // Storage path for http cache and cookie storage.
780 "/data/data/org.chromium.net/app_cronet_test/test_storage",
Misha Efimovd4ab38302018-01-30 23:56:42781 // Accept-Language request header field.
782 "foreign-language",
Yixin Wang10f477ed2017-11-21 04:20:20783 // User-Agent request header field.
784 "fake agent",
785 // JSON encoded experimental options.
786 "{\"QUIC\":{\"host_whitelist\":\"www.example.com,www.example.org\"}}",
787 // MockCertVerifier to use for testing purposes.
788 std::unique_ptr<net::CertVerifier>(),
789 // Enable network quality estimator.
790 false,
791 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41792 true,
793 // Optional network thread priority.
794 base::Optional<double>());
Yixin Wang10f477ed2017-11-21 04:20:20795
796 net::URLRequestContextBuilder builder;
797 net::NetLog net_log;
798 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
799 // Set a ProxyConfigService to avoid DCHECK failure when building.
800 builder.set_proxy_config_service(
Lily Houghtonef028852017-12-06 20:52:30801 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49802 net::ProxyConfigWithAnnotation::CreateDirect()));
Yixin Wang10f477ed2017-11-21 04:20:20803 std::unique_ptr<net::URLRequestContext> context(builder.Build());
804 const net::HttpNetworkSession::Params* params =
805 context->GetNetworkSessionParams();
806
Jan Wilken Dörrie45d34f42019-06-08 09:40:54807 EXPECT_TRUE(base::Contains(params->quic_host_whitelist, "www.example.com"));
808 EXPECT_TRUE(base::Contains(params->quic_host_whitelist, "www.example.org"));
Yixin Wang10f477ed2017-11-21 04:20:20809}
810
Yixin Wang983875152017-11-21 20:30:13811TEST(URLRequestContextConfigTest, SetQuicMaxTimeBeforeCryptoHandshake) {
812 base::test::ScopedTaskEnvironment scoped_task_environment_(
813 base::test::ScopedTaskEnvironment::MainThreadType::IO);
814
815 URLRequestContextConfig config(
816 // Enable QUIC.
817 true,
818 // QUIC User Agent ID.
819 "Default QUIC User Agent ID",
820 // Enable SPDY.
821 true,
822 // Enable Brotli.
823 false,
824 // Type of http cache.
825 URLRequestContextConfig::HttpCacheType::DISK,
826 // Max size of http cache in bytes.
827 1024000,
828 // Disable caching for HTTP responses. Other information may be stored in
829 // the cache.
830 false,
831 // Storage path for http cache and cookie storage.
832 "/data/data/org.chromium.net/app_cronet_test/test_storage",
Misha Efimovd4ab38302018-01-30 23:56:42833 // Accept-Language request header field.
834 "foreign-language",
Yixin Wang983875152017-11-21 20:30:13835 // User-Agent request header field.
836 "fake agent",
837 // JSON encoded experimental options.
838 "{\"QUIC\":{\"max_time_before_crypto_handshake_seconds\":7,"
839 "\"max_idle_time_before_crypto_handshake_seconds\":11}}",
840 // MockCertVerifier to use for testing purposes.
841 std::unique_ptr<net::CertVerifier>(),
842 // Enable network quality estimator.
843 false,
844 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41845 true,
846 // Optional network thread priority.
847 base::Optional<double>());
Yixin Wang983875152017-11-21 20:30:13848
849 net::URLRequestContextBuilder builder;
850 net::NetLog net_log;
851 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
852 // Set a ProxyConfigService to avoid DCHECK failure when building.
853 builder.set_proxy_config_service(
Lily Houghtonef028852017-12-06 20:52:30854 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49855 net::ProxyConfigWithAnnotation::CreateDirect()));
Yixin Wang983875152017-11-21 20:30:13856 std::unique_ptr<net::URLRequestContext> context(builder.Build());
857 const net::HttpNetworkSession::Params* params =
858 context->GetNetworkSessionParams();
859
Nick Harper72ade192019-07-17 03:30:42860 EXPECT_EQ(7, params->quic_params.max_time_before_crypto_handshake_seconds);
861 EXPECT_EQ(11,
862 params->quic_params.max_idle_time_before_crypto_handshake_seconds);
Yixin Wang983875152017-11-21 20:30:13863}
864
Yixin Wang1875fdb2017-12-06 02:26:49865TEST(URLURLRequestContextConfigTest, SetQuicConnectionOptions) {
866 base::test::ScopedTaskEnvironment scoped_task_environment_(
867 base::test::ScopedTaskEnvironment::MainThreadType::IO);
868
869 URLRequestContextConfig config(
870 // Enable QUIC.
871 true,
872 // QUIC User Agent ID.
873 "Default QUIC User Agent ID",
874 // Enable SPDY.
875 true,
876 // Enable Brotli.
877 false,
878 // Type of http cache.
879 URLRequestContextConfig::HttpCacheType::DISK,
880 // Max size of http cache in bytes.
881 1024000,
882 // Disable caching for HTTP responses. Other information may be stored in
883 // the cache.
884 false,
885 // Storage path for http cache and cookie storage.
886 "/data/data/org.chromium.net/app_cronet_test/test_storage",
Misha Efimovd4ab38302018-01-30 23:56:42887 // Accept-Language request header field.
888 "foreign-language",
Yixin Wang1875fdb2017-12-06 02:26:49889 // User-Agent request header field.
890 "fake agent",
891 // JSON encoded experimental options.
892 "{\"QUIC\":{\"connection_options\":\"TIME,TBBR,REJ\","
893 "\"client_connection_options\":\"TBBR,1RTT\"}}",
894 // MockCertVerifier to use for testing purposes.
895 std::unique_ptr<net::CertVerifier>(),
896 // Enable network quality estimator.
897 false,
898 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41899 true,
900 // Optional network thread priority.
901 base::Optional<double>());
Yixin Wang1875fdb2017-12-06 02:26:49902
903 net::URLRequestContextBuilder builder;
904 net::NetLog net_log;
905 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
906 // Set a ProxyConfigService to avoid DCHECK failure when building.
907 builder.set_proxy_config_service(
Gyuyoung Kim6afb5082018-01-19 13:35:57908 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49909 net::ProxyConfigWithAnnotation::CreateDirect()));
Yixin Wang1875fdb2017-12-06 02:26:49910 std::unique_ptr<net::URLRequestContext> context(builder.Build());
911 const net::HttpNetworkSession::Params* params =
912 context->GetNetworkSessionParams();
913
Ryan Hamilton8d9ee76e2018-05-29 23:52:52914 quic::QuicTagVector connection_options;
915 connection_options.push_back(quic::kTIME);
916 connection_options.push_back(quic::kTBBR);
917 connection_options.push_back(quic::kREJ);
Nick Harper72ade192019-07-17 03:30:42918 EXPECT_EQ(connection_options, params->quic_params.connection_options);
Yixin Wang1875fdb2017-12-06 02:26:49919
Ryan Hamilton8d9ee76e2018-05-29 23:52:52920 quic::QuicTagVector client_connection_options;
921 client_connection_options.push_back(quic::kTBBR);
922 client_connection_options.push_back(quic::k1RTT);
Nick Harper72ade192019-07-17 03:30:42923 EXPECT_EQ(client_connection_options,
924 params->quic_params.client_connection_options);
Yixin Wang1875fdb2017-12-06 02:26:49925}
926
Misha Efimovd4ab38302018-01-30 23:56:42927TEST(URLURLRequestContextConfigTest, SetAcceptLanguageAndUserAgent) {
928 base::test::ScopedTaskEnvironment scoped_task_environment_(
929 base::test::ScopedTaskEnvironment::MainThreadType::IO);
930
931 URLRequestContextConfig config(
932 // Enable QUIC.
933 true,
934 // QUIC User Agent ID.
935 "Default QUIC User Agent ID",
936 // Enable SPDY.
937 true,
938 // Enable Brotli.
939 false,
940 // Type of http cache.
941 URLRequestContextConfig::HttpCacheType::DISK,
942 // Max size of http cache in bytes.
943 1024000,
944 // Disable caching for HTTP responses. Other information may be stored in
945 // the cache.
946 false,
947 // Storage path for http cache and cookie storage.
948 "/data/data/org.chromium.net/app_cronet_test/test_storage",
949 // Accept-Language request header field.
950 "foreign-language",
951 // User-Agent request header field.
952 "fake agent",
953 // JSON encoded experimental options.
954 "{}",
955 // MockCertVerifier to use for testing purposes.
956 std::unique_ptr<net::CertVerifier>(),
957 // Enable network quality estimator.
958 false,
959 // Enable Public Key Pinning bypass for local trust anchors.
Paul Jensen6a1ea3a2018-08-24 14:46:41960 true,
961 // Optional network thread priority.
962 base::Optional<double>());
Misha Efimovd4ab38302018-01-30 23:56:42963
964 net::URLRequestContextBuilder builder;
965 net::NetLog net_log;
966 config.ConfigureURLRequestContextBuilder(&builder, &net_log);
967 // Set a ProxyConfigService to avoid DCHECK failure when building.
968 builder.set_proxy_config_service(
969 std::make_unique<net::ProxyConfigServiceFixed>(
Ramin Halavatica8d5252018-03-12 05:33:49970 net::ProxyConfigWithAnnotation::CreateDirect()));
Misha Efimovd4ab38302018-01-30 23:56:42971 std::unique_ptr<net::URLRequestContext> context(builder.Build());
972 EXPECT_EQ("foreign-language",
973 context->http_user_agent_settings()->GetAcceptLanguage());
974 EXPECT_EQ("fake agent", context->http_user_agent_settings()->GetUserAgent());
975}
976
juliatuttle50d9c4b2016-08-23 22:49:19977// See stale_host_resolver_unittest.cc for test of StaleDNS options.
978
xunjielif24ee5f2015-11-23 18:05:26979} // namespace cronet