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

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

Issue 24095009: KURL not handling NULL m_string members properly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix regression in set-href-attribute-pathname.html Created 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/weborigin/KURL.cpp ('k') | no next file » | 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 const char url[] = "http://www.google.com/"; 598 const char url[] = "http://www.google.com/";
599 WebCore::KURL src(WebCore::ParsedURLString, url); 599 WebCore::KURL src(WebCore::ParsedURLString, url);
600 EXPECT_TRUE(src.string() == url); // This really just initializes the cache. 600 EXPECT_TRUE(src.string() == url); // This really just initializes the cache.
601 WebCore::KURL dest = src.copy(); 601 WebCore::KURL dest = src.copy();
602 EXPECT_TRUE(dest.string() == url); // This really just initializes the cache . 602 EXPECT_TRUE(dest.string() == url); // This really just initializes the cache .
603 603
604 // The pointers should be different for both UTF-8 and UTF-16. 604 // The pointers should be different for both UTF-8 and UTF-16.
605 EXPECT_NE(dest.string().impl(), src.string().impl()); 605 EXPECT_NE(dest.string().impl(), src.string().impl());
606 } 606 }
607 607
608 TEST(KURLTest, LastPathComponent)
609 {
610 WebCore::KURL url1(WebCore::ParsedURLString, "http://host/path/to/file.txt") ;
611 EXPECT_EQ("file.txt", url1.lastPathComponent());
612
613 WebCore::KURL invalidUTF8(WebCore::ParsedURLString, "http://a@9%aa%:/path/to /file.txt");
614 EXPECT_EQ(String(), invalidUTF8.lastPathComponent());
615 }
616
617 TEST(KURLTest, IsHierarchical)
618 {
619 WebCore::KURL url1(WebCore::ParsedURLString, "http://host/path/to/file.txt") ;
620 EXPECT_TRUE(url1.isHierarchical());
621
622 WebCore::KURL invalidUTF8(WebCore::ParsedURLString, "http://a@9%aa%:/path/to /file.txt");
623 EXPECT_FALSE(invalidUTF8.isHierarchical());
624 }
625
626 TEST(KURLTest, PathAfterLastSlash)
627 {
628 WebCore::KURL url1(WebCore::ParsedURLString, "http://host/path/to/file.txt") ;
629 EXPECT_EQ(20u, url1.pathAfterLastSlash());
630
631 WebCore::KURL invalidUTF8(WebCore::ParsedURLString, "http://a@9%aa%:/path/to /file.txt");
632 EXPECT_EQ(0u, invalidUTF8.pathAfterLastSlash());
633 }
634
635 TEST(KURLTest, ProtocolIsInHTTPFamily)
636 {
637 WebCore::KURL url1(WebCore::ParsedURLString, "http://host/path/to/file.txt") ;
638 EXPECT_TRUE(url1.protocolIsInHTTPFamily());
639
640 WebCore::KURL invalidUTF8(WebCore::ParsedURLString, "http://a@9%aa%:/path/to /file.txt");
641 EXPECT_FALSE(invalidUTF8.protocolIsInHTTPFamily());
642 }
643
608 TEST(KURLTest, ProtocolIs) 644 TEST(KURLTest, ProtocolIs)
609 { 645 {
610 WebCore::KURL url1(WebCore::ParsedURLString, "foo://bar"); 646 WebCore::KURL url1(WebCore::ParsedURLString, "foo://bar");
611 EXPECT_TRUE(url1.protocolIs("foo")); 647 EXPECT_TRUE(url1.protocolIs("foo"));
612 EXPECT_FALSE(url1.protocolIs("foo-bar")); 648 EXPECT_FALSE(url1.protocolIs("foo-bar"));
613 649
614 WebCore::KURL url2(WebCore::ParsedURLString, "foo-bar:"); 650 WebCore::KURL url2(WebCore::ParsedURLString, "foo-bar:");
615 EXPECT_TRUE(url2.protocolIs("foo-bar")); 651 EXPECT_TRUE(url2.protocolIs("foo-bar"));
616 EXPECT_FALSE(url2.protocolIs("foo")); 652 EXPECT_FALSE(url2.protocolIs("foo"));
653
654 WebCore::KURL invalidUTF8(WebCore::ParsedURLString, "http://a@9%aa%:");
655 EXPECT_FALSE(invalidUTF8.protocolIs("http"));
656 EXPECT_TRUE(invalidUTF8.protocolIs(""));
617 } 657 }
618 658
619 } // namespace 659 } // namespace
OLDNEW
« no previous file with comments | « Source/weborigin/KURL.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698