| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "net/base/mock_host_resolver.h" | 9 #include "net/base/mock_host_resolver.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 // TODO(eroman): This isn't quite right... should probably stringize | 369 // TODO(eroman): This isn't quite right... should probably stringize |
| 370 // to something like "['3']". | 370 // to something like "['3']". |
| 371 EXPECT_EQ("3", bindings->dns_resolves[6]); | 371 EXPECT_EQ("3", bindings->dns_resolves[6]); |
| 372 | 372 |
| 373 EXPECT_EQ("arg1", bindings->dns_resolves[7]); | 373 EXPECT_EQ("arg1", bindings->dns_resolves[7]); |
| 374 | 374 |
| 375 // MyIpAddress was called two times. | 375 // MyIpAddress was called two times. |
| 376 EXPECT_EQ(2, bindings->my_ip_address_count); | 376 EXPECT_EQ(2, bindings->my_ip_address_count); |
| 377 } | 377 } |
| 378 | 378 |
| 379 // Try loading a PAC script which ends with a trailing comment (no terminal |
| 380 // newline). This should not cause problems with the PAC utility functions |
| 381 // that we add to the script. |
| 382 // http://crbug.com/22864 |
| 383 TEST(ProxyResolverV8Test, TrailingComment) { |
| 384 ProxyResolverV8WithMockBindings resolver; |
| 385 resolver.SetPacScriptFromDisk("ends_with_comment.js"); |
| 386 |
| 387 net::ProxyInfo proxy_info; |
| 388 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); |
| 389 |
| 390 EXPECT_EQ(net::OK, result); |
| 391 EXPECT_FALSE(proxy_info.is_direct()); |
| 392 EXPECT_EQ("success:80", proxy_info.proxy_server().ToURI()); |
| 393 } |
| 394 |
| 379 TEST(ProxyResolverV8DefaultBindingsTest, DnsResolve) { | 395 TEST(ProxyResolverV8DefaultBindingsTest, DnsResolve) { |
| 380 // Get a hold of a DefaultJSBindings* (it is a hidden impl class). | 396 // Get a hold of a DefaultJSBindings* (it is a hidden impl class). |
| 381 scoped_ptr<net::ProxyResolverV8::JSBindings> bindings( | 397 scoped_ptr<net::ProxyResolverV8::JSBindings> bindings( |
| 382 net::ProxyResolverV8::CreateDefaultBindings( | 398 net::ProxyResolverV8::CreateDefaultBindings( |
| 383 new net::MockHostResolver, NULL)); | 399 new net::MockHostResolver, NULL)); |
| 384 | 400 |
| 385 // Considered an error. | 401 // Considered an error. |
| 386 EXPECT_EQ("", bindings->DnsResolve("")); | 402 EXPECT_EQ("", bindings->DnsResolve("")); |
| 387 | 403 |
| 388 const struct { | 404 const struct { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 scoped_ptr<net::ProxyResolverV8::JSBindings> bindings( | 449 scoped_ptr<net::ProxyResolverV8::JSBindings> bindings( |
| 434 net::ProxyResolverV8::CreateDefaultBindings( | 450 net::ProxyResolverV8::CreateDefaultBindings( |
| 435 new net::MockHostResolver, NULL)); | 451 new net::MockHostResolver, NULL)); |
| 436 | 452 |
| 437 // Our IP address is always going to be 127.0.0.1, since we are using a | 453 // Our IP address is always going to be 127.0.0.1, since we are using a |
| 438 // mock host resolver. | 454 // mock host resolver. |
| 439 std::string my_ip_address = bindings->MyIpAddress(); | 455 std::string my_ip_address = bindings->MyIpAddress(); |
| 440 | 456 |
| 441 EXPECT_EQ("127.0.0.1", my_ip_address); | 457 EXPECT_EQ("127.0.0.1", my_ip_address); |
| 442 } | 458 } |
| OLD | NEW |