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

Side by Side Diff: content/browser/site_instance_impl_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: Move declaration of more services to a separate CL. Created 6 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 unified diff | Download patch | Annotate | Revision Log
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/browsing_instance.h" 10 #include "content/browser/browsing_instance.h"
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } 555 }
556 556
557 // Test to ensure that pages that require certain privileges are grouped 557 // Test to ensure that pages that require certain privileges are grouped
558 // in processes with similar pages. 558 // in processes with similar pages.
559 TEST_F(SiteInstanceTest, ProcessSharingByType) { 559 TEST_F(SiteInstanceTest, ProcessSharingByType) {
560 // This test shouldn't run with --site-per-process mode, since it doesn't 560 // This test shouldn't run with --site-per-process mode, since it doesn't
561 // allow render process reuse, which this test explicitly exercises. 561 // allow render process reuse, which this test explicitly exercises.
562 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) 562 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess))
563 return; 563 return;
564 564
565 // On Android by default the number of renderer hosts is unlimited and process
566 // sharing doesn't happen. We set the override so that the test can run
567 // everywhere.
568 size_t old_renderer_process_limit =
569 RenderProcessHost::GetMaxRendererProcessCount();
570 RenderProcessHost::SetMaxRendererProcessCount(kMaxRendererProcessCount);
571
565 ChildProcessSecurityPolicyImpl* policy = 572 ChildProcessSecurityPolicyImpl* policy =
566 ChildProcessSecurityPolicyImpl::GetInstance(); 573 ChildProcessSecurityPolicyImpl::GetInstance();
567 574
568 // Make a bunch of mock renderers so that we hit the limit. 575 // Make a bunch of mock renderers so that we hit the limit.
569 scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); 576 scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
570 ScopedVector<MockRenderProcessHost> hosts; 577 ScopedVector<MockRenderProcessHost> hosts;
571 for (size_t i = 0; i < kMaxRendererProcessCount; ++i) 578 for (size_t i = 0; i < kMaxRendererProcessCount; ++i)
572 hosts.push_back(new MockRenderProcessHost(browser_context.get())); 579 hosts.push_back(new MockRenderProcessHost(browser_context.get()));
573 580
574 // Create some extension instances and make sure they share a process. 581 // Create some extension instances and make sure they share a process.
(...skipping 25 matching lines...) Expand all
600 607
601 // Make sure none of differing privilege processes are mixed. 608 // Make sure none of differing privilege processes are mixed.
602 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess()); 609 EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess());
603 610
604 for (size_t i = 0; i < kMaxRendererProcessCount; ++i) { 611 for (size_t i = 0; i < kMaxRendererProcessCount; ++i) {
605 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); 612 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]);
606 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]); 613 EXPECT_NE(webui1_instance->GetProcess(), hosts[i]);
607 } 614 }
608 615
609 DrainMessageLoops(); 616 DrainMessageLoops();
617
618 // Disable the process limit override.
619 RenderProcessHost::SetMaxRendererProcessCount(0);
610 } 620 }
611 621
612 // Test to ensure that HasWrongProcessForURL behaves properly for different 622 // Test to ensure that HasWrongProcessForURL behaves properly for different
613 // types of URLs. 623 // types of URLs.
614 TEST_F(SiteInstanceTest, HasWrongProcessForURL) { 624 TEST_F(SiteInstanceTest, HasWrongProcessForURL) {
615 scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); 625 scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
616 scoped_ptr<RenderProcessHost> host; 626 scoped_ptr<RenderProcessHost> host;
617 scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>( 627 scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>(
618 SiteInstance::Create(browser_context.get()))); 628 SiteInstance::Create(browser_context.get())));
619 629
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 EXPECT_TRUE(instance->GetSiteURL().is_empty()); 767 EXPECT_TRUE(instance->GetSiteURL().is_empty());
758 host.reset(instance->GetProcess()); 768 host.reset(instance->GetProcess());
759 769
760 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( 770 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite(
761 browser_context.get(), GURL())); 771 browser_context.get(), GURL()));
762 772
763 DrainMessageLoops(); 773 DrainMessageLoops();
764 } 774 }
765 775
766 } // namespace content 776 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698