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 LocalHttpTestServer : public TestServer { |
| 71 public: |
| 72 explicit LocalHttpTestServer(const FilePath& document_root) |
| 73 : TestServer(TestServer::TYPE_HTTP, |
| 74 ScopedCustomUrlRequestTestHttpHost::value(), |
| 75 document_root) {} |
| 76 LocalHttpTestServer() |
| 77 : TestServer(TestServer::TYPE_HTTP, |
| 78 ScopedCustomUrlRequestTestHttpHost::value(), |
| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 417 |
403 protected: | 418 protected: |
404 TestNetworkDelegate default_network_delegate_; // must outlive URLRequest | 419 TestNetworkDelegate default_network_delegate_; // must outlive URLRequest |
405 scoped_refptr<TestURLRequestContext> default_context_; | 420 scoped_refptr<TestURLRequestContext> default_context_; |
406 URLRequestJobFactory job_factory_; | 421 URLRequestJobFactory job_factory_; |
407 }; | 422 }; |
408 | 423 |
409 class URLRequestTestHTTP : public URLRequestTest { | 424 class URLRequestTestHTTP : public URLRequestTest { |
410 public: | 425 public: |
411 URLRequestTestHTTP() | 426 URLRequestTestHTTP() |
412 : test_server_(TestServer::TYPE_HTTP, | 427 : test_server_(FilePath(FILE_PATH_LITERAL( |
413 FilePath(FILE_PATH_LITERAL( | |
414 "net/data/url_request_unittest"))) { | 428 "net/data/url_request_unittest"))) { |
415 } | 429 } |
416 | 430 |
417 protected: | 431 protected: |
418 // Requests |redirect_url|, which must return a HTTP 3xx redirect. | 432 // Requests |redirect_url|, which must return a HTTP 3xx redirect. |
419 // |request_method| is the method to use for the initial request. | 433 // |request_method| is the method to use for the initial request. |
420 // |redirect_method| is the method that is expected to be used for the second | 434 // |redirect_method| is the method that is expected to be used for the second |
421 // request, after redirection. | 435 // request, after redirection. |
422 // If |include_data| is true, data is uploaded with the request. The | 436 // If |include_data| is true, data is uploaded with the request. The |
423 // response body is expected to match it exactly, if and only if | 437 // 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... |
513 ASSERT_EQ(1, d->response_started_count()) << "request failed: " << | 527 ASSERT_EQ(1, d->response_started_count()) << "request failed: " << |
514 (int) r->status().status() << ", os error: " << r->status().error(); | 528 (int) r->status().status() << ", os error: " << r->status().error(); |
515 | 529 |
516 EXPECT_FALSE(d->received_data_before_response()); | 530 EXPECT_FALSE(d->received_data_before_response()); |
517 | 531 |
518 ASSERT_EQ(strlen(expected_data), static_cast<size_t>(d->bytes_received())); | 532 ASSERT_EQ(strlen(expected_data), static_cast<size_t>(d->bytes_received())); |
519 EXPECT_EQ(0, memcmp(d->data_received().c_str(), expected_data, | 533 EXPECT_EQ(0, memcmp(d->data_received().c_str(), expected_data, |
520 strlen(expected_data))); | 534 strlen(expected_data))); |
521 } | 535 } |
522 | 536 |
523 TestServer test_server_; | 537 LocalHttpTestServer test_server_; |
524 }; | 538 }; |
525 | 539 |
526 // In this unit test, we're using the HTTPTestServer as a proxy server and | 540 // In this unit test, we're using the HTTPTestServer as a proxy server and |
527 // issuing a CONNECT request with the magic host name "www.redirect.com". | 541 // issuing a CONNECT request with the magic host name "www.redirect.com". |
528 // The HTTPTestServer will return a 302 response, which we should not | 542 // The HTTPTestServer will return a 302 response, which we should not |
529 // follow. | 543 // follow. |
530 TEST_F(URLRequestTestHTTP, ProxyTunnelRedirectTest) { | 544 TEST_F(URLRequestTestHTTP, ProxyTunnelRedirectTest) { |
531 ASSERT_TRUE(test_server_.Start()); | 545 ASSERT_TRUE(test_server_.Start()); |
532 | 546 |
533 TestNetworkDelegate network_delegate; // must outlive URLRequest | 547 TestNetworkDelegate network_delegate; // must outlive URLRequest |
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2535 | 2549 |
2536 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); | 2550 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); |
2537 | 2551 |
2538 // Make sure we sent the cookie in the restarted transaction. | 2552 // Make sure we sent the cookie in the restarted transaction. |
2539 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") | 2553 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") |
2540 != std::string::npos); | 2554 != std::string::npos); |
2541 } | 2555 } |
2542 } | 2556 } |
2543 | 2557 |
2544 TEST_F(URLRequestTest, DelayedCookieCallback) { | 2558 TEST_F(URLRequestTest, DelayedCookieCallback) { |
2545 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2559 LocalHttpTestServer test_server; |
2546 ASSERT_TRUE(test_server.Start()); | 2560 ASSERT_TRUE(test_server.Start()); |
2547 | 2561 |
2548 scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); | 2562 scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); |
2549 scoped_refptr<DelayedCookieMonster> delayed_cm = | 2563 scoped_refptr<DelayedCookieMonster> delayed_cm = |
2550 new DelayedCookieMonster(); | 2564 new DelayedCookieMonster(); |
2551 scoped_refptr<CookieStore> cookie_store = delayed_cm; | 2565 scoped_refptr<CookieStore> cookie_store = delayed_cm; |
2552 context->set_cookie_store(delayed_cm); | 2566 context->set_cookie_store(delayed_cm); |
2553 | 2567 |
2554 // Set up a cookie. | 2568 // Set up a cookie. |
2555 { | 2569 { |
(...skipping 16 matching lines...) Expand all Loading... |
2572 MessageLoop::current()->Run(); | 2586 MessageLoop::current()->Run(); |
2573 | 2587 |
2574 EXPECT_TRUE(d.data_received().find("CookieToNotSend=1") | 2588 EXPECT_TRUE(d.data_received().find("CookieToNotSend=1") |
2575 != std::string::npos); | 2589 != std::string::npos); |
2576 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2590 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
2577 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2591 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2578 } | 2592 } |
2579 } | 2593 } |
2580 | 2594 |
2581 TEST_F(URLRequestTest, DoNotSendCookies) { | 2595 TEST_F(URLRequestTest, DoNotSendCookies) { |
2582 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2596 LocalHttpTestServer test_server; |
2583 ASSERT_TRUE(test_server.Start()); | 2597 ASSERT_TRUE(test_server.Start()); |
2584 | 2598 |
2585 // Set up a cookie. | 2599 // Set up a cookie. |
2586 { | 2600 { |
2587 TestDelegate d; | 2601 TestDelegate d; |
2588 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); | 2602 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
2589 req.set_context(default_context_); | 2603 req.set_context(default_context_); |
2590 req.Start(); | 2604 req.Start(); |
2591 MessageLoop::current()->Run(); | 2605 MessageLoop::current()->Run(); |
2592 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2606 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
(...skipping 26 matching lines...) Expand all Loading... |
2619 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") | 2633 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") |
2620 == std::string::npos); | 2634 == std::string::npos); |
2621 | 2635 |
2622 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies. | 2636 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies. |
2623 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2637 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
2624 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2638 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2625 } | 2639 } |
2626 } | 2640 } |
2627 | 2641 |
2628 TEST_F(URLRequestTest, DoNotSaveCookies) { | 2642 TEST_F(URLRequestTest, DoNotSaveCookies) { |
2629 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2643 LocalHttpTestServer test_server; |
2630 ASSERT_TRUE(test_server.Start()); | 2644 ASSERT_TRUE(test_server.Start()); |
2631 | 2645 |
2632 // Set up a cookie. | 2646 // Set up a cookie. |
2633 { | 2647 { |
2634 TestDelegate d; | 2648 TestDelegate d; |
2635 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); | 2649 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); |
2636 req.set_context(default_context_); | 2650 req.set_context(default_context_); |
2637 req.Start(); | 2651 req.Start(); |
2638 MessageLoop::current()->Run(); | 2652 MessageLoop::current()->Run(); |
2639 | 2653 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2672 EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2") | 2686 EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2") |
2673 != std::string::npos); | 2687 != std::string::npos); |
2674 | 2688 |
2675 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2689 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
2676 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2690 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2677 EXPECT_EQ(0, d.set_cookie_count()); | 2691 EXPECT_EQ(0, d.set_cookie_count()); |
2678 } | 2692 } |
2679 } | 2693 } |
2680 | 2694 |
2681 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { | 2695 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) { |
2682 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2696 LocalHttpTestServer test_server; |
2683 ASSERT_TRUE(test_server.Start()); | 2697 ASSERT_TRUE(test_server.Start()); |
2684 | 2698 |
2685 // Set up a cookie. | 2699 // Set up a cookie. |
2686 { | 2700 { |
2687 TestDelegate d; | 2701 TestDelegate d; |
2688 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); | 2702 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
2689 req.set_context(default_context_); | 2703 req.set_context(default_context_); |
2690 req.Start(); | 2704 req.Start(); |
2691 MessageLoop::current()->Run(); | 2705 MessageLoop::current()->Run(); |
2692 | 2706 |
(...skipping 27 matching lines...) Expand all Loading... |
2720 | 2734 |
2721 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") | 2735 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") |
2722 == std::string::npos); | 2736 == std::string::npos); |
2723 | 2737 |
2724 EXPECT_EQ(1, d.blocked_get_cookies_count()); | 2738 EXPECT_EQ(1, d.blocked_get_cookies_count()); |
2725 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2739 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2726 } | 2740 } |
2727 } | 2741 } |
2728 | 2742 |
2729 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) { | 2743 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) { |
2730 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2744 LocalHttpTestServer test_server; |
2731 ASSERT_TRUE(test_server.Start()); | 2745 ASSERT_TRUE(test_server.Start()); |
2732 | 2746 |
2733 // Set up a cookie. | 2747 // Set up a cookie. |
2734 { | 2748 { |
2735 TestDelegate d; | 2749 TestDelegate d; |
2736 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); | 2750 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); |
2737 req.set_context(default_context_); | 2751 req.set_context(default_context_); |
2738 req.Start(); | 2752 req.Start(); |
2739 MessageLoop::current()->Run(); | 2753 MessageLoop::current()->Run(); |
2740 | 2754 |
(...skipping 29 matching lines...) Expand all Loading... |
2770 == std::string::npos); | 2784 == std::string::npos); |
2771 EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2") | 2785 EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2") |
2772 != std::string::npos); | 2786 != std::string::npos); |
2773 | 2787 |
2774 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2788 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
2775 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2789 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2776 } | 2790 } |
2777 } | 2791 } |
2778 | 2792 |
2779 TEST_F(URLRequestTest, DoNotSaveEmptyCookies) { | 2793 TEST_F(URLRequestTest, DoNotSaveEmptyCookies) { |
2780 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2794 LocalHttpTestServer test_server; |
2781 ASSERT_TRUE(test_server.Start()); | 2795 ASSERT_TRUE(test_server.Start()); |
2782 | 2796 |
2783 // Set up an empty cookie. | 2797 // Set up an empty cookie. |
2784 { | 2798 { |
2785 TestDelegate d; | 2799 TestDelegate d; |
2786 URLRequest req(test_server.GetURL("set-cookie"), &d); | 2800 URLRequest req(test_server.GetURL("set-cookie"), &d); |
2787 req.set_context(default_context_); | 2801 req.set_context(default_context_); |
2788 req.Start(); | 2802 req.Start(); |
2789 MessageLoop::current()->Run(); | 2803 MessageLoop::current()->Run(); |
2790 | 2804 |
2791 EXPECT_EQ(0, d.blocked_get_cookies_count()); | 2805 EXPECT_EQ(0, d.blocked_get_cookies_count()); |
2792 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2806 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2793 EXPECT_EQ(0, d.set_cookie_count()); | 2807 EXPECT_EQ(0, d.set_cookie_count()); |
2794 } | 2808 } |
2795 } | 2809 } |
2796 | 2810 |
2797 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { | 2811 TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) { |
2798 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2812 LocalHttpTestServer test_server; |
2799 ASSERT_TRUE(test_server.Start()); | 2813 ASSERT_TRUE(test_server.Start()); |
2800 | 2814 |
2801 // Set up a cookie. | 2815 // Set up a cookie. |
2802 { | 2816 { |
2803 TestDelegate d; | 2817 TestDelegate d; |
2804 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); | 2818 URLRequest req(test_server.GetURL("set-cookie?CookieToNotSend=1"), &d); |
2805 req.set_context(default_context_); | 2819 req.set_context(default_context_); |
2806 req.Start(); | 2820 req.Start(); |
2807 MessageLoop::current()->Run(); | 2821 MessageLoop::current()->Run(); |
2808 | 2822 |
(...skipping 27 matching lines...) Expand all Loading... |
2836 | 2850 |
2837 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") | 2851 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") |
2838 == std::string::npos); | 2852 == std::string::npos); |
2839 | 2853 |
2840 EXPECT_EQ(1, d.blocked_get_cookies_count()); | 2854 EXPECT_EQ(1, d.blocked_get_cookies_count()); |
2841 EXPECT_EQ(0, d.blocked_set_cookie_count()); | 2855 EXPECT_EQ(0, d.blocked_set_cookie_count()); |
2842 } | 2856 } |
2843 } | 2857 } |
2844 | 2858 |
2845 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { | 2859 TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) { |
2846 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2860 LocalHttpTestServer test_server; |
2847 ASSERT_TRUE(test_server.Start()); | 2861 ASSERT_TRUE(test_server.Start()); |
2848 | 2862 |
2849 // Set up a cookie. | 2863 // Set up a cookie. |
2850 { | 2864 { |
2851 TestDelegate d; | 2865 TestDelegate d; |
2852 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); | 2866 URLRequest req(test_server.GetURL("set-cookie?CookieToNotUpdate=2"), &d); |
2853 req.set_context(default_context_); | 2867 req.set_context(default_context_); |
2854 req.Start(); | 2868 req.Start(); |
2855 MessageLoop::current()->Run(); | 2869 MessageLoop::current()->Run(); |
2856 | 2870 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2892 } | 2906 } |
2893 | 2907 |
2894 void CheckCookiePolicyCallback(bool* was_run, const CookieList& cookies) { | 2908 void CheckCookiePolicyCallback(bool* was_run, const CookieList& cookies) { |
2895 EXPECT_EQ(1U, cookies.size()); | 2909 EXPECT_EQ(1U, cookies.size()); |
2896 EXPECT_FALSE(cookies[0].IsPersistent()); | 2910 EXPECT_FALSE(cookies[0].IsPersistent()); |
2897 *was_run = true; | 2911 *was_run = true; |
2898 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 2912 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
2899 } | 2913 } |
2900 | 2914 |
2901 TEST_F(URLRequestTest, CookiePolicy_ForceSession) { | 2915 TEST_F(URLRequestTest, CookiePolicy_ForceSession) { |
2902 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 2916 LocalHttpTestServer test_server; |
2903 ASSERT_TRUE(test_server.Start()); | 2917 ASSERT_TRUE(test_server.Start()); |
2904 | 2918 |
2905 // Set up a cookie. | 2919 // Set up a cookie. |
2906 { | 2920 { |
2907 TestDelegate d; | 2921 TestDelegate d; |
2908 d.set_cookie_options(TestDelegate::FORCE_SESSION); | 2922 d.set_cookie_options(TestDelegate::FORCE_SESSION); |
2909 URLRequest req(test_server.GetURL( | 2923 URLRequest req(test_server.GetURL( |
2910 "set-cookie?A=1;expires=\"Fri, 05 Feb 2010 23:42:01 GMT\""), &d); | 2924 "set-cookie?A=1;expires=\"Fri, 05 Feb 2010 23:42:01 GMT\""), &d); |
2911 req.set_context(default_context_); | 2925 req.set_context(default_context_); |
2912 req.Start(); // Triggers an asynchronous cookie policy check. | 2926 req.Start(); // Triggers an asynchronous cookie policy check. |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3570 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, req.status().error()); | 3584 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, req.status().error()); |
3571 | 3585 |
3572 EXPECT_EQ(1, network_delegate.error_count()); | 3586 EXPECT_EQ(1, network_delegate.error_count()); |
3573 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, network_delegate.last_error()); | 3587 EXPECT_EQ(ERR_PROXY_CONNECTION_FAILED, network_delegate.last_error()); |
3574 EXPECT_EQ(1, network_delegate.completed_requests()); | 3588 EXPECT_EQ(1, network_delegate.completed_requests()); |
3575 } | 3589 } |
3576 | 3590 |
3577 // Check that it is impossible to change the referrer in the extra headers of | 3591 // Check that it is impossible to change the referrer in the extra headers of |
3578 // an URLRequest. | 3592 // an URLRequest. |
3579 TEST_F(URLRequestTest, DoNotOverrideReferrer) { | 3593 TEST_F(URLRequestTest, DoNotOverrideReferrer) { |
3580 TestServer test_server(TestServer::TYPE_HTTP, FilePath()); | 3594 LocalHttpTestServer test_server; |
3581 ASSERT_TRUE(test_server.Start()); | 3595 ASSERT_TRUE(test_server.Start()); |
3582 | 3596 |
3583 // If extra headers contain referer and the request contains a referer, | 3597 // If extra headers contain referer and the request contains a referer, |
3584 // only the latter shall be respected. | 3598 // only the latter shall be respected. |
3585 { | 3599 { |
3586 TestDelegate d; | 3600 TestDelegate d; |
3587 TestURLRequest req(test_server.GetURL("echoheader?Referer"), &d); | 3601 TestURLRequest req(test_server.GetURL("echoheader?Referer"), &d); |
3588 req.set_referrer("http://foo.com/"); | 3602 req.set_referrer("http://foo.com/"); |
3589 req.set_context(default_context_); | 3603 req.set_context(default_context_); |
3590 | 3604 |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4122 req.SetExtraRequestHeaders(headers); | 4136 req.SetExtraRequestHeaders(headers); |
4123 req.Start(); | 4137 req.Start(); |
4124 MessageLoop::current()->Run(); | 4138 MessageLoop::current()->Run(); |
4125 // If the net tests are being run with ChromeFrame then we need to allow for | 4139 // If the net tests are being run with ChromeFrame then we need to allow for |
4126 // the 'chromeframe' suffix which is added to the user agent before the | 4140 // the 'chromeframe' suffix which is added to the user agent before the |
4127 // closing parentheses. | 4141 // closing parentheses. |
4128 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4142 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
4129 } | 4143 } |
4130 | 4144 |
4131 } // namespace net | 4145 } // namespace net |
OLD | NEW |