Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Unified Diff: content/browser/site_instance_impl_unittest.cc

Issue 1911573002: Teach SiteInstance::GetSiteForURL() about blob and filesystem URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Attempt simple fix for NTP failures Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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");
Charlie Reis 2016/04/22 18:11:09 This needs a comment. :)
+ 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());
+
+ // 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/"
Charlie Reis 2016/04/22 18:11:09 Good case. Or you could use co.uk.
+ "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);
+
// 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);

Powered by Google App Engine
This is Rietveld 408576698