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

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

Issue 2463703002: Optimize KURL protocols (Closed)
Patch Set: 16 bit test Created 4 years, 1 month 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; 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 EXPECT_TRUE(kurl.protocolIs(""));
395
396 kurl = KURL(KURL(), "http://wide#ιΈ‘");
392 EXPECT_TRUE(kurl.protocolIs("http")); 397 EXPECT_TRUE(kurl.protocolIs("http"));
393 EXPECT_FALSE(kurl.isValid()); 398 EXPECT_EQ(kurl.protocol(), "http");
394 399
395 kurl = KURL(KURL(), "http-so://"); 400 kurl = KURL(KURL(), "http-so://foo");
396 EXPECT_TRUE(kurl.protocolIs("http-so")); 401 EXPECT_TRUE(kurl.protocolIs("http-so"));
397 EXPECT_FALSE(kurl.isValid());
398 402
399 kurl = KURL(KURL(), "https://"); 403 kurl = KURL(KURL(), "https://foo");
400 EXPECT_TRUE(kurl.protocolIs("https")); 404 EXPECT_TRUE(kurl.protocolIs("https"));
401 EXPECT_FALSE(kurl.isValid());
402 405
403 kurl = KURL(KURL(), "https-so://"); 406 kurl = KURL(KURL(), "https-so://foo");
404 EXPECT_TRUE(kurl.protocolIs("https-so")); 407 EXPECT_TRUE(kurl.protocolIs("https-so"));
405 EXPECT_FALSE(kurl.isValid());
406 408
407 kurl = KURL(KURL(), "ftp://"); 409 kurl = KURL(KURL(), "ftp://foo");
408 EXPECT_TRUE(kurl.protocolIs("ftp")); 410 EXPECT_TRUE(kurl.protocolIs("ftp"));
409 EXPECT_FALSE(kurl.isValid());
410 411
411 kurl = KURL(KURL(), "http://host/"); 412 kurl = KURL(KURL(), "http://host/");
412 EXPECT_TRUE(kurl.isValid()); 413 EXPECT_TRUE(kurl.isValid());
413 kurl.setHost(""); 414 kurl.setHost("");
414 EXPECT_FALSE(kurl.isValid()); 415 EXPECT_FALSE(kurl.isValid());
415 416
416 kurl = KURL(KURL(), "http-so://host/"); 417 kurl = KURL(KURL(), "http-so://host/");
417 EXPECT_TRUE(kurl.isValid()); 418 EXPECT_TRUE(kurl.isValid());
418 kurl.setHost(""); 419 kurl.setHost("");
419 EXPECT_FALSE(kurl.isValid()); 420 EXPECT_FALSE(kurl.isValid());
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 }; 726 };
726 727
727 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) { 728 for (size_t i = 0; i < WTF_ARRAY_LENGTH(referrerCases); i++) {
728 KURL kurl(ParsedURLString, referrerCases[i].input); 729 KURL kurl(ParsedURLString, referrerCases[i].input);
729 String referrer = kurl.strippedForUseAsReferrer(); 730 String referrer = kurl.strippedForUseAsReferrer();
730 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data()); 731 EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data());
731 } 732 }
732 } 733 }
733 734
734 } // namespace blink 735 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698