Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: content/browser/loader/resource_dispatcher_host_unittest.cc

Issue 2321543002: Merge CrossSiteResourceHandler and NavigationResourceThrottle (Closed)
Patch Set: Fixed test compilation error Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
22 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_split.h" 23 #include "base/strings/string_split.h"
24 #include "base/threading/thread_task_runner_handle.h" 24 #include "base/threading/thread_task_runner_handle.h"
25 #include "content/browser/browser_thread_impl.h" 25 #include "content/browser/browser_thread_impl.h"
26 #include "content/browser/cert_store_impl.h" 26 #include "content/browser/cert_store_impl.h"
27 #include "content/browser/child_process_security_policy_impl.h" 27 #include "content/browser/child_process_security_policy_impl.h"
28 #include "content/browser/download/download_manager_impl.h" 28 #include "content/browser/download/download_manager_impl.h"
29 #include "content/browser/download/download_resource_handler.h" 29 #include "content/browser/download/download_resource_handler.h"
30 #include "content/browser/frame_host/navigation_request_info.h" 30 #include "content/browser/frame_host/navigation_request_info.h"
31 #include "content/browser/loader/cross_site_resource_handler.h"
32 #include "content/browser/loader/detachable_resource_handler.h" 31 #include "content/browser/loader/detachable_resource_handler.h"
32 #include "content/browser/loader/navigation_resource_throttle.h"
33 #include "content/browser/loader/navigation_url_loader.h" 33 #include "content/browser/loader/navigation_url_loader.h"
34 #include "content/browser/loader/resource_dispatcher_host_impl.h" 34 #include "content/browser/loader/resource_dispatcher_host_impl.h"
35 #include "content/browser/loader/resource_loader.h" 35 #include "content/browser/loader/resource_loader.h"
36 #include "content/browser/loader/resource_message_filter.h" 36 #include "content/browser/loader/resource_message_filter.h"
37 #include "content/browser/loader/resource_request_info_impl.h" 37 #include "content/browser/loader/resource_request_info_impl.h"
38 #include "content/browser/loader_delegate_impl.h" 38 #include "content/browser/loader_delegate_impl.h"
39 #include "content/common/appcache_interfaces.h" 39 #include "content/common/appcache_interfaces.h"
40 #include "content/common/child_process_host_impl.h" 40 #include "content/common/child_process_host_impl.h"
41 #include "content/common/navigation_params.h" 41 #include "content/common/navigation_params.h"
42 #include "content/common/resource_messages.h" 42 #include "content/common/resource_messages.h"
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 explicit TestUserData(bool* was_deleted) 618 explicit TestUserData(bool* was_deleted)
619 : was_deleted_(was_deleted) { 619 : was_deleted_(was_deleted) {
620 } 620 }
621 621
622 ~TestUserData() override { *was_deleted_ = true; } 622 ~TestUserData() override { *was_deleted_ = true; }
623 623
624 private: 624 private:
625 bool* was_deleted_; 625 bool* was_deleted_;
626 }; 626 };
627 627
628 class TransfersAllNavigationsContentBrowserClient
629 : public TestContentBrowserClient {
630 public:
631 bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context,
632 const GURL& current_url,
633 const GURL& new_url) override {
634 return true;
635 }
636 };
637
638 enum GenericResourceThrottleFlags { 628 enum GenericResourceThrottleFlags {
639 NONE = 0, 629 NONE = 0,
640 DEFER_STARTING_REQUEST = 1 << 0, 630 DEFER_STARTING_REQUEST = 1 << 0,
641 DEFER_PROCESSING_RESPONSE = 1 << 1, 631 DEFER_PROCESSING_RESPONSE = 1 << 1,
642 CANCEL_BEFORE_START = 1 << 2, 632 CANCEL_BEFORE_START = 1 << 2,
643 CANCEL_PROCESSING_RESPONSE = 1 << 3, 633 CANCEL_PROCESSING_RESPONSE = 1 << 3,
644 MUST_NOT_CACHE_BODY = 1 << 4, 634 MUST_NOT_CACHE_BODY = 1 << 4,
645 }; 635 };
646 636
647 // Throttle that tracks the current throttle blocking a request. Only one 637 // Throttle that tracks the current throttle blocking a request. Only one
(...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2485 accum_.GetClassifiedMessages(&msgs); 2475 accum_.GetClassifiedMessages(&msgs);
2486 ASSERT_EQ(1U, msgs.size()); 2476 ASSERT_EQ(1U, msgs.size());
2487 2477
2488 ResourceResponseHead response_head; 2478 ResourceResponseHead response_head;
2489 GetResponseHead(msgs[0], &response_head); 2479 GetResponseHead(msgs[0], &response_head);
2490 ASSERT_EQ("text/plain", response_head.mime_type); 2480 ASSERT_EQ("text/plain", response_head.mime_type);
2491 } 2481 }
2492 2482
2493 // Tests for crbug.com/31266 (Non-2xx + application/octet-stream). 2483 // Tests for crbug.com/31266 (Non-2xx + application/octet-stream).
2494 TEST_P(ResourceDispatcherHostTest, ForbiddenDownload) { 2484 TEST_P(ResourceDispatcherHostTest, ForbiddenDownload) {
2485 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
2495 std::string raw_headers("HTTP/1.1 403 Forbidden\n" 2486 std::string raw_headers("HTTP/1.1 403 Forbidden\n"
2496 "Content-disposition: attachment; filename=blah\n" 2487 "Content-disposition: attachment; filename=blah\n"
2497 "Content-type: application/octet-stream\n\n"); 2488 "Content-type: application/octet-stream\n\n");
2498 std::string response_data("<html><title>Test One</title></html>"); 2489 std::string response_data("<html><title>Test One</title></html>");
2499 SetResponse(raw_headers, response_data); 2490 SetResponse(raw_headers, response_data);
2500 2491
2501 HandleScheme("http"); 2492 HandleScheme("http");
2502 2493
2503 int expected_error_code = net::ERR_INVALID_RESPONSE; 2494 int expected_error_code = net::ERR_INVALID_RESPONSE;
2504 GURL forbidden_download_url = GURL("http:bla"); 2495 GURL forbidden_download_url = GURL("http:bla");
2505 2496
2506 CompleteFailingMainResourceRequest(forbidden_download_url, 2497 CompleteFailingMainResourceRequest(forbidden_download_url,
2507 expected_error_code); 2498 expected_error_code);
2508 } 2499 }
2509 2500
2510 // Test for http://crbug.com/76202 . We don't want to destroy a 2501 // Test for http://crbug.com/76202 . We don't want to destroy a
2511 // download request prematurely when processing a cancellation from 2502 // download request prematurely when processing a cancellation from
2512 // the renderer. 2503 // the renderer.
2513 TEST_P(ResourceDispatcherHostTest, IgnoreCancelForDownloads) { 2504 TEST_P(ResourceDispatcherHostTest, IgnoreCancelForDownloads) {
2514 // PlzNavigate: A request that ends up being a download is a main resource 2505 // PlzNavigate: A request that ends up being a download is a main resource
2515 // request. Hence, it has been initiated by the browser and is not associated 2506 // request. Hence, it has been initiated by the browser and is not associated
2516 // with a renderer. Therefore, it cannot be canceled by a renderer IPC. 2507 // with a renderer. Therefore, it cannot be canceled by a renderer IPC.
2517 if (IsBrowserSideNavigationEnabled()) { 2508 if (IsBrowserSideNavigationEnabled()) {
2518 SUCCEED() << "Not applicable with --enable-browser-side-navigation."; 2509 SUCCEED() << "Not applicable with --enable-browser-side-navigation.";
2519 return; 2510 return;
2520 } 2511 }
2521 2512
2513 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
2514
2522 EXPECT_EQ(0, host_.pending_requests()); 2515 EXPECT_EQ(0, host_.pending_requests());
2523 2516
2524 int render_view_id = 0; 2517 int render_view_id = 0;
2525 int request_id = 1; 2518 int request_id = 1;
2526 2519
2527 std::string raw_headers("HTTP\n" 2520 std::string raw_headers("HTTP\n"
2528 "Content-disposition: attachment; filename=foo\n\n"); 2521 "Content-disposition: attachment; filename=foo\n\n");
2529 std::string response_data("01234567890123456789\x01foobar"); 2522 std::string response_data("01234567890123456789\x01foobar");
2530 2523
2531 // Get past sniffing metrics in the MimeTypeResourceHandler. Note that 2524 // Get past sniffing metrics in the MimeTypeResourceHandler. Note that
(...skipping 23 matching lines...) Expand all
2555 // the cancellation above should have been ignored and the request 2548 // the cancellation above should have been ignored and the request
2556 // should still be alive. 2549 // should still be alive.
2557 EXPECT_EQ(1, host_.pending_requests()); 2550 EXPECT_EQ(1, host_.pending_requests());
2558 2551
2559 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2552 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2560 base::RunLoop().RunUntilIdle(); 2553 base::RunLoop().RunUntilIdle();
2561 } 2554 }
2562 2555
2563 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContext) { 2556 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContext) {
2564 EXPECT_EQ(0, host_.pending_requests()); 2557 EXPECT_EQ(0, host_.pending_requests());
2558 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
2565 2559
2566 int render_view_id = 0; 2560 int render_view_id = 0;
2567 int request_id = 1; 2561 int request_id = 1;
2568 2562
2569 std::string raw_headers("HTTP\n" 2563 std::string raw_headers("HTTP\n"
2570 "Content-disposition: attachment; filename=foo\n\n"); 2564 "Content-disposition: attachment; filename=foo\n\n");
2571 std::string response_data("01234567890123456789\x01foobar"); 2565 std::string response_data("01234567890123456789\x01foobar");
2572 // Get past sniffing metrics. 2566 // Get past sniffing metrics.
2573 response_data.resize(1025, ' '); 2567 response_data.resize(1025, ' ');
2574 2568
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2670 EXPECT_EQ(0, host_.pending_requests()); 2664 EXPECT_EQ(0, host_.pending_requests());
2671 } 2665 }
2672 2666
2673 // Test the cancelling of requests that are being transferred to a new renderer 2667 // Test the cancelling of requests that are being transferred to a new renderer
2674 // due to a redirection. 2668 // due to a redirection.
2675 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContextTransferred) { 2669 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContextTransferred) {
2676 // PlzNavigate: there are no transferred requests in PlzNavigate. 2670 // PlzNavigate: there are no transferred requests in PlzNavigate.
2677 if (IsBrowserSideNavigationEnabled()) 2671 if (IsBrowserSideNavigationEnabled())
2678 return; 2672 return;
2679 2673
2674 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
2675
2680 EXPECT_EQ(0, host_.pending_requests()); 2676 EXPECT_EQ(0, host_.pending_requests());
2681 2677
2682 int request_id = 1; 2678 int request_id = 1;
2683 2679
2684 std::string raw_headers("HTTP/1.1 200 OK\n" 2680 std::string raw_headers("HTTP/1.1 200 OK\n"
2685 "Content-Type: text/html; charset=utf-8\n\n"); 2681 "Content-Type: text/html; charset=utf-8\n\n");
2686 std::string response_data("<html>foobar</html>"); 2682 std::string response_data("<html>foobar</html>");
2687 2683
2688 SetResponse(raw_headers, response_data); 2684 SetResponse(raw_headers, response_data);
2689 HandleScheme("http"); 2685 HandleScheme("http");
2690 2686
2691 MakeWebContentsAssociatedTestRequestWithResourceType( 2687 MakeWebContentsAssociatedTestRequestWithResourceType(
2692 request_id, GURL("http://example.com/blah"), RESOURCE_TYPE_MAIN_FRAME); 2688 request_id, GURL("http://example.com/blah"), RESOURCE_TYPE_MAIN_FRAME);
2693 2689
2694 GlobalRequestID global_request_id(web_contents_filter_->child_id(), 2690 GlobalRequestID global_request_id(web_contents_filter_->child_id(),
2695 request_id); 2691 request_id);
2696 host_.MarkAsTransferredNavigation(global_request_id, nullptr); 2692 host_.MarkAsTransferredNavigation(global_request_id, base::Closure());
2697 2693
2698 // And now simulate a cancellation coming from the renderer. 2694 // And now simulate a cancellation coming from the renderer.
2699 ResourceHostMsg_CancelRequest msg(request_id); 2695 ResourceHostMsg_CancelRequest msg(request_id);
2700 host_.OnMessageReceived(msg, web_contents_filter_.get()); 2696 host_.OnMessageReceived(msg, web_contents_filter_.get());
2701 2697
2702 // Since the request is marked as being transferred, 2698 // Since the request is marked as being transferred,
2703 // the cancellation above should have been ignored and the request 2699 // the cancellation above should have been ignored and the request
2704 // should still be alive. 2700 // should still be alive.
2705 EXPECT_EQ(1, host_.pending_requests()); 2701 EXPECT_EQ(1, host_.pending_requests());
2706 2702
2707 // Cancelling by other methods shouldn't work either. 2703 // Cancelling by other methods shouldn't work either.
2708 host_.CancelRequestsForProcess(web_contents_->GetRoutingID()); 2704 host_.CancelRequestsForProcess(web_contents_->GetRoutingID());
2709 EXPECT_EQ(1, host_.pending_requests()); 2705 EXPECT_EQ(1, host_.pending_requests());
2710 2706
2711 // Cancelling by context should work. 2707 // Cancelling by context should work.
2712 host_.CancelRequestsForContext(web_contents_filter_->resource_context()); 2708 host_.CancelRequestsForContext(web_contents_filter_->resource_context());
2713 EXPECT_EQ(0, host_.pending_requests()); 2709 EXPECT_EQ(0, host_.pending_requests());
2714 } 2710 }
2715 2711
2716 // Test transferred navigations with text/html, which doesn't trigger any 2712 // Test transferred navigations with text/html, which doesn't trigger any
2717 // content sniffing. 2713 // content sniffing.
2718 TEST_P(ResourceDispatcherHostTest, TransferNavigationHtml) { 2714 TEST_P(ResourceDispatcherHostTest, TransferNavigationHtml) {
2719 if (IsBrowserSideNavigationEnabled()) { 2715 if (IsBrowserSideNavigationEnabled()) {
2720 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2716 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2721 return; 2717 return;
2722 } 2718 }
2723 // This test expects the cross site request to be leaked, so it can transfer
2724 // the request directly.
2725 CrossSiteResourceHandler::SetLeakRequestsForTesting(true);
2726 2719
2727 EXPECT_EQ(0, host_.pending_requests()); 2720 EXPECT_EQ(0, host_.pending_requests());
2728 2721
2722 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
2723 NavigationResourceThrottle::SetForceTransferForTesting(true);
2724
2729 int render_view_id = 0; 2725 int render_view_id = 0;
2730 int request_id = 1; 2726 int request_id = 1;
2731 2727
2732 // Configure initial request. 2728 // Configure initial request.
2733 SetResponse("HTTP/1.1 302 Found\n" 2729 SetResponse("HTTP/1.1 302 Found\n"
2734 "Location: http://other.com/blech\n\n"); 2730 "Location: http://other.com/blech\n\n");
2735 2731
2736 HandleScheme("http"); 2732 HandleScheme("http");
2737 2733
2738 // Temporarily replace ContentBrowserClient with one that will trigger the
2739 // transfer navigation code paths.
2740 TransfersAllNavigationsContentBrowserClient new_client;
2741 ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
2742
2743 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2734 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2744 GURL("http://example.com/blah"), 2735 GURL("http://example.com/blah"),
2745 RESOURCE_TYPE_MAIN_FRAME); 2736 RESOURCE_TYPE_MAIN_FRAME);
2746 2737
2747 // Now that we're blocked on the redirect, update the response and unblock by 2738 // Now that we're blocked on the redirect, update the response and unblock by
2748 // telling the AsyncResourceHandler to follow the redirect. 2739 // telling the AsyncResourceHandler to follow the redirect.
2749 const std::string kResponseBody = "hello world"; 2740 const std::string kResponseBody = "hello world";
2750 SetResponse("HTTP/1.1 200 OK\n" 2741 SetResponse("HTTP/1.1 200 OK\n"
2751 "Content-Type: text/html\n\n", 2742 "Content-Type: text/html\n\n",
2752 kResponseBody); 2743 kResponseBody);
2753 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 2744 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
2754 host_.OnMessageReceived(redirect_msg, filter_.get()); 2745 host_.OnMessageReceived(redirect_msg, filter_.get());
2755 base::RunLoop().RunUntilIdle(); 2746 base::RunLoop().RunUntilIdle();
2756 2747
2757 // Flush all the pending requests to get the response through the 2748 // Flush all the pending requests to get the response through the
2758 // MimeTypeResourceHandler. 2749 // MimeTypeResourceHandler.
2759 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2750 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2760 2751
2761 // Restore, now that we've set up a transfer.
2762 SetBrowserClientForTesting(old_client);
2763
2764 // This second filter is used to emulate a second process. 2752 // This second filter is used to emulate a second process.
2765 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2753 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2766 2754
2767 int new_render_view_id = 1; 2755 int new_render_view_id = 1;
2768 int new_request_id = 2; 2756 int new_request_id = 2;
2769 2757
2770 ResourceRequest request = CreateResourceRequest( 2758 ResourceRequest request = CreateResourceRequest(
2771 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("http://other.com/blech")); 2759 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("http://other.com/blech"));
2772 request.transferred_request_child_id = filter_->child_id(); 2760 request.transferred_request_child_id = filter_->child_id();
2773 request.transferred_request_request_id = request_id; 2761 request.transferred_request_request_id = request_id;
(...skipping 13 matching lines...) Expand all
2787 } 2775 }
2788 2776
2789 // Tests that during a navigation transferred from one process to 2777 // Tests that during a navigation transferred from one process to
2790 // another, the certificate is updated to be associated with the new 2778 // another, the certificate is updated to be associated with the new
2791 // process. 2779 // process.
2792 TEST_P(ResourceDispatcherHostTest, TransferNavigationCertificateUpdate) { 2780 TEST_P(ResourceDispatcherHostTest, TransferNavigationCertificateUpdate) {
2793 if (IsBrowserSideNavigationEnabled()) { 2781 if (IsBrowserSideNavigationEnabled()) {
2794 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2782 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2795 return; 2783 return;
2796 } 2784 }
2797 // This test expects the cross site request to be leaked, so it can transfer 2785
2798 // the request directly. 2786 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
2799 CrossSiteResourceHandler::SetLeakRequestsForTesting(true); 2787 NavigationResourceThrottle::SetForceTransferForTesting(true);
2800 2788
2801 EXPECT_EQ(0, host_.pending_requests()); 2789 EXPECT_EQ(0, host_.pending_requests());
2802 2790
2803 int render_view_id = 0; 2791 int render_view_id = 0;
2804 int request_id = 1; 2792 int request_id = 1;
2805 2793
2806 // Configure initial request. 2794 // Configure initial request.
2807 SetResponse( 2795 SetResponse(
2808 "HTTP/1.1 302 Found\n" 2796 "HTTP/1.1 302 Found\n"
2809 "Location: https://example.com/blech\n\n"); 2797 "Location: https://example.com/blech\n\n");
2810 2798
2811 HandleScheme("https"); 2799 HandleScheme("https");
2812 2800
2813 // Temporarily replace ContentBrowserClient with one that will trigger the
2814 // transfer navigation code paths.
2815 TransfersAllNavigationsContentBrowserClient new_client;
2816 ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
2817
2818 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2801 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2819 GURL("https://example2.com/blah"), 2802 GURL("https://example2.com/blah"),
2820 RESOURCE_TYPE_MAIN_FRAME); 2803 RESOURCE_TYPE_MAIN_FRAME);
2821 2804
2822 // Now that the resource loader is blocked on the redirect, update the 2805 // Now that the resource loader is blocked on the redirect, update the
2823 // response and unblock by telling the AsyncResourceHandler to follow 2806 // response and unblock by telling the AsyncResourceHandler to follow
2824 // the redirect. 2807 // the redirect.
2825 const std::string kResponseBody = "hello world"; 2808 const std::string kResponseBody = "hello world";
2826 SetResponse( 2809 SetResponse(
2827 "HTTP/1.1 200 OK\n" 2810 "HTTP/1.1 200 OK\n"
2828 "Content-Type: text/html\n\n", 2811 "Content-Type: text/html\n\n",
2829 kResponseBody); 2812 kResponseBody);
2830 SetTestSSLCertificate(); 2813 SetTestSSLCertificate();
2831 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 2814 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
2832 host_.OnMessageReceived(redirect_msg, filter_.get()); 2815 host_.OnMessageReceived(redirect_msg, filter_.get());
2833 base::RunLoop().RunUntilIdle(); 2816 base::RunLoop().RunUntilIdle();
2834 2817
2835 // Flush all the pending requests to get the response through the 2818 // Flush all the pending requests to get the response through the
2836 // MimeTypeResourceHandler.` 2819 // MimeTypeResourceHandler.`
2837 while (net::URLRequestTestJob::ProcessOnePendingMessage()) { 2820 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {
2838 } 2821 }
2839 2822
2840 // Restore, now that we've set up a transfer.
2841 SetBrowserClientForTesting(old_client);
2842
2843 // This second filter is used to emulate a second process. 2823 // This second filter is used to emulate a second process.
2844 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2824 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2845 2825
2846 int new_render_view_id = 1; 2826 int new_render_view_id = 1;
2847 int new_request_id = 2; 2827 int new_request_id = 2;
2848 2828
2849 ResourceRequest request = CreateResourceRequest( 2829 ResourceRequest request = CreateResourceRequest(
2850 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("https://example.com/blech")); 2830 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("https://example.com/blech"));
2851 request.transferred_request_child_id = filter_->child_id(); 2831 request.transferred_request_child_id = filter_->child_id();
2852 request.transferred_request_request_id = request_id; 2832 request.transferred_request_request_id = request_id;
(...skipping 27 matching lines...) Expand all
2880 EXPECT_EQ(1, ssl.cert_id); 2860 EXPECT_EQ(1, ssl.cert_id);
2881 } 2861 }
2882 2862
2883 // Test transferring two navigations with text/html, to ensure the resource 2863 // Test transferring two navigations with text/html, to ensure the resource
2884 // accounting works. 2864 // accounting works.
2885 TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) { 2865 TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) {
2886 if (IsBrowserSideNavigationEnabled()) { 2866 if (IsBrowserSideNavigationEnabled()) {
2887 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2867 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2888 return; 2868 return;
2889 } 2869 }
2890 // This test expects the cross site request to be leaked, so it can transfer 2870
2891 // the request directly. 2871 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
2892 CrossSiteResourceHandler::SetLeakRequestsForTesting(true); 2872 NavigationResourceThrottle::SetForceTransferForTesting(true);
2893 2873
2894 EXPECT_EQ(0, host_.pending_requests()); 2874 EXPECT_EQ(0, host_.pending_requests());
2895 2875
2896 int render_view_id = 0; 2876 int render_view_id = 0;
2897 int request_id = 1; 2877 int request_id = 1;
2898 2878
2899 // Configure initial request. 2879 // Configure initial request.
2900 const std::string kResponseBody = "hello world"; 2880 const std::string kResponseBody = "hello world";
2901 SetResponse("HTTP/1.1 200 OK\n" 2881 SetResponse("HTTP/1.1 200 OK\n"
2902 "Content-Type: text/html\n\n", 2882 "Content-Type: text/html\n\n",
2903 kResponseBody); 2883 kResponseBody);
2904 2884
2905 HandleScheme("http"); 2885 HandleScheme("http");
2906 2886
2907 // Temporarily replace ContentBrowserClient with one that will trigger the
2908 // transfer navigation code paths.
2909 TransfersAllNavigationsContentBrowserClient new_client;
2910 ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
2911
2912 // Make the first request. 2887 // Make the first request.
2913 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2888 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2914 GURL("http://example.com/blah"), 2889 GURL("http://example.com/blah"),
2915 RESOURCE_TYPE_MAIN_FRAME); 2890 RESOURCE_TYPE_MAIN_FRAME);
2916 2891
2917 // Make a second request from the same process. 2892 // Make a second request from the same process.
2918 int second_request_id = 2; 2893 int second_request_id = 2;
2919 MakeTestRequestWithResourceType(filter_.get(), render_view_id, 2894 MakeTestRequestWithResourceType(filter_.get(), render_view_id,
2920 second_request_id, 2895 second_request_id,
2921 GURL("http://example.com/foo"), 2896 GURL("http://example.com/foo"),
2922 RESOURCE_TYPE_MAIN_FRAME); 2897 RESOURCE_TYPE_MAIN_FRAME);
2923 2898
2924 // Flush all the pending requests to get the response through the 2899 // Flush all the pending requests to get the response through the
2925 // MimeTypeResourceHandler. 2900 // MimeTypeResourceHandler.
2926 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2901 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2927 2902
2928 // Restore, now that we've set up a transfer. 2903 NavigationResourceThrottle::SetForceTransferForTesting(false);
2929 SetBrowserClientForTesting(old_client);
2930 2904
2931 // This second filter is used to emulate a second process. 2905 // This second filter is used to emulate a second process.
2932 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2906 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2933 2907
2934 // Transfer the first request. 2908 // Transfer the first request.
2935 int new_render_view_id = 1; 2909 int new_render_view_id = 1;
2936 int new_request_id = 5; 2910 int new_request_id = 5;
2937 ResourceRequest request = CreateResourceRequest( 2911 ResourceRequest request = CreateResourceRequest(
2938 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("http://example.com/blah")); 2912 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("http://example.com/blah"));
2939 request.transferred_request_child_id = filter_->child_id(); 2913 request.transferred_request_child_id = filter_->child_id();
(...skipping 25 matching lines...) Expand all
2965 } 2939 }
2966 2940
2967 // Test transferred navigations with text/plain, which causes 2941 // Test transferred navigations with text/plain, which causes
2968 // MimeTypeResourceHandler to buffer the response to sniff the content before 2942 // MimeTypeResourceHandler to buffer the response to sniff the content before
2969 // the transfer occurs. 2943 // the transfer occurs.
2970 TEST_P(ResourceDispatcherHostTest, TransferNavigationText) { 2944 TEST_P(ResourceDispatcherHostTest, TransferNavigationText) {
2971 if (IsBrowserSideNavigationEnabled()) { 2945 if (IsBrowserSideNavigationEnabled()) {
2972 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2946 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2973 return; 2947 return;
2974 } 2948 }
2975 // This test expects the cross site request to be leaked, so it can transfer 2949
2976 // the request directly. 2950 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
2977 CrossSiteResourceHandler::SetLeakRequestsForTesting(true); 2951 NavigationResourceThrottle::SetForceTransferForTesting(true);
2978 2952
2979 EXPECT_EQ(0, host_.pending_requests()); 2953 EXPECT_EQ(0, host_.pending_requests());
2980 2954
2981 int render_view_id = 0; 2955 int render_view_id = 0;
2982 int request_id = 1; 2956 int request_id = 1;
2983 2957
2984 // Configure initial request. 2958 // Configure initial request.
2985 SetResponse("HTTP/1.1 302 Found\n" 2959 SetResponse("HTTP/1.1 302 Found\n"
2986 "Location: http://other.com/blech\n\n"); 2960 "Location: http://other.com/blech\n\n");
2987 2961
2988 HandleScheme("http"); 2962 HandleScheme("http");
2989 2963
2990 // Temporarily replace ContentBrowserClient with one that will trigger the
2991 // transfer navigation code paths.
2992 TransfersAllNavigationsContentBrowserClient new_client;
2993 ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
2994
2995 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2964 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2996 GURL("http://example.com/blah"), 2965 GURL("http://example.com/blah"),
2997 RESOURCE_TYPE_MAIN_FRAME); 2966 RESOURCE_TYPE_MAIN_FRAME);
2998 2967
2999 // Now that we're blocked on the redirect, update the response and unblock by 2968 // Now that we're blocked on the redirect, update the response and unblock by
3000 // telling the AsyncResourceHandler to follow the redirect. Use a text/plain 2969 // telling the AsyncResourceHandler to follow the redirect. Use a text/plain
3001 // MIME type, which causes MimeTypeResourceHandler to buffer it before the 2970 // MIME type, which causes MimeTypeResourceHandler to buffer it before the
3002 // transfer occurs. 2971 // transfer occurs.
3003 const std::string kResponseBody = "hello world"; 2972 const std::string kResponseBody = "hello world";
3004 SetResponse("HTTP/1.1 200 OK\n" 2973 SetResponse("HTTP/1.1 200 OK\n"
3005 "Content-Type: text/plain\n\n", 2974 "Content-Type: text/plain\n\n",
3006 kResponseBody); 2975 kResponseBody);
3007 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 2976 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
3008 host_.OnMessageReceived(redirect_msg, filter_.get()); 2977 host_.OnMessageReceived(redirect_msg, filter_.get());
3009 base::RunLoop().RunUntilIdle(); 2978 base::RunLoop().RunUntilIdle();
3010 2979
3011 // Flush all the pending requests to get the response through the 2980 // Flush all the pending requests to get the response through the
3012 // MimeTypeResourceHandler. 2981 // MimeTypeResourceHandler.
3013 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2982 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
3014 base::RunLoop().RunUntilIdle(); 2983 base::RunLoop().RunUntilIdle();
3015 2984
3016 // Restore, now that we've set up a transfer.
3017 SetBrowserClientForTesting(old_client);
3018
3019 // This second filter is used to emulate a second process. 2985 // This second filter is used to emulate a second process.
3020 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2986 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
3021 2987
3022 int new_render_view_id = 1; 2988 int new_render_view_id = 1;
3023 int new_request_id = 2; 2989 int new_request_id = 2;
3024 2990
3025 ResourceRequest request = CreateResourceRequest( 2991 ResourceRequest request = CreateResourceRequest(
3026 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("http://other.com/blech")); 2992 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("http://other.com/blech"));
3027 request.transferred_request_child_id = filter_->child_id(); 2993 request.transferred_request_child_id = filter_->child_id();
3028 request.transferred_request_request_id = request_id; 2994 request.transferred_request_request_id = request_id;
(...skipping 10 matching lines...) Expand all
3039 ASSERT_EQ(2U, msgs.size()); 3005 ASSERT_EQ(2U, msgs.size());
3040 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 3006 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
3041 CheckSuccessfulRequest(msgs[1], kResponseBody); 3007 CheckSuccessfulRequest(msgs[1], kResponseBody);
3042 } 3008 }
3043 3009
3044 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) { 3010 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) {
3045 if (IsBrowserSideNavigationEnabled()) { 3011 if (IsBrowserSideNavigationEnabled()) {
3046 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 3012 SUCCEED() << "Test is not applicable with browser side navigation enabled";
3047 return; 3013 return;
3048 } 3014 }
3049 // This test expects the cross site request to be leaked, so it can transfer 3015
3050 // the request directly. 3016 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
3051 CrossSiteResourceHandler::SetLeakRequestsForTesting(true); 3017 NavigationResourceThrottle::SetForceTransferForTesting(true);
3052 3018
3053 EXPECT_EQ(0, host_.pending_requests()); 3019 EXPECT_EQ(0, host_.pending_requests());
3054 3020
3055 int render_view_id = 0; 3021 int render_view_id = 0;
3056 int request_id = 1; 3022 int request_id = 1;
3057 int first_child_id = -1; 3023 int first_child_id = -1;
3058 3024
3059 // Configure initial request. 3025 // Configure initial request.
3060 SetResponse("HTTP/1.1 302 Found\n" 3026 SetResponse("HTTP/1.1 302 Found\n"
3061 "Location: http://other.com/blech\n\n"); 3027 "Location: http://other.com/blech\n\n");
3062 const std::string kResponseBody = "hello world"; 3028 const std::string kResponseBody = "hello world";
3063 3029
3064 HandleScheme("http"); 3030 HandleScheme("http");
3065 3031
3066 // Temporarily replace ContentBrowserClient with one that will trigger the
3067 // transfer navigation code paths.
3068 TransfersAllNavigationsContentBrowserClient new_client;
3069 ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
3070
3071 // Create a first filter that can be deleted before the second one starts. 3032 // Create a first filter that can be deleted before the second one starts.
3072 { 3033 {
3073 scoped_refptr<ForwardingFilter> first_filter = MakeForwardingFilter(); 3034 scoped_refptr<ForwardingFilter> first_filter = MakeForwardingFilter();
3074 first_child_id = first_filter->child_id(); 3035 first_child_id = first_filter->child_id();
3075 3036
3076 ResourceRequest first_request = CreateResourceRequest( 3037 ResourceRequest first_request = CreateResourceRequest(
3077 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("http://example.com/blah")); 3038 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("http://example.com/blah"));
3078 3039
3079 ResourceHostMsg_RequestResource first_request_msg( 3040 ResourceHostMsg_RequestResource first_request_msg(
3080 render_view_id, request_id, first_request); 3041 render_view_id, request_id, first_request);
3081 host_.OnMessageReceived(first_request_msg, first_filter.get()); 3042 host_.OnMessageReceived(first_request_msg, first_filter.get());
3082 base::RunLoop().RunUntilIdle(); 3043 base::RunLoop().RunUntilIdle();
3083 3044
3084 // Now that we're blocked on the redirect, update the response and unblock 3045 // Now that we're blocked on the redirect, update the response and unblock
3085 // by telling the AsyncResourceHandler to follow the redirect. 3046 // by telling the AsyncResourceHandler to follow the redirect.
3086 SetResponse("HTTP/1.1 200 OK\n" 3047 SetResponse("HTTP/1.1 200 OK\n"
3087 "Content-Type: text/html\n\n", 3048 "Content-Type: text/html\n\n",
3088 kResponseBody); 3049 kResponseBody);
3089 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 3050 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
3090 host_.OnMessageReceived(redirect_msg, first_filter.get()); 3051 host_.OnMessageReceived(redirect_msg, first_filter.get());
3091 base::RunLoop().RunUntilIdle(); 3052 base::RunLoop().RunUntilIdle();
3092 3053
3093 // Flush all the pending requests to get the response through the 3054 // Flush all the pending requests to get the response through the
3094 // MimeTypeResourceHandler. 3055 // MimeTypeResourceHandler.
3095 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 3056 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
3096 } 3057 }
3097 // The first filter is now deleted, as if the child process died. 3058 // The first filter is now deleted, as if the child process died.
3098 3059
3099 // Restore.
3100 SetBrowserClientForTesting(old_client);
3101
3102 // Make sure we don't hold onto the ResourceMessageFilter after it is deleted. 3060 // Make sure we don't hold onto the ResourceMessageFilter after it is deleted.
3103 GlobalRequestID first_global_request_id(first_child_id, request_id); 3061 GlobalRequestID first_global_request_id(first_child_id, request_id);
3104 3062
3105 // This second filter is used to emulate a second process. 3063 // This second filter is used to emulate a second process.
3106 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 3064 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
3107 3065
3108 int new_render_view_id = 1; 3066 int new_render_view_id = 1;
3109 int new_request_id = 2; 3067 int new_request_id = 2;
3110 3068
3111 ResourceRequest request = CreateResourceRequest( 3069 ResourceRequest request = CreateResourceRequest(
(...skipping 15 matching lines...) Expand all
3127 ASSERT_EQ(2U, msgs.size()); 3085 ASSERT_EQ(2U, msgs.size());
3128 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 3086 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
3129 CheckSuccessfulRequest(msgs[1], kResponseBody); 3087 CheckSuccessfulRequest(msgs[1], kResponseBody);
3130 } 3088 }
3131 3089
3132 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) { 3090 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
3133 if (IsBrowserSideNavigationEnabled()) { 3091 if (IsBrowserSideNavigationEnabled()) {
3134 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 3092 SUCCEED() << "Test is not applicable with browser side navigation enabled";
3135 return; 3093 return;
3136 } 3094 }
3137 // This test expects the cross site request to be leaked, so it can transfer 3095
3138 // the request directly. 3096 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
3139 CrossSiteResourceHandler::SetLeakRequestsForTesting(true); 3097 NavigationResourceThrottle::SetForceTransferForTesting(true);
3140 3098
3141 EXPECT_EQ(0, host_.pending_requests()); 3099 EXPECT_EQ(0, host_.pending_requests());
3142 3100
3143 int render_view_id = 0; 3101 int render_view_id = 0;
3144 int request_id = 1; 3102 int request_id = 1;
3145 3103
3146 // Configure initial request. 3104 // Configure initial request.
3147 SetResponse("HTTP/1.1 302 Found\n" 3105 SetResponse("HTTP/1.1 302 Found\n"
3148 "Location: http://other.com/blech\n\n"); 3106 "Location: http://other.com/blech\n\n");
3149 3107
3150 HandleScheme("http"); 3108 HandleScheme("http");
3151 3109
3152 // Temporarily replace ContentBrowserClient with one that will trigger the
3153 // transfer navigation code paths.
3154 TransfersAllNavigationsContentBrowserClient new_client;
3155 ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
3156
3157 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 3110 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
3158 GURL("http://example.com/blah"), 3111 GURL("http://example.com/blah"),
3159 RESOURCE_TYPE_MAIN_FRAME); 3112 RESOURCE_TYPE_MAIN_FRAME);
3160 3113
3161 // Now that we're blocked on the redirect, simulate hitting another redirect. 3114 // Now that we're blocked on the redirect, simulate hitting another redirect.
3162 SetResponse("HTTP/1.1 302 Found\n" 3115 SetResponse("HTTP/1.1 302 Found\n"
3163 "Location: http://other.com/blerg\n\n"); 3116 "Location: http://other.com/blerg\n\n");
3164 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 3117 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
3165 host_.OnMessageReceived(redirect_msg, filter_.get()); 3118 host_.OnMessageReceived(redirect_msg, filter_.get());
3166 base::RunLoop().RunUntilIdle(); 3119 base::RunLoop().RunUntilIdle();
3167 3120
3168 // Now that we're blocked on the second redirect, update the response and 3121 // Now that we're blocked on the second redirect, update the response and
3169 // unblock by telling the AsyncResourceHandler to follow the redirect. 3122 // unblock by telling the AsyncResourceHandler to follow the redirect.
3170 // Again, use text/plain to force MimeTypeResourceHandler to buffer before 3123 // Again, use text/plain to force MimeTypeResourceHandler to buffer before
3171 // the transfer. 3124 // the transfer.
3172 const std::string kResponseBody = "hello world"; 3125 const std::string kResponseBody = "hello world";
3173 SetResponse("HTTP/1.1 200 OK\n" 3126 SetResponse("HTTP/1.1 200 OK\n"
3174 "Content-Type: text/plain\n\n", 3127 "Content-Type: text/plain\n\n",
3175 kResponseBody); 3128 kResponseBody);
3176 ResourceHostMsg_FollowRedirect redirect_msg2(request_id); 3129 ResourceHostMsg_FollowRedirect redirect_msg2(request_id);
3177 host_.OnMessageReceived(redirect_msg2, filter_.get()); 3130 host_.OnMessageReceived(redirect_msg2, filter_.get());
3178 base::RunLoop().RunUntilIdle(); 3131 base::RunLoop().RunUntilIdle();
3179 3132
3180 // Flush all the pending requests to get the response through the 3133 // Flush all the pending requests to get the response through the
3181 // MimeTypeResourceHandler. 3134 // MimeTypeResourceHandler.
3182 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 3135 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
3183 base::RunLoop().RunUntilIdle(); 3136 base::RunLoop().RunUntilIdle();
3184 3137
3185 // Restore.
3186 SetBrowserClientForTesting(old_client);
3187
3188 // This second filter is used to emulate a second process. 3138 // This second filter is used to emulate a second process.
3189 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 3139 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
3190 3140
3191 int new_render_view_id = 1; 3141 int new_render_view_id = 1;
3192 int new_request_id = 2; 3142 int new_request_id = 2;
3193 3143
3194 ResourceRequest request = CreateResourceRequest( 3144 ResourceRequest request = CreateResourceRequest(
3195 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("http://other.com/blech")); 3145 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("http://other.com/blech"));
3196 request.transferred_request_child_id = filter_->child_id(); 3146 request.transferred_request_child_id = filter_->child_id();
3197 request.transferred_request_request_id = request_id; 3147 request.transferred_request_request_id = request_id;
(...skipping 19 matching lines...) Expand all
3217 // Check generated messages. 3167 // Check generated messages.
3218 ResourceIPCAccumulator::ClassifiedMessages msgs; 3168 ResourceIPCAccumulator::ClassifiedMessages msgs;
3219 accum_.GetClassifiedMessages(&msgs); 3169 accum_.GetClassifiedMessages(&msgs);
3220 3170
3221 ASSERT_EQ(2U, msgs.size()); 3171 ASSERT_EQ(2U, msgs.size());
3222 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 3172 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
3223 CheckSuccessfulRequest(msgs[1], kResponseBody); 3173 CheckSuccessfulRequest(msgs[1], kResponseBody);
3224 } 3174 }
3225 3175
3226 TEST_P(ResourceDispatcherHostTest, UnknownURLScheme) { 3176 TEST_P(ResourceDispatcherHostTest, UnknownURLScheme) {
3177 NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
3227 EXPECT_EQ(0, host_.pending_requests()); 3178 EXPECT_EQ(0, host_.pending_requests());
3228 3179
3229 HandleScheme("http"); 3180 HandleScheme("http");
3230 3181
3231 const GURL invalid_sheme_url = GURL("foo://bar"); 3182 const GURL invalid_sheme_url = GURL("foo://bar");
3232 const int expected_error_code = net::ERR_UNKNOWN_URL_SCHEME; 3183 const int expected_error_code = net::ERR_UNKNOWN_URL_SCHEME;
3233 3184
3234 CompleteFailingMainResourceRequest(invalid_sheme_url, expected_error_code); 3185 CompleteFailingMainResourceRequest(invalid_sheme_url, expected_error_code);
3235 } 3186 }
3236 3187
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
3911 return nullptr; 3862 return nullptr;
3912 } 3863 }
3913 3864
3914 INSTANTIATE_TEST_CASE_P( 3865 INSTANTIATE_TEST_CASE_P(
3915 ResourceDispatcherHostTests, 3866 ResourceDispatcherHostTests,
3916 ResourceDispatcherHostTest, 3867 ResourceDispatcherHostTest,
3917 testing::Values(TestConfig::kDefault, 3868 testing::Values(TestConfig::kDefault,
3918 TestConfig::kOptimizeIPCForSmallResourceEnabled)); 3869 TestConfig::kOptimizeIPCForSmallResourceEnabled));
3919 3870
3920 } // namespace content 3871 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698