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

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

Issue 600993002: Fix RenderProcessHostUnitTest.RendererProcessLimit to pass with --site-per-process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add CONTENT_EXPORT to kEnableStrictSiteIsolation Created 6 years, 2 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
« no previous file with comments | « no previous file | content/browser/site_instance_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> 5 #include <limits>
6 6
7 #include "base/command_line.h"
7 #include "content/public/common/content_constants.h" 8 #include "content/public/common/content_constants.h"
9 #include "content/public/common/content_switches.h"
8 #include "content/public/test/mock_render_process_host.h" 10 #include "content/public/test/mock_render_process_host.h"
9 #include "content/test/test_render_view_host.h" 11 #include "content/test/test_render_view_host.h"
10 12
11 namespace content { 13 namespace content {
12 14
13 class RenderProcessHostUnitTest : public RenderViewHostTestHarness {}; 15 class RenderProcessHostUnitTest : public RenderViewHostTestHarness {};
14 16
15 // Tests that guest RenderProcessHosts are not considered suitable hosts when 17 // Tests that guest RenderProcessHosts are not considered suitable hosts when
16 // searching for RenderProcessHost. 18 // searching for RenderProcessHost.
17 TEST_F(RenderProcessHostUnitTest, GuestsAreNotSuitableHosts) { 19 TEST_F(RenderProcessHostUnitTest, GuestsAreNotSuitableHosts) {
18 GURL test_url("http://foo.com"); 20 GURL test_url("http://foo.com");
19 21
20 MockRenderProcessHost guest_host(browser_context()); 22 MockRenderProcessHost guest_host(browser_context());
21 guest_host.set_is_isolated_guest(true); 23 guest_host.set_is_isolated_guest(true);
22 24
23 EXPECT_FALSE(RenderProcessHostImpl::IsSuitableHost( 25 EXPECT_FALSE(RenderProcessHostImpl::IsSuitableHost(
24 &guest_host, browser_context(), test_url)); 26 &guest_host, browser_context(), test_url));
25 EXPECT_TRUE(RenderProcessHostImpl::IsSuitableHost( 27 EXPECT_TRUE(RenderProcessHostImpl::IsSuitableHost(
26 process(), browser_context(), test_url)); 28 process(), browser_context(), test_url));
27 EXPECT_EQ( 29 EXPECT_EQ(
28 process(), 30 process(),
29 RenderProcessHost::GetExistingProcessHost(browser_context(), test_url)); 31 RenderProcessHost::GetExistingProcessHost(browser_context(), test_url));
30 } 32 }
31 33
32 #if !defined(OS_ANDROID) 34 #if !defined(OS_ANDROID)
33 TEST_F(RenderProcessHostUnitTest, RendererProcessLimit) { 35 TEST_F(RenderProcessHostUnitTest, RendererProcessLimit) {
36 // This test shouldn't run with --site-per-process or
37 // --enable-strict-site-isolation modes, since they don't allow renderer
38 // process reuse, which this test explicitly exercises.
39 const base::CommandLine& command_line =
40 *base::CommandLine::ForCurrentProcess();
41 if (command_line.HasSwitch(switches::kSitePerProcess) ||
42 command_line.HasSwitch(switches::kEnableStrictSiteIsolation))
43 return;
44
34 // Disable any overrides. 45 // Disable any overrides.
35 RenderProcessHostImpl::SetMaxRendererProcessCount(0); 46 RenderProcessHostImpl::SetMaxRendererProcessCount(0);
36 47
37 // Verify that the limit is between 1 and kMaxRendererProcessCount. 48 // Verify that the limit is between 1 and kMaxRendererProcessCount.
38 EXPECT_GT(RenderProcessHostImpl::GetMaxRendererProcessCount(), 0u); 49 EXPECT_GT(RenderProcessHostImpl::GetMaxRendererProcessCount(), 0u);
39 EXPECT_LE(RenderProcessHostImpl::GetMaxRendererProcessCount(), 50 EXPECT_LE(RenderProcessHostImpl::GetMaxRendererProcessCount(),
40 kMaxRendererProcessCount); 51 kMaxRendererProcessCount);
41 52
42 // Add dummy process hosts to saturate the limit. 53 // Add dummy process hosts to saturate the limit.
43 ASSERT_NE(0u, kMaxRendererProcessCount); 54 ASSERT_NE(0u, kMaxRendererProcessCount);
(...skipping 26 matching lines...) Expand all
70 } 81 }
71 82
72 // Verify that the renderer sharing still won't happen. 83 // Verify that the renderer sharing still won't happen.
73 GURL test_url("http://foo.com"); 84 GURL test_url("http://foo.com");
74 EXPECT_FALSE(RenderProcessHostImpl::ShouldTryToUseExistingProcessHost( 85 EXPECT_FALSE(RenderProcessHostImpl::ShouldTryToUseExistingProcessHost(
75 browser_context(), test_url)); 86 browser_context(), test_url));
76 } 87 }
77 #endif 88 #endif
78 89
79 } // namespace content 90 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/site_instance_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698