 Chromium Code Reviews
 Chromium Code Reviews Issue 1911573002:
  Teach SiteInstance::GetSiteForURL() about blob and filesystem URLs.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1911573002:
  Teach SiteInstance::GetSiteForURL() about blob and filesystem URLs.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: content/browser/site_instance_impl_unittest.cc | 
| diff --git a/content/browser/site_instance_impl_unittest.cc b/content/browser/site_instance_impl_unittest.cc | 
| index 9a52e3b97dcfeee102c3707646c172047f309882..da719353a17d24197bad213d319cd8f0d3a37055 100644 | 
| --- a/content/browser/site_instance_impl_unittest.cc | 
| +++ b/content/browser/site_instance_impl_unittest.cc | 
| @@ -289,12 +289,38 @@ TEST_F(SiteInstanceTest, GetSiteForURL) { | 
| EXPECT_EQ("http", site_url.scheme()); | 
| EXPECT_EQ("google.com", site_url.host()); | 
| - // Ports are irrlevant. | 
| + // Ports are irrelevant. | 
| test_url = GURL("https://www.google.com:8080"); | 
| site_url = SiteInstanceImpl::GetSiteForURL(nullptr, test_url); | 
| EXPECT_EQ(GURL("https://google.com"), site_url); | 
| - // Hostnames without TLDs are ok. | 
| + // Punycode is canonicalized. | 
| + test_url = GURL("http://☃snowperson☃.net:333/"); | 
| + site_url = SiteInstanceImpl::GetSiteForURL(nullptr, test_url); | 
| + EXPECT_EQ(GURL("http://xn--snowperson-di0gka.net"), site_url); | 
| + | 
| + // Username and password are stripped out. | 
| + test_url = GURL("ftp://username:password@ftp.chromium.org/files/README"); | 
| + site_url = SiteInstanceImpl::GetSiteForURL(nullptr, test_url); | 
| + EXPECT_EQ(GURL("ftp://chromium.org"), site_url); | 
| + | 
| + // Literal IP addresses of any flavor are okay. | 
| + test_url = GURL("http://127.0.0.1/a.html"); | 
| + site_url = SiteInstanceImpl::GetSiteForURL(nullptr, test_url); | 
| + EXPECT_EQ(GURL("http://127.0.0.1"), site_url); | 
| + EXPECT_EQ("127.0.0.1", site_url.host()); | 
| + | 
| + test_url = GURL("http://2130706433/a.html"); | 
| + site_url = SiteInstanceImpl::GetSiteForURL(nullptr, test_url); | 
| + EXPECT_EQ(GURL("http://127.0.0.1"), site_url); | 
| + EXPECT_EQ("127.0.0.1", site_url.host()); | 
| + | 
| + test_url = GURL("http://[::1]:2/page.html"); | 
| + site_url = SiteInstanceImpl::GetSiteForURL(nullptr, test_url); | 
| + EXPECT_EQ(GURL("http://[::1]"), site_url); | 
| + EXPECT_EQ("[::1]", site_url.host()); | 
| 
ncarter (slow)
2016/04/20 23:06:00
These are added just for good measure, and pass be
 | 
| + | 
| + // Hostnames without TLDs are okay. | 
| test_url = GURL("http://foo/a.html"); | 
| site_url = SiteInstanceImpl::GetSiteForURL(nullptr, test_url); | 
| EXPECT_EQ(GURL("http://foo"), site_url); | 
| @@ -327,6 +353,25 @@ TEST_F(SiteInstanceTest, GetSiteForURL) { | 
| EXPECT_EQ("javascript", site_url.scheme()); | 
| EXPECT_FALSE(site_url.has_host()); | 
| + // Blob URLs extract the site from the origin. | 
| + test_url = GURL( | 
| + "blob:gopher://www.ftp.chromium.org/" | 
| + "4d4ff040-6d61-4446-86d3-13ca07ec9ab9"); | 
| + site_url = SiteInstanceImpl::GetSiteForURL(nullptr, test_url); | 
| + EXPECT_EQ(GURL("gopher://chromium.org"), site_url); | 
| + | 
| + // Private domains are preserved, appspot being such a site. | 
| + test_url = GURL( | 
| + "blob:http://www.example.appspot.com:44/" | 
| + "4d4ff040-6d61-4446-86d3-13ca07ec9ab9"); | 
| + site_url = SiteInstanceImpl::GetSiteForURL(nullptr, test_url); | 
| + EXPECT_EQ(GURL("http://example.appspot.com"), site_url); | 
| + | 
| + // The site of filesystem URLs is determined by the inner URL. | 
| + test_url = GURL("filesystem:http://www.google.com/foo/bar.html?foo#bar"); | 
| + site_url = SiteInstanceImpl::GetSiteForURL(nullptr, test_url); | 
| + EXPECT_EQ(GURL("http://google.com"), site_url); | 
| 
ncarter (slow)
2016/04/20 23:06:00
These 3 tests would have failed prior to this chan
 | 
| + | 
| // Guest URLs are special and need to have the path in the site as well, | 
| // since it affects the StoragePartition configuration. | 
| std::string guest_url(kGuestScheme); |