OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/frame_host/cross_site_transferring_request.h" | 7 #include "content/browser/frame_host/cross_site_transferring_request.h" |
8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/frame_host/navigation_request.h" | 10 #include "content/browser/frame_host/navigation_request.h" |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 RenderFrameHostImpl* host2 = manager->Navigate(entry2); | 918 RenderFrameHostImpl* host2 = manager->Navigate(entry2); |
919 int host2_process_id = host2->GetProcess()->GetID(); | 919 int host2_process_id = host2->GetProcess()->GetID(); |
920 | 920 |
921 // A new RenderFrameHost should be created. | 921 // A new RenderFrameHost should be created. |
922 EXPECT_TRUE(manager->pending_frame_host()); | 922 EXPECT_TRUE(manager->pending_frame_host()); |
923 ASSERT_EQ(host2, manager->pending_frame_host()); | 923 ASSERT_EQ(host2, manager->pending_frame_host()); |
924 EXPECT_NE(host2, host); | 924 EXPECT_NE(host2, host); |
925 | 925 |
926 // Check that the navigation is still suspended because the old RVH | 926 // Check that the navigation is still suspended because the old RVH |
927 // is not swapped out, yet. | 927 // is not swapped out, yet. |
928 EXPECT_TRUE(host2->are_navigations_suspended()); | 928 EXPECT_TRUE(host2->render_view_host()->are_navigations_suspended()); |
929 MockRenderProcessHost* test_process_host2 = | 929 MockRenderProcessHost* test_process_host2 = |
930 static_cast<MockRenderProcessHost*>(host2->GetProcess()); | 930 static_cast<MockRenderProcessHost*>(host2->GetProcess()); |
931 test_process_host2->sink().ClearMessages(); | 931 test_process_host2->sink().ClearMessages(); |
932 host2->render_view_host()->NavigateToURL(kUrl2); | 932 host2->render_view_host()->NavigateToURL(kUrl2); |
933 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( | 933 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( |
934 FrameMsg_Navigate::ID)); | 934 FrameMsg_Navigate::ID)); |
935 | 935 |
936 // Allow closing the current Render View (precondition for swapping out | 936 // Allow closing the current Render View (precondition for swapping out |
937 // the RVH): Simulate response from RenderFrame for FrameMsg_BeforeUnload sent | 937 // the RVH): Simulate response from RenderFrame for FrameMsg_BeforeUnload sent |
938 // by DispatchBeforeUnload. | 938 // by DispatchBeforeUnload. |
(...skipping 30 matching lines...) Expand all Loading... |
969 test_process_host->sink().ClearMessages(); | 969 test_process_host->sink().ClearMessages(); |
970 RenderFrameHostImpl* host3 = manager->Navigate(entry3); | 970 RenderFrameHostImpl* host3 = manager->Navigate(entry3); |
971 | 971 |
972 // A new RenderFrameHost should be created. host2 is now deleted. | 972 // A new RenderFrameHost should be created. host2 is now deleted. |
973 EXPECT_TRUE(manager->pending_frame_host()); | 973 EXPECT_TRUE(manager->pending_frame_host()); |
974 ASSERT_EQ(host3, manager->pending_frame_host()); | 974 ASSERT_EQ(host3, manager->pending_frame_host()); |
975 EXPECT_NE(host3, host); | 975 EXPECT_NE(host3, host); |
976 EXPECT_NE(host3->GetProcess()->GetID(), host2_process_id); | 976 EXPECT_NE(host3->GetProcess()->GetID(), host2_process_id); |
977 | 977 |
978 // Navigations in the new RVH should be suspended. | 978 // Navigations in the new RVH should be suspended. |
979 EXPECT_TRUE(host3->are_navigations_suspended()); | 979 EXPECT_TRUE(static_cast<RenderViewHostImpl*>( |
| 980 host3->render_view_host())->are_navigations_suspended()); |
980 EXPECT_EQ(host, manager->current_frame_host()); | 981 EXPECT_EQ(host, manager->current_frame_host()); |
981 EXPECT_FALSE(manager->current_frame_host()->is_swapped_out()); | 982 EXPECT_FALSE(manager->current_frame_host()->is_swapped_out()); |
982 | 983 |
983 // Simulate a response to the second beforeunload request. | 984 // Simulate a response to the second beforeunload request. |
984 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( | 985 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( |
985 FrameMsg_BeforeUnload::ID)); | 986 FrameMsg_BeforeUnload::ID)); |
986 test_host->SendBeforeUnloadACK(true); | 987 test_host->SendBeforeUnloadACK(true); |
987 | 988 |
988 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a | 989 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a |
989 // call of RenderFrameHostManager::SwapOutOldPage before | 990 // call of RenderFrameHostManager::SwapOutOldPage before |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 TestRenderViewHost* rvh2 = pending_test_rvh(); | 1041 TestRenderViewHost* rvh2 = pending_test_rvh(); |
1041 EXPECT_TRUE(rvh2); | 1042 EXPECT_TRUE(rvh2); |
1042 static_cast<SiteInstanceImpl*>(rvh2->GetSiteInstance())-> | 1043 static_cast<SiteInstanceImpl*>(rvh2->GetSiteInstance())-> |
1043 increment_active_view_count(); | 1044 increment_active_view_count(); |
1044 | 1045 |
1045 contents()->GetController().LoadURL( | 1046 contents()->GetController().LoadURL( |
1046 kUrl3, Referrer(), PAGE_TRANSITION_LINK, std::string()); | 1047 kUrl3, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
1047 // Pending rvh2 is already deleted. | 1048 // Pending rvh2 is already deleted. |
1048 contents()->ProceedWithCrossSiteNavigation(); | 1049 contents()->ProceedWithCrossSiteNavigation(); |
1049 | 1050 |
1050 TestRenderFrameHost* rfh3 = pending_main_test_rfh(); | 1051 TestRenderViewHost* rvh3 = pending_test_rvh(); |
1051 EXPECT_TRUE(rfh3); | 1052 EXPECT_TRUE(rvh3); |
1052 // Navigation should be already unblocked by rvh1. | 1053 // Navigation should be already unblocked by rvh1. |
1053 EXPECT_FALSE(rfh3->are_navigations_suspended()); | 1054 EXPECT_FALSE(rvh3->are_navigations_suspended()); |
1054 } | 1055 } |
1055 | 1056 |
1056 // Tests WebUI creation. | 1057 // Tests WebUI creation. |
1057 TEST_F(RenderFrameHostManagerTest, WebUI) { | 1058 TEST_F(RenderFrameHostManagerTest, WebUI) { |
1058 set_should_create_webui(true); | 1059 set_should_create_webui(true); |
1059 SiteInstance* instance = SiteInstance::Create(browser_context()); | 1060 SiteInstance* instance = SiteInstance::Create(browser_context()); |
1060 | 1061 |
1061 scoped_ptr<TestWebContents> web_contents( | 1062 scoped_ptr<TestWebContents> web_contents( |
1062 TestWebContents::Create(browser_context(), instance)); | 1063 TestWebContents::Create(browser_context(), instance)); |
1063 RenderFrameHostManager* manager = web_contents->GetRenderManagerForTesting(); | 1064 RenderFrameHostManager* manager = web_contents->GetRenderManagerForTesting(); |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 NavigationRequestForRenderFrameManager( | 1886 NavigationRequestForRenderFrameManager( |
1886 main_test_rfh()->frame_tree_node()->render_manager()); | 1887 main_test_rfh()->frame_tree_node()->render_manager()); |
1887 ASSERT_TRUE(main_request); | 1888 ASSERT_TRUE(main_request); |
1888 EXPECT_EQ(kUrl3, main_request->info_for_testing().navigation_params.url); | 1889 EXPECT_EQ(kUrl3, main_request->info_for_testing().navigation_params.url); |
1889 EXPECT_EQ(kUrl3, main_request->info_for_testing().first_party_for_cookies); | 1890 EXPECT_EQ(kUrl3, main_request->info_for_testing().first_party_for_cookies); |
1890 EXPECT_TRUE(main_request->info_for_testing().is_main_frame); | 1891 EXPECT_TRUE(main_request->info_for_testing().is_main_frame); |
1891 EXPECT_FALSE(main_request->info_for_testing().parent_is_main_frame); | 1892 EXPECT_FALSE(main_request->info_for_testing().parent_is_main_frame); |
1892 } | 1893 } |
1893 | 1894 |
1894 } // namespace content | 1895 } // namespace content |
OLD | NEW |