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

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

Issue 11194003: Test WebRequest attributes and compatible stages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 36b138800a3c14fcf34adc4d0656c664e514ffb6..52569f743ab577fd897b032d2220632972c635d8 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_unittest.cc
@@ -244,10 +244,38 @@ TEST(WebRequestConditionTest, TestPortFilter) {
ASSERT_EQ(0u, url_match_ids.size());
}
-// TODO(vabr): Once the condition attribute for request headers has been
-// implemented, add a new test for WebRequestCondition::Create that
-// creates a condition with two attributes: one on the request header
-// and one on the response header. The Create() method should fail complaining
-// that it is impossible that both conditions are fulfilled at the same time.
+// Create a condition with two attributes: one on the request header and one on
+// the response header. The Create() method should fail and complain that it is
+// impossible that both conditions are fulfilled at the same time.
+TEST(WebRequestConditionTest, ConditionsWithConflictingStages) {
+ // Necessary for TestURLRequest.
+ MessageLoop message_loop(MessageLoop::TYPE_IO);
+ URLMatcher matcher;
+
+ std::string error;
+ scoped_ptr<WebRequestCondition> result;
+
+ DictionaryValue condition_value;
+ condition_value.SetString(keys::kInstanceTypeKey, keys::kRequestMatcherType);
+
+ // Create two JS arrays, each with one empty object...
+ scoped_ptr<ListValue> request_header_filters(new ListValue());
+ request_header_filters->Append(new DictionaryValue());
+ scoped_ptr<ListValue> response_header_filters(new ListValue());
+ response_header_filters->Append(new DictionaryValue());
+
+ // ...and pass them as the header filters to the request matcher.
+ condition_value.Set(keys::kRequestHeadersKey,
+ request_header_filters.release());
+ condition_value.Set(keys::kResponseHeadersKey,
+ response_header_filters.release());
+
+ // Test error on incompatible application stages for involved attributes.
+ error.clear();
+ result = WebRequestCondition::Create(matcher.condition_factory(),
+ condition_value, &error);
+ EXPECT_FALSE(error.empty());
+ EXPECT_FALSE(result.get());
+}
} // namespace extensions
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698