Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1146)

Side by Side Diff: content/browser/web_contents/render_view_host_manager_unittest.cc

Issue 19021004: Prevent creating a swapped out RVH in the same SiteInstance as the current one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix decisions for hosted apps Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/render_view_host_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( 938 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost(
939 rvh3->GetSiteInstance())); 939 rvh3->GetSiteInstance()));
940 EXPECT_FALSE(opener2_manager->GetSwappedOutRenderViewHost( 940 EXPECT_FALSE(opener2_manager->GetSwappedOutRenderViewHost(
941 rvh3->GetSiteInstance())); 941 rvh3->GetSiteInstance()));
942 } 942 }
943 943
944 // Test that we clean up swapped out RenderViewHosts when a process hosting 944 // Test that we clean up swapped out RenderViewHosts when a process hosting
945 // those associated RenderViews crashes. http://crbug.com/258993 945 // those associated RenderViews crashes. http://crbug.com/258993
946 TEST_F(RenderViewHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) { 946 TEST_F(RenderViewHostManagerTest, CleanUpSwappedOutRVHOnProcessCrash) {
947 const GURL kUrl1("http://www.google.com/"); 947 const GURL kUrl1("http://www.google.com/");
948 const GURL kUrl2("http://www.chromium.org/");
948 949
949 // Navigate to an initial URL. 950 // Navigate to an initial URL.
950 contents()->NavigateAndCommit(kUrl1); 951 contents()->NavigateAndCommit(kUrl1);
951 TestRenderViewHost* rvh1 = test_rvh(); 952 TestRenderViewHost* rvh1 = test_rvh();
952 953
953 // Create a new tab as an opener for the main tab. 954 // Create a new tab as an opener for the main tab.
954 scoped_ptr<TestWebContents> opener1( 955 scoped_ptr<TestWebContents> opener1(
955 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance())); 956 TestWebContents::Create(browser_context(), rvh1->GetSiteInstance()));
956 RenderViewHostManager* opener1_manager = 957 RenderViewHostManager* opener1_manager =
957 opener1->GetRenderManagerForTesting(); 958 opener1->GetRenderManagerForTesting();
958 contents()->SetOpener(opener1.get()); 959 contents()->SetOpener(opener1.get());
959 960
961 // Make sure the new opener RVH is considered live.
962 opener1_manager->current_host()->CreateRenderView(string16(), -1, -1);
963
960 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost( 964 EXPECT_FALSE(opener1_manager->GetSwappedOutRenderViewHost(
961 rvh1->GetSiteInstance())); 965 rvh1->GetSiteInstance()));
962 opener1->CreateSwappedOutRenderView(rvh1->GetSiteInstance()); 966 opener1->NavigateAndCommit(kUrl2);
963 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost( 967 EXPECT_TRUE(opener1_manager->GetSwappedOutRenderViewHost(
964 rvh1->GetSiteInstance())); 968 rvh1->GetSiteInstance()));
965 969
966 // Fake a process crash. 970 // Fake a process crash.
967 RenderProcessHost::RendererClosedDetails details( 971 RenderProcessHost::RendererClosedDetails details(
968 rvh1->GetProcess()->GetHandle(), 972 rvh1->GetProcess()->GetHandle(),
969 base::TERMINATION_STATUS_PROCESS_CRASHED, 973 base::TERMINATION_STATUS_PROCESS_CRASHED,
970 0); 974 0);
971 NotificationService::current()->Notify( 975 NotificationService::current()->Notify(
972 NOTIFICATION_RENDERER_PROCESS_CLOSED, 976 NOTIFICATION_RENDERER_PROCESS_CLOSED,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 1078
1075 // Commit. 1079 // Commit.
1076 manager.DidNavigateMainFrame(host); 1080 manager.DidNavigateMainFrame(host);
1077 EXPECT_EQ(host, manager.current_host()); 1081 EXPECT_EQ(host, manager.current_host());
1078 ASSERT_TRUE(host); 1082 ASSERT_TRUE(host);
1079 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()), 1083 EXPECT_EQ(static_cast<SiteInstanceImpl*>(host->GetSiteInstance()),
1080 instance); 1084 instance);
1081 } 1085 }
1082 1086
1083 } // namespace content 1087 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/render_view_host_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698