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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif | 10 #endif |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 #include "net/url_request/url_request_test_util.h" | 57 #include "net/url_request/url_request_test_util.h" |
58 #include "testing/gtest/include/gtest/gtest.h" | 58 #include "testing/gtest/include/gtest/gtest.h" |
59 #include "testing/platform_test.h" | 59 #include "testing/platform_test.h" |
60 | 60 |
61 using base::Time; | 61 using base::Time; |
62 | 62 |
63 namespace net { | 63 namespace net { |
64 | 64 |
65 namespace { | 65 namespace { |
66 | 66 |
67 // A subclass of TestServer that uses a statically-configured hostname. This is | |
68 // to work around mysterious failures in chrome_frame_net_tests. See: | |
69 // http://crbug.com/114369 | |
70 class LocalHttpServer : public TestServer { | |
eroman
2012/02/16 02:41:00
nit: I suggest calling LocalHttpTestServer
erikwright (departed)
2012/02/16 16:04:13
Done.
| |
71 public: | |
72 explicit LocalHttpServer(const FilePath& document_root) | |
73 : TestServer(TestServer::TYPE_HTTP, | |
74 url_request_test_http_host(), | |
75 document_root) {} | |
76 LocalHttpServer() | |
77 : TestServer(TestServer::TYPE_HTTP, | |
78 url_request_test_http_host(), | |
79 FilePath()) {} | |
80 }; | |
81 | |
67 const string16 kChrome(ASCIIToUTF16("chrome")); | 82 const string16 kChrome(ASCIIToUTF16("chrome")); |
68 const string16 kSecret(ASCIIToUTF16("secret")); | 83 const string16 kSecret(ASCIIToUTF16("secret")); |
69 const string16 kUser(ASCIIToUTF16("user")); | 84 const string16 kUser(ASCIIToUTF16("user")); |
70 | 85 |
71 base::StringPiece TestNetResourceProvider(int key) { | 86 base::StringPiece TestNetResourceProvider(int key) { |
72 return "header"; | 87 return "header"; |
73 } | 88 } |
74 | 89 |
75 // Do a case-insensitive search through |haystack| for |needle|. | 90 // Do a case-insensitive search through |haystack| for |needle|. |
76 bool ContainsString(const std::string& haystack, const char* needle) { | 91 bool ContainsString(const std::string& haystack, const char* needle) { |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 | 403 |
389 protected: | 404 protected: |
390 TestNetworkDelegate default_network_delegate_; // must outlive URLRequest | 405 TestNetworkDelegate default_network_delegate_; // must outlive URLRequest |
391 scoped_refptr<TestURLRequestContext> default_context_; | 406 scoped_refptr<TestURLRequestContext> default_context_; |
392 URLRequestJobFactory job_factory_; | 407 URLRequestJobFactory job_factory_; |
393 }; | 408 }; |
394 | 409 |
395 class URLRequestTestHTTP : public URLRequestTest { | 410 class URLRequestTestHTTP : public URLRequestTest { |
396 public: | 411 public: |
397 URLRequestTestHTTP() | 412 URLRequestTestHTTP() |
398 : test_server_(TestServer::TYPE_HTTP, | 413 : test_server_(FilePath(FILE_PATH_LITERAL( |
399 FilePath(FILE_PATH_LITERAL( | |
400 "net/data/url_request_unittest"))) { | 414 "net/data/url_request_unittest"))) { |
401 } | 415 } |
402 | 416 |
403 protected: | 417 protected: |
404 // Requests |redirect_url|, which must return a HTTP 3xx redirect. | 418 // Requests |redirect_url|, which must return a HTTP 3xx redirect. |
405 // |request_method| is the method to use for the initial request. | 419 // |request_method| is the method to use for the initial request. |
406 // |redirect_method| is the method that is expected to be used for the second | 420 // |redirect_method| is the method that is expected to be used for the second |
407 // request, after redirection. | 421 // request, after redirection. |
408 // If |include_data| is true, data is uploaded with the request. The | 422 // If |include_data| is true, data is uploaded with the request. The |
409 // response body is expected to match it exactly, if and only if | 423 // response body is expected to match it exactly, if and only if |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 ASSERT_EQ(1, d->response_started_count()) << "request failed: " << | 513 ASSERT_EQ(1, d->response_started_count()) << "request failed: " << |
500 (int) r->status().status() << ", os error: " << r->status().error(); | 514 (int) r->status().status() << ", os error: " << r->status().error(); |
501 | 515 |
502 EXPECT_FALSE(d->received_data_before_response()); | 516 EXPECT_FALSE(d->received_data_before_response()); |
503 | 517 |
504 ASSERT_EQ(strlen(expected_data), static_cast<size_t>(d->bytes_received())); | 518 ASSERT_EQ(strlen(expected_data), static_cast<size_t>(d->bytes_received())); |
505 EXPECT_EQ(0, memcmp(d->data_received().c_str(), expected_data, | 519 EXPECT_EQ(0, memcmp(d->data_received().c_str(), expected_data, |
506 strlen(expected_data))); | 520 strlen(expected_data))); |
507 } | 521 } |
508 | 522 |
509 TestServer test_server_; | 523 LocalHttpServer test_server_; |
510 }; | 524 }; |
511 | 525 |
512 // In this unit test, we're using the HTTPTestServer as a proxy server and | 526 // In this unit test, we're using the HTTPTestServer as a proxy server and |
513 // issuing a CONNECT request with the magic host name "www.redirect.com". | 527 // issuing a CONNECT request with the magic host name "www.redirect.com". |
514 // The HTTPTestServer will return a 302 response, which we should not | 528 // The HTTPTestServer will return a 302 response, which we should not |
515 // follow. | 529 // follow. |
516 TEST_F(URLRequestTestHTTP, ProxyTunnelRedirectTest) { | 530 TEST_F(URLRequestTestHTTP, ProxyTunnelRedirectTest) { |
517 ASSERT_TRUE(test_server_.Start()); | 531 ASSERT_TRUE(test_server_.Start()); |
518 | 532 |
519 TestNetworkDelegate network_delegate; // must outlive URLRequest | 533 TestNetworkDelegate network_delegate; // must outlive URLRequest |
(...skipping 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2492 | 2506 |
2493 EXPECT_TRUE(d.data_received().find("user2/secret") != std::string::npos); | 2507 EXPECT_TRUE(d.data_received().find("user2/secret") != std::string::npos); |
2494 | 2508 |
2495 // Make sure we sent the cookie in the restarted transaction. | 2509 // Make sure we sent the cookie in the restarted transaction. |
2496 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") | 2510 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") |
2497 != std::string::npos); | 2511 != std::string::npos); |
2498 } | 2512 } |
2499 } | 2513 } |
2500 | 2514 |
2501 TEST_F(URLRequestTest, DelayedCookieCallback) { | 2515 TEST_F(URLRequestTest, DelayedCookieCallback) { |
2502 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2516 LocalHttpServer test_server; |
2503 ASSERT_TRUE(test_server.Start()); | 2517 ASSERT_TRUE(test_server.Start()); |
2504 | 2518 |
2505 scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); | 2519 scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); |
2506 scoped_refptr<DelayedCookieMonster> delayed_cm = | 2520 scoped_refptr<DelayedCookieMonster> delayed_cm = |
2507 new DelayedCookieMonster(); | 2521 new DelayedCookieMonster(); |
2508 scoped_refptr<CookieStore> cookie_store = delayed_cm; | 2522 scoped_refptr<CookieStore> cookie_store = delayed_cm; |
2509 context->set_cookie_store(delayed_cm); | 2523 context->set_cookie_store(delayed_cm); |
2510 | 2524 |
2511 // Set up a cookie. | 2525 // Set up a cookie. |
2512 { | 2526 { |
(...skipping 16 matching lines...) Expand all Loading... | |
2529 MessageLoop::current()->Run(); | 2543 MessageLoop::current()->Run(); |
2530 | 2544 |
2531 EXPECT_TRUE(d.data_received().find("CookieToNotSend=1") | 2545 EXPECT_TRUE(d.data_received().find("CookieToNotSend=1") |
2532 != std::string::npos); | 2546 != std::string::npos); |
2533 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2547 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
2534 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2548 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2535 } | 2549 } |
2536 } | 2550 } |
2537 | 2551 |
2538 TEST_F(URLRequestTest, DoNotSendCookies) { | 2552 TEST_F(URLRequestTest, DoNotSendCookies) { |
2539 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2553 LocalHttpServer test_server; |
2540 ASSERT_TRUE(test_server.Start()); | 2554 ASSERT_TRUE(test_server.Start()); |
2541 | 2555 |
2542 // Set up a cookie. | 2556 // Set up a cookie. |
2543 { | 2557 { |
2544 TestDelegate d; | 2558 TestDelegate d; |
2545 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); | 2559 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
2546 req.set_context(default_context_); | 2560 req.set_context(default_context_); |
2547 req.Start(); | 2561 req.Start(); |
2548 MessageLoop::current()->Run(); | 2562 MessageLoop::current()->Run(); |
2549 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2563 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
(...skipping 26 matching lines...) Expand all Loading... | |
2576 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") | 2590 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") |
2577 == std::string::npos); | 2591 == std::string::npos); |
2578 | 2592 |
2579 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies. | 2593 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies. |
2580 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2594 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
2581 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2595 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2582 } | 2596 } |
2583 } | 2597 } |
2584 | 2598 |
2585 TEST_F(URLRequestTest, DoNotSaveCookies) { | 2599 TEST_F(URLRequestTest, DoNotSaveCookies) { |
2586 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2600 LocalHttpServer test_server; |
2587 ASSERT_TRUE(test_server.Start()); | 2601 ASSERT_TRUE(test_server.Start()); |
2588 | 2602 |
2589 // Set up a cookie. | 2603 // Set up a cookie. |
2590 { | 2604 { |
2591 TestDelegate d; | 2605 TestDelegate d; |
2592 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); | 2606 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); |
2593 req.set_context(default_context_); | 2607 req.set_context(default_context_); |
2594 req.Start(); | 2608 req.Start(); |
2595 MessageLoop::current()->Run(); | 2609 MessageLoop::current()->Run(); |
2596 | 2610 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2629 EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2") | 2643 EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2") |
2630 != std::string::npos); | 2644 != std::string::npos); |
2631 | 2645 |
2632 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2646 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
2633 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2647 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2634 EXPECT_EQ(0, d.set_cookie_count()); | 2648 EXPECT_EQ(0, d.set_cookie_count()); |
2635 } | 2649 } |
2636 } | 2650 } |
2637 | 2651 |
2638 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { | 2652 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { |
2639 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2653 LocalHttpServer test_server; |
2640 ASSERT_TRUE(test_server.Start()); | 2654 ASSERT_TRUE(test_server.Start()); |
2641 | 2655 |
2642 // Set up a cookie. | 2656 // Set up a cookie. |
2643 { | 2657 { |
2644 TestDelegate d; | 2658 TestDelegate d; |
2645 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); | 2659 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
2646 req.set_context(default_context_); | 2660 req.set_context(default_context_); |
2647 req.Start(); | 2661 req.Start(); |
2648 MessageLoop::current()->Run(); | 2662 MessageLoop::current()->Run(); |
2649 | 2663 |
(...skipping 27 matching lines...) Expand all Loading... | |
2677 | 2691 |
2678 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") | 2692 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") |
2679 == std::string::npos); | 2693 == std::string::npos); |
2680 | 2694 |
2681 EXPECT_EQ(1, d.blocked_get_cookies_count()); | 2695 EXPECT_EQ(1, d.blocked_get_cookies_count()); |
2682 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2696 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2683 } | 2697 } |
2684 } | 2698 } |
2685 | 2699 |
2686 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) { | 2700 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) { |
2687 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2701 LocalHttpServer test_server; |
2688 ASSERT_TRUE(test_server.Start()); | 2702 ASSERT_TRUE(test_server.Start()); |
2689 | 2703 |
2690 // Set up a cookie. | 2704 // Set up a cookie. |
2691 { | 2705 { |
2692 TestDelegate d; | 2706 TestDelegate d; |
2693 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); | 2707 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); |
2694 req.set_context(default_context_); | 2708 req.set_context(default_context_); |
2695 req.Start(); | 2709 req.Start(); |
2696 MessageLoop::current()->Run(); | 2710 MessageLoop::current()->Run(); |
2697 | 2711 |
(...skipping 29 matching lines...) Expand all Loading... | |
2727 == std::string::npos); | 2741 == std::string::npos); |
2728 EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2") | 2742 EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2") |
2729 != std::string::npos); | 2743 != std::string::npos); |
2730 | 2744 |
2731 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2745 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
2732 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2746 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2733 } | 2747 } |
2734 } | 2748 } |
2735 | 2749 |
2736 TEST_F(URLRequestTest, DoNotSaveEmptyCookies) { | 2750 TEST_F(URLRequestTest, DoNotSaveEmptyCookies) { |
2737 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2751 LocalHttpServer test_server; |
2738 ASSERT_TRUE(test_server.Start()); | 2752 ASSERT_TRUE(test_server.Start()); |
2739 | 2753 |
2740 // Set up an empty cookie. | 2754 // Set up an empty cookie. |
2741 { | 2755 { |
2742 TestDelegate d; | 2756 TestDelegate d; |
2743 URLRequest req(test_server.GetURL("set-cookie"), &d); | 2757 URLRequest req(test_server.GetURL("set-cookie"), &d); |
2744 req.set_context(default_context_); | 2758 req.set_context(default_context_); |
2745 req.Start(); | 2759 req.Start(); |
2746 MessageLoop::current()->Run(); | 2760 MessageLoop::current()->Run(); |
2747 | 2761 |
2748 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2762 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
2749 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2763 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2750 EXPECT_EQ(0, d.set_cookie_count()); | 2764 EXPECT_EQ(0, d.set_cookie_count()); |
2751 } | 2765 } |
2752 } | 2766 } |
2753 | 2767 |
2754 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { | 2768 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { |
2755 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2769 LocalHttpServer test_server; |
2756 ASSERT_TRUE(test_server.Start()); | 2770 ASSERT_TRUE(test_server.Start()); |
2757 | 2771 |
2758 // Set up a cookie. | 2772 // Set up a cookie. |
2759 { | 2773 { |
2760 TestDelegate d; | 2774 TestDelegate d; |
2761 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); | 2775 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
2762 req.set_context(default_context_); | 2776 req.set_context(default_context_); |
2763 req.Start(); | 2777 req.Start(); |
2764 MessageLoop::current()->Run(); | 2778 MessageLoop::current()->Run(); |
2765 | 2779 |
(...skipping 27 matching lines...) Expand all Loading... | |
2793 | 2807 |
2794 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") | 2808 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") |
2795 == std::string::npos); | 2809 == std::string::npos); |
2796 | 2810 |
2797 EXPECT_EQ(1, d.blocked_get_cookies_count()); | 2811 EXPECT_EQ(1, d.blocked_get_cookies_count()); |
2798 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2812 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2799 } | 2813 } |
2800 } | 2814 } |
2801 | 2815 |
2802 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { | 2816 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { |
2803 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2817 LocalHttpServer test_server; |
2804 ASSERT_TRUE(test_server.Start()); | 2818 ASSERT_TRUE(test_server.Start()); |
2805 | 2819 |
2806 // Set up a cookie. | 2820 // Set up a cookie. |
2807 { | 2821 { |
2808 TestDelegate d; | 2822 TestDelegate d; |
2809 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); | 2823 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); |
2810 req.set_context(default_context_); | 2824 req.set_context(default_context_); |
2811 req.Start(); | 2825 req.Start(); |
2812 MessageLoop::current()->Run(); | 2826 MessageLoop::current()->Run(); |
2813 | 2827 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2849 } | 2863 } |
2850 | 2864 |
2851 void CheckCookiePolicyCallback(bool* was_run, const CookieList& cookies) { | 2865 void CheckCookiePolicyCallback(bool* was_run, const CookieList& cookies) { |
2852 EXPECT_EQ(1U, cookies.size()); | 2866 EXPECT_EQ(1U, cookies.size()); |
2853 EXPECT_FALSE(cookies[0].IsPersistent()); | 2867 EXPECT_FALSE(cookies[0].IsPersistent()); |
2854 *was_run = true; | 2868 *was_run = true; |
2855 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 2869 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
2856 } | 2870 } |
2857 | 2871 |
2858 TEST_F(URLRequestTest, CookiePolicy_ForceSession) { | 2872 TEST_F(URLRequestTest, CookiePolicy_ForceSession) { |
2859 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2873 LocalHttpServer test_server; |
2860 ASSERT_TRUE(test_server.Start()); | 2874 ASSERT_TRUE(test_server.Start()); |
2861 | 2875 |
2862 // Set up a cookie. | 2876 // Set up a cookie. |
2863 { | 2877 { |
2864 TestDelegate d; | 2878 TestDelegate d; |
2865 d.set_cookie_options(TestDelegate::FORCE_SESSION); | 2879 d.set_cookie_options(TestDelegate::FORCE_SESSION); |
2866 URLRequest req(test_server.GetURL( | 2880 URLRequest req(test_server.GetURL( |
2867 "set-cookie?A=1;expires=\"Fri, 05 Feb 2010 23:42:01 GMT\""), &d); | 2881 "set-cookie?A=1;expires=\"Fri, 05 Feb 2010 23:42:01 GMT\""), &d); |
2868 req.set_context(default_context_); | 2882 req.set_context(default_context_); |
2869 req.Start(); // Triggers an asynchronous cookie policy check. | 2883 req.Start(); // Triggers an asynchronous cookie policy check. |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3527 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, req.status().error()); | 3541 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, req.status().error()); |
3528 | 3542 |
3529 EXPECT_EQ(1, network_delegate.error_count()); | 3543 EXPECT_EQ(1, network_delegate.error_count()); |
3530 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, network_delegate.last_error()); | 3544 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, network_delegate.last_error()); |
3531 EXPECT_EQ(1, network_delegate.completed_requests()); | 3545 EXPECT_EQ(1, network_delegate.completed_requests()); |
3532 } | 3546 } |
3533 | 3547 |
3534 // Check that it is impossible to change the referrer in the extra headers of | 3548 // Check that it is impossible to change the referrer in the extra headers of |
3535 // an URLRequest. | 3549 // an URLRequest. |
3536 TEST_F(URLRequestTest, DoNotOverrideReferrer) { | 3550 TEST_F(URLRequestTest, DoNotOverrideReferrer) { |
3537 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 3551 LocalHttpServer test_server; |
3538 ASSERT_TRUE(test_server.Start()); | 3552 ASSERT_TRUE(test_server.Start()); |
3539 | 3553 |
3540 // If extra headers contain referer and the request contains a referer, | 3554 // If extra headers contain referer and the request contains a referer, |
3541 // only the latter shall be respected. | 3555 // only the latter shall be respected. |
3542 { | 3556 { |
3543 TestDelegate d; | 3557 TestDelegate d; |
3544 TestURLRequest req(test_server.GetURL("echoheader?Referer"), &d); | 3558 TestURLRequest req(test_server.GetURL("echoheader?Referer"), &d); |
3545 req.set_referrer("http://foo.com/"); | 3559 req.set_referrer("http://foo.com/"); |
3546 req.set_context(default_context_); | 3560 req.set_context(default_context_); |
3547 | 3561 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3586 EXPECT_EQ("", d.data_received()); | 3600 EXPECT_EQ("", d.data_received()); |
3587 EXPECT_EQ(1, default_network_delegate_.completed_requests()); | 3601 EXPECT_EQ(1, default_network_delegate_.completed_requests()); |
3588 } | 3602 } |
3589 | 3603 |
3590 class URLRequestTestFTP : public URLRequestTest { | 3604 class URLRequestTestFTP : public URLRequestTest { |
3591 public: | 3605 public: |
3592 URLRequestTestFTP() : test_server_(TestServer::TYPE_FTP, FilePath()) { | 3606 URLRequestTestFTP() : test_server_(TestServer::TYPE_FTP, FilePath()) { |
3593 } | 3607 } |
3594 | 3608 |
3595 protected: | 3609 protected: |
3596 TestServer test_server_; | 3610 TestServer test_server_; |
eroman
2012/02/16 02:41:00
You don't need to make the same change here (for t
erikwright (departed)
2012/02/16 16:04:13
No. Chrome Frame never handles requests besides HT
| |
3597 }; | 3611 }; |
3598 | 3612 |
3599 // Flaky, see http://crbug.com/25045. | 3613 // Flaky, see http://crbug.com/25045. |
3600 TEST_F(URLRequestTestFTP, FLAKY_FTPDirectoryListing) { | 3614 TEST_F(URLRequestTestFTP, FLAKY_FTPDirectoryListing) { |
3601 ASSERT_TRUE(test_server_.Start()); | 3615 ASSERT_TRUE(test_server_.Start()); |
3602 | 3616 |
3603 TestDelegate d; | 3617 TestDelegate d; |
3604 { | 3618 { |
3605 TestURLRequest r(test_server_.GetURL("/"), &d); | 3619 TestURLRequest r(test_server_.GetURL("/"), &d); |
3606 r.set_context(default_context_); | 3620 r.set_context(default_context_); |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4079 req.SetExtraRequestHeaders(headers); | 4093 req.SetExtraRequestHeaders(headers); |
4080 req.Start(); | 4094 req.Start(); |
4081 MessageLoop::current()->Run(); | 4095 MessageLoop::current()->Run(); |
4082 // If the net tests are being run with ChromeFrame then we need to allow for | 4096 // If the net tests are being run with ChromeFrame then we need to allow for |
4083 // the 'chromeframe' suffix which is added to the user agent before the | 4097 // the 'chromeframe' suffix which is added to the user agent before the |
4084 // closing parentheses. | 4098 // closing parentheses. |
4085 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4099 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
4086 } | 4100 } |
4087 | 4101 |
4088 } // namespace net | 4102 } // namespace net |
OLD | NEW |