diff options
author | mnissler <mnissler@chromium.org> | 2015-05-29 06:57:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-29 13:58:09 +0000 |
commit | d9cdcd8702111079c27787a2d49b48470bc10ae7 (patch) | |
tree | 21b8612c0bf4f8b5c805e4a652db400a18d2080b /components/url_matcher/url_matcher_unittest.cc | |
parent | 673eda698a02bbc74c07b790e52eb5185a693bde (diff) | |
download | chromium_src-d9cdcd8702111079c27787a2d49b48470bc10ae7.zip chromium_src-d9cdcd8702111079c27787a2d49b48470bc10ae7.tar.gz chromium_src-d9cdcd8702111079c27787a2d49b48470bc10ae7.tar.bz2 |
url_matcher: Treat FQDN hosts as if they were relative.
This changes URLMatcher to not make a difference between
fully-qualified and relative URLs. Patterns that specify
fully-qualified host names now also match the corresponding relative
host name in URLs and fully-qualified host names in URLs now match
patterns that use relative host names.
BUG=chromium:493142
TEST=Added unit and browser test coverage.
Review URL: https://codereview.chromium.org/1167483002
Cr-Commit-Position: refs/heads/master@{#331963}
Diffstat (limited to 'components/url_matcher/url_matcher_unittest.cc')
-rw-r--r-- | components/url_matcher/url_matcher_unittest.cc | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/components/url_matcher/url_matcher_unittest.cc b/components/url_matcher/url_matcher_unittest.cc index b69364c..328c633 100644 --- a/components/url_matcher/url_matcher_unittest.cc +++ b/components/url_matcher/url_matcher_unittest.cc @@ -241,10 +241,14 @@ TEST(URLMatcherConditionFactoryTest, TestSingletonProperty) { } TEST(URLMatcherConditionFactoryTest, TestComponentSearches) { + URLMatcherConditionFactory factory; GURL gurl("https://www.google.com:1234/webhp?sourceid=chrome-instant&ie=UTF-8" "&ion=1#hl=en&output=search&sclient=psy-ab&q=chrome%20is%20awesome"); - URLMatcherConditionFactory factory; std::string url = factory.CanonicalizeURLForComponentSearches(gurl); + GURL gurl2("https://www.google.com.:1234/webhp?sourceid=chrome-instant" + "&ie=UTF-8&ion=1#hl=en&output=search&sclient=psy-ab" + "&q=chrome%20is%20awesome"); + std::string url2 = factory.CanonicalizeURLForComponentSearches(gurl2); // Test host component. EXPECT_TRUE(Matches(factory.CreateHostPrefixCondition(std::string()), url)); @@ -259,12 +263,18 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) { EXPECT_FALSE(Matches(factory.CreateHostPrefixCondition("webhp"), url)); EXPECT_TRUE(Matches(factory.CreateHostSuffixCondition(std::string()), url)); + EXPECT_TRUE(Matches(factory.CreateHostSuffixCondition(std::string()), url2)); EXPECT_TRUE(Matches(factory.CreateHostSuffixCondition("com"), url)); + EXPECT_TRUE(Matches(factory.CreateHostSuffixCondition("com"), url2)); EXPECT_TRUE(Matches(factory.CreateHostSuffixCondition(".com"), url)); EXPECT_TRUE( Matches(factory.CreateHostSuffixCondition("www.google.com"), url)); EXPECT_TRUE( Matches(factory.CreateHostSuffixCondition(".www.google.com"), url)); + EXPECT_TRUE( + Matches(factory.CreateHostSuffixCondition(".www.google.com"), url2)); + EXPECT_TRUE( + Matches(factory.CreateHostSuffixCondition(".www.google.com."), url)); EXPECT_FALSE(Matches(factory.CreateHostSuffixCondition("www"), url)); EXPECT_FALSE( Matches(factory.CreateHostSuffixCondition("www.google.com/"), url)); @@ -274,9 +284,14 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) { EXPECT_FALSE(Matches(factory.CreateHostEqualsCondition("www"), url)); EXPECT_TRUE( Matches(factory.CreateHostEqualsCondition("www.google.com"), url)); + EXPECT_TRUE( + Matches(factory.CreateHostEqualsCondition("www.google.com"), url2)); EXPECT_FALSE( Matches(factory.CreateHostEqualsCondition("www.google.com/"), url)); - + EXPECT_TRUE( + Matches(factory.CreateHostEqualsCondition(".www.google.com."), url)); + EXPECT_TRUE( + Matches(factory.CreateHostEqualsCondition(".www.google.com."), url2)); // Test path component. EXPECT_TRUE(Matches(factory.CreatePathPrefixCondition(std::string()), url)); @@ -330,6 +345,12 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) { // Test adjacent components EXPECT_TRUE(Matches(factory.CreateHostSuffixPathPrefixCondition( "google.com", "/webhp"), url)); + EXPECT_TRUE(Matches(factory.CreateHostSuffixPathPrefixCondition( + "google.com", "/webhp"), url2)); + EXPECT_TRUE(Matches(factory.CreateHostSuffixPathPrefixCondition( + "google.com.", "/webhp"), url)); + EXPECT_TRUE(Matches(factory.CreateHostSuffixPathPrefixCondition( + "google.com.", "/webhp"), url2)); EXPECT_TRUE(Matches( factory.CreateHostSuffixPathPrefixCondition(std::string(), "/webhp"), url)); @@ -341,6 +362,12 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) { EXPECT_TRUE(Matches(factory.CreateHostEqualsPathPrefixCondition( "www.google.com", "/webhp"), url)); + EXPECT_TRUE(Matches(factory.CreateHostEqualsPathPrefixCondition( + "www.google.com", "/webhp"), url2)); + EXPECT_TRUE(Matches(factory.CreateHostEqualsPathPrefixCondition( + ".www.google.com.", "/webhp"), url)); + EXPECT_TRUE(Matches(factory.CreateHostEqualsPathPrefixCondition( + ".www.google.com.", "/webhp"), url2)); EXPECT_FALSE(Matches( factory.CreateHostEqualsPathPrefixCondition(std::string(), "/webhp"), url)); |