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/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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
365 | 365 |
366 // Test of distinguishing URLs from different sites. Most of this logic is | 366 // Test of distinguishing URLs from different sites. Most of this logic is |
367 // tested in RegistryControlledDomainTest. This test focuses on URLs with | 367 // tested in RegistryControlledDomainTest. This test focuses on URLs with |
368 // different schemes or ports. | 368 // different schemes or ports. |
369 TEST_F(SiteInstanceTest, IsSameWebSite) { | 369 TEST_F(SiteInstanceTest, IsSameWebSite) { |
370 GURL url_foo = GURL("http://foo/a.html"); | 370 GURL url_foo = GURL("http://foo/a.html"); |
371 GURL url_foo2 = GURL("http://foo/b.html"); | 371 GURL url_foo2 = GURL("http://foo/b.html"); |
372 GURL url_foo_https = GURL("https://foo/a.html"); | 372 GURL url_foo_https = GURL("https://foo/a.html"); |
373 GURL url_foo_port = GURL("http://foo:8080/a.html"); | 373 GURL url_foo_port = GURL("http://foo:8080/a.html"); |
374 GURL url_javascript = GURL("javascript:alert(1);"); | 374 GURL url_javascript = GURL("javascript:alert(1);"); |
375 GURL url_blank = GURL(url::kAboutBlankURL); | |
375 | 376 |
376 // Same scheme and port -> same site. | 377 // Same scheme and port -> same site. |
377 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo2)); | 378 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo2)); |
378 | 379 |
379 // Different scheme -> different site. | 380 // Different scheme -> different site. |
380 EXPECT_FALSE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo_https)); | 381 EXPECT_FALSE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo_https)); |
381 | 382 |
382 // Different port -> same site. | 383 // Different port -> same site. |
383 // (Changes to document.domain make renderer ignore the port.) | 384 // (Changes to document.domain make renderer ignore the port.) |
384 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo_port)); | 385 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_foo, url_foo_port)); |
385 | 386 |
386 // JavaScript links should be considered same site for anything. | 387 // JavaScript links should be considered same site for anything. |
387 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo)); | 388 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo)); |
388 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo_https)); | 389 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo_https)); |
389 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo_port)); | 390 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_javascript, url_foo_port)); |
390 | 391 |
392 // Blank pages should be considered same site for anything. | |
Charlie Reis
2014/07/25 17:31:22
Great. Let's update this to show that it's for bl
shatch
2014/07/25 20:57:06
Done.
| |
393 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_blank, url_foo)); | |
394 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_blank, url_foo_https)); | |
395 EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_blank, url_foo_port)); | |
396 | |
391 DrainMessageLoops(); | 397 DrainMessageLoops(); |
392 } | 398 } |
393 | 399 |
394 // Test to ensure that there is only one SiteInstance per site in a given | 400 // Test to ensure that there is only one SiteInstance per site in a given |
395 // BrowsingInstance, when process-per-site is not in use. | 401 // BrowsingInstance, when process-per-site is not in use. |
396 TEST_F(SiteInstanceTest, OneSiteInstancePerSite) { | 402 TEST_F(SiteInstanceTest, OneSiteInstancePerSite) { |
397 ASSERT_FALSE(CommandLine::ForCurrentProcess()->HasSwitch( | 403 ASSERT_FALSE(CommandLine::ForCurrentProcess()->HasSwitch( |
398 switches::kProcessPerSite)); | 404 switches::kProcessPerSite)); |
399 int delete_counter = 0; | 405 int delete_counter = 0; |
400 scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); | 406 scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 EXPECT_TRUE(instance->GetSiteURL().is_empty()); | 763 EXPECT_TRUE(instance->GetSiteURL().is_empty()); |
758 host.reset(instance->GetProcess()); | 764 host.reset(instance->GetProcess()); |
759 | 765 |
760 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( | 766 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( |
761 browser_context.get(), GURL())); | 767 browser_context.get(), GURL())); |
762 | 768 |
763 DrainMessageLoops(); | 769 DrainMessageLoops(); |
764 } | 770 } |
765 | 771 |
766 } // namespace content | 772 } // namespace content |
OLD | NEW |