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

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
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, ValidHttpAndFtpUrlsHaveHosts)
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://");
palmer 2015/08/27 22:59:03 Maybe try some weird ones, like http:///noodles/pa
michaeln 2015/08/28 23:15:51 Done, KURL interprets http:///noodles/pancakes.php
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
411 TEST(KURLTest, Path) 454 TEST(KURLTest, Path)
412 { 455 {
413 const char initial[] = "http://www.google.com/path/foo"; 456 const char initial[] = "http://www.google.com/path/foo";
414 KURL kurl(ParsedURLString, initial); 457 KURL kurl(ParsedURLString, initial);
415 458
416 // Clear by setting a null string. 459 // Clear by setting a null string.
417 String nullString; 460 String nullString;
418 EXPECT_TRUE(nullString.isNull()); 461 EXPECT_TRUE(nullString.isNull());
419 kurl.setPath(nullString); 462 kurl.setPath(nullString);
420 EXPECT_STREQ("http://www.google.com/", kurl.string().utf8().data()); 463 EXPECT_STREQ("http://www.google.com/", kurl.string().utf8().data());
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 }; 738 };
696 739
697 for (size_t i = 0; i < arraysize(referrerCases); i++) { 740 for (size_t i = 0; i < arraysize(referrerCases); i++) {
698 KURL kurl(ParsedURLString, referrerCases[i].input); 741 KURL kurl(ParsedURLString, referrerCases[i].input);
699 String referrer = kurl.strippedForUseAsReferrer(); 742 String referrer = kurl.strippedForUseAsReferrer();
700 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); 743 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data());
701 } 744 }
702 } 745 }
703 746
704 } // namespace blink 747 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/platform/weborigin/SecurityOrigin.cpp » ('j') | Source/platform/weborigin/SecurityOrigin.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698