Index: content/browser/renderer_host/render_process_host_unittest.cc |
diff --git a/content/browser/renderer_host/render_process_host_unittest.cc b/content/browser/renderer_host/render_process_host_unittest.cc |
index 13825258663da34a2260345b379d40f1a580f3d9..8411513ee3cac3b2c1e72f0fa3eac3075cbccf2c 100644 |
--- a/content/browser/renderer_host/render_process_host_unittest.cc |
+++ b/content/browser/renderer_host/render_process_host_unittest.cc |
@@ -151,6 +151,37 @@ TEST_F(RenderProcessHostUnitTest, ReuseCommittedSite) { |
EXPECT_EQ(subframe->GetProcess(), site_instance->GetProcess()); |
} |
+// Check that only new processes that haven't yet hosted any web content are |
+// allowed to be reused to host a site requiring a dedicated process. |
+TEST_F(RenderProcessHostUnitTest, CanBecomeDedicatedProcess) { |
+ const GURL kUrl1("http://foo.com"); |
+ |
+ // A process for a SiteInstance that has no site should be able to host any |
+ // site that requires a dedicated process. |
+ EXPECT_FALSE(main_test_rfh()->GetSiteInstance()->HasSite()); |
+ EXPECT_TRUE(main_test_rfh()->GetProcess()->CanBecomeDedicatedProcess()); |
+ { |
+ scoped_refptr<SiteInstanceImpl> site_instance = |
+ SiteInstanceImpl::Create(browser_context()); |
+ EXPECT_FALSE(site_instance->HasSite()); |
+ EXPECT_TRUE(site_instance->GetProcess()->CanBecomeDedicatedProcess()); |
+ } |
+ |
+ // Navigation should mark the process as unable to become a dedicated process |
+ // for arbitrary sites. |
+ NavigateAndCommit(kUrl1); |
+ EXPECT_FALSE(main_test_rfh()->GetProcess()->CanBecomeDedicatedProcess()); |
+ |
+ // A process for a SiteInstance that has been created for a particular site |
+ // is considered unsuitable to host arbitrary sites requiring a dedicated |
+ // process from the point it is created via GetProcess(). |
+ { |
+ scoped_refptr<SiteInstanceImpl> site_instance = |
+ SiteInstanceImpl::CreateForURL(browser_context(), kUrl1); |
+ EXPECT_FALSE(site_instance->GetProcess()->CanBecomeDedicatedProcess()); |
Charlie Reis
2017/06/12 23:08:17
What would happen if kUrl1 was a site requiring a
alexmos
2017/06/14 22:39:05
Yes, I renamed the method and reworded the comment
|
+ } |
+} |
+ |
// Tests that RenderProcessHost will not consider reusing a process that has |
// committed an error page. |
TEST_F(RenderProcessHostUnitTest, DoNotReuseError) { |