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

Side by Side 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, 1 month 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/SecurityOrigin.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 RefPtr<SecurityOrigin> tupleOrigin = 495 RefPtr<SecurityOrigin> tupleOrigin =
496 SecurityOrigin::createFromString("http://example.com"); 496 SecurityOrigin::createFromString("http://example.com");
497 497
498 EXPECT_TRUE(uniqueOrigin->isSameSchemeHostPort(uniqueOrigin.get())); 498 EXPECT_TRUE(uniqueOrigin->isSameSchemeHostPort(uniqueOrigin.get()));
499 EXPECT_FALSE( 499 EXPECT_FALSE(
500 SecurityOrigin::createUnique()->isSameSchemeHostPort(uniqueOrigin.get())); 500 SecurityOrigin::createUnique()->isSameSchemeHostPort(uniqueOrigin.get()));
501 EXPECT_FALSE(tupleOrigin->isSameSchemeHostPort(uniqueOrigin.get())); 501 EXPECT_FALSE(tupleOrigin->isSameSchemeHostPort(uniqueOrigin.get()));
502 EXPECT_FALSE(uniqueOrigin->isSameSchemeHostPort(tupleOrigin.get())); 502 EXPECT_FALSE(uniqueOrigin->isSameSchemeHostPort(tupleOrigin.get()));
503 } 503 }
504 504
505 TEST_F(SecurityOriginTest, CanonicalizeHost) {
506 struct TestCase {
507 const char* host;
508 const char* canonicalOutput;
509 bool expectedSuccess;
510 } cases[] = {
511 {"", "", true},
512 {"example.test", "example.test", true},
513 {"EXAMPLE.TEST", "example.test", true},
514 {"eXaMpLe.TeSt/path", "example.test%2Fpath", false},
515 {",", "%2C", true},
516 {"💩", "xn--ls8h", true},
517 {"[]", "[]", false},
518 {"%yo", "%25yo", false},
519 };
520
521 for (const TestCase& test : cases) {
522 SCOPED_TRACE(testing::Message() << "raw host: '" << test.host << "'");
523 String host = String::fromUTF8(test.host);
524 bool success = false;
525 String canonicalHost = SecurityOrigin::canonicalizeHost(host, &success);
526 EXPECT_EQ(test.canonicalOutput, canonicalHost);
527 EXPECT_EQ(test.expectedSuccess, success);
528 }
529 }
530
505 } // namespace blink 531 } // namespace blink
OLDNEW
« 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