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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit ion.h" 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit ion.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 TestURLRequest http_request_1000(http_url_1000, NULL, &context); 237 TestURLRequest http_request_1000(http_url_1000, NULL, &context);
238 url_match_ids = matcher.MatchURL(http_url_1000); 238 url_match_ids = matcher.MatchURL(http_url_1000);
239 ASSERT_EQ(1u, url_match_ids.size()); 239 ASSERT_EQ(1u, url_match_ids.size());
240 240
241 GURL http_url_2000("http://www.example.com:2000"); 241 GURL http_url_2000("http://www.example.com:2000");
242 TestURLRequest http_request_2000(http_url_2000, NULL, &context); 242 TestURLRequest http_request_2000(http_url_2000, NULL, &context);
243 url_match_ids = matcher.MatchURL(http_url_2000); 243 url_match_ids = matcher.MatchURL(http_url_2000);
244 ASSERT_EQ(0u, url_match_ids.size()); 244 ASSERT_EQ(0u, url_match_ids.size());
245 } 245 }
246 246
247 // TODO(vabr): Once the condition attribute for request headers has been 247 // Create a condition with two attributes: one on the request header and one on
248 // implemented, add a new test for WebRequestCondition::Create that 248 // the response header. The Create() method should fail and complain that it is
249 // creates a condition with two attributes: one on the request header 249 // impossible that both conditions are fulfilled at the same time.
250 // and one on the response header. The Create() method should fail complaining 250 TEST(WebRequestConditionTest, ConditionsWithConflictingStages) {
251 // that it is impossible that both conditions are fulfilled at the same time. 251 // Necessary for TestURLRequest.
252 MessageLoop message_loop(MessageLoop::TYPE_IO);
253 URLMatcher matcher;
254
255 std::string error;
256 scoped_ptr<WebRequestCondition> result;
257
258 DictionaryValue condition_value;
259 condition_value.SetString(keys::kInstanceTypeKey, keys::kRequestMatcherType);
260
261 // Create two JS arrays, each with one empty object...
262 scoped_ptr<ListValue> request_header_filters(new ListValue());
263 request_header_filters->Append(new DictionaryValue());
264 scoped_ptr<ListValue> response_header_filters(new ListValue());
265 response_header_filters->Append(new DictionaryValue());
266
267 // ...and pass them as the header filters to the request matcher.
268 condition_value.Set(keys::kRequestHeadersKey,
269 request_header_filters.release());
270 condition_value.Set(keys::kResponseHeadersKey,
271 response_header_filters.release());
272
273 // Test error on incompatible application stages for involved attributes.
274 error.clear();
275 result = WebRequestCondition::Create(matcher.condition_factory(),
276 condition_value, &error);
277 EXPECT_FALSE(error.empty());
278 EXPECT_FALSE(result.get());
279 }
252 280
253 } // namespace extensions 281 } // namespace extensions
OLDNEW
« 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