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

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: 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
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 09fc562c17229ba582172ee1fa2853f57cc5d3cd..27a901e15b1633048e4c1deec40ae2b66d4a438b 100644
--- a/extensions/common/matcher/url_matcher_unittest.cc
+++ b/extensions/common/matcher/url_matcher_unittest.cc
@@ -484,6 +484,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.CreateStrippedURLMatchesCondition("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));
}
@@ -626,4 +636,40 @@ TEST(URLMatcherTest, TestComponentsImplyContains) {
EXPECT_EQ(1u, matcher.MatchURL(url).size());
}
+// Check that matches in everything but the query are found.
+TEST(URLMatcherTest, TestStrippedUrlRegExPositive) {
+ 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->CreateStrippedURLMatchesCondition("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, TestStrippedUrlRegExNegative) {
+ 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->CreateStrippedURLMatchesCondition("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

Powered by Google App Engine
This is Rietveld 408576698