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

Unified Diff: net/base/net_util_unittest.cc

Issue 938093003: Always treat .localhost as loopback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move constants, add a test case, style fix 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
Index: net/base/net_util_unittest.cc
diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc
index fa2a60b3714c6ed6c54faacb30d94ce838cc8637..cada1a9a8fb2feac0ed7fb903e8a9c3fe29cb01d 100644
--- a/net/base/net_util_unittest.cc
+++ b/net/base/net_util_unittest.cc
@@ -803,6 +803,7 @@ TEST(NetUtilTest, IsLocalhost) {
EXPECT_TRUE(net::IsLocalhost("127.255.0.0"));
EXPECT_TRUE(net::IsLocalhost("::1"));
EXPECT_TRUE(net::IsLocalhost("0:0:0:0:0:0:0:1"));
+ EXPECT_TRUE(net::IsLocalhost("foo.localhost"));
EXPECT_FALSE(net::IsLocalhost("localhostx"));
EXPECT_FALSE(net::IsLocalhost("foo.localdomain"));
@@ -816,6 +817,16 @@ TEST(NetUtilTest, IsLocalhost) {
EXPECT_FALSE(net::IsLocalhost("0:0:0:0:1:0:0:1"));
EXPECT_FALSE(net::IsLocalhost("::1:1"));
EXPECT_FALSE(net::IsLocalhost("0:0:0:0:0:0:0:0:1"));
+ EXPECT_FALSE(net::IsLocalhost("foo.localhost.com"));
+ EXPECT_FALSE(net::IsLocalhost("foo.localhoste"));
+}
+
+TEST(NetUtilTest, IsLocalhostTLD) {
+ EXPECT_TRUE(net::IsLocalhostTLD("foo.localhost"));
+ EXPECT_TRUE(net::IsLocalhostTLD("foo.localhost."));
+ EXPECT_FALSE(net::IsLocalhostTLD("foo.localhos"));
+ EXPECT_FALSE(net::IsLocalhostTLD("foo.localhost.com"));
+ EXPECT_FALSE(net::IsLocalhost("foo.localhoste"));
}
// Verify GetNetworkList().
« net/base/net_util.cc ('K') | « net/base/net_util.cc ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698