| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |