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

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

Issue 2469673002: Invalidate WeakPtrs of ResourceMessageFilter on channel shutdown (Closed)
Patch Set: remove test Created 4 years, 1 month 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 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 base::RunLoop().RunUntilIdle(); 854 base::RunLoop().RunUntilIdle();
855 filter_ = MakeForwardingFilter(); 855 filter_ = MakeForwardingFilter();
856 // TODO(cbentzel): Better way to get URLRequestContext? 856 // TODO(cbentzel): Better way to get URLRequestContext?
857 net::URLRequestContext* request_context = 857 net::URLRequestContext* request_context =
858 browser_context_->GetResourceContext()->GetRequestContext(); 858 browser_context_->GetResourceContext()->GetRequestContext();
859 job_factory_.reset(new TestURLRequestJobFactory(this)); 859 job_factory_.reset(new TestURLRequestJobFactory(this));
860 request_context->set_job_factory(job_factory_.get()); 860 request_context->set_job_factory(job_factory_.get());
861 request_context->set_network_delegate(&network_delegate_); 861 request_context->set_network_delegate(&network_delegate_);
862 } 862 }
863 863
864 ~ResourceDispatcherHostTest() override {
865 filter_->OnChannelClosing();
866 }
867
864 // IPC::Sender implementation 868 // IPC::Sender implementation
865 bool Send(IPC::Message* msg) override { 869 bool Send(IPC::Message* msg) override {
866 accum_.AddMessage(*msg); 870 accum_.AddMessage(*msg);
867 871
868 if (send_data_received_acks_ && 872 if (send_data_received_acks_ &&
869 msg->type() == ResourceMsg_DataReceived::ID) { 873 msg->type() == ResourceMsg_DataReceived::ID) {
870 GenerateDataReceivedACK(*msg); 874 GenerateDataReceivedACK(*msg);
871 } 875 }
872 876
873 if (wait_for_request_complete_loop_ && 877 if (wait_for_request_complete_loop_ &&
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 scoped_feature_list_.InitAndEnableFeature( 909 scoped_feature_list_.InitAndEnableFeature(
906 features::kOptimizeLoadingIPCForSmallResources); 910 features::kOptimizeLoadingIPCForSmallResources);
907 ASSERT_TRUE(base::FeatureList::IsEnabled( 911 ASSERT_TRUE(base::FeatureList::IsEnabled(
908 features::kOptimizeLoadingIPCForSmallResources)); 912 features::kOptimizeLoadingIPCForSmallResources));
909 break; 913 break;
910 } 914 }
911 } 915 }
912 } 916 }
913 917
914 void TearDown() override { 918 void TearDown() override {
919 web_contents_filter_->OnChannelClosing();
915 web_contents_observer_.reset(); 920 web_contents_observer_.reset();
916 web_contents_.reset(); 921 web_contents_.reset();
917 922
918 EXPECT_TRUE(URLRequestTestDelayedStartJob::DelayedStartQueueEmpty()); 923 EXPECT_TRUE(URLRequestTestDelayedStartJob::DelayedStartQueueEmpty());
919 URLRequestTestDelayedStartJob::ClearQueue(); 924 URLRequestTestDelayedStartJob::ClearQueue();
920 925
921 for (std::set<int>::iterator it = child_ids_.begin(); 926 for (std::set<int>::iterator it = child_ids_.begin();
922 it != child_ids_.end(); ++it) { 927 it != child_ids_.end(); ++it) {
923 host_.CancelRequestsForProcess(*it); 928 host_.CancelRequestsForProcess(*it);
924 } 929 }
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2()); 1890 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2());
1886 // The detachable request was cancelled by the renderer before it 1891 // The detachable request was cancelled by the renderer before it
1887 // finished. From the perspective of the renderer, it should have cancelled. 1892 // finished. From the perspective of the renderer, it should have cancelled.
1888 ASSERT_EQ(2U, msgs[1].size()); 1893 ASSERT_EQ(2U, msgs[1].size());
1889 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type()); 1894 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type());
1890 CheckRequestCompleteErrorCode(msgs[1][1], net::ERR_ABORTED); 1895 CheckRequestCompleteErrorCode(msgs[1][1], net::ERR_ABORTED);
1891 // But it completed anyway. For the network stack, no requests were canceled. 1896 // But it completed anyway. For the network stack, no requests were canceled.
1892 EXPECT_EQ(4, network_delegate()->completed_requests()); 1897 EXPECT_EQ(4, network_delegate()->completed_requests());
1893 EXPECT_EQ(0, network_delegate()->canceled_requests()); 1898 EXPECT_EQ(0, network_delegate()->canceled_requests());
1894 EXPECT_EQ(0, network_delegate()->error_count()); 1899 EXPECT_EQ(0, network_delegate()->error_count());
1900
1901 test_filter->OnChannelClosing();
1895 } 1902 }
1896 1903
1897 // Tests whether the correct requests get canceled when a RenderViewHost is 1904 // Tests whether the correct requests get canceled when a RenderViewHost is
1898 // deleted. 1905 // deleted.
1899 TEST_P(ResourceDispatcherHostTest, CancelRequestsOnRenderFrameDeleted) { 1906 TEST_P(ResourceDispatcherHostTest, CancelRequestsOnRenderFrameDeleted) {
1900 // Requests all hang once started. This prevents requests from being 1907 // Requests all hang once started. This prevents requests from being
1901 // destroyed due to completion. 1908 // destroyed due to completion.
1902 job_factory_->SetHangAfterStartJobGeneration(true); 1909 job_factory_->SetHangAfterStartJobGeneration(true);
1903 HandleScheme("http"); 1910 HandleScheme("http");
1904 1911
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 accum_.GetClassifiedMessages(&msgs); 2142 accum_.GetClassifiedMessages(&msgs);
2136 2143
2137 // The 2 requests for the RVH 0 should have been processed. Note that 2144 // The 2 requests for the RVH 0 should have been processed. Note that
2138 // blocked detachable requests are canceled without delay. 2145 // blocked detachable requests are canceled without delay.
2139 ASSERT_EQ(2U, msgs.size()); 2146 ASSERT_EQ(2U, msgs.size());
2140 2147
2141 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 2148 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
2142 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3()); 2149 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3());
2143 2150
2144 EXPECT_TRUE(host_.blocked_loaders_map_.empty()); 2151 EXPECT_TRUE(host_.blocked_loaders_map_.empty());
2152 second_filter->OnChannelClosing();
2145 } 2153 }
2146 2154
2147 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes 2155 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes
2148 // away. Note that we rely on Purify for finding the leaks if any. 2156 // away. Note that we rely on Purify for finding the leaks if any.
2149 // If this test turns the Purify bot red, check the ResourceDispatcherHost 2157 // If this test turns the Purify bot red, check the ResourceDispatcherHost
2150 // destructor to make sure the blocked requests are deleted. 2158 // destructor to make sure the blocked requests are deleted.
2151 TEST_P(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) { 2159 TEST_P(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
2152 // This second filter is used to emulate a second process. 2160 // This second filter is used to emulate a second process.
2153 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2161 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2154 2162
(...skipping 25 matching lines...) Expand all
2180 RESOURCE_TYPE_PREFETCH); // detachable type 2188 RESOURCE_TYPE_PREFETCH); // detachable type
2181 MakeTestRequestWithResourceType(second_filter.get(), 1, 8, 2189 MakeTestRequestWithResourceType(second_filter.get(), 1, 8,
2182 net::URLRequestTestJob::test_url_4(), 2190 net::URLRequestTestJob::test_url_4(),
2183 RESOURCE_TYPE_PREFETCH); // detachable type 2191 RESOURCE_TYPE_PREFETCH); // detachable type
2184 2192
2185 host_.CancelRequestsForProcess(filter_->child_id()); 2193 host_.CancelRequestsForProcess(filter_->child_id());
2186 host_.CancelRequestsForProcess(second_filter->child_id()); 2194 host_.CancelRequestsForProcess(second_filter->child_id());
2187 2195
2188 // Flush all the pending requests. 2196 // Flush all the pending requests.
2189 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2197 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2198
2199 second_filter->OnChannelClosing();
2190 } 2200 }
2191 2201
2192 // Test the private helper method "CalculateApproximateMemoryCost()". 2202 // Test the private helper method "CalculateApproximateMemoryCost()".
2193 TEST_P(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) { 2203 TEST_P(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) {
2194 net::URLRequestContext context; 2204 net::URLRequestContext context;
2195 std::unique_ptr<net::URLRequest> req(context.CreateRequest( 2205 std::unique_ptr<net::URLRequest> req(context.CreateRequest(
2196 GURL("http://www.google.com"), net::DEFAULT_PRIORITY, NULL)); 2206 GURL("http://www.google.com"), net::DEFAULT_PRIORITY, NULL));
2197 EXPECT_EQ( 2207 EXPECT_EQ(
2198 4427, 2208 4427,
2199 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(req.get())); 2209 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(req.get()));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 int index = kMaxRequests + i; 2296 int index = kMaxRequests + i;
2287 CheckFailedRequest(msgs[index], net::URLRequestTestJob::test_data_2(), 2297 CheckFailedRequest(msgs[index], net::URLRequestTestJob::test_data_2(),
2288 net::ERR_INSUFFICIENT_RESOURCES); 2298 net::ERR_INSUFFICIENT_RESOURCES);
2289 } 2299 }
2290 2300
2291 // The final 2 requests should have succeeded. 2301 // The final 2 requests should have succeeded.
2292 CheckSuccessfulRequest(msgs[kMaxRequests + 2], 2302 CheckSuccessfulRequest(msgs[kMaxRequests + 2],
2293 net::URLRequestTestJob::test_data_2()); 2303 net::URLRequestTestJob::test_data_2());
2294 CheckSuccessfulRequest(msgs[kMaxRequests + 3], 2304 CheckSuccessfulRequest(msgs[kMaxRequests + 3],
2295 net::URLRequestTestJob::test_data_2()); 2305 net::URLRequestTestJob::test_data_2());
2306
2307 second_filter->OnChannelClosing();
2296 } 2308 }
2297 2309
2298 // Test that when too many requests are outstanding for a particular 2310 // Test that when too many requests are outstanding for a particular
2299 // render_process_host_id, any subsequent request from it fails. Also verify 2311 // render_process_host_id, any subsequent request from it fails. Also verify
2300 // that the global limit is honored. 2312 // that the global limit is honored.
2301 TEST_P(ResourceDispatcherHostTest, TooManyOutstandingRequests) { 2313 TEST_P(ResourceDispatcherHostTest, TooManyOutstandingRequests) {
2302 // Tighten the bound on the ResourceDispatcherHost, to speed things up. 2314 // Tighten the bound on the ResourceDispatcherHost, to speed things up.
2303 const size_t kMaxRequestsPerProcess = 2; 2315 const size_t kMaxRequestsPerProcess = 2;
2304 host_.set_max_num_in_flight_requests_per_process(kMaxRequestsPerProcess); 2316 host_.set_max_num_in_flight_requests_per_process(kMaxRequestsPerProcess);
2305 const size_t kMaxRequests = 3; 2317 const size_t kMaxRequests = 3;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 CheckSuccessfulRequest(msgs[i], net::URLRequestTestJob::test_data_2()); 2363 CheckSuccessfulRequest(msgs[i], net::URLRequestTestJob::test_data_2());
2352 2364
2353 CheckFailedRequest(msgs[kMaxRequestsPerProcess + 0], 2365 CheckFailedRequest(msgs[kMaxRequestsPerProcess + 0],
2354 net::URLRequestTestJob::test_data_2(), 2366 net::URLRequestTestJob::test_data_2(),
2355 net::ERR_INSUFFICIENT_RESOURCES); 2367 net::ERR_INSUFFICIENT_RESOURCES);
2356 CheckSuccessfulRequest(msgs[kMaxRequestsPerProcess + 1], 2368 CheckSuccessfulRequest(msgs[kMaxRequestsPerProcess + 1],
2357 net::URLRequestTestJob::test_data_2()); 2369 net::URLRequestTestJob::test_data_2());
2358 CheckFailedRequest(msgs[kMaxRequestsPerProcess + 2], 2370 CheckFailedRequest(msgs[kMaxRequestsPerProcess + 2],
2359 net::URLRequestTestJob::test_data_2(), 2371 net::URLRequestTestJob::test_data_2(),
2360 net::ERR_INSUFFICIENT_RESOURCES); 2372 net::ERR_INSUFFICIENT_RESOURCES);
2373
2374 second_filter->OnChannelClosing();
2375 third_filter->OnChannelClosing();
2361 } 2376 }
2362 2377
2363 // Tests that we sniff the mime type for a simple request. 2378 // Tests that we sniff the mime type for a simple request.
2364 TEST_P(ResourceDispatcherHostTest, MimeSniffed) { 2379 TEST_P(ResourceDispatcherHostTest, MimeSniffed) {
2365 std::string raw_headers("HTTP/1.1 200 OK\n\n"); 2380 std::string raw_headers("HTTP/1.1 200 OK\n\n");
2366 std::string response_data("<html><title>Test One</title></html>"); 2381 std::string response_data("<html><title>Test One</title></html>");
2367 SetResponse(raw_headers, response_data); 2382 SetResponse(raw_headers, response_data);
2368 2383
2369 HandleScheme("http"); 2384 HandleScheme("http");
2370 MakeTestRequest(0, 1, GURL("http:bla")); 2385 MakeTestRequest(0, 1, GURL("http:bla"));
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2750 host_.OnMessageReceived(transfer_request_msg, second_filter.get()); 2765 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2751 base::RunLoop().RunUntilIdle(); 2766 base::RunLoop().RunUntilIdle();
2752 2767
2753 // Check generated messages. 2768 // Check generated messages.
2754 ResourceIPCAccumulator::ClassifiedMessages msgs; 2769 ResourceIPCAccumulator::ClassifiedMessages msgs;
2755 accum_.GetClassifiedMessages(&msgs); 2770 accum_.GetClassifiedMessages(&msgs);
2756 2771
2757 ASSERT_EQ(2U, msgs.size()); 2772 ASSERT_EQ(2U, msgs.size());
2758 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 2773 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2759 CheckSuccessfulRequest(msgs[1], kResponseBody); 2774 CheckSuccessfulRequest(msgs[1], kResponseBody);
2775
2776 second_filter->OnChannelClosing();
2760 } 2777 }
2761 2778
2762 // Test transferring two navigations with text/html, to ensure the resource 2779 // Test transferring two navigations with text/html, to ensure the resource
2763 // accounting works. 2780 // accounting works.
2764 TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) { 2781 TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) {
2765 if (IsBrowserSideNavigationEnabled()) { 2782 if (IsBrowserSideNavigationEnabled()) {
2766 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2783 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2767 return; 2784 return;
2768 } 2785 }
2769 2786
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2828 new_render_view_id, new_second_request_id, second_request); 2845 new_render_view_id, new_second_request_id, second_request);
2829 host_.OnMessageReceived(second_transfer_request_msg, second_filter.get()); 2846 host_.OnMessageReceived(second_transfer_request_msg, second_filter.get());
2830 base::RunLoop().RunUntilIdle(); 2847 base::RunLoop().RunUntilIdle();
2831 2848
2832 // Check generated messages. 2849 // Check generated messages.
2833 ResourceIPCAccumulator::ClassifiedMessages msgs; 2850 ResourceIPCAccumulator::ClassifiedMessages msgs;
2834 accum_.GetClassifiedMessages(&msgs); 2851 accum_.GetClassifiedMessages(&msgs);
2835 2852
2836 ASSERT_EQ(2U, msgs.size()); 2853 ASSERT_EQ(2U, msgs.size());
2837 CheckSuccessfulRequest(msgs[0], kResponseBody); 2854 CheckSuccessfulRequest(msgs[0], kResponseBody);
2855
2856 second_filter->OnChannelClosing();
2838 } 2857 }
2839 2858
2840 // Test transferred navigations with text/plain, which causes 2859 // Test transferred navigations with text/plain, which causes
2841 // MimeTypeResourceHandler to buffer the response to sniff the content before 2860 // MimeTypeResourceHandler to buffer the response to sniff the content before
2842 // the transfer occurs. 2861 // the transfer occurs.
2843 TEST_P(ResourceDispatcherHostTest, TransferNavigationText) { 2862 TEST_P(ResourceDispatcherHostTest, TransferNavigationText) {
2844 if (IsBrowserSideNavigationEnabled()) { 2863 if (IsBrowserSideNavigationEnabled()) {
2845 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2864 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2846 return; 2865 return;
2847 } 2866 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 host_.OnMessageReceived(transfer_request_msg, second_filter.get()); 2916 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2898 base::RunLoop().RunUntilIdle(); 2917 base::RunLoop().RunUntilIdle();
2899 2918
2900 // Check generated messages. 2919 // Check generated messages.
2901 ResourceIPCAccumulator::ClassifiedMessages msgs; 2920 ResourceIPCAccumulator::ClassifiedMessages msgs;
2902 accum_.GetClassifiedMessages(&msgs); 2921 accum_.GetClassifiedMessages(&msgs);
2903 2922
2904 ASSERT_EQ(2U, msgs.size()); 2923 ASSERT_EQ(2U, msgs.size());
2905 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 2924 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2906 CheckSuccessfulRequest(msgs[1], kResponseBody); 2925 CheckSuccessfulRequest(msgs[1], kResponseBody);
2926
2927 second_filter->OnChannelClosing();
2907 } 2928 }
2908 2929
2909 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) { 2930 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) {
2910 if (IsBrowserSideNavigationEnabled()) { 2931 if (IsBrowserSideNavigationEnabled()) {
2911 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2932 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2912 return; 2933 return;
2913 } 2934 }
2914 2935
2915 NavigationResourceThrottle::set_force_transfer_for_testing(true); 2936 NavigationResourceThrottle::set_force_transfer_for_testing(true);
2916 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 2937 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
(...skipping 29 matching lines...) Expand all
2946 SetResponse("HTTP/1.1 200 OK\n" 2967 SetResponse("HTTP/1.1 200 OK\n"
2947 "Content-Type: text/html\n\n", 2968 "Content-Type: text/html\n\n",
2948 kResponseBody); 2969 kResponseBody);
2949 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 2970 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
2950 host_.OnMessageReceived(redirect_msg, first_filter.get()); 2971 host_.OnMessageReceived(redirect_msg, first_filter.get());
2951 base::RunLoop().RunUntilIdle(); 2972 base::RunLoop().RunUntilIdle();
2952 2973
2953 // Flush all the pending requests to get the response through the 2974 // Flush all the pending requests to get the response through the
2954 // MimeTypeResourceHandler. 2975 // MimeTypeResourceHandler.
2955 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2976 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2977
2978 first_filter->OnChannelClosing();
2956 } 2979 }
2957 // The first filter is now deleted, as if the child process died. 2980 // The first filter is now deleted, as if the child process died.
2958 2981
2959 // Make sure we don't hold onto the ResourceMessageFilter after it is deleted. 2982 // Make sure we don't hold onto the ResourceMessageFilter after it is deleted.
2960 GlobalRequestID first_global_request_id(first_child_id, request_id); 2983 GlobalRequestID first_global_request_id(first_child_id, request_id);
2961 2984
2962 // This second filter is used to emulate a second process. 2985 // This second filter is used to emulate a second process.
2963 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2986 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2964 2987
2965 int new_render_view_id = 1; 2988 int new_render_view_id = 1;
(...skipping 11 matching lines...) Expand all
2977 host_.OnMessageReceived(transfer_request_msg, second_filter.get()); 3000 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2978 base::RunLoop().RunUntilIdle(); 3001 base::RunLoop().RunUntilIdle();
2979 3002
2980 // Check generated messages. 3003 // Check generated messages.
2981 ResourceIPCAccumulator::ClassifiedMessages msgs; 3004 ResourceIPCAccumulator::ClassifiedMessages msgs;
2982 accum_.GetClassifiedMessages(&msgs); 3005 accum_.GetClassifiedMessages(&msgs);
2983 3006
2984 ASSERT_EQ(2U, msgs.size()); 3007 ASSERT_EQ(2U, msgs.size());
2985 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 3008 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2986 CheckSuccessfulRequest(msgs[1], kResponseBody); 3009 CheckSuccessfulRequest(msgs[1], kResponseBody);
3010
3011 second_filter->OnChannelClosing();
2987 } 3012 }
2988 3013
2989 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) { 3014 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
2990 if (IsBrowserSideNavigationEnabled()) { 3015 if (IsBrowserSideNavigationEnabled()) {
2991 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 3016 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2992 return; 3017 return;
2993 } 3018 }
2994 3019
2995 NavigationResourceThrottle::set_force_transfer_for_testing(true); 3020 NavigationResourceThrottle::set_force_transfer_for_testing(true);
2996 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 3021 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3063 // Let request complete. 3088 // Let request complete.
3064 base::RunLoop().RunUntilIdle(); 3089 base::RunLoop().RunUntilIdle();
3065 3090
3066 // Check generated messages. 3091 // Check generated messages.
3067 ResourceIPCAccumulator::ClassifiedMessages msgs; 3092 ResourceIPCAccumulator::ClassifiedMessages msgs;
3068 accum_.GetClassifiedMessages(&msgs); 3093 accum_.GetClassifiedMessages(&msgs);
3069 3094
3070 ASSERT_EQ(2U, msgs.size()); 3095 ASSERT_EQ(2U, msgs.size());
3071 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 3096 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
3072 CheckSuccessfulRequest(msgs[1], kResponseBody); 3097 CheckSuccessfulRequest(msgs[1], kResponseBody);
3098
3099 second_filter->OnChannelClosing();
3073 } 3100 }
3074 3101
3075 TEST_P(ResourceDispatcherHostTest, UnknownURLScheme) { 3102 TEST_P(ResourceDispatcherHostTest, UnknownURLScheme) {
3076 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 3103 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
3077 EXPECT_EQ(0, host_.pending_requests()); 3104 EXPECT_EQ(0, host_.pending_requests());
3078 3105
3079 HandleScheme("http"); 3106 HandleScheme("http");
3080 3107
3081 const GURL invalid_sheme_url = GURL("foo://bar"); 3108 const GURL invalid_sheme_url = GURL("foo://bar");
3082 const int expected_error_code = net::ERR_UNKNOWN_URL_SCHEME; 3109 const int expected_error_code = net::ERR_UNKNOWN_URL_SCHEME;
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
3843 return nullptr; 3870 return nullptr;
3844 } 3871 }
3845 3872
3846 INSTANTIATE_TEST_CASE_P( 3873 INSTANTIATE_TEST_CASE_P(
3847 ResourceDispatcherHostTests, 3874 ResourceDispatcherHostTests,
3848 ResourceDispatcherHostTest, 3875 ResourceDispatcherHostTest,
3849 testing::Values(TestConfig::kDefault, 3876 testing::Values(TestConfig::kDefault,
3850 TestConfig::kOptimizeIPCForSmallResourceEnabled)); 3877 TestConfig::kOptimizeIPCForSmallResourceEnabled));
3851 3878
3852 } // namespace content 3879 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/async_revalidation_manager_unittest.cc ('k') | content/browser/loader/resource_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698