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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 360 |
361 TEST(KURLTest, Valid_HTTP_FTP_URLsHaveHosts) { | 361 TEST(KURLTest, Valid_HTTP_FTP_URLsHaveHosts) { |
362 // Since the suborigin schemes are added at the content layer, its | 362 // Since the suborigin schemes are added at the content layer, its |
363 // necessary it explicitly add them as standard schemes for this test. If | 363 // necessary it explicitly add them as standard schemes for this test. If |
364 // this is needed in the future across mulitple KURLTests, then KURLTest | 364 // this is needed in the future across mulitple KURLTests, then KURLTest |
365 // should probably be converted to a test fixture with a proper SetUp() | 365 // should probably be converted to a test fixture with a proper SetUp() |
366 // method. | 366 // method. |
367 url::AddStandardScheme("http-so", url::SCHEME_WITH_PORT); | 367 url::AddStandardScheme("http-so", url::SCHEME_WITH_PORT); |
368 url::AddStandardScheme("https-so", url::SCHEME_WITH_PORT); | 368 url::AddStandardScheme("https-so", url::SCHEME_WITH_PORT); |
369 | 369 |
370 KURL kurl; | 370 KURL kurl(ParsedURLString, "foo://www.google.com/"); |
371 EXPECT_TRUE(kurl.setProtocol("http")); | 371 EXPECT_TRUE(kurl.setProtocol("http")); |
372 EXPECT_TRUE(kurl.protocolIs("http")); | 372 EXPECT_TRUE(kurl.protocolIs("http")); |
373 EXPECT_FALSE(kurl.isValid()); | 373 EXPECT_TRUE(kurl.protocolIsInHTTPFamily()); |
| 374 EXPECT_TRUE(kurl.isValid()); |
374 | 375 |
375 EXPECT_TRUE(kurl.setProtocol("http-so")); | 376 EXPECT_TRUE(kurl.setProtocol("http-so")); |
376 EXPECT_TRUE(kurl.protocolIs("http-so")); | 377 EXPECT_TRUE(kurl.protocolIs("http-so")); |
377 EXPECT_FALSE(kurl.isValid()); | 378 EXPECT_TRUE(kurl.isValid()); |
378 | 379 |
379 EXPECT_TRUE(kurl.setProtocol("https")); | 380 EXPECT_TRUE(kurl.setProtocol("https")); |
380 EXPECT_TRUE(kurl.protocolIs("https")); | 381 EXPECT_TRUE(kurl.protocolIs("https")); |
381 EXPECT_FALSE(kurl.isValid()); | 382 EXPECT_TRUE(kurl.isValid()); |
382 | 383 |
383 EXPECT_TRUE(kurl.setProtocol("https-so")); | 384 EXPECT_TRUE(kurl.setProtocol("https-so")); |
384 EXPECT_TRUE(kurl.protocolIs("https-so")); | 385 EXPECT_TRUE(kurl.protocolIs("https-so")); |
385 EXPECT_FALSE(kurl.isValid()); | 386 EXPECT_TRUE(kurl.isValid()); |
386 | 387 |
387 EXPECT_TRUE(kurl.setProtocol("ftp")); | 388 EXPECT_TRUE(kurl.setProtocol("ftp")); |
388 EXPECT_TRUE(kurl.protocolIs("ftp")); | 389 EXPECT_TRUE(kurl.protocolIs("ftp")); |
389 EXPECT_FALSE(kurl.isValid()); | 390 EXPECT_TRUE(kurl.isValid()); |
390 | 391 |
391 kurl = KURL(KURL(), "http://"); | 392 kurl = KURL(KURL(), "http://"); |
| 393 EXPECT_FALSE(kurl.protocolIs("http")); |
| 394 |
| 395 kurl = KURL(KURL(), "http://wide#ιΈ‘"); |
392 EXPECT_TRUE(kurl.protocolIs("http")); | 396 EXPECT_TRUE(kurl.protocolIs("http")); |
393 EXPECT_FALSE(kurl.isValid()); | 397 EXPECT_EQ(kurl.protocol(), "http"); |
394 | 398 |
395 kurl = KURL(KURL(), "http-so://"); | 399 kurl = KURL(KURL(), "http-so://foo"); |
396 EXPECT_TRUE(kurl.protocolIs("http-so")); | 400 EXPECT_TRUE(kurl.protocolIs("http-so")); |
397 EXPECT_FALSE(kurl.isValid()); | |
398 | 401 |
399 kurl = KURL(KURL(), "https://"); | 402 kurl = KURL(KURL(), "https://foo"); |
400 EXPECT_TRUE(kurl.protocolIs("https")); | 403 EXPECT_TRUE(kurl.protocolIs("https")); |
401 EXPECT_FALSE(kurl.isValid()); | |
402 | 404 |
403 kurl = KURL(KURL(), "https-so://"); | 405 kurl = KURL(KURL(), "https-so://foo"); |
404 EXPECT_TRUE(kurl.protocolIs("https-so")); | 406 EXPECT_TRUE(kurl.protocolIs("https-so")); |
405 EXPECT_FALSE(kurl.isValid()); | |
406 | 407 |
407 kurl = KURL(KURL(), "ftp://"); | 408 kurl = KURL(KURL(), "ftp://foo"); |
408 EXPECT_TRUE(kurl.protocolIs("ftp")); | 409 EXPECT_TRUE(kurl.protocolIs("ftp")); |
409 EXPECT_FALSE(kurl.isValid()); | |
410 | 410 |
411 kurl = KURL(KURL(), "http://host/"); | 411 kurl = KURL(KURL(), "http://host/"); |
412 EXPECT_TRUE(kurl.isValid()); | 412 EXPECT_TRUE(kurl.isValid()); |
413 kurl.setHost(""); | 413 kurl.setHost(""); |
414 EXPECT_FALSE(kurl.isValid()); | 414 EXPECT_FALSE(kurl.isValid()); |
415 | 415 |
416 kurl = KURL(KURL(), "http-so://host/"); | 416 kurl = KURL(KURL(), "http-so://host/"); |
417 EXPECT_TRUE(kurl.isValid()); | 417 EXPECT_TRUE(kurl.isValid()); |
418 kurl.setHost(""); | 418 kurl.setHost(""); |
419 EXPECT_FALSE(kurl.isValid()); | 419 EXPECT_FALSE(kurl.isValid()); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 KURL url1(ParsedURLString, "foo://bar"); | 692 KURL url1(ParsedURLString, "foo://bar"); |
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("")); | |
703 | 702 |
704 KURL capital(KURL(), "HTTP://www.example.text"); | 703 KURL capital(KURL(), "HTTP://www.example.text"); |
705 EXPECT_TRUE(capital.protocolIs("http")); | 704 EXPECT_TRUE(capital.protocolIs("http")); |
706 EXPECT_EQ(capital.protocol(), "http"); | 705 EXPECT_EQ(capital.protocol(), "http"); |
707 } | 706 } |
708 | 707 |
709 TEST(KURLTest, strippedForUseAsReferrer) { | 708 TEST(KURLTest, strippedForUseAsReferrer) { |
710 struct ReferrerCase { | 709 struct ReferrerCase { |
711 const char* input; | 710 const char* input; |
712 const char* output; | 711 const char* output; |
(...skipping 12 matching lines...) Expand all Loading... |
725 }; | 724 }; |
726 | 725 |
727 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) { | 726 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) { |
728 KURL kurl(ParsedURLString, referrerCases[i].input); | 727 KURL kurl(ParsedURLString, referrerCases[i].input); |
729 String referrer = kurl.strippedForUseAsReferrer(); | 728 String referrer = kurl.strippedForUseAsReferrer(); |
730 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); | 729 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); |
731 } | 730 } |
732 } | 731 } |
733 | 732 |
734 } // namespace blink | 733 } // namespace blink |
OLD | NEW |