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

Unified Diff: content/browser/renderer_host/render_process_host_unittest.cc

Issue 2921063003: Fix process reuse for dedicated processes when over process limit. (Closed)
Patch Set: Fix IsSuitableHost for sites that require a dedicated process but don't set an origin lock Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
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..c9598351f5d869e99cc8b6b306844032a3033f64 100644
--- a/content/browser/renderer_host/render_process_host_unittest.cc
+++ b/content/browser/renderer_host/render_process_host_unittest.cc
@@ -151,6 +151,36 @@ 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, IsUnused) {
+ 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()->IsUnused());
+ {
+ scoped_refptr<SiteInstanceImpl> site_instance =
+ SiteInstanceImpl::Create(browser_context());
+ EXPECT_FALSE(site_instance->HasSite());
+ EXPECT_TRUE(site_instance->GetProcess()->IsUnused());
+ }
+
+ // Navigation should mark the process as unable to become a dedicated process
+ // for arbitrary sites.
+ NavigateAndCommit(kUrl1);
+ EXPECT_FALSE(main_test_rfh()->GetProcess()->IsUnused());
+
+ // A process for a SiteInstance with a preassigned site should be considered
+ // "used" from the point the process is created via GetProcess().
+ {
+ scoped_refptr<SiteInstanceImpl> site_instance =
+ SiteInstanceImpl::CreateForURL(browser_context(), kUrl1);
+ EXPECT_FALSE(site_instance->GetProcess()->IsUnused());
+ }
+}
+
// Tests that RenderProcessHost will not consider reusing a process that has
// committed an error page.
TEST_F(RenderProcessHostUnitTest, DoNotReuseError) {

Powered by Google App Engine
This is Rietveld 408576698