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

Unified Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc

Issue 11569007: Refactoring how conditions without URL attributes are handled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Polished 1st version Created 8 years 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: chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc
index 85b503fa46e322a1fbe3488ed7cad137922b3a24..858ddeed4fee2737482b5d47c60d090d2c467ed9 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc
@@ -109,6 +109,9 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
https_condition.SetString(keys::kInstanceTypeKey, keys::kRequestMatcherType);
https_condition.Set(keys::kUrlKey, https_url_filter);
+ DictionaryValue empty_condition;
+ empty_condition.SetString(keys::kInstanceTypeKey, keys::kRequestMatcherType);
+
WebRequestConditionSet::AnyVector conditions;
linked_ptr<json_schema_compiler::any::Any> condition1 = make_linked_ptr(
@@ -121,6 +124,11 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
condition2->Init(https_condition);
conditions.push_back(condition2);
+ linked_ptr<json_schema_compiler::any::Any> condition3 = make_linked_ptr(
+ new json_schema_compiler::any::Any);
+ condition3->Init(empty_condition);
+ conditions.push_back(condition3);
+
// Test insertion
std::string error;
scoped_ptr<WebRequestConditionSet> result =
@@ -128,7 +136,7 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
conditions, &error);
EXPECT_EQ("", error);
ASSERT_TRUE(result.get());
- EXPECT_EQ(2u, result->conditions().size());
+ EXPECT_EQ(3u, result->conditions().size());
// Tell the URLMatcher about our shiny new patterns.
URLMatcherConditionSet::Vector url_matcher_condition_set;
@@ -177,6 +185,21 @@ TEST(WebRequestConditionTest, CreateConditionSet) {
++number_matches;
}
EXPECT_EQ(0, number_matches);
+
+ // Check that the empty condition reports success independently of the URL.
Jeffrey Yasskin 2012/12/18 02:24:32 Please check a non-empty condition that doesn't ha
vabr (Chromium) 2012/12/18 18:26:42 Done, as WebRequestConditionTest.IsFulfilledIndepe
+ // We need to use IsFulfilledWithoutURLMatcher instead of IsFulfilled to
+ // ignore the URL-dependent conditions.
+ number_matches = 0;
+ if (result->IsFulfilledWithoutURLMatcher(
+ WebRequestRule::RequestData(&http_request, ON_BEFORE_REQUEST)))
+ ++number_matches;
+ if (result->IsFulfilledWithoutURLMatcher(
+ WebRequestRule::RequestData(&https_request, ON_BEFORE_REQUEST)))
+ ++number_matches;
+ if (result->IsFulfilledWithoutURLMatcher(
+ WebRequestRule::RequestData(&https_foo_request, ON_BEFORE_REQUEST)))
+ ++number_matches;
+ EXPECT_EQ(3, number_matches);
}
TEST(WebRequestConditionTest, TestPortFilter) {

Powered by Google App Engine
This is Rietveld 408576698