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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "content/browser/frame_host/navigation_controller_impl.h" | 6 #include "content/browser/frame_host/navigation_controller_impl.h" |
7 #include "content/browser/frame_host/navigation_entry_impl.h" | 7 #include "content/browser/frame_host/navigation_entry_impl.h" |
8 #include "content/browser/frame_host/render_frame_host_manager.h" | 8 #include "content/browser/frame_host/render_frame_host_manager.h" |
9 #include "content/browser/site_instance_impl.h" | 9 #include "content/browser/site_instance_impl.h" |
10 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 10 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 | 1051 |
1052 // Navigate to a cross-site URL (different SiteInstance but same | 1052 // Navigate to a cross-site URL (different SiteInstance but same |
1053 // BrowsingInstance). | 1053 // BrowsingInstance). |
1054 contents()->NavigateAndCommit(kUrl2); | 1054 contents()->NavigateAndCommit(kUrl2); |
1055 TestRenderViewHost* rvh2 = test_rvh(); | 1055 TestRenderViewHost* rvh2 = test_rvh(); |
1056 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); | 1056 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); |
1057 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 1057 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
1058 rvh2->GetSiteInstance())); | 1058 rvh2->GetSiteInstance())); |
1059 | 1059 |
1060 // Ensure rvh1 is placed on swapped out list of the current tab. | 1060 // Ensure rvh1 is placed on swapped out list of the current tab. |
1061 EXPECT_TRUE(manager->IsOnSwappedOutList(rvh1)); | 1061 EXPECT_TRUE(manager->IsRVHOnSwappedOutList(rvh1)); |
1062 EXPECT_EQ(rvh1, | 1062 EXPECT_EQ(rvh1, |
1063 manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance())); | 1063 manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance())); |
1064 | 1064 |
1065 // Ensure a swapped out RVH is created in the first opener tab. | 1065 // Ensure a swapped out RVH is created in the first opener tab. |
1066 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 1066 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
1067 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1067 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
1068 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rvh)); | 1068 EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh)); |
1069 EXPECT_TRUE(opener1_rvh->is_swapped_out()); | 1069 EXPECT_TRUE(opener1_rvh->is_swapped_out()); |
1070 | 1070 |
1071 // Ensure a swapped out RVH is created in the second opener tab. | 1071 // Ensure a swapped out RVH is created in the second opener tab. |
1072 TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( | 1072 TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( |
1073 opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1073 opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
1074 EXPECT_TRUE(opener2_manager->IsOnSwappedOutList(opener2_rvh)); | 1074 EXPECT_TRUE(opener2_manager->IsRVHOnSwappedOutList(opener2_rvh)); |
1075 EXPECT_TRUE(opener2_rvh->is_swapped_out()); | 1075 EXPECT_TRUE(opener2_rvh->is_swapped_out()); |
1076 | 1076 |
1077 // Navigate to a cross-BrowsingInstance URL. | 1077 // Navigate to a cross-BrowsingInstance URL. |
1078 contents()->NavigateAndCommit(kChromeUrl); | 1078 contents()->NavigateAndCommit(kChromeUrl); |
1079 TestRenderViewHost* rvh3 = test_rvh(); | 1079 TestRenderViewHost* rvh3 = test_rvh(); |
1080 EXPECT_NE(rvh1->GetSiteInstance(), rvh3->GetSiteInstance()); | 1080 EXPECT_NE(rvh1->GetSiteInstance(), rvh3->GetSiteInstance()); |
1081 EXPECT_FALSE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 1081 EXPECT_FALSE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
1082 rvh3->GetSiteInstance())); | 1082 rvh3->GetSiteInstance())); |
1083 | 1083 |
1084 // No scripting is allowed across BrowsingInstances, so we should not create | 1084 // No scripting is allowed across BrowsingInstances, so we should not create |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 // BrowsingInstance). | 1166 // BrowsingInstance). |
1167 contents()->NavigateAndCommit(kPluginUrl); | 1167 contents()->NavigateAndCommit(kPluginUrl); |
1168 TestRenderViewHost* rvh2 = test_rvh(); | 1168 TestRenderViewHost* rvh2 = test_rvh(); |
1169 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); | 1169 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); |
1170 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 1170 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
1171 rvh2->GetSiteInstance())); | 1171 rvh2->GetSiteInstance())); |
1172 | 1172 |
1173 // Ensure a swapped out RVH is created in the first opener tab. | 1173 // Ensure a swapped out RVH is created in the first opener tab. |
1174 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 1174 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
1175 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1175 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
1176 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rvh)); | 1176 EXPECT_TRUE(opener1_manager->IsRVHOnSwappedOutList(opener1_rvh)); |
1177 EXPECT_TRUE(opener1_rvh->is_swapped_out()); | 1177 EXPECT_TRUE(opener1_rvh->is_swapped_out()); |
1178 | 1178 |
1179 // Ensure the new RVH has WebUI bindings. | 1179 // Ensure the new RVH has WebUI bindings. |
1180 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1180 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
1181 } | 1181 } |
1182 | 1182 |
1183 // Test that we reuse the same guest SiteInstance if we navigate across sites. | 1183 // Test that we reuse the same guest SiteInstance if we navigate across sites. |
1184 TEST_F(RenderFrameHostManagerTest, NoSwapOnGuestNavigations) { | 1184 TEST_F(RenderFrameHostManagerTest, NoSwapOnGuestNavigations) { |
1185 TestNotificationTracker notifications; | 1185 TestNotificationTracker notifications; |
1186 | 1186 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 Source<RenderWidgetHost>(host2)); | 1310 Source<RenderWidgetHost>(host2)); |
1311 manager.ShouldClosePage(false, true, base::TimeTicks()); | 1311 manager.ShouldClosePage(false, true, base::TimeTicks()); |
1312 | 1312 |
1313 EXPECT_TRUE( | 1313 EXPECT_TRUE( |
1314 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED)); | 1314 notifications.Check1AndReset(NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED)); |
1315 EXPECT_FALSE(manager.pending_render_view_host()); | 1315 EXPECT_FALSE(manager.pending_render_view_host()); |
1316 EXPECT_EQ(host, manager.current_host()); | 1316 EXPECT_EQ(host, manager.current_host()); |
1317 } | 1317 } |
1318 | 1318 |
1319 } // namespace content | 1319 } // namespace content |
OLD | NEW |