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

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

Issue 13699007: Provide a mechanism to the decl. WebRequest API to match URLs without the query against a RegEx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 7 years, 8 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 | « extensions/common/matcher/url_matcher_factory.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/matcher/url_matcher_unittest.cc
diff --git a/extensions/common/matcher/url_matcher_unittest.cc b/extensions/common/matcher/url_matcher_unittest.cc
index b17c13c3f014c4070916f2b3a21728a83be83645..7ccc058f0a00c9e5956ea37f0c0cb22ae1d1ceb4 100644
--- a/extensions/common/matcher/url_matcher_unittest.cc
+++ b/extensions/common/matcher/url_matcher_unittest.cc
@@ -489,6 +489,16 @@ TEST(URLMatcherConditionSetTest, Matching) {
EXPECT_FALSE(condition_set6->IsMatch(matching_patterns, url1));
matching_patterns.insert(m1.string_pattern()->id());
EXPECT_TRUE(condition_set6->IsMatch(matching_patterns, url1));
+
+ matching_patterns.clear();
+ regex_conditions.clear();
+ URLMatcherCondition r2 = factory.CreateOriginAndPathMatchesCondition("b[a]r");
+ regex_conditions.insert(r2);
+ scoped_refptr<URLMatcherConditionSet> condition_set7(
+ new URLMatcherConditionSet(1, regex_conditions));
+ EXPECT_FALSE(condition_set7->IsMatch(matching_patterns, url1));
+ matching_patterns.insert(r2.string_pattern()->id());
+ EXPECT_TRUE(condition_set7->IsMatch(matching_patterns, url1));
}
@@ -631,4 +641,40 @@ TEST(URLMatcherTest, TestComponentsImplyContains) {
EXPECT_EQ(1u, matcher.MatchURL(url).size());
}
+// Check that matches in everything but the query are found.
+TEST(URLMatcherTest, TestOriginAndPathRegExPositive) {
+ GURL url("https://www.google.com:1234/webhp?test=val&a=b");
+
+ URLMatcher matcher;
+ URLMatcherConditionFactory* factory = matcher.condition_factory();
+
+ URLMatcherConditionSet::Conditions conditions;
+
+ conditions.insert(factory->CreateOriginAndPathMatchesCondition("w..hp"));
+ const int kConditionSetId = 1;
+ URLMatcherConditionSet::Vector insert;
+ insert.push_back(make_scoped_refptr(
+ new URLMatcherConditionSet(kConditionSetId, conditions)));
+ matcher.AddConditionSets(insert);
+ EXPECT_EQ(1u, matcher.MatchURL(url).size());
+}
+
+// Check that matches in the query are ignored.
+TEST(URLMatcherTest, TestOriginAndPathRegExNegative) {
+ GURL url("https://www.google.com:1234/webhp?test=val&a=b");
+
+ URLMatcher matcher;
+ URLMatcherConditionFactory* factory = matcher.condition_factory();
+
+ URLMatcherConditionSet::Conditions conditions;
+
+ conditions.insert(factory->CreateOriginAndPathMatchesCondition("val"));
+ const int kConditionSetId = 1;
+ URLMatcherConditionSet::Vector insert;
+ insert.push_back(make_scoped_refptr(
+ new URLMatcherConditionSet(kConditionSetId, conditions)));
+ matcher.AddConditionSets(insert);
+ EXPECT_EQ(0u, matcher.MatchURL(url).size());
+}
+
} // namespace extensions
« no previous file with comments | « extensions/common/matcher/url_matcher_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698