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

Side by Side Diff: content/browser/renderer_host/render_process_host_unittest.cc

Issue 356453003: Don't share renderers between unrelated tabs on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address John(me)'s comments. Created 6 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
OLDNEW
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 <limits>
6
7 #include "content/public/common/content_constants.h"
5 #include "content/public/test/mock_render_process_host.h" 8 #include "content/public/test/mock_render_process_host.h"
6 #include "content/test/test_render_view_host.h" 9 #include "content/test/test_render_view_host.h"
7 10
8 namespace content { 11 namespace content {
9 12
10 class RenderProcessHostUnitTest : public RenderViewHostTestHarness {}; 13 class RenderProcessHostUnitTest : public RenderViewHostTestHarness {};
11 14
12 // Tests that guest RenderProcessHosts are not considered suitable hosts when 15 // Tests that guest RenderProcessHosts are not considered suitable hosts when
13 // searching for RenderProcessHost. 16 // searching for RenderProcessHost.
14 TEST_F(RenderProcessHostUnitTest, GuestsAreNotSuitableHosts) { 17 TEST_F(RenderProcessHostUnitTest, GuestsAreNotSuitableHosts) {
15 GURL test_url("http://foo.com"); 18 GURL test_url("http://foo.com");
16 19
17 MockRenderProcessHost guest_host(browser_context()); 20 MockRenderProcessHost guest_host(browser_context());
18 guest_host.set_is_isolated_guest(true); 21 guest_host.set_is_isolated_guest(true);
19 22
20 EXPECT_FALSE(RenderProcessHostImpl::IsSuitableHost( 23 EXPECT_FALSE(RenderProcessHostImpl::IsSuitableHost(
21 &guest_host, browser_context(), test_url)); 24 &guest_host, browser_context(), test_url));
22 EXPECT_TRUE(RenderProcessHostImpl::IsSuitableHost( 25 EXPECT_TRUE(RenderProcessHostImpl::IsSuitableHost(
23 process(), browser_context(), test_url)); 26 process(), browser_context(), test_url));
24 EXPECT_EQ( 27 EXPECT_EQ(
25 process(), 28 process(),
26 RenderProcessHost::GetExistingProcessHost(browser_context(), test_url)); 29 RenderProcessHost::GetExistingProcessHost(browser_context(), test_url));
27 } 30 }
28 31
32 #if !defined(OS_ANDROID)
33 TEST_F(RenderProcessHostUnitTest, RendererProcessLimit) {
34 // Disable any overrides.
35 RenderProcessHostImpl::SetMaxRendererProcessCount(0);
36
37 // Verify that the limit is between 1 and kMaxRendererProcessCount.
38 EXPECT_GT(RenderProcessHostImpl::GetMaxRendererProcessCount(), 0u);
39 EXPECT_LE(RenderProcessHostImpl::GetMaxRendererProcessCount(),
40 kMaxRendererProcessCount);
41
42 // Add dummy process hosts to saturate the limit.
43 ASSERT_NE(0u, kMaxRendererProcessCount);
44 ScopedVector<MockRenderProcessHost> hosts;
45 for (size_t i = 0; i < kMaxRendererProcessCount; ++i) {
46 hosts.push_back(new MockRenderProcessHost(browser_context()));
47 }
48
49 // Verify that the renderer sharing will happen.
50 GURL test_url("http://foo.com");
51 EXPECT_TRUE(RenderProcessHostImpl::ShouldTryToUseExistingProcessHost(
52 browser_context(), test_url));
53 }
54 #endif
55
56 #if defined(OS_ANDROID)
57 TEST_F(RenderProcessHostUnitTest, NoRendererProcessLimitOnAndroid) {
58 // Disable any overrides.
59 RenderProcessHostImpl::SetMaxRendererProcessCount(0);
60
61 // Verify that by default the limit on Android returns max size_t.
62 EXPECT_EQ(std::numeric_limits<size_t>::max(),
63 RenderProcessHostImpl::GetMaxRendererProcessCount());
64
65 // Add a few dummy process hosts.
66 ASSERT_NE(0u, kMaxRendererProcessCount);
67 ScopedVector<MockRenderProcessHost> hosts;
68 for (size_t i = 0; i < kMaxRendererProcessCount; ++i) {
69 hosts.push_back(new MockRenderProcessHost(browser_context()));
70 }
71
72 // Verify that the renderer sharing still won't happen.
73 GURL test_url("http://foo.com");
74 EXPECT_FALSE(RenderProcessHostImpl::ShouldTryToUseExistingProcessHost(
75 browser_context(), test_url));
76 }
77 #endif
78
29 } // namespace content 79 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/browser/site_instance_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698