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

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

Issue 2315443003: Stop sending serialized SSLStatus to the renderer. (Closed)
Patch Set: merge 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 23 matching lines...) Expand all
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"
43 #include "content/common/resource_request.h" 43 #include "content/common/resource_request.h"
44 #include "content/common/ssl_status_serialization.h"
45 #include "content/common/view_messages.h" 44 #include "content/common/view_messages.h"
46 #include "content/public/browser/global_request_id.h" 45 #include "content/public/browser/global_request_id.h"
47 #include "content/public/browser/render_process_host.h" 46 #include "content/public/browser/render_process_host.h"
48 #include "content/public/browser/resource_context.h" 47 #include "content/public/browser/resource_context.h"
49 #include "content/public/browser/resource_dispatcher_host_delegate.h" 48 #include "content/public/browser/resource_dispatcher_host_delegate.h"
50 #include "content/public/browser/resource_request_info.h" 49 #include "content/public/browser/resource_request_info.h"
51 #include "content/public/browser/resource_throttle.h" 50 #include "content/public/browser/resource_throttle.h"
52 #include "content/public/browser/web_contents.h" 51 #include "content/public/browser/web_contents.h"
53 #include "content/public/browser/web_contents_observer.h" 52 #include "content/public/browser/web_contents_observer.h"
54 #include "content/public/common/browser_side_navigation_policy.h" 53 #include "content/public/common/browser_side_navigation_policy.h"
(...skipping 2724 matching lines...) Expand 10 before | Expand all | Expand 10 after
2779 2778
2780 // Check generated messages. 2779 // Check generated messages.
2781 ResourceIPCAccumulator::ClassifiedMessages msgs; 2780 ResourceIPCAccumulator::ClassifiedMessages msgs;
2782 accum_.GetClassifiedMessages(&msgs); 2781 accum_.GetClassifiedMessages(&msgs);
2783 2782
2784 ASSERT_EQ(2U, msgs.size()); 2783 ASSERT_EQ(2U, msgs.size());
2785 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 2784 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2786 CheckSuccessfulRequest(msgs[1], kResponseBody); 2785 CheckSuccessfulRequest(msgs[1], kResponseBody);
2787 } 2786 }
2788 2787
2789 // Tests that during a navigation transferred from one process to
jam 2016/09/06 21:08:24 this is redundant with a browser test (SitePerProc
2790 // another, the certificate is updated to be associated with the new
2791 // process.
2792 TEST_P(ResourceDispatcherHostTest, TransferNavigationCertificateUpdate) {
2793 if (IsBrowserSideNavigationEnabled()) {
2794 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2795 return;
2796 }
2797 // This test expects the cross site request to be leaked, so it can transfer
2798 // the request directly.
2799 CrossSiteResourceHandler::SetLeakRequestsForTesting(true);
2800
2801 EXPECT_EQ(0, host_.pending_requests());
2802
2803 int render_view_id = 0;
2804 int request_id = 1;
2805
2806 // Configure initial request.
2807 SetResponse(
2808 "HTTP/1.1 302 Found\n"
2809 "Location: https://example.com/blech\n\n");
2810
2811 HandleScheme("https");
2812
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,
2819 GURL("https://example2.com/blah"),
2820 RESOURCE_TYPE_MAIN_FRAME);
2821
2822 // Now that the resource loader is blocked on the redirect, update the
2823 // response and unblock by telling the AsyncResourceHandler to follow
2824 // the redirect.
2825 const std::string kResponseBody = "hello world";
2826 SetResponse(
2827 "HTTP/1.1 200 OK\n"
2828 "Content-Type: text/html\n\n",
2829 kResponseBody);
2830 SetTestSSLCertificate();
2831 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
2832 host_.OnMessageReceived(redirect_msg, filter_.get());
2833 base::RunLoop().RunUntilIdle();
2834
2835 // Flush all the pending requests to get the response through the
2836 // MimeTypeResourceHandler.`
2837 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {
2838 }
2839
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.
2844 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2845
2846 int new_render_view_id = 1;
2847 int new_request_id = 2;
2848
2849 ResourceRequest request = CreateResourceRequest(
2850 "GET", RESOURCE_TYPE_MAIN_FRAME, GURL("https://example.com/blech"));
2851 request.transferred_request_child_id = filter_->child_id();
2852 request.transferred_request_request_id = request_id;
2853
2854 // Before sending the transfer request, set up the mock cert store so
2855 // that the test can assert that the cert id is set during transfer.
2856 mock_cert_store_.set_default_cert_id(1);
2857
2858 ResourceHostMsg_RequestResource transfer_request_msg(new_render_view_id,
2859 new_request_id, request);
2860 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2861 base::RunLoop().RunUntilIdle();
2862
2863 // Check generated messages.
2864 ResourceIPCAccumulator::ClassifiedMessages msgs;
2865 accum_.GetClassifiedMessages(&msgs);
2866
2867 ASSERT_EQ(2U, msgs.size());
2868 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2869 CheckSuccessfulRequest(msgs[1], kResponseBody);
2870
2871 // Check that the cert id was as expected in ReceivedResponse.
2872 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type());
2873 base::PickleIterator iter(msgs[1][0]);
2874 int sent_request_id;
2875 ASSERT_TRUE(IPC::ReadParam(&msgs[1][0], &iter, &sent_request_id));
2876 ResourceResponseHead response;
2877 ASSERT_TRUE(IPC::ReadParam(&msgs[1][0], &iter, &response));
2878 SSLStatus ssl;
2879 ASSERT_TRUE(DeserializeSecurityInfo(response.security_info, &ssl));
2880 EXPECT_EQ(1, ssl.cert_id);
2881 }
2882
2883 // Test transferring two navigations with text/html, to ensure the resource 2788 // Test transferring two navigations with text/html, to ensure the resource
2884 // accounting works. 2789 // accounting works.
2885 TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) { 2790 TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) {
2886 if (IsBrowserSideNavigationEnabled()) { 2791 if (IsBrowserSideNavigationEnabled()) {
2887 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2792 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2888 return; 2793 return;
2889 } 2794 }
2890 // This test expects the cross site request to be leaked, so it can transfer 2795 // This test expects the cross site request to be leaked, so it can transfer
2891 // the request directly. 2796 // the request directly.
2892 CrossSiteResourceHandler::SetLeakRequestsForTesting(true); 2797 CrossSiteResourceHandler::SetLeakRequestsForTesting(true);
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
3911 return nullptr; 3816 return nullptr;
3912 } 3817 }
3913 3818
3914 INSTANTIATE_TEST_CASE_P( 3819 INSTANTIATE_TEST_CASE_P(
3915 ResourceDispatcherHostTests, 3820 ResourceDispatcherHostTests,
3916 ResourceDispatcherHostTest, 3821 ResourceDispatcherHostTest,
3917 testing::Values(TestConfig::kDefault, 3822 testing::Values(TestConfig::kDefault,
3918 TestConfig::kOptimizeIPCForSmallResourceEnabled)); 3823 TestConfig::kOptimizeIPCForSmallResourceEnabled));
3919 3824
3920 } // namespace content 3825 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698