| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/proxy/proxy_service.h" | 5 #include "net/proxy/proxy_service.h" |
| 6 | 6 |
| 7 #include <cstdarg> | 7 #include <cstdarg> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 17 #include "net/base/network_delegate_impl.h" | 17 #include "net/base/proxy_delegate.h" |
| 18 #include "net/base/test_completion_callback.h" | 18 #include "net/base/test_completion_callback.h" |
| 19 #include "net/log/net_log.h" | 19 #include "net/log/net_log.h" |
| 20 #include "net/log/test_net_log.h" | 20 #include "net/log/test_net_log.h" |
| 21 #include "net/log/test_net_log_entry.h" | 21 #include "net/log/test_net_log_entry.h" |
| 22 #include "net/log/test_net_log_util.h" | 22 #include "net/log/test_net_log_util.h" |
| 23 #include "net/proxy/dhcp_proxy_script_fetcher.h" | 23 #include "net/proxy/dhcp_proxy_script_fetcher.h" |
| 24 #include "net/proxy/mock_proxy_resolver.h" | 24 #include "net/proxy/mock_proxy_resolver.h" |
| 25 #include "net/proxy/mock_proxy_script_fetcher.h" | 25 #include "net/proxy/mock_proxy_script_fetcher.h" |
| 26 #include "net/proxy/proxy_config_service.h" | 26 #include "net/proxy/proxy_config_service.h" |
| 27 #include "net/proxy/proxy_resolver.h" | 27 #include "net/proxy/proxy_resolver.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 OnProxyConfigChanged(config_, availability_)); | 155 OnProxyConfigChanged(config_, availability_)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 private: | 158 private: |
| 159 ConfigAvailability availability_; | 159 ConfigAvailability availability_; |
| 160 ProxyConfig config_; | 160 ProxyConfig config_; |
| 161 base::ObserverList<Observer, true> observers_; | 161 base::ObserverList<Observer, true> observers_; |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 // A test network delegate that exercises the OnResolveProxy callback. | 164 // A test network delegate that exercises the OnResolveProxy callback. |
| 165 class TestResolveProxyNetworkDelegate : public NetworkDelegateImpl { | 165 class TestResolveProxyDelegate : public ProxyDelegate { |
| 166 public: | 166 public: |
| 167 TestResolveProxyNetworkDelegate() | 167 TestResolveProxyDelegate() |
| 168 : on_resolve_proxy_called_(false), | 168 : on_resolve_proxy_called_(false), |
| 169 add_proxy_(false), | 169 add_proxy_(false), |
| 170 remove_proxy_(false), | 170 remove_proxy_(false), |
| 171 proxy_service_(NULL) { | 171 proxy_service_(NULL) {} |
| 172 } | |
| 173 | 172 |
| 174 void OnResolveProxy(const GURL& url, | 173 void OnResolveProxy(const GURL& url, |
| 175 int load_flags, | 174 int load_flags, |
| 176 const ProxyService& proxy_service, | 175 const ProxyService& proxy_service, |
| 177 ProxyInfo* result) override { | 176 ProxyInfo* result) override { |
| 178 on_resolve_proxy_called_ = true; | 177 on_resolve_proxy_called_ = true; |
| 179 proxy_service_ = &proxy_service; | 178 proxy_service_ = &proxy_service; |
| 180 DCHECK(!add_proxy_ || !remove_proxy_); | 179 DCHECK(!add_proxy_ || !remove_proxy_); |
| 181 if (add_proxy_) { | 180 if (add_proxy_) { |
| 182 result->UseNamedProxy("delegate_proxy.com"); | 181 result->UseNamedProxy("delegate_proxy.com"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 194 } | 193 } |
| 195 | 194 |
| 196 void set_remove_proxy(bool remove_proxy) { | 195 void set_remove_proxy(bool remove_proxy) { |
| 197 remove_proxy_ = remove_proxy; | 196 remove_proxy_ = remove_proxy; |
| 198 } | 197 } |
| 199 | 198 |
| 200 const ProxyService* proxy_service() const { | 199 const ProxyService* proxy_service() const { |
| 201 return proxy_service_; | 200 return proxy_service_; |
| 202 } | 201 } |
| 203 | 202 |
| 203 void OnTunnelConnectCompleted(const HostPortPair& endpoint, |
| 204 const HostPortPair& proxy_server, |
| 205 int net_error) override {} |
| 206 void OnFallback(const ProxyServer& bad_proxy, int net_error) override {} |
| 207 void OnBeforeSendHeaders(URLRequest* request, |
| 208 const ProxyInfo& proxy_info, |
| 209 HttpRequestHeaders* headers) override {} |
| 210 void OnBeforeTunnelRequest(const HostPortPair& proxy_server, |
| 211 HttpRequestHeaders* extra_headers) override {} |
| 212 void OnTunnelHeadersReceived( |
| 213 const HostPortPair& origin, |
| 214 const HostPortPair& proxy_server, |
| 215 const HttpResponseHeaders& response_headers) override {} |
| 216 bool IsTrustedSpdyProxy(const net::ProxyServer& proxy_server) override { |
| 217 return true; |
| 218 } |
| 219 |
| 204 private: | 220 private: |
| 205 bool on_resolve_proxy_called_; | 221 bool on_resolve_proxy_called_; |
| 206 bool add_proxy_; | 222 bool add_proxy_; |
| 207 bool remove_proxy_; | 223 bool remove_proxy_; |
| 208 const ProxyService* proxy_service_; | 224 const ProxyService* proxy_service_; |
| 209 }; | 225 }; |
| 210 | 226 |
| 211 // A test network delegate that exercises the OnProxyFallback callback. | 227 // A test network delegate that exercises the OnProxyFallback callback. |
| 212 class TestProxyFallbackNetworkDelegate : public NetworkDelegateImpl { | 228 class TestProxyFallbackProxyDelegate : public ProxyDelegate { |
| 213 public: | 229 public: |
| 214 TestProxyFallbackNetworkDelegate() | 230 TestProxyFallbackProxyDelegate() |
| 215 : on_proxy_fallback_called_(false), | 231 : on_proxy_fallback_called_(false), proxy_fallback_net_error_(OK) {} |
| 216 proxy_fallback_net_error_(OK) { | 232 // ProxyDelegate implementation: |
| 217 } | 233 void OnResolveProxy(const GURL& url, |
| 218 | 234 int load_flags, |
| 219 void OnProxyFallback(const ProxyServer& proxy_server, | 235 const ProxyService& proxy_service, |
| 220 int net_error) override { | 236 ProxyInfo* result) override {} |
| 221 proxy_server_ = proxy_server; | 237 void OnTunnelConnectCompleted(const HostPortPair& endpoint, |
| 238 const HostPortPair& proxy_server, |
| 239 int net_error) override {} |
| 240 void OnFallback(const ProxyServer& bad_proxy, int net_error) override { |
| 241 proxy_server_ = bad_proxy; |
| 222 proxy_fallback_net_error_ = net_error; | 242 proxy_fallback_net_error_ = net_error; |
| 223 on_proxy_fallback_called_ = true; | 243 on_proxy_fallback_called_ = true; |
| 224 } | 244 } |
| 245 void OnBeforeSendHeaders(URLRequest* request, |
| 246 const ProxyInfo& proxy_info, |
| 247 HttpRequestHeaders* headers) override {} |
| 248 void OnBeforeTunnelRequest(const HostPortPair& proxy_server, |
| 249 HttpRequestHeaders* extra_headers) override {} |
| 250 void OnTunnelHeadersReceived( |
| 251 const HostPortPair& origin, |
| 252 const HostPortPair& proxy_server, |
| 253 const HttpResponseHeaders& response_headers) override {} |
| 254 bool IsTrustedSpdyProxy(const net::ProxyServer& proxy_server) override { |
| 255 return true; |
| 256 } |
| 225 | 257 |
| 226 bool on_proxy_fallback_called() const { | 258 bool on_proxy_fallback_called() const { |
| 227 return on_proxy_fallback_called_; | 259 return on_proxy_fallback_called_; |
| 228 } | 260 } |
| 229 | 261 |
| 230 const ProxyServer& proxy_server() const { | 262 const ProxyServer& proxy_server() const { |
| 231 return proxy_server_; | 263 return proxy_server_; |
| 232 } | 264 } |
| 233 | 265 |
| 234 int proxy_fallback_net_error() const { | 266 int proxy_fallback_net_error() const { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 ProxyInfo info; | 391 ProxyInfo info; |
| 360 TestCompletionCallback callback; | 392 TestCompletionCallback callback; |
| 361 BoundTestNetLog log; | 393 BoundTestNetLog log; |
| 362 | 394 |
| 363 // First, warm up the ProxyService. | 395 // First, warm up the ProxyService. |
| 364 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), | 396 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), |
| 365 NULL, NULL, log.bound()); | 397 NULL, NULL, log.bound()); |
| 366 EXPECT_EQ(OK, rv); | 398 EXPECT_EQ(OK, rv); |
| 367 | 399 |
| 368 // Verify that network delegate is invoked. | 400 // Verify that network delegate is invoked. |
| 369 TestResolveProxyNetworkDelegate delegate; | 401 TestResolveProxyDelegate delegate; |
| 370 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, | 402 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, |
| 371 &delegate, log.bound()); | 403 &delegate, log.bound()); |
| 372 EXPECT_TRUE(delegate.on_resolve_proxy_called()); | 404 EXPECT_TRUE(delegate.on_resolve_proxy_called()); |
| 373 EXPECT_EQ(&service, delegate.proxy_service()); | 405 EXPECT_EQ(&service, delegate.proxy_service()); |
| 374 | 406 |
| 375 // Verify that the NetworkDelegate's behavior is stateless across | 407 // Verify that the ProxyDelegate's behavior is stateless across |
| 376 // invocations of ResolveProxy. Start by having the callback add a proxy | 408 // invocations of ResolveProxy. Start by having the callback add a proxy |
| 377 // and checking that subsequent requests are not affected. | 409 // and checking that subsequent requests are not affected. |
| 378 delegate.set_add_proxy(true); | 410 delegate.set_add_proxy(true); |
| 379 | 411 |
| 380 // Callback should interpose: | 412 // Callback should interpose: |
| 381 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, | 413 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, |
| 382 &delegate, log.bound()); | 414 &delegate, log.bound()); |
| 383 EXPECT_FALSE(info.is_direct()); | 415 EXPECT_FALSE(info.is_direct()); |
| 384 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "delegate_proxy.com"); | 416 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "delegate_proxy.com"); |
| 385 delegate.set_add_proxy(false); | 417 delegate.set_add_proxy(false); |
| 386 | 418 |
| 387 // Check non-bypassed URL: | 419 // Check non-bypassed URL: |
| 388 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, | 420 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, |
| 389 &delegate, log.bound()); | 421 &delegate, log.bound()); |
| 390 EXPECT_FALSE(info.is_direct()); | 422 EXPECT_FALSE(info.is_direct()); |
| 391 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "foopy1"); | 423 EXPECT_EQ(info.proxy_server().host_port_pair().host(), "foopy1"); |
| 392 | 424 |
| 393 // Check bypassed URL: | 425 // Check bypassed URL: |
| 394 rv = service.ResolveProxy(bypass_url, LOAD_NORMAL, &info, callback.callback(), | 426 rv = service.ResolveProxy(bypass_url, LOAD_NORMAL, &info, callback.callback(), |
| 395 NULL, &delegate, log.bound()); | 427 NULL, &delegate, log.bound()); |
| 396 EXPECT_TRUE(info.is_direct()); | 428 EXPECT_TRUE(info.is_direct()); |
| 397 } | 429 } |
| 398 | 430 |
| 399 TEST_F(ProxyServiceTest, OnResolveProxyCallbackRemoveProxy) { | 431 TEST_F(ProxyServiceTest, OnResolveProxyCallbackRemoveProxy) { |
| 400 // Same as OnResolveProxyCallbackAddProxy, but verify that the | 432 // Same as OnResolveProxyCallbackAddProxy, but verify that the |
| 401 // NetworkDelegate's behavior is stateless across invocations after it | 433 // ProxyDelegate's behavior is stateless across invocations after it |
| 402 // *removes* a proxy. | 434 // *removes* a proxy. |
| 403 ProxyConfig config; | 435 ProxyConfig config; |
| 404 config.proxy_rules().ParseFromString("foopy1:8080"); | 436 config.proxy_rules().ParseFromString("foopy1:8080"); |
| 405 config.set_auto_detect(false); | 437 config.set_auto_detect(false); |
| 406 config.proxy_rules().bypass_rules.ParseFromString("*.org"); | 438 config.proxy_rules().bypass_rules.ParseFromString("*.org"); |
| 407 | 439 |
| 408 ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)), | 440 ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)), |
| 409 nullptr, NULL); | 441 nullptr, NULL); |
| 410 | 442 |
| 411 GURL url("http://www.google.com/"); | 443 GURL url("http://www.google.com/"); |
| 412 GURL bypass_url("http://internet.org"); | 444 GURL bypass_url("http://internet.org"); |
| 413 | 445 |
| 414 ProxyInfo info; | 446 ProxyInfo info; |
| 415 TestCompletionCallback callback; | 447 TestCompletionCallback callback; |
| 416 BoundTestNetLog log; | 448 BoundTestNetLog log; |
| 417 | 449 |
| 418 // First, warm up the ProxyService. | 450 // First, warm up the ProxyService. |
| 419 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), | 451 int rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), |
| 420 NULL, NULL, log.bound()); | 452 NULL, NULL, log.bound()); |
| 421 EXPECT_EQ(OK, rv); | 453 EXPECT_EQ(OK, rv); |
| 422 | 454 |
| 423 TestResolveProxyNetworkDelegate delegate; | 455 TestResolveProxyDelegate delegate; |
| 424 delegate.set_remove_proxy(true); | 456 delegate.set_remove_proxy(true); |
| 425 | 457 |
| 426 // Callback should interpose: | 458 // Callback should interpose: |
| 427 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, | 459 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, |
| 428 &delegate, log.bound()); | 460 &delegate, log.bound()); |
| 429 EXPECT_TRUE(info.is_direct()); | 461 EXPECT_TRUE(info.is_direct()); |
| 430 delegate.set_remove_proxy(false); | 462 delegate.set_remove_proxy(false); |
| 431 | 463 |
| 432 // Check non-bypassed URL: | 464 // Check non-bypassed URL: |
| 433 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, | 465 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback.callback(), NULL, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 EXPECT_EQ("foopy:8080", info.proxy_server().ToURI()); | 601 EXPECT_EQ("foopy:8080", info.proxy_server().ToURI()); |
| 570 EXPECT_TRUE(info.did_use_pac_script()); | 602 EXPECT_TRUE(info.did_use_pac_script()); |
| 571 | 603 |
| 572 EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); | 604 EXPECT_FALSE(info.proxy_resolve_start_time().is_null()); |
| 573 EXPECT_FALSE(info.proxy_resolve_end_time().is_null()); | 605 EXPECT_FALSE(info.proxy_resolve_end_time().is_null()); |
| 574 EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time()); | 606 EXPECT_LE(info.proxy_resolve_start_time(), info.proxy_resolve_end_time()); |
| 575 | 607 |
| 576 // Now, imagine that connecting to foopy:8080 fails: there is nothing | 608 // Now, imagine that connecting to foopy:8080 fails: there is nothing |
| 577 // left to fallback to, since our proxy list was NOT terminated by | 609 // left to fallback to, since our proxy list was NOT terminated by |
| 578 // DIRECT. | 610 // DIRECT. |
| 579 NetworkDelegateImpl network_delegate; | 611 TestResolveProxyDelegate proxy_delegate; |
| 580 TestCompletionCallback callback2; | 612 TestCompletionCallback callback2; |
| 581 ProxyServer expected_proxy_server = info.proxy_server(); | 613 ProxyServer expected_proxy_server = info.proxy_server(); |
| 582 rv = service.ReconsiderProxyAfterError( | 614 rv = service.ReconsiderProxyAfterError( |
| 583 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, | 615 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, |
| 584 callback2.callback(), NULL, &network_delegate, BoundNetLog()); | 616 callback2.callback(), NULL, &proxy_delegate, BoundNetLog()); |
| 585 // ReconsiderProxyAfterError returns error indicating nothing left. | 617 // ReconsiderProxyAfterError returns error indicating nothing left. |
| 586 EXPECT_EQ(ERR_FAILED, rv); | 618 EXPECT_EQ(ERR_FAILED, rv); |
| 587 EXPECT_TRUE(info.is_empty()); | 619 EXPECT_TRUE(info.is_empty()); |
| 588 } | 620 } |
| 589 | 621 |
| 590 // Test that if the execution of the PAC script fails (i.e. javascript runtime | 622 // Test that if the execution of the PAC script fails (i.e. javascript runtime |
| 591 // error), and the PAC settings are non-mandatory, that we fall-back to direct. | 623 // error), and the PAC settings are non-mandatory, that we fall-back to direct. |
| 592 TEST_F(ProxyServiceTest, PAC_RuntimeError) { | 624 TEST_F(ProxyServiceTest, PAC_RuntimeError) { |
| 593 MockProxyConfigService* config_service = | 625 MockProxyConfigService* config_service = |
| 594 new MockProxyConfigService("http://foopy/proxy.pac"); | 626 new MockProxyConfigService("http://foopy/proxy.pac"); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 // Fallback 1. | 715 // Fallback 1. |
| 684 TestCompletionCallback callback2; | 716 TestCompletionCallback callback2; |
| 685 rv = service.ReconsiderProxyAfterError( | 717 rv = service.ReconsiderProxyAfterError( |
| 686 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, | 718 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, |
| 687 callback2.callback(), NULL, NULL, BoundNetLog()); | 719 callback2.callback(), NULL, NULL, BoundNetLog()); |
| 688 EXPECT_EQ(OK, rv); | 720 EXPECT_EQ(OK, rv); |
| 689 EXPECT_FALSE(info.is_direct()); | 721 EXPECT_FALSE(info.is_direct()); |
| 690 EXPECT_EQ("foobar:10", info.proxy_server().ToURI()); | 722 EXPECT_EQ("foobar:10", info.proxy_server().ToURI()); |
| 691 | 723 |
| 692 // Fallback 2. | 724 // Fallback 2. |
| 693 NetworkDelegateImpl network_delegate; | 725 TestResolveProxyDelegate proxy_delegate; |
| 694 ProxyServer expected_proxy_server3 = info.proxy_server(); | 726 ProxyServer expected_proxy_server3 = info.proxy_server(); |
| 695 TestCompletionCallback callback3; | 727 TestCompletionCallback callback3; |
| 696 rv = service.ReconsiderProxyAfterError( | 728 rv = service.ReconsiderProxyAfterError( |
| 697 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, | 729 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, |
| 698 callback3.callback(), NULL, &network_delegate, BoundNetLog()); | 730 callback3.callback(), NULL, &proxy_delegate, BoundNetLog()); |
| 699 EXPECT_EQ(OK, rv); | 731 EXPECT_EQ(OK, rv); |
| 700 EXPECT_TRUE(info.is_direct()); | 732 EXPECT_TRUE(info.is_direct()); |
| 701 | 733 |
| 702 // Fallback 3. | 734 // Fallback 3. |
| 703 ProxyServer expected_proxy_server4 = info.proxy_server(); | 735 ProxyServer expected_proxy_server4 = info.proxy_server(); |
| 704 TestCompletionCallback callback4; | 736 TestCompletionCallback callback4; |
| 705 rv = service.ReconsiderProxyAfterError( | 737 rv = service.ReconsiderProxyAfterError( |
| 706 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, | 738 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, |
| 707 callback4.callback(), NULL, &network_delegate, BoundNetLog()); | 739 callback4.callback(), NULL, &proxy_delegate, BoundNetLog()); |
| 708 EXPECT_EQ(OK, rv); | 740 EXPECT_EQ(OK, rv); |
| 709 EXPECT_FALSE(info.is_direct()); | 741 EXPECT_FALSE(info.is_direct()); |
| 710 EXPECT_EQ("foobar:20", info.proxy_server().ToURI()); | 742 EXPECT_EQ("foobar:20", info.proxy_server().ToURI()); |
| 711 | 743 |
| 712 // Fallback 4 -- Nothing to fall back to! | 744 // Fallback 4 -- Nothing to fall back to! |
| 713 ProxyServer expected_proxy_server5 = info.proxy_server(); | 745 ProxyServer expected_proxy_server5 = info.proxy_server(); |
| 714 TestCompletionCallback callback5; | 746 TestCompletionCallback callback5; |
| 715 rv = service.ReconsiderProxyAfterError( | 747 rv = service.ReconsiderProxyAfterError( |
| 716 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, | 748 url, LOAD_NORMAL, ERR_PROXY_CONNECTION_FAILED, &info, |
| 717 callback5.callback(), NULL, &network_delegate, BoundNetLog()); | 749 callback5.callback(), NULL, &proxy_delegate, BoundNetLog()); |
| 718 EXPECT_EQ(ERR_FAILED, rv); | 750 EXPECT_EQ(ERR_FAILED, rv); |
| 719 EXPECT_TRUE(info.is_empty()); | 751 EXPECT_TRUE(info.is_empty()); |
| 720 } | 752 } |
| 721 | 753 |
| 722 TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) { | 754 TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) { |
| 723 // Test whether the ProxyConfigSource set by the ProxyConfigService is applied | 755 // Test whether the ProxyConfigSource set by the ProxyConfigService is applied |
| 724 // to ProxyInfo after the proxy is resolved via a PAC script. | 756 // to ProxyInfo after the proxy is resolved via a PAC script. |
| 725 ProxyConfig config = | 757 ProxyConfig config = |
| 726 ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac")); | 758 ProxyConfig::CreateFromCustomPacURL(GURL("http://foopy/proxy.pac")); |
| 727 config.set_source(PROXY_CONFIG_SOURCE_TEST); | 759 config.set_source(PROXY_CONFIG_SOURCE_TEST); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 EXPECT_EQ(OK, rv); | 1200 EXPECT_EQ(OK, rv); |
| 1169 | 1201 |
| 1170 // Proxy times should not have been modified by fallback. | 1202 // Proxy times should not have been modified by fallback. |
| 1171 EXPECT_EQ(proxy_resolve_start_time, info.proxy_resolve_start_time()); | 1203 EXPECT_EQ(proxy_resolve_start_time, info.proxy_resolve_start_time()); |
| 1172 EXPECT_EQ(proxy_resolve_end_time, info.proxy_resolve_end_time()); | 1204 EXPECT_EQ(proxy_resolve_end_time, info.proxy_resolve_end_time()); |
| 1173 | 1205 |
| 1174 // The second proxy should be specified. | 1206 // The second proxy should be specified. |
| 1175 EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI()); | 1207 EXPECT_EQ("foopy2:9090", info.proxy_server().ToURI()); |
| 1176 // Report back that the second proxy worked. This will globally mark the | 1208 // Report back that the second proxy worked. This will globally mark the |
| 1177 // first proxy as bad. | 1209 // first proxy as bad. |
| 1178 TestProxyFallbackNetworkDelegate test_delegate; | 1210 TestProxyFallbackProxyDelegate test_delegate; |
| 1179 service.ReportSuccess(info, &test_delegate); | 1211 service.ReportSuccess(info, &test_delegate); |
| 1180 EXPECT_EQ("foopy1:8080", test_delegate.proxy_server().ToURI()); | 1212 EXPECT_EQ("foopy1:8080", test_delegate.proxy_server().ToURI()); |
| 1181 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, | 1213 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, |
| 1182 test_delegate.proxy_fallback_net_error()); | 1214 test_delegate.proxy_fallback_net_error()); |
| 1183 | 1215 |
| 1184 TestCompletionCallback callback3; | 1216 TestCompletionCallback callback3; |
| 1185 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback3.callback(), NULL, | 1217 rv = service.ResolveProxy(url, LOAD_NORMAL, &info, callback3.callback(), NULL, |
| 1186 NULL, BoundNetLog()); | 1218 NULL, BoundNetLog()); |
| 1187 EXPECT_EQ(ERR_IO_PENDING, rv); | 1219 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1188 | 1220 |
| (...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3377 url, LOAD_NORMAL, &info, NULL, log.bound()); | 3409 url, LOAD_NORMAL, &info, NULL, log.bound()); |
| 3378 EXPECT_TRUE(synchronous_success); | 3410 EXPECT_TRUE(synchronous_success); |
| 3379 EXPECT_FALSE(info.is_direct()); | 3411 EXPECT_FALSE(info.is_direct()); |
| 3380 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host()); | 3412 EXPECT_EQ("foopy1", info.proxy_server().host_port_pair().host()); |
| 3381 | 3413 |
| 3382 // No request should have been queued. | 3414 // No request should have been queued. |
| 3383 EXPECT_EQ(0u, factory->pending_requests().size()); | 3415 EXPECT_EQ(0u, factory->pending_requests().size()); |
| 3384 } | 3416 } |
| 3385 | 3417 |
| 3386 } // namespace net | 3418 } // namespace net |
| OLD | NEW |