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

Side by Side Diff: third_party/WebKit/Source/platform/weborigin/KURLTest.cpp

Issue 2586253004: Revert of Optimize KURL protocols (Closed)
Patch Set: Created 4 years 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) 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
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(ParsedURLString, "foo://www.google.com/"); 370 KURL kurl;
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_TRUE(kurl.protocolIsInHTTPFamily()); 373 EXPECT_FALSE(kurl.isValid());
374 EXPECT_TRUE(kurl.isValid());
375 374
376 EXPECT_TRUE(kurl.setProtocol("http-so")); 375 EXPECT_TRUE(kurl.setProtocol("http-so"));
377 EXPECT_TRUE(kurl.protocolIs("http-so")); 376 EXPECT_TRUE(kurl.protocolIs("http-so"));
378 EXPECT_TRUE(kurl.isValid()); 377 EXPECT_FALSE(kurl.isValid());
379 378
380 EXPECT_TRUE(kurl.setProtocol("https")); 379 EXPECT_TRUE(kurl.setProtocol("https"));
381 EXPECT_TRUE(kurl.protocolIs("https")); 380 EXPECT_TRUE(kurl.protocolIs("https"));
382 EXPECT_TRUE(kurl.isValid()); 381 EXPECT_FALSE(kurl.isValid());
383 382
384 EXPECT_TRUE(kurl.setProtocol("https-so")); 383 EXPECT_TRUE(kurl.setProtocol("https-so"));
385 EXPECT_TRUE(kurl.protocolIs("https-so")); 384 EXPECT_TRUE(kurl.protocolIs("https-so"));
386 EXPECT_TRUE(kurl.isValid()); 385 EXPECT_FALSE(kurl.isValid());
387 386
388 EXPECT_TRUE(kurl.setProtocol("ftp")); 387 EXPECT_TRUE(kurl.setProtocol("ftp"));
389 EXPECT_TRUE(kurl.protocolIs("ftp")); 388 EXPECT_TRUE(kurl.protocolIs("ftp"));
390 EXPECT_TRUE(kurl.isValid()); 389 EXPECT_FALSE(kurl.isValid());
391 390
392 kurl = KURL(KURL(), "http://"); 391 kurl = KURL(KURL(), "http://");
393 EXPECT_FALSE(kurl.protocolIs("http")); 392 EXPECT_TRUE(kurl.protocolIs("http"));
393 EXPECT_FALSE(kurl.isValid());
394 394
395 kurl = KURL(KURL(), "http://wide#ιΈ‘"); 395 kurl = KURL(KURL(), "http-so://");
396 EXPECT_TRUE(kurl.protocolIs("http")); 396 EXPECT_TRUE(kurl.protocolIs("http-so"));
397 EXPECT_EQ(kurl.protocol(), "http"); 397 EXPECT_FALSE(kurl.isValid());
398 398
399 kurl = KURL(KURL(), "http-so://foo"); 399 kurl = KURL(KURL(), "https://");
400 EXPECT_TRUE(kurl.protocolIs("http-so")); 400 EXPECT_TRUE(kurl.protocolIs("https"));
401 EXPECT_FALSE(kurl.isValid());
401 402
402 kurl = KURL(KURL(), "https://foo"); 403 kurl = KURL(KURL(), "https-so://");
403 EXPECT_TRUE(kurl.protocolIs("https")); 404 EXPECT_TRUE(kurl.protocolIs("https-so"));
405 EXPECT_FALSE(kurl.isValid());
404 406
405 kurl = KURL(KURL(), "https-so://foo"); 407 kurl = KURL(KURL(), "ftp://");
406 EXPECT_TRUE(kurl.protocolIs("https-so"));
407
408 kurl = KURL(KURL(), "ftp://foo");
409 EXPECT_TRUE(kurl.protocolIs("ftp")); 408 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
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(""));
702 703
703 KURL capital(KURL(), "HTTP://www.example.text"); 704 KURL capital(KURL(), "HTTP://www.example.text");
704 EXPECT_TRUE(capital.protocolIs("http")); 705 EXPECT_TRUE(capital.protocolIs("http"));
705 EXPECT_EQ(capital.protocol(), "http"); 706 EXPECT_EQ(capital.protocol(), "http");
706 } 707 }
707 708
708 TEST(KURLTest, strippedForUseAsReferrer) { 709 TEST(KURLTest, strippedForUseAsReferrer) {
709 struct ReferrerCase { 710 struct ReferrerCase {
710 const char* input; 711 const char* input;
711 const char* output; 712 const char* output;
(...skipping 12 matching lines...) Expand all
724 }; 725 };
725 726
726 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) { 727 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) {
727 KURL kurl(ParsedURLString, referrerCases[i].input); 728 KURL kurl(ParsedURLString, referrerCases[i].input);
728 String referrer = kurl.strippedForUseAsReferrer(); 729 String referrer = kurl.strippedForUseAsReferrer();
729 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); 730 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data());
730 } 731 }
731 } 732 }
732 733
733 } // namespace blink 734 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/KURL.cpp ('k') | third_party/WebKit/Source/wtf/text/AtomicString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698