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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "content/browser/renderer_host/test_render_view_host.h" | 6 #include "content/browser/renderer_host/test_render_view_host.h" |
7 #include "content/browser/site_instance_impl.h" | 7 #include "content/browser/site_instance_impl.h" |
8 #include "content/browser/web_contents/navigation_controller_impl.h" | 8 #include "content/browser/web_contents/navigation_controller_impl.h" |
9 #include "content/browser/web_contents/navigation_entry_impl.h" | 9 #include "content/browser/web_contents/navigation_entry_impl.h" |
10 #include "content/browser/web_contents/render_view_host_manager.h" | 10 #include "content/browser/web_contents/render_view_host_manager.h" |
11 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 11 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
12 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
13 #include "content/public/browser/notification_details.h" | 13 #include "content/public/browser/notification_details.h" |
14 #include "content/public/browser/notification_service.h" | |
14 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
15 #include "content/public/browser/notification_types.h" | 16 #include "content/public/browser/notification_types.h" |
17 #include "content/public/browser/render_process_host.h" | |
16 #include "content/public/browser/web_ui_controller.h" | 18 #include "content/public/browser/web_ui_controller.h" |
17 #include "content/public/common/bindings_policy.h" | 19 #include "content/public/common/bindings_policy.h" |
18 #include "content/public/common/javascript_message_type.h" | 20 #include "content/public/common/javascript_message_type.h" |
19 #include "content/public/common/page_transition_types.h" | 21 #include "content/public/common/page_transition_types.h" |
20 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
21 #include "content/public/common/url_utils.h" | 23 #include "content/public/common/url_utils.h" |
22 #include "content/public/test/mock_render_process_host.h" | 24 #include "content/public/test/mock_render_process_host.h" |
23 #include "content/public/test/test_notification_tracker.h" | 25 #include "content/public/test/test_notification_tracker.h" |
24 #include "content/test/test_content_browser_client.h" | 26 #include "content/test/test_content_browser_client.h" |
25 #include "content/test/test_content_client.h" | 27 #include "content/test/test_content_client.h" |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
932 rvh3->GetSiteInstance())); | 934 rvh3->GetSiteInstance())); |
933 | 935 |
934 // No scripting is allowed across BrowsingInstances, so we should not create | 936 // No scripting is allowed across BrowsingInstances, so we should not create |
935 // swapped out RVHs for the opener chain in this case. | 937 // swapped out RVHs for the opener chain in this case. |
936 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( | 938 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( |
937 rvh3->GetSiteInstance())); | 939 rvh3->GetSiteInstance())); |
938 EXPECT_FALSE(opener2_manager->GetSwappedOutRenderViewHost( | 940 EXPECT_FALSE(opener2_manager->GetSwappedOutRenderViewHost( |
939 rvh3->GetSiteInstance())); | 941 rvh3->GetSiteInstance())); |
940 } | 942 } |
941 | 943 |
944 // Test that we clean up swapped out RenderViewHosts when a process hosting | |
945 // those associated RenderViews crashes. | |
nasko
2013/07/10 17:29:00
nit: Add a link to the bug here.
Fady Samuel
2013/07/10 17:51:33
Done.
| |
946 TEST_F(RenderViewHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) { | |
947 const GURL kUrl1("http://www.google.com/"); | |
948 | |
949 //// Navigate to an initial URL. | |
Charlie Reis
2013/07/10 17:23:30
nit: Only two //
Fady Samuel
2013/07/10 17:51:33
Done.
| |
950 contents()->NavigateAndCommit(kUrl1); | |
951 TestRenderViewHost* rvh1 = test_rvh(); | |
952 | |
953 // Create a new tab as an opener for the main tab. | |
954 scoped_ptr<TestWebContents> opener1( | |
955 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); | |
956 RenderViewHostManager* opener1_manager = | |
957 opener1->GetRenderManagerForTesting(); | |
958 contents()->SetOpener(opener1.get()); | |
959 | |
960 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( | |
961 rvh1->GetSiteInstance())); | |
962 opener1->CreateSwappedOutRenderView(rvh1->GetSiteInstance()); | |
963 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost( | |
964 rvh1->GetSiteInstance())); | |
965 | |
966 // Fake a process crash. | |
967 RenderProcessHost::RendererClosedDetails details( | |
968 rvh1->GetProcess()->GetHandle(), | |
969 base::TERMINATION_STATUS_NORMAL_TERMINATION, | |
Charlie Reis
2013/07/10 17:23:30
Should this be TERMINATION_STATUS_PROCESS_CRASHED?
Fady Samuel
2013/07/10 17:51:33
Done.
| |
970 0); | |
971 NotificationService::current()->Notify( | |
972 NOTIFICATION_RENDERER_PROCESS_CLOSED, | |
973 Source<RenderProcessHost>(rvh1->GetProcess()), | |
974 Details<RenderProcessHost::RendererClosedDetails>(&details)); | |
975 | |
976 // Ensure that the swapped out RenderViewHost has been deleted. | |
977 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( | |
978 rvh1->GetSiteInstance())); | |
979 } | |
980 | |
942 // Test that RenderViewHosts created for WebUI navigations are properly | 981 // Test that RenderViewHosts created for WebUI navigations are properly |
943 // granted WebUI bindings even if an unprivileged swapped out RenderViewHost | 982 // granted WebUI bindings even if an unprivileged swapped out RenderViewHost |
944 // is in the same process (http://crbug.com/79918). | 983 // is in the same process (http://crbug.com/79918). |
945 TEST_F(RenderViewHostManagerTest, EnableWebUIWithSwappedOutOpener) { | 984 TEST_F(RenderViewHostManagerTest, EnableWebUIWithSwappedOutOpener) { |
946 set_should_create_webui(true); | 985 set_should_create_webui(true); |
947 const GURL kSettingsUrl("chrome://chrome/settings"); | 986 const GURL kSettingsUrl("chrome://chrome/settings"); |
948 const GURL kPluginUrl("chrome://plugins"); | 987 const GURL kPluginUrl("chrome://plugins"); |
949 | 988 |
950 // Navigate to an initial WebUI URL. | 989 // Navigate to an initial WebUI URL. |
951 contents()->NavigateAndCommit(kSettingsUrl); | 990 contents()->NavigateAndCommit(kSettingsUrl); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1035 | 1074 |
1036 // Commit. | 1075 // Commit. |
1037 manager.DidNavigateMainFrame(host); | 1076 manager.DidNavigateMainFrame(host); |
1038 EXPECT_EQ(host, manager.current_host()); | 1077 EXPECT_EQ(host, manager.current_host()); |
1039 ASSERT_TRUE(host); | 1078 ASSERT_TRUE(host); |
1040 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), | 1079 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), |
1041 instance); | 1080 instance); |
1042 } | 1081 } |
1043 | 1082 |
1044 } // namespace content | 1083 } // namespace content |
OLD | NEW |