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

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

Issue 1320793002: Remove some code, an obsolete criteria, from SecurityOrigin test for uniqueness. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 months 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
« no previous file with comments | « no previous file | Source/platform/weborigin/SecurityOrigin.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 EXPECT_TRUE(kurl.isValid()); 401 EXPECT_TRUE(kurl.isValid());
402 EXPECT_FALSE(kurl.isEmpty()); 402 EXPECT_FALSE(kurl.isEmpty());
403 EXPECT_STREQ("http://www.google.com:8000/favicon.ico", kurl.string().utf8(). data()); 403 EXPECT_STREQ("http://www.google.com:8000/favicon.ico", kurl.string().utf8(). data());
404 404
405 // Now let's test that giving an invalid replacement fails. Invalid 405 // Now let's test that giving an invalid replacement fails. Invalid
406 // protocols fail without modifying the URL, which should remain valid. 406 // protocols fail without modifying the URL, which should remain valid.
407 EXPECT_FALSE(kurl.setProtocol("f/sj#@")); 407 EXPECT_FALSE(kurl.setProtocol("f/sj#@"));
408 EXPECT_TRUE(kurl.isValid()); 408 EXPECT_TRUE(kurl.isValid());
409 } 409 }
410 410
411 TEST(KURLTest, Valid_HTTP_FTP_URLsHaveHosts)
412 {
413 KURL kurl;
414 EXPECT_TRUE(kurl.setProtocol("http"));
415 EXPECT_TRUE(kurl.protocolIs("http"));
416 EXPECT_FALSE(kurl.isValid());
417
418 EXPECT_TRUE(kurl.setProtocol("https"));
419 EXPECT_TRUE(kurl.protocolIs("https"));
420 EXPECT_FALSE(kurl.isValid());
421
422 EXPECT_TRUE(kurl.setProtocol("ftp"));
423 EXPECT_TRUE(kurl.protocolIs("ftp"));
424 EXPECT_FALSE(kurl.isValid());
425
426 kurl = KURL(KURL(), "http://");
427 EXPECT_TRUE(kurl.protocolIs("http"));
428 EXPECT_FALSE(kurl.isValid());
429
430 kurl = KURL(KURL(), "https://");
431 EXPECT_TRUE(kurl.protocolIs("https"));
432 EXPECT_FALSE(kurl.isValid());
433
434 kurl = KURL(KURL(), "ftp://");
435 EXPECT_TRUE(kurl.protocolIs("ftp"));
436 EXPECT_FALSE(kurl.isValid());
437
438 kurl = KURL(KURL(), "http://host/");
439 EXPECT_TRUE(kurl.isValid());
440 kurl.setHost("");
441 EXPECT_FALSE(kurl.isValid());
442
443 kurl = KURL(KURL(), "https://host/");
444 EXPECT_TRUE(kurl.isValid());
445 kurl.setHost("");
446 EXPECT_FALSE(kurl.isValid());
447
448 kurl = KURL(KURL(), "ftp://host/");
449 EXPECT_TRUE(kurl.isValid());
450 kurl.setHost("");
451 EXPECT_FALSE(kurl.isValid());
452
453 kurl = KURL(KURL(), "http:///noodles/pho.php");
454 EXPECT_STREQ("http://noodles/pho.php", kurl.string().utf8().data());
455 EXPECT_STREQ("noodles", kurl.host().utf8().data());
456 EXPECT_TRUE(kurl.isValid());
457
458 kurl = KURL(KURL(), "https://username:password@/");
459 EXPECT_FALSE(kurl.isValid());
460
461 kurl = KURL(KURL(), "https://username:password@host/");
462 EXPECT_TRUE(kurl.isValid());
463 }
464
411 TEST(KURLTest, Path) 465 TEST(KURLTest, Path)
412 { 466 {
413 const char initial[] = "http://www.google.com/path/foo"; 467 const char initial[] = "http://www.google.com/path/foo";
414 KURL kurl(ParsedURLString, initial); 468 KURL kurl(ParsedURLString, initial);
415 469
416 // Clear by setting a null string. 470 // Clear by setting a null string.
417 String nullString; 471 String nullString;
418 EXPECT_TRUE(nullString.isNull()); 472 EXPECT_TRUE(nullString.isNull());
419 kurl.setPath(nullString); 473 kurl.setPath(nullString);
420 EXPECT_STREQ("http://www.google.com/", kurl.string().utf8().data()); 474 EXPECT_STREQ("http://www.google.com/", kurl.string().utf8().data());
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 }; 749 };
696 750
697 for (size_t i = 0; i < arraysize(referrerCases); i++) { 751 for (size_t i = 0; i < arraysize(referrerCases); i++) {
698 KURL kurl(ParsedURLString, referrerCases[i].input); 752 KURL kurl(ParsedURLString, referrerCases[i].input);
699 String referrer = kurl.strippedForUseAsReferrer(); 753 String referrer = kurl.strippedForUseAsReferrer();
700 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); 754 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data());
701 } 755 }
702 } 756 }
703 757
704 } // namespace blink 758 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/platform/weborigin/SecurityOrigin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698