Chromium Code Reviews| Index: third_party/WebKit/Source/platform/network/NetworkUtilsTest.cpp |
| diff --git a/third_party/WebKit/Source/platform/network/NetworkUtilsTest.cpp b/third_party/WebKit/Source/platform/network/NetworkUtilsTest.cpp |
| index d5d84f933f07435e82e55121be8774414da9dee9..d45d212fc3d6190435e08a5546e7b6fac5b9bc36 100644 |
| --- a/third_party/WebKit/Source/platform/network/NetworkUtilsTest.cpp |
| +++ b/third_party/WebKit/Source/platform/network/NetworkUtilsTest.cpp |
| @@ -61,4 +61,29 @@ TEST(NetworkUtilsTest, IsReservedIPAddress) |
| } |
| } |
| +TEST(NetworkUtilsTest, GetDomainAndRegistry) |
| +{ |
| + EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("", true)); |
| + EXPECT_EQ("", NetworkUtils::getDomainAndRegistry(".", true)); |
| + EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("..", true)); |
| + EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("com", true)); |
| + EXPECT_EQ("", NetworkUtils::getDomainAndRegistry(".com", true)); |
| + EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("www.example.com:8000", true)); |
| + |
| + EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("localhost", true)); |
| + EXPECT_EQ("", NetworkUtils::getDomainAndRegistry("127.0.0.1", true)); |
| + |
| + EXPECT_EQ("example.com", NetworkUtils::getDomainAndRegistry("example.com", true)); |
| + EXPECT_EQ("example.com", NetworkUtils::getDomainAndRegistry("www.example.com", true)); |
| + EXPECT_EQ("example.com", NetworkUtils::getDomainAndRegistry("multilevel.www.example.com", true)); |
| + EXPECT_EQ("example.co.uk", NetworkUtils::getDomainAndRegistry("www.example.co.uk", true)); |
| + |
| + // Verify proper handling of 'private registries'. |
| + EXPECT_EQ("foo.appspot.com", NetworkUtils::getDomainAndRegistry("www.foo.appspot.com", true)); |
| + EXPECT_EQ("appspot.com", NetworkUtils::getDomainAndRegistry("www.foo.appspot.com", false)); |
|
shivanisha
2016/08/01 16:35:55
Can we also include the example mentioned in the c
Bryan McQuade
2016/08/01 18:43:51
Ah, replied to the overall change rather than the
|
| + |
| + // Verify that unknown registries are included. |
| + EXPECT_EQ("example.notarealregistry", NetworkUtils::getDomainAndRegistry("www.example.notarealregistry", true)); |
| +} |
| + |
| } // namespace blink |