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

Unified Diff: chrome/common/extensions/matcher/url_matcher_unittest.cc

Issue 10823313: Let url filter test the scheme in urlContains/Equals/Prefix/Suffix criteria (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/matcher/url_matcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/matcher/url_matcher_unittest.cc
diff --git a/chrome/common/extensions/matcher/url_matcher_unittest.cc b/chrome/common/extensions/matcher/url_matcher_unittest.cc
index add8530ff137e8a70b29c91302e9502aa71d2888..acf414fc6ce19ebb7a937d06d2918c6c3f8ceffb 100644
--- a/chrome/common/extensions/matcher/url_matcher_unittest.cc
+++ b/chrome/common/extensions/matcher/url_matcher_unittest.cc
@@ -230,7 +230,7 @@ TEST(URLMatcherConditionFactoryTest, TestSingletonProperty) {
}
TEST(URLMatcherConditionFactoryTest, TestComponentSearches) {
- GURL gurl("https://www.google.com/webhp?sourceid=chrome-instant&ie=UTF-8"
+ 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);
@@ -326,18 +326,21 @@ TEST(URLMatcherConditionFactoryTest, TestComponentSearches) {
}
TEST(URLMatcherConditionFactoryTest, TestFullSearches) {
- GURL gurl("https://www.google.com/webhp?sourceid=chrome-instant&ie=UTF-8"
+ // The Port 443 is stripped because it is the default port for https.
+ GURL gurl("https://www.google.com:443/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.CanonicalizeURLForFullSearches(gurl);
EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition(""), url));
- EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition("www.goog"), url));
- EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition("www.google.com"), url));
- EXPECT_TRUE(
- Matches(factory.CreateURLPrefixCondition(".www.google.com"), url));
- EXPECT_TRUE(
- Matches(factory.CreateURLPrefixCondition("www.google.com/"), url));
+ EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition(
+ "https://www.goog"), url));
+ EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition(
+ "https://www.google.com"), url));
+ EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition(
+ "https://www.google.com/webhp?"), url));
+ EXPECT_FALSE(Matches(factory.CreateURLPrefixCondition(
+ "http://www.google.com"), url));
EXPECT_FALSE(Matches(factory.CreateURLPrefixCondition("webhp"), url));
EXPECT_TRUE(Matches(factory.CreateURLSuffixCondition(""), url));
@@ -346,18 +349,29 @@ TEST(URLMatcherConditionFactoryTest, TestFullSearches) {
EXPECT_TRUE(Matches(factory.CreateURLContainsCondition(""), url));
EXPECT_TRUE(Matches(factory.CreateURLContainsCondition("www.goog"), url));
- EXPECT_TRUE(Matches(factory.CreateURLContainsCondition(".www.goog"), url));
EXPECT_TRUE(Matches(factory.CreateURLContainsCondition("webhp"), url));
EXPECT_TRUE(Matches(factory.CreateURLContainsCondition("?"), url));
EXPECT_TRUE(Matches(factory.CreateURLContainsCondition("sourceid"), url));
EXPECT_TRUE(Matches(factory.CreateURLContainsCondition("ion=1"), url));
+ EXPECT_FALSE(Matches(factory.CreateURLContainsCondition(".www.goog"), url));
EXPECT_FALSE(Matches(factory.CreateURLContainsCondition("foobar"), url));
EXPECT_FALSE(Matches(factory.CreateURLContainsCondition("search"), url));
+ EXPECT_FALSE(Matches(factory.CreateURLContainsCondition(":443"), url));
EXPECT_TRUE(Matches(factory.CreateURLEqualsCondition(
- "www.google.com/webhp?sourceid=chrome-instant&ie=UTF-8&ion=1"), url));
+ "https://www.google.com/webhp?sourceid=chrome-instant&ie=UTF-8&ion=1"),
+ url));
EXPECT_FALSE(
- Matches(factory.CreateURLEqualsCondition("www.google.com"), url));
+ Matches(factory.CreateURLEqualsCondition("https://www.google.com"), url));
+
+ // Same as above but this time with a non-standard port.
+ 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%20"
+ "awesome");
+ url = factory.CanonicalizeURLForFullSearches(gurl);
+ EXPECT_TRUE(Matches(factory.CreateURLPrefixCondition(
+ "https://www.google.com:1234/webhp?"), url));
+ EXPECT_TRUE(Matches(factory.CreateURLContainsCondition(":1234"), url));
}
« no previous file with comments | « chrome/common/extensions/matcher/url_matcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698