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

Unified Diff: content/common/origin_util_unittest.cc

Issue 2005783005: Re-enable storage for Suborigins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Compile fix Created 4 years, 3 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/common/origin_util_unittest.cc
diff --git a/content/common/origin_util_unittest.cc b/content/common/origin_util_unittest.cc
index 3c2328bff9928f5f5812f8169c354a2424e89401..ed6c01ffc803030d442b0701f7427f35d40e41a1 100644
--- a/content/common/origin_util_unittest.cc
+++ b/content/common/origin_util_unittest.cc
@@ -47,4 +47,39 @@ TEST(URLSchemesTest, IsOriginSecure) {
IsOriginSecure(GURL("filesystem:https://www.example.com/temporary/")));
}
+TEST(OriginUtilTest, Suborigins) {
+ GURL no_suborigin_simple_url("https://b");
+ GURL suborigin_simple_url("https-so://a.b");
+ GURL no_suborigin_bigger_url("https://example.com/some/path");
+ GURL suborigin_bigger_url("https-so://foobar.example.com/some/path");
nasko 2016/09/29 16:49:56 Why not throw in all the parts of an URL to ensure
jww 2016/09/29 22:21:00 Done.
+
+ EXPECT_FALSE(HasSuborigin(no_suborigin_simple_url));
+ EXPECT_FALSE(HasSuborigin(no_suborigin_bigger_url));
+ EXPECT_TRUE(HasSuborigin(suborigin_simple_url));
+ EXPECT_TRUE(HasSuborigin(suborigin_bigger_url));
+
+ EXPECT_EQ("", SuboriginFromUrl(no_suborigin_simple_url));
+ EXPECT_EQ("", SuboriginFromUrl(no_suborigin_bigger_url));
+ EXPECT_EQ("a", SuboriginFromUrl(suborigin_simple_url));
+ EXPECT_EQ("foobar", SuboriginFromUrl(suborigin_bigger_url));
+
+ EXPECT_EQ(no_suborigin_simple_url,
+ StripSuboriginFromUrl(no_suborigin_simple_url));
+ EXPECT_EQ(no_suborigin_bigger_url,
+ StripSuboriginFromUrl(no_suborigin_bigger_url));
+ EXPECT_EQ(no_suborigin_simple_url,
+ StripSuboriginFromUrl(suborigin_simple_url));
+ EXPECT_EQ(no_suborigin_bigger_url,
+ StripSuboriginFromUrl(suborigin_bigger_url));
+
+ GURL just_dot_url("https-so://.");
+ GURL empty_hostname_url("https-so://");
+ GURL empty_suborigin_url("https-so://.foo");
+ GURL suborigin_but_empty_host_url("https-so://foo.");
nasko 2016/09/29 16:49:56 What about testing StripSuboriginFromUrl and Subor
jww 2016/09/29 22:21:00 Done.
+ EXPECT_FALSE(HasSuborigin(just_dot_url));
+ EXPECT_FALSE(HasSuborigin(empty_hostname_url));
+ EXPECT_FALSE(HasSuborigin(empty_suborigin_url));
+ EXPECT_FALSE(HasSuborigin(suborigin_but_empty_host_url));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698