Chromium Code Reviews| Index: content/browser/site_instance_unittest.cc |
| diff --git a/content/browser/site_instance_unittest.cc b/content/browser/site_instance_unittest.cc |
| index dcfcd3efbfb01f380891f7330c078f75f2a3c91c..a30a97548a0f2087f2c382cbcfd1f82f9336fb09 100644 |
| --- a/content/browser/site_instance_unittest.cc |
| +++ b/content/browser/site_instance_unittest.cc |
| @@ -151,6 +151,12 @@ class TestSiteInstance : public SiteInstance { |
| return new TestSiteInstance(browsing_instance, siteDeleteCounter); |
| } |
| + bool HasProcess() const OVERRIDE { |
| + return hasProcess; |
| + } |
| + |
| + bool hasProcess; |
|
awong
2012/01/12 22:56:41
incorrect naming convention. :(
http://google-sty
nasko
2012/01/13 01:34:50
Moved to a different test that doesn't require mod
|
| + |
| private: |
| TestSiteInstance(BrowsingInstance* browsing_instance, int* deleteCounter) |
| : SiteInstance(browsing_instance), deleteCounter_(deleteCounter) {} |
| @@ -546,3 +552,31 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) { |
| STLDeleteContainerPointers(hosts.begin(), hosts.end()); |
| } |
| + |
| +// Test to ensure that javascript URLs always run in the same process. |
| +TEST_F(SiteInstanceTest, HasWrongProcessForURL) { |
| + |
| + int siteDeleteCounter = 0; |
| + int browsingDeleteCounter = 0; |
| + const GURL url_javascript = GURL("javascript:alert(document.location.href);"); |
| + const GURL goog = GURL("http://google.com"); |
| + |
| + TestSiteInstance* instance = TestSiteInstance::CreateTestSiteInstance( |
|
awong
2012/01/12 22:56:41
Line indent on wrapping should be 4 spaces.
http:
nasko
2012/01/13 01:34:50
Done.
|
| + NULL, &siteDeleteCounter, |
| + &browsingDeleteCounter); |
| + |
| + EXPECT_FALSE(instance->has_site()); |
| + EXPECT_TRUE(instance->site().is_empty()); |
| + |
| + instance->SetSite(GURL("http://www.evernote.com/")); |
| + EXPECT_TRUE(instance->has_site()); |
| + |
| + // Check prior to "assigning" a process to the instance, which is expected |
| + // to return false due to not being attached to any process yet. |
| + EXPECT_FALSE(instance->HasWrongProcessForURL(goog)); |
| + |
| + instance->hasProcess = true; |
| + EXPECT_TRUE(instance->HasProcess()); |
| + |
| + EXPECT_FALSE(instance->HasWrongProcessForURL(url_javascript)); |
| +} |