| Index: third_party/WebKit/Source/platform/weborigin/SecurityOriginTest.cpp
|
| diff --git a/third_party/WebKit/Source/platform/weborigin/SecurityOriginTest.cpp b/third_party/WebKit/Source/platform/weborigin/SecurityOriginTest.cpp
|
| index 7c6af427bca9dd666c2f12624f01c52f51cdcee0..a61f7f2ddf3036c2352204945301d34f3adef601 100644
|
| --- a/third_party/WebKit/Source/platform/weborigin/SecurityOriginTest.cpp
|
| +++ b/third_party/WebKit/Source/platform/weborigin/SecurityOriginTest.cpp
|
| @@ -502,4 +502,30 @@ TEST_F(SecurityOriginTest, UniqueOriginIsSameSchemeHostPort) {
|
| EXPECT_FALSE(uniqueOrigin->isSameSchemeHostPort(tupleOrigin.get()));
|
| }
|
|
|
| +TEST_F(SecurityOriginTest, CanonicalizeHost) {
|
| + struct TestCase {
|
| + const char* host;
|
| + const char* canonicalOutput;
|
| + bool expectedSuccess;
|
| + } cases[] = {
|
| + {"", "", true},
|
| + {"example.test", "example.test", true},
|
| + {"EXAMPLE.TEST", "example.test", true},
|
| + {"eXaMpLe.TeSt/path", "example.test%2Fpath", false},
|
| + {",", "%2C", true},
|
| + {"💩", "xn--ls8h", true},
|
| + {"[]", "[]", false},
|
| + {"%yo", "%25yo", false},
|
| + };
|
| +
|
| + for (const TestCase& test : cases) {
|
| + SCOPED_TRACE(testing::Message() << "raw host: '" << test.host << "'");
|
| + String host = String::fromUTF8(test.host);
|
| + bool success = false;
|
| + String canonicalHost = SecurityOrigin::canonicalizeHost(host, &success);
|
| + EXPECT_EQ(test.canonicalOutput, canonicalHost);
|
| + EXPECT_EQ(test.expectedSuccess, success);
|
| + }
|
| +}
|
| +
|
| } // namespace blink
|
|
|