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

Side by Side Diff: url/gurl_unittest.cc

Issue 2895953002: Update dangling markup mitigations. (Closed)
Patch Set: Test. Created 3 years, 7 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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 638
639 GURL url_2("filesystem:http://www.iamnotgoogle.com/foo/"); 639 GURL url_2("filesystem:http://www.iamnotgoogle.com/foo/");
640 EXPECT_FALSE(url_2.DomainIs("google.com")); 640 EXPECT_FALSE(url_2.DomainIs("google.com"));
641 } 641 }
642 642
643 // Newlines should be stripped from inputs. 643 // Newlines should be stripped from inputs.
644 TEST(GURLTest, Newlines) { 644 TEST(GURLTest, Newlines) {
645 // Constructor. 645 // Constructor.
646 GURL url_1(" \t ht\ntp://\twww.goo\rgle.com/as\ndf \n "); 646 GURL url_1(" \t ht\ntp://\twww.goo\rgle.com/as\ndf \n ");
647 EXPECT_EQ("http://www.google.com/asdf", url_1.spec()); 647 EXPECT_EQ("http://www.google.com/asdf", url_1.spec());
648 EXPECT_TRUE(url_1.parsed_for_possibly_invalid_spec().whitespace_removed); 648 EXPECT_FALSE(
649 url_1.parsed_for_possibly_invalid_spec().potentially_dangling_markup);
649 650
650 // Relative path resolver. 651 // Relative path resolver.
651 GURL url_2 = url_1.Resolve(" \n /fo\to\r "); 652 GURL url_2 = url_1.Resolve(" \n /fo\to\r ");
652 EXPECT_EQ("http://www.google.com/foo", url_2.spec()); 653 EXPECT_EQ("http://www.google.com/foo", url_2.spec());
653 EXPECT_TRUE(url_2.parsed_for_possibly_invalid_spec().whitespace_removed); 654 EXPECT_FALSE(
655 url_2.parsed_for_possibly_invalid_spec().potentially_dangling_markup);
656
657 // Constructor.
658 GURL url_3(" \t ht\ntp://\twww.goo\rgle.com/as\ndf< \n ");
659 EXPECT_EQ("http://www.google.com/asdf%3C", url_3.spec());
660 EXPECT_TRUE(
661 url_3.parsed_for_possibly_invalid_spec().potentially_dangling_markup);
662
663 // Relative path resolver.
664 GURL url_4 = url_1.Resolve(" \n /fo\to<\r ");
665 EXPECT_EQ("http://www.google.com/foo%3C", url_4.spec());
666 EXPECT_TRUE(
667 url_4.parsed_for_possibly_invalid_spec().potentially_dangling_markup);
654 668
655 // Note that newlines are NOT stripped from ReplaceComponents. 669 // Note that newlines are NOT stripped from ReplaceComponents.
656 } 670 }
657 671
658 TEST(GURLTest, IsStandard) { 672 TEST(GURLTest, IsStandard) {
659 GURL a("http:foo/bar"); 673 GURL a("http:foo/bar");
660 EXPECT_TRUE(a.IsStandard()); 674 EXPECT_TRUE(a.IsStandard());
661 675
662 GURL b("foo:bar/baz"); 676 GURL b("foo:bar/baz");
663 EXPECT_FALSE(b.IsStandard()); 677 EXPECT_FALSE(b.IsStandard());
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 // A versus B. 823 // A versus B.
810 EXPECT_EQ(test_case.are_equals, 824 EXPECT_EQ(test_case.are_equals,
811 GURL(test_case.url_a).EqualsIgnoringRef(GURL(test_case.url_b))); 825 GURL(test_case.url_a).EqualsIgnoringRef(GURL(test_case.url_b)));
812 // B versus A. 826 // B versus A.
813 EXPECT_EQ(test_case.are_equals, 827 EXPECT_EQ(test_case.are_equals,
814 GURL(test_case.url_b).EqualsIgnoringRef(GURL(test_case.url_a))); 828 GURL(test_case.url_b).EqualsIgnoringRef(GURL(test_case.url_a)));
815 } 829 }
816 } 830 }
817 831
818 } // namespace url 832 } // namespace url
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698