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

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 canonicalizeHost() as static method on SecurityOrigin and call from Document::setDomain 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
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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 RefPtr<SecurityOrigin> tupleOrigin = 465 RefPtr<SecurityOrigin> tupleOrigin =
466 SecurityOrigin::createFromString("http://example.com"); 466 SecurityOrigin::createFromString("http://example.com");
467 467
468 EXPECT_TRUE(uniqueOrigin->isSameSchemeHostPort(uniqueOrigin.get())); 468 EXPECT_TRUE(uniqueOrigin->isSameSchemeHostPort(uniqueOrigin.get()));
469 EXPECT_FALSE( 469 EXPECT_FALSE(
470 SecurityOrigin::createUnique()->isSameSchemeHostPort(uniqueOrigin.get())); 470 SecurityOrigin::createUnique()->isSameSchemeHostPort(uniqueOrigin.get()));
471 EXPECT_FALSE(tupleOrigin->isSameSchemeHostPort(uniqueOrigin.get())); 471 EXPECT_FALSE(tupleOrigin->isSameSchemeHostPort(uniqueOrigin.get()));
472 EXPECT_FALSE(uniqueOrigin->isSameSchemeHostPort(tupleOrigin.get())); 472 EXPECT_FALSE(uniqueOrigin->isSameSchemeHostPort(tupleOrigin.get()));
473 } 473 }
474 474
475 TEST_F(SecurityOriginTest, CanonicalizeHost) {
476 struct TestCase {
477 const char* host;
478 const char* canonicalOutput;
479 bool expectedSuccess;
480 } cases[] = {
481 {"", "", true},
482 {"example.test", "example.test", true},
483 {"EXAMPLE.TEST", "example.test", true},
484 {"eXaMpLe.TeSt/path", "example.test%2Fpath", false},
485 {",", "%2C", true},
486 {"💩", "xn--ls8h", true},
487 {"[]", "[]", false},
488 {"%yo", "%25yo", false},
489 };
490
491 for (const TestCase& test : cases) {
492 SCOPED_TRACE(testing::Message() << "raw host: '" << test.host << "'");
493 String host = String::fromUTF8(test.host);
494 bool success = false;
495 String canonicalHost = SecurityOrigin::canonicalizeHost(host, &success);
496 EXPECT_EQ(test.canonicalOutput, canonicalHost);
497 EXPECT_EQ(test.expectedSuccess, success);
498 }
499 }
500
475 } // namespace blink 501 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698