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

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

Issue 2332263002: Updated suborigin serialization to latest spec proposal (Closed)
Patch Set: Actually disable test Created 4 years, 2 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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 // Basic tests that verify our KURL's interface behaves the same as the 31 // Basic tests that verify our KURL's interface behaves the same as the
32 // original KURL's. 32 // original KURL's.
33 33
34 #include "platform/weborigin/KURL.h" 34 #include "platform/weborigin/KURL.h"
35 35
36 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
37 #include "url/url_util.h"
37 #include "wtf/StdLibExtras.h" 38 #include "wtf/StdLibExtras.h"
38 #include "wtf/text/CString.h" 39 #include "wtf/text/CString.h"
39 #include "wtf/text/WTFString.h" 40 #include "wtf/text/WTFString.h"
40 41
41 namespace blink { 42 namespace blink {
42 43
43 TEST(KURLTest, Getters) 44 TEST(KURLTest, Getters)
44 { 45 {
45 struct GetterCase { 46 struct GetterCase {
46 const char* url; 47 const char* url;
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 EXPECT_STREQ("http://www.google.com:8000/favicon.ico", kurl.getString().utf8 ().data()); 365 EXPECT_STREQ("http://www.google.com:8000/favicon.ico", kurl.getString().utf8 ().data());
365 366
366 // Now let's test that giving an invalid replacement fails. Invalid 367 // Now let's test that giving an invalid replacement fails. Invalid
367 // protocols fail without modifying the URL, which should remain valid. 368 // protocols fail without modifying the URL, which should remain valid.
368 EXPECT_FALSE(kurl.setProtocol("f/sj#@")); 369 EXPECT_FALSE(kurl.setProtocol("f/sj#@"));
369 EXPECT_TRUE(kurl.isValid()); 370 EXPECT_TRUE(kurl.isValid());
370 } 371 }
371 372
372 TEST(KURLTest, Valid_HTTP_FTP_URLsHaveHosts) 373 TEST(KURLTest, Valid_HTTP_FTP_URLsHaveHosts)
373 { 374 {
375 // Since the suborigin schemes are added at the content layer, its
376 // necessary it explicitly add them as standard schemes for this test. If
377 // this is needed in the future across mulitple KURLTests, then KURLTest
378 // should probably be converted to a test fixture with a proper SetUp()
379 // method.
380 url::AddStandardScheme("http-so", url::SCHEME_WITH_PORT);
381 url::AddStandardScheme("https-so", url::SCHEME_WITH_PORT);
382
374 KURL kurl; 383 KURL kurl;
375 EXPECT_TRUE(kurl.setProtocol("http")); 384 EXPECT_TRUE(kurl.setProtocol("http"));
376 EXPECT_TRUE(kurl.protocolIs("http")); 385 EXPECT_TRUE(kurl.protocolIs("http"));
377 EXPECT_FALSE(kurl.isValid()); 386 EXPECT_FALSE(kurl.isValid());
378 387
388 EXPECT_TRUE(kurl.setProtocol("http-so"));
389 EXPECT_TRUE(kurl.protocolIs("http-so"));
390 EXPECT_FALSE(kurl.isValid());
391
379 EXPECT_TRUE(kurl.setProtocol("https")); 392 EXPECT_TRUE(kurl.setProtocol("https"));
380 EXPECT_TRUE(kurl.protocolIs("https")); 393 EXPECT_TRUE(kurl.protocolIs("https"));
381 EXPECT_FALSE(kurl.isValid()); 394 EXPECT_FALSE(kurl.isValid());
382 395
396 EXPECT_TRUE(kurl.setProtocol("https-so"));
397 EXPECT_TRUE(kurl.protocolIs("https-so"));
398 EXPECT_FALSE(kurl.isValid());
399
383 EXPECT_TRUE(kurl.setProtocol("ftp")); 400 EXPECT_TRUE(kurl.setProtocol("ftp"));
384 EXPECT_TRUE(kurl.protocolIs("ftp")); 401 EXPECT_TRUE(kurl.protocolIs("ftp"));
385 EXPECT_FALSE(kurl.isValid()); 402 EXPECT_FALSE(kurl.isValid());
386 403
387 kurl = KURL(KURL(), "http://"); 404 kurl = KURL(KURL(), "http://");
388 EXPECT_TRUE(kurl.protocolIs("http")); 405 EXPECT_TRUE(kurl.protocolIs("http"));
389 EXPECT_FALSE(kurl.isValid()); 406 EXPECT_FALSE(kurl.isValid());
390 407
408 kurl = KURL(KURL(), "http-so://");
409 EXPECT_TRUE(kurl.protocolIs("http-so"));
410 EXPECT_FALSE(kurl.isValid());
411
391 kurl = KURL(KURL(), "https://"); 412 kurl = KURL(KURL(), "https://");
392 EXPECT_TRUE(kurl.protocolIs("https")); 413 EXPECT_TRUE(kurl.protocolIs("https"));
393 EXPECT_FALSE(kurl.isValid()); 414 EXPECT_FALSE(kurl.isValid());
394 415
416 kurl = KURL(KURL(), "https-so://");
417 EXPECT_TRUE(kurl.protocolIs("https-so"));
418 EXPECT_FALSE(kurl.isValid());
419
395 kurl = KURL(KURL(), "ftp://"); 420 kurl = KURL(KURL(), "ftp://");
396 EXPECT_TRUE(kurl.protocolIs("ftp")); 421 EXPECT_TRUE(kurl.protocolIs("ftp"));
397 EXPECT_FALSE(kurl.isValid()); 422 EXPECT_FALSE(kurl.isValid());
398 423
399 kurl = KURL(KURL(), "http://host/"); 424 kurl = KURL(KURL(), "http://host/");
400 EXPECT_TRUE(kurl.isValid()); 425 EXPECT_TRUE(kurl.isValid());
401 kurl.setHost(""); 426 kurl.setHost("");
402 EXPECT_FALSE(kurl.isValid()); 427 EXPECT_FALSE(kurl.isValid());
403 428
429 kurl = KURL(KURL(), "http-so://host/");
430 EXPECT_TRUE(kurl.isValid());
431 kurl.setHost("");
432 EXPECT_FALSE(kurl.isValid());
433
404 kurl = KURL(KURL(), "https://host/"); 434 kurl = KURL(KURL(), "https://host/");
405 EXPECT_TRUE(kurl.isValid()); 435 EXPECT_TRUE(kurl.isValid());
406 kurl.setHost(""); 436 kurl.setHost("");
407 EXPECT_FALSE(kurl.isValid()); 437 EXPECT_FALSE(kurl.isValid());
408 438
439 kurl = KURL(KURL(), "https-so://host/");
440 EXPECT_TRUE(kurl.isValid());
441 kurl.setHost("");
442 EXPECT_FALSE(kurl.isValid());
443
409 kurl = KURL(KURL(), "ftp://host/"); 444 kurl = KURL(KURL(), "ftp://host/");
410 EXPECT_TRUE(kurl.isValid()); 445 EXPECT_TRUE(kurl.isValid());
411 kurl.setHost(""); 446 kurl.setHost("");
412 EXPECT_FALSE(kurl.isValid()); 447 EXPECT_FALSE(kurl.isValid());
413 448
414 kurl = KURL(KURL(), "http:///noodles/pho.php"); 449 kurl = KURL(KURL(), "http:///noodles/pho.php");
415 EXPECT_STREQ("http://noodles/pho.php", kurl.getString().utf8().data()); 450 EXPECT_STREQ("http://noodles/pho.php", kurl.getString().utf8().data());
416 EXPECT_STREQ("noodles", kurl.host().utf8().data()); 451 EXPECT_STREQ("noodles", kurl.host().utf8().data());
417 EXPECT_TRUE(kurl.isValid()); 452 EXPECT_TRUE(kurl.isValid());
418 453
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 }; 745 };
711 746
712 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) { 747 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) {
713 KURL kurl(ParsedURLString, referrerCases[i].input); 748 KURL kurl(ParsedURLString, referrerCases[i].input);
714 String referrer = kurl.strippedForUseAsReferrer(); 749 String referrer = kurl.strippedForUseAsReferrer();
715 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); 750 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data());
716 } 751 }
717 } 752 }
718 753
719 } // namespace blink 754 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/KURL.cpp ('k') | third_party/WebKit/Source/platform/weborigin/SecurityOrigin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698