OLD | NEW |
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/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/string16.h" | 8 #include "base/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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 static_cast<SiteInstanceImpl*>( | 680 static_cast<SiteInstanceImpl*>( |
681 SiteInstance::Create(browser_context.get()))); | 681 SiteInstance::Create(browser_context.get()))); |
682 webui_instance2->SetSite(webui_url); | 682 webui_instance2->SetSite(webui_url); |
683 EXPECT_FALSE(webui_instance2->HasWrongProcessForURL(webui_url)); | 683 EXPECT_FALSE(webui_instance2->HasWrongProcessForURL(webui_url)); |
684 EXPECT_TRUE( | 684 EXPECT_TRUE( |
685 webui_instance2->HasWrongProcessForURL(GURL("http://google.com"))); | 685 webui_instance2->HasWrongProcessForURL(GURL("http://google.com"))); |
686 | 686 |
687 DrainMessageLoops(); | 687 DrainMessageLoops(); |
688 } | 688 } |
689 | 689 |
| 690 // Test to ensure that HasWrongProcessForURL behaves properly even when |
| 691 // --site-per-process is used (http://crbug.com/160671). |
| 692 TEST_F(SiteInstanceTest, HasWrongProcessForURLInSitePerProcess) { |
| 693 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 694 switches::kSitePerProcess); |
| 695 |
| 696 scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); |
| 697 scoped_ptr<RenderProcessHost> host; |
| 698 scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>( |
| 699 SiteInstance::Create(browser_context.get()))); |
| 700 |
| 701 instance->SetSite(GURL("http://evernote.com/")); |
| 702 EXPECT_TRUE(instance->HasSite()); |
| 703 |
| 704 // Check prior to "assigning" a process to the instance, which is expected |
| 705 // to return false due to not being attached to any process yet. |
| 706 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://google.com"))); |
| 707 |
| 708 // The call to GetProcess actually creates a new real process, which works |
| 709 // fine, but might be a cause for problems in different contexts. |
| 710 host.reset(instance->GetProcess()); |
| 711 EXPECT_TRUE(host.get() != NULL); |
| 712 EXPECT_TRUE(instance->HasProcess()); |
| 713 |
| 714 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); |
| 715 EXPECT_FALSE(instance->HasWrongProcessForURL( |
| 716 GURL("javascript:alert(document.location.href);"))); |
| 717 |
| 718 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); |
| 719 |
| 720 DrainMessageLoops(); |
| 721 } |
| 722 |
690 } // namespace content | 723 } // namespace content |
OLD | NEW |