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

Unified Diff: url/gurl_unittest.cc

Issue 1049533002: Add IsOriginSecure and GURL::SchemeUsesTLS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move it to content::, so we can call into net:: and blink::. Created 5 years, 9 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
« url/gurl.h ('K') | « url/gurl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/gurl_unittest.cc
diff --git a/url/gurl_unittest.cc b/url/gurl_unittest.cc
index bea1a0cd58a5af8b5c198af7a97b93ab2a4da25e..ea35c9b495c50906ba12e4cb4a5de2fa9c66894c 100644
--- a/url/gurl_unittest.cc
+++ b/url/gurl_unittest.cc
@@ -642,4 +642,28 @@ TEST(GURLTest, SchemeIsBlob) {
EXPECT_FALSE(GURL("http://bar/").SchemeIsBlob());
}
+TEST(GURLTest, TestSecureOrigins) {
+ EXPECT_TRUE(GURL("file:///test/fun.html").OriginIsSecure());
+ EXPECT_TRUE(GURL("file:///test/").OriginIsSecure());
+
+ EXPECT_TRUE(GURL("https://example.com/fun.html").OriginIsSecure());
+ EXPECT_FALSE(GURL("http://example.com/fun.html").OriginIsSecure());
+
+ EXPECT_TRUE(GURL("wss://example.com/fun.html").OriginIsSecure());
+ EXPECT_FALSE(GURL("ws://example.com/fun.html").OriginIsSecure());
+
+ EXPECT_TRUE(GURL("http://localhost/fun.html").OriginIsSecure());
+ EXPECT_FALSE(GURL("http://localhost.com/fun.html").OriginIsSecure());
+ EXPECT_TRUE(GURL("https://localhost.com/fun.html").OriginIsSecure());
+
+ EXPECT_TRUE(GURL("http://127.0.0.1/fun.html").OriginIsSecure());
+ EXPECT_TRUE(GURL("http://127.3.0.1/fun.html").OriginIsSecure());
+ EXPECT_FALSE(GURL("http://127.example.com/fun.html").OriginIsSecure());
+ EXPECT_TRUE(GURL("https://127.example.com/fun.html").OriginIsSecure());
+
+ EXPECT_TRUE(GURL("http://[::1]/fun.html").OriginIsSecure());
+ EXPECT_FALSE(GURL("http://[::2]/fun.html").OriginIsSecure());
+ EXPECT_FALSE(GURL("http://[::1].example.com/fun.html").OriginIsSecure());
+}
+
} // namespace url
« url/gurl.h ('K') | « url/gurl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698