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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 EXPECT_NE(host1.get(), host2.get()); | 342 EXPECT_NE(host1.get(), host2.get()); |
343 | 343 |
344 DrainMessageLoops(); | 344 DrainMessageLoops(); |
345 } | 345 } |
346 | 346 |
347 // Test to ensure SetSite and site() work properly. | 347 // Test to ensure SetSite and site() work properly. |
348 TEST_F(SiteInstanceTest, SetSite) { | 348 TEST_F(SiteInstanceTest, SetSite) { |
349 scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>( | 349 scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>( |
350 SiteInstance::Create(NULL))); | 350 SiteInstance::Create(NULL))); |
351 EXPECT_FALSE(instance->HasSite()); | 351 EXPECT_FALSE(instance->HasSite()); |
352 EXPECT_TRUE(instance->GetSite().is_empty()); | 352 EXPECT_TRUE(instance->GetSiteURL().is_empty()); |
353 | 353 |
354 instance->SetSite(GURL("http://www.google.com/index.html")); | 354 instance->SetSite(GURL("http://www.google.com/index.html")); |
355 EXPECT_EQ(GURL("http://google.com"), instance->GetSite()); | 355 EXPECT_EQ(GURL("http://google.com"), instance->GetSiteURL()); |
356 | 356 |
357 EXPECT_TRUE(instance->HasSite()); | 357 EXPECT_TRUE(instance->HasSite()); |
358 | 358 |
359 DrainMessageLoops(); | 359 DrainMessageLoops(); |
360 } | 360 } |
361 | 361 |
362 // Test to ensure GetSiteForURL properly returns sites for URLs. | 362 // Test to ensure GetSiteForURL properly returns sites for URLs. |
363 TEST_F(SiteInstanceTest, GetSiteForURL) { | 363 TEST_F(SiteInstanceTest, GetSiteForURL) { |
364 // Pages are irrelevant. | 364 // Pages are irrelevant. |
365 GURL test_url = GURL("http://www.google.com/index.html"); | 365 GURL test_url = GURL("http://www.google.com/index.html"); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 // Test to ensure that HasWrongProcessForURL behaves properly for different | 655 // Test to ensure that HasWrongProcessForURL behaves properly for different |
656 // types of URLs. | 656 // types of URLs. |
657 TEST_F(SiteInstanceTest, HasWrongProcessForURL) { | 657 TEST_F(SiteInstanceTest, HasWrongProcessForURL) { |
658 scoped_ptr<content::TestBrowserContext> browser_context( | 658 scoped_ptr<content::TestBrowserContext> browser_context( |
659 new content::TestBrowserContext()); | 659 new content::TestBrowserContext()); |
660 scoped_ptr<content::RenderProcessHost> host; | 660 scoped_ptr<content::RenderProcessHost> host; |
661 scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>( | 661 scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>( |
662 SiteInstance::Create(browser_context.get()))); | 662 SiteInstance::Create(browser_context.get()))); |
663 | 663 |
664 EXPECT_FALSE(instance->HasSite()); | 664 EXPECT_FALSE(instance->HasSite()); |
665 EXPECT_TRUE(instance->GetSite().is_empty()); | 665 EXPECT_TRUE(instance->GetSiteURL().is_empty()); |
666 | 666 |
667 instance->SetSite(GURL("http://evernote.com/")); | 667 instance->SetSite(GURL("http://evernote.com/")); |
668 EXPECT_TRUE(instance->HasSite()); | 668 EXPECT_TRUE(instance->HasSite()); |
669 | 669 |
670 // Check prior to "assigning" a process to the instance, which is expected | 670 // Check prior to "assigning" a process to the instance, which is expected |
671 // to return false due to not being attached to any process yet. | 671 // to return false due to not being attached to any process yet. |
672 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://google.com"))); | 672 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://google.com"))); |
673 | 673 |
674 // The call to GetProcess actually creates a new real process, which works | 674 // The call to GetProcess actually creates a new real process, which works |
675 // fine, but might be a cause for problems in different contexts. | 675 // fine, but might be a cause for problems in different contexts. |
676 host.reset(instance->GetProcess()); | 676 host.reset(instance->GetProcess()); |
677 EXPECT_TRUE(host.get() != NULL); | 677 EXPECT_TRUE(host.get() != NULL); |
678 EXPECT_TRUE(instance->HasProcess()); | 678 EXPECT_TRUE(instance->HasProcess()); |
679 | 679 |
680 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); | 680 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); |
681 EXPECT_FALSE(instance->HasWrongProcessForURL( | 681 EXPECT_FALSE(instance->HasWrongProcessForURL( |
682 GURL("javascript:alert(document.location.href);"))); | 682 GURL("javascript:alert(document.location.href);"))); |
683 | 683 |
684 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); | 684 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); |
685 | 685 |
686 DrainMessageLoops(); | 686 DrainMessageLoops(); |
687 } | 687 } |
OLD | NEW |