| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 EXPECT_TRUE(url1.protocolIs("foo")); | 693 EXPECT_TRUE(url1.protocolIs("foo")); |
| 694 EXPECT_FALSE(url1.protocolIs("foo-bar")); | 694 EXPECT_FALSE(url1.protocolIs("foo-bar")); |
| 695 | 695 |
| 696 KURL url2(ParsedURLString, "foo-bar:"); | 696 KURL url2(ParsedURLString, "foo-bar:"); |
| 697 EXPECT_TRUE(url2.protocolIs("foo-bar")); | 697 EXPECT_TRUE(url2.protocolIs("foo-bar")); |
| 698 EXPECT_FALSE(url2.protocolIs("foo")); | 698 EXPECT_FALSE(url2.protocolIs("foo")); |
| 699 | 699 |
| 700 KURL invalidUTF8(ParsedURLString, "http://a@9%aa%:"); | 700 KURL invalidUTF8(ParsedURLString, "http://a@9%aa%:"); |
| 701 EXPECT_FALSE(invalidUTF8.protocolIs("http")); | 701 EXPECT_FALSE(invalidUTF8.protocolIs("http")); |
| 702 EXPECT_TRUE(invalidUTF8.protocolIs("")); | 702 EXPECT_TRUE(invalidUTF8.protocolIs("")); |
| 703 |
| 704 KURL capital(KURL(), "HTTP://www.example.text"); |
| 705 EXPECT_TRUE(capital.protocolIs("http")); |
| 706 EXPECT_EQ(capital.protocol(), "http"); |
| 703 } | 707 } |
| 704 | 708 |
| 705 TEST(KURLTest, strippedForUseAsReferrer) { | 709 TEST(KURLTest, strippedForUseAsReferrer) { |
| 706 struct ReferrerCase { | 710 struct ReferrerCase { |
| 707 const char* input; | 711 const char* input; |
| 708 const char* output; | 712 const char* output; |
| 709 } referrerCases[] = { | 713 } referrerCases[] = { |
| 710 {"data:text/html;charset=utf-8,<html></html>", ""}, | 714 {"data:text/html;charset=utf-8,<html></html>", ""}, |
| 711 {"javascript:void(0);", ""}, | 715 {"javascript:void(0);", ""}, |
| 712 {"about:config", ""}, | 716 {"about:config", ""}, |
| 713 {"https://www.google.com/", "https://www.google.com/"}, | 717 {"https://www.google.com/", "https://www.google.com/"}, |
| 714 {"http://me@news.google.com:8888/", "http://news.google.com:8888/"}, | 718 {"http://me@news.google.com:8888/", "http://news.google.com:8888/"}, |
| 715 {"http://:pass@news.google.com:8888/foo", | 719 {"http://:pass@news.google.com:8888/foo", |
| 716 "http://news.google.com:8888/foo"}, | 720 "http://news.google.com:8888/foo"}, |
| 717 {"http://me:pass@news.google.com:8888/", "http://news.google.com:8888/"}, | 721 {"http://me:pass@news.google.com:8888/", "http://news.google.com:8888/"}, |
| 718 {"https://www.google.com/a?f#b", "https://www.google.com/a?f"}, | 722 {"https://www.google.com/a?f#b", "https://www.google.com/a?f"}, |
| 719 {"file:///tmp/test.html", ""}, | 723 {"file:///tmp/test.html", ""}, |
| 720 {"https://www.google.com/#", "https://www.google.com/"}, | 724 {"https://www.google.com/#", "https://www.google.com/"}, |
| 721 }; | 725 }; |
| 722 | 726 |
| 723 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) { | 727 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) { |
| 724 KURL kurl(ParsedURLString, referrerCases[i].input); | 728 KURL kurl(ParsedURLString, referrerCases[i].input); |
| 725 String referrer = kurl.strippedForUseAsReferrer(); | 729 String referrer = kurl.strippedForUseAsReferrer(); |
| 726 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); | 730 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); |
| 727 } | 731 } |
| 728 } | 732 } |
| 729 | 733 |
| 730 } // namespace blink | 734 } // namespace blink |
| OLD | NEW |