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

Unified Diff: third_party/WebKit/Source/platform/weborigin/SecurityOriginTest.cpp

Issue 2447293002: Don't call lower() on KURL protocol/host (Closed)
Patch Set: add canonicalization layout test Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/SecurityOrigin.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/SecurityOrigin.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698