| 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 "content/browser/frame_host/render_frame_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 TestRenderViewHost* rvh2 = test_rvh(); | 1331 TestRenderViewHost* rvh2 = test_rvh(); |
| 1332 EXPECT_NE(site_instance1, rfh2->GetSiteInstance()); | 1332 EXPECT_NE(site_instance1, rfh2->GetSiteInstance()); |
| 1333 EXPECT_TRUE(site_instance1->IsRelatedSiteInstance(rfh2->GetSiteInstance())); | 1333 EXPECT_TRUE(site_instance1->IsRelatedSiteInstance(rfh2->GetSiteInstance())); |
| 1334 | 1334 |
| 1335 // Ensure rvh1 is placed on swapped out list of the current tab. | 1335 // Ensure rvh1 is placed on swapped out list of the current tab. |
| 1336 EXPECT_TRUE(rfh1_deleted_observer.deleted()); | 1336 EXPECT_TRUE(rfh1_deleted_observer.deleted()); |
| 1337 EXPECT_TRUE(manager->GetRenderFrameProxyHost(site_instance1.get())); | 1337 EXPECT_TRUE(manager->GetRenderFrameProxyHost(site_instance1.get())); |
| 1338 EXPECT_EQ(rvh1, | 1338 EXPECT_EQ(rvh1, |
| 1339 manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance())); | 1339 manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance())); |
| 1340 | 1340 |
| 1341 // Ensure a swapped out RFH and RFH is created in the first opener tab. | 1341 // Ensure a proxy and swapped out RVH are created in the first opener tab. |
| 1342 RenderFrameProxyHost* opener1_proxy = | 1342 EXPECT_TRUE( |
| 1343 opener1_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance()); | 1343 opener1_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance())); |
| 1344 RenderFrameHostImpl* opener1_rfh = opener1_proxy->render_frame_host(); | |
| 1345 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 1344 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
| 1346 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1345 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
| 1347 EXPECT_FALSE(opener1_rfh); | |
| 1348 EXPECT_FALSE(opener1_rvh->is_active()); | 1346 EXPECT_FALSE(opener1_rvh->is_active()); |
| 1349 | 1347 |
| 1350 // Ensure a swapped out RFH and RVH is created in the second opener tab. | 1348 // Ensure a proxy and swapped out RVH are created in the second opener tab. |
| 1351 RenderFrameProxyHost* opener2_proxy = | 1349 EXPECT_TRUE( |
| 1352 opener2_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance()); | 1350 opener2_manager->GetRenderFrameProxyHost(rfh2->GetSiteInstance())); |
| 1353 RenderFrameHostImpl* opener2_rfh = opener2_proxy->render_frame_host(); | |
| 1354 TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( | 1351 TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( |
| 1355 opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1352 opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
| 1356 EXPECT_FALSE(opener2_rfh); | |
| 1357 EXPECT_FALSE(opener2_rvh->is_active()); | 1353 EXPECT_FALSE(opener2_rvh->is_active()); |
| 1358 | 1354 |
| 1359 // Navigate to a cross-BrowsingInstance URL. | 1355 // Navigate to a cross-BrowsingInstance URL. |
| 1360 contents()->NavigateAndCommit(kChromeUrl); | 1356 contents()->NavigateAndCommit(kChromeUrl); |
| 1361 TestRenderFrameHost* rfh3 = main_test_rfh(); | 1357 TestRenderFrameHost* rfh3 = main_test_rfh(); |
| 1362 EXPECT_NE(site_instance1, rfh3->GetSiteInstance()); | 1358 EXPECT_NE(site_instance1, rfh3->GetSiteInstance()); |
| 1363 EXPECT_FALSE(site_instance1->IsRelatedSiteInstance(rfh3->GetSiteInstance())); | 1359 EXPECT_FALSE(site_instance1->IsRelatedSiteInstance(rfh3->GetSiteInstance())); |
| 1364 | 1360 |
| 1365 // No scripting is allowed across BrowsingInstances, so we should not create | 1361 // No scripting is allowed across BrowsingInstances, so we should not create |
| 1366 // swapped out RVHs for the opener chain in this case. | 1362 // swapped out RVHs for the opener chain in this case. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 contents()->SetOpener(opener1.get()); | 1583 contents()->SetOpener(opener1.get()); |
| 1588 | 1584 |
| 1589 // Navigate to a different WebUI URL (different SiteInstance, same | 1585 // Navigate to a different WebUI URL (different SiteInstance, same |
| 1590 // BrowsingInstance). | 1586 // BrowsingInstance). |
| 1591 contents()->NavigateAndCommit(kPluginUrl); | 1587 contents()->NavigateAndCommit(kPluginUrl); |
| 1592 TestRenderViewHost* rvh2 = test_rvh(); | 1588 TestRenderViewHost* rvh2 = test_rvh(); |
| 1593 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); | 1589 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); |
| 1594 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 1590 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
| 1595 rvh2->GetSiteInstance())); | 1591 rvh2->GetSiteInstance())); |
| 1596 | 1592 |
| 1597 // Ensure a swapped out RFH and RVH is created in the first opener tab. | 1593 // Ensure a proxy and swapped out RVH are created in the first opener tab. |
| 1598 RenderFrameProxyHost* opener1_proxy = | 1594 EXPECT_TRUE( |
| 1599 opener1_manager->GetRenderFrameProxyHost(rvh2->GetSiteInstance()); | 1595 opener1_manager->GetRenderFrameProxyHost(rvh2->GetSiteInstance())); |
| 1600 RenderFrameHostImpl* opener1_rfh = opener1_proxy->render_frame_host(); | |
| 1601 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 1596 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
| 1602 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 1597 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
| 1603 EXPECT_FALSE(opener1_rfh); | |
| 1604 EXPECT_FALSE(opener1_rvh->is_active()); | 1598 EXPECT_FALSE(opener1_rvh->is_active()); |
| 1605 | 1599 |
| 1606 // Ensure the new RVH has WebUI bindings. | 1600 // Ensure the new RVH has WebUI bindings. |
| 1607 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 1601 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
| 1608 } | 1602 } |
| 1609 | 1603 |
| 1610 // Test that we reuse the same guest SiteInstance if we navigate across sites. | 1604 // Test that we reuse the same guest SiteInstance if we navigate across sites. |
| 1611 TEST_F(RenderFrameHostManagerTest, NoSwapOnGuestNavigations) { | 1605 TEST_F(RenderFrameHostManagerTest, NoSwapOnGuestNavigations) { |
| 1612 GURL guest_url(std::string(kGuestScheme).append("://abc123")); | 1606 GURL guest_url(std::string(kGuestScheme).append("://abc123")); |
| 1613 scoped_refptr<SiteInstance> instance = | 1607 scoped_refptr<SiteInstance> instance = |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3101 commit_params.should_enforce_strict_mixed_content_checking = false; | 3095 commit_params.should_enforce_strict_mixed_content_checking = false; |
| 3102 child_host->SendNavigateWithParams(&commit_params); | 3096 child_host->SendNavigateWithParams(&commit_params); |
| 3103 EXPECT_NO_FATAL_FAILURE(CheckMixedContentIPC( | 3097 EXPECT_NO_FATAL_FAILURE(CheckMixedContentIPC( |
| 3104 main_test_rfh(), false, proxy_to_parent->GetRoutingID())); | 3098 main_test_rfh(), false, proxy_to_parent->GetRoutingID())); |
| 3105 EXPECT_FALSE(root->child_at(0) | 3099 EXPECT_FALSE(root->child_at(0) |
| 3106 ->current_replication_state() | 3100 ->current_replication_state() |
| 3107 .should_enforce_strict_mixed_content_checking); | 3101 .should_enforce_strict_mixed_content_checking); |
| 3108 } | 3102 } |
| 3109 | 3103 |
| 3110 } // namespace content | 3104 } // namespace content |
| OLD | NEW |