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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "content/browser/browser_thread_impl.h" | 6 #include "content/browser/browser_thread_impl.h" |
7 #include "content/browser/renderer_host/test_render_view_host.h" | 7 #include "content/browser/renderer_host/test_render_view_host.h" |
8 #include "content/browser/site_instance_impl.h" | 8 #include "content/browser/site_instance_impl.h" |
9 #include "content/browser/web_contents/navigation_controller_impl.h" | 9 #include "content/browser/web_contents/navigation_controller_impl.h" |
10 #include "content/browser/web_contents/navigation_entry_impl.h" | 10 #include "content/browser/web_contents/navigation_entry_impl.h" |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 808 |
809 // Navigate to a cross-site URL (different SiteInstance but same | 809 // Navigate to a cross-site URL (different SiteInstance but same |
810 // BrowsingInstance). | 810 // BrowsingInstance). |
811 contents()->NavigateAndCommit(kUrl2); | 811 contents()->NavigateAndCommit(kUrl2); |
812 TestRenderViewHost* rvh2 = test_rvh(); | 812 TestRenderViewHost* rvh2 = test_rvh(); |
813 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); | 813 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); |
814 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 814 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
815 rvh2->GetSiteInstance())); | 815 rvh2->GetSiteInstance())); |
816 | 816 |
817 // Ensure rvh1 is placed on swapped out list of the current tab. | 817 // Ensure rvh1 is placed on swapped out list of the current tab. |
818 EXPECT_TRUE(manager->IsSwappedOut(rvh1)); | 818 EXPECT_TRUE(manager->IsOnSwappedOutList(rvh1)); |
819 EXPECT_EQ(rvh1, | 819 EXPECT_EQ(rvh1, |
820 manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance())); | 820 manager->GetSwappedOutRenderViewHost(rvh1->GetSiteInstance())); |
821 | 821 |
822 // Ensure a swapped out RVH is created in the first opener tab. | 822 // Ensure a swapped out RVH is created in the first opener tab. |
823 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 823 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
824 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 824 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
825 EXPECT_TRUE(opener1_manager->IsSwappedOut(opener1_rvh)); | 825 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rvh)); |
826 EXPECT_TRUE(opener1_rvh->is_swapped_out()); | 826 EXPECT_TRUE(opener1_rvh->is_swapped_out()); |
827 | 827 |
828 // Ensure a swapped out RVH is created in the second opener tab. | 828 // Ensure a swapped out RVH is created in the second opener tab. |
829 TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( | 829 TestRenderViewHost* opener2_rvh = static_cast<TestRenderViewHost*>( |
830 opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 830 opener2_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
831 EXPECT_TRUE(opener2_manager->IsSwappedOut(opener2_rvh)); | 831 EXPECT_TRUE(opener2_manager->IsOnSwappedOutList(opener2_rvh)); |
832 EXPECT_TRUE(opener2_rvh->is_swapped_out()); | 832 EXPECT_TRUE(opener2_rvh->is_swapped_out()); |
833 | 833 |
834 // Navigate to a cross-BrowsingInstance URL. | 834 // Navigate to a cross-BrowsingInstance URL. |
835 contents()->NavigateAndCommit(kChromeUrl); | 835 contents()->NavigateAndCommit(kChromeUrl); |
836 TestRenderViewHost* rvh3 = test_rvh(); | 836 TestRenderViewHost* rvh3 = test_rvh(); |
837 EXPECT_NE(rvh1->GetSiteInstance(), rvh3->GetSiteInstance()); | 837 EXPECT_NE(rvh1->GetSiteInstance(), rvh3->GetSiteInstance()); |
838 EXPECT_FALSE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 838 EXPECT_FALSE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
839 rvh3->GetSiteInstance())); | 839 rvh3->GetSiteInstance())); |
840 | 840 |
841 // No scripting is allowed across BrowsingInstances, so we should not create | 841 // No scripting is allowed across BrowsingInstances, so we should not create |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 // BrowsingInstance). | 873 // BrowsingInstance). |
874 contents()->NavigateAndCommit(kPluginUrl); | 874 contents()->NavigateAndCommit(kPluginUrl); |
875 TestRenderViewHost* rvh2 = test_rvh(); | 875 TestRenderViewHost* rvh2 = test_rvh(); |
876 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); | 876 EXPECT_NE(rvh1->GetSiteInstance(), rvh2->GetSiteInstance()); |
877 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( | 877 EXPECT_TRUE(rvh1->GetSiteInstance()->IsRelatedSiteInstance( |
878 rvh2->GetSiteInstance())); | 878 rvh2->GetSiteInstance())); |
879 | 879 |
880 // Ensure a swapped out RVH is created in the first opener tab. | 880 // Ensure a swapped out RVH is created in the first opener tab. |
881 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( | 881 TestRenderViewHost* opener1_rvh = static_cast<TestRenderViewHost*>( |
882 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); | 882 opener1_manager->GetSwappedOutRenderViewHost(rvh2->GetSiteInstance())); |
883 EXPECT_TRUE(opener1_manager->IsSwappedOut(opener1_rvh)); | 883 EXPECT_TRUE(opener1_manager->IsOnSwappedOutList(opener1_rvh)); |
884 EXPECT_TRUE(opener1_rvh->is_swapped_out()); | 884 EXPECT_TRUE(opener1_rvh->is_swapped_out()); |
885 | 885 |
886 // Ensure the new RVH has WebUI bindings. | 886 // Ensure the new RVH has WebUI bindings. |
887 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); | 887 EXPECT_TRUE(rvh2->GetEnabledBindings() & BINDINGS_POLICY_WEB_UI); |
888 } | 888 } |
889 | 889 |
890 // Test that we reuse the same guest SiteInstance if we navigate across sites. | 890 // Test that we reuse the same guest SiteInstance if we navigate across sites. |
891 TEST_F(RenderViewHostManagerTest, NoSwapOnGuestNavigations) { | 891 TEST_F(RenderViewHostManagerTest, NoSwapOnGuestNavigations) { |
892 TestNotificationTracker notifications; | 892 TestNotificationTracker notifications; |
893 | 893 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 | 942 |
943 // Commit. | 943 // Commit. |
944 manager.DidNavigateMainFrame(host); | 944 manager.DidNavigateMainFrame(host); |
945 EXPECT_EQ(host, manager.current_host()); | 945 EXPECT_EQ(host, manager.current_host()); |
946 ASSERT_TRUE(host); | 946 ASSERT_TRUE(host); |
947 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), | 947 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), |
948 instance); | 948 instance); |
949 } | 949 } |
950 | 950 |
951 } // namespace content | 951 } // namespace content |
OLD | NEW |