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

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc

Issue 11038031: Adding condition attributes for request headers to Declarative WebRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Dominic's comments addressed 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
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_attribute.h" 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit ion_attribute.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 return dictionary.Pass(); 227 return dictionary.Pass();
228 } 228 }
229 229
230 // Returns whether the response headers from |url_request| satisfy the match 230 // Returns whether the response headers from |url_request| satisfy the match
231 // criteria given in |tests|. For at least one |i| all tests from |tests[i]| 231 // criteria given in |tests|. For at least one |i| all tests from |tests[i]|
232 // must pass. If |positive_test| is true, the dictionary is interpreted as the 232 // must pass. If |positive_test| is true, the dictionary is interpreted as the
233 // containsHeaders property of a RequestMatcher, otherwise as 233 // containsHeaders property of a RequestMatcher, otherwise as
234 // doesNotContainHeaders. 234 // doesNotContainHeaders.
235 void MatchAndCheck(const std::vector< std::vector<const std::string*> >& tests, 235 void MatchAndCheck(const std::vector< std::vector<const std::string*> >& tests,
236 const std::string& key, 236 const std::string& key,
237 RequestStage stage,
237 net::URLRequest* url_request, 238 net::URLRequest* url_request,
238 bool* result) { 239 bool* result) {
239 ListValue contains_headers; 240 ListValue contains_headers;
240 for (size_t i = 0; i < tests.size(); ++i) { 241 for (size_t i = 0; i < tests.size(); ++i) {
241 scoped_ptr<DictionaryValue> temp(GetDictionaryFromArray(tests[i])); 242 scoped_ptr<DictionaryValue> temp(GetDictionaryFromArray(tests[i]));
242 ASSERT_TRUE(temp.get() != NULL); 243 ASSERT_TRUE(temp.get() != NULL);
243 contains_headers.Append(temp.release()); 244 contains_headers.Append(temp.release());
244 } 245 }
245 246
246 std::string error; 247 std::string error;
247 scoped_ptr<WebRequestConditionAttribute> attribute = 248 scoped_ptr<WebRequestConditionAttribute> attribute =
248 WebRequestConditionAttribute::Create(key, &contains_headers, &error); 249 WebRequestConditionAttribute::Create(key, &contains_headers, &error);
249 ASSERT_EQ("", error); 250 ASSERT_EQ("", error);
250 ASSERT_TRUE(attribute.get() != NULL); 251 ASSERT_TRUE(attribute.get() != NULL);
251 252
252 *result = attribute->IsFulfilled(WebRequestRule::RequestData( 253 *result = attribute->IsFulfilled(WebRequestRule::RequestData(
253 url_request, ON_HEADERS_RECEIVED, url_request->response_headers())); 254 url_request, stage, url_request->response_headers()));
254 } 255 }
255 256
256 } // namespace 257 } // namespace
257 258
259 // Here we test WebRequestConditionAttributeRequestHeaders for matching
260 // correctly against request headers. This test is not as extensive as
261 // "ResponseHeaders" (below), because the header-matching code is shared
262 // by both types of condition attributes, so it is enough to test it once.
263 TEST(WebRequestConditionAttributeTest, RequestHeaders) {
264 // Necessary for TestURLRequest.
265 MessageLoop message_loop(MessageLoop::TYPE_IO);
266
267 TestURLRequestContext context;
268 TestDelegate delegate;
269 TestURLRequest url_request(GURL("http://example.com"), // Dummy URL.
270 &delegate, &context);
271 url_request.SetExtraRequestHeaderByName(
272 "Custom-header", "custom/value", true /* overwrite */);
273 url_request.Start();
274 MessageLoop::current()->Run();
275
276 std::vector<std::vector<const std::string*> > tests;
277 bool result = false;
278
279 const RequestStage stage = ON_BEFORE_SEND_HEADERS;
280
281 // First set of test data -- passing conjunction.
282 const std::string kPassingCondition[] = {
283 keys::kNameContainsKey, "CuStOm", // Header names are case insensitive.
284 keys::kNameEqualsKey, "custom-header",
285 keys::kValueSuffixKey, "alue",
286 keys::kValuePrefixKey, "custom/value"
287 };
288 const size_t kPassingConditionSizes[] = { arraysize(kPassingCondition) };
289 GetArrayAsVector(kPassingCondition, kPassingConditionSizes, 1u, &tests);
290 // Positive filter, passing (conjunction of tests).
291 MatchAndCheck(tests, keys::kRequestHeadersKey, stage, &url_request, &result);
292 EXPECT_TRUE(result);
293 // Negative filter, failing (conjunction of tests).
294 MatchAndCheck(
295 tests, keys::kExcludeRequestHeadersKey, stage, &url_request, &result);
296 EXPECT_FALSE(result);
297
298 // Second set of test data -- failing disjunction.
299 const std::string kFailCondition[] = {
300 keys::kNameSuffixKey, "Custom", // Test 1.
301 keys::kNameEqualsKey, "ustom-valu", // Test 2.
302 keys::kValuePrefixKey, "custom ", // Test 3.
303 keys::kValueContainsKey, " value" // Test 4.
304 };
305 const size_t kFailConditionSizes[] = { 2u, 2u, 2u, 2u };
306 GetArrayAsVector(kFailCondition, kFailConditionSizes, 4u, &tests);
307 // Positive filter, failing (disjunction of tests).
308 MatchAndCheck(tests, keys::kRequestHeadersKey, stage, &url_request, &result);
309 EXPECT_FALSE(result);
310 // Negative filter, passing (disjunction of tests).
311 MatchAndCheck(
312 tests, keys::kExcludeRequestHeadersKey, stage, &url_request, &result);
313 EXPECT_TRUE(result);
314
315 // Third set of test data, corner case -- empty disjunction.
316 GetArrayAsVector(NULL, NULL, 0u, &tests);
317 // Positive filter, failing (no test to pass).
318 MatchAndCheck(tests, keys::kRequestHeadersKey, stage, &url_request, &result);
319 EXPECT_FALSE(result);
320 // Negative filter, passing (no test to fail).
321 MatchAndCheck(
322 tests, keys::kExcludeRequestHeadersKey, stage, &url_request, &result);
323 EXPECT_TRUE(result);
324
325 // Fourth set of test data, corner case -- empty conjunction.
326 const size_t kEmptyConjunctionSizes[] = { 0u };
327 GetArrayAsVector(NULL, kEmptyConjunctionSizes, 1u, &tests);
328 // Positive filter, passing (trivial test).
329 MatchAndCheck(tests, keys::kRequestHeadersKey, stage, &url_request, &result);
330 EXPECT_TRUE(result);
331 // Negative filter, failing.
332 MatchAndCheck(
333 tests, keys::kExcludeRequestHeadersKey, stage, &url_request, &result);
334 EXPECT_FALSE(result);
335 }
336
258 // Here we test WebRequestConditionAttributeResponseHeaders for: 337 // Here we test WebRequestConditionAttributeResponseHeaders for:
259 // 1. Correct implementation of prefix/suffix/contains/equals matching. 338 // 1. Correct implementation of prefix/suffix/contains/equals matching.
260 // 2. Performing logical disjunction (||) between multiple specifications. 339 // 2. Performing logical disjunction (||) between multiple specifications.
261 // 3. Negating the match in case of 'doesNotContainHeaders'. 340 // 3. Negating the match in case of 'doesNotContainHeaders'.
262 TEST(WebRequestConditionAttributeTest, Headers) { 341 TEST(WebRequestConditionAttributeTest, ResponseHeaders) {
263 // Necessary for TestURLRequest. 342 // Necessary for TestURLRequest.
264 MessageLoop message_loop(MessageLoop::TYPE_IO); 343 MessageLoop message_loop(MessageLoop::TYPE_IO);
265 344
266 net::TestServer test_server( 345 net::TestServer test_server(
267 net::TestServer::TYPE_HTTP, 346 net::TestServer::TYPE_HTTP,
268 net::TestServer::kLocalhost, 347 net::TestServer::kLocalhost,
269 FilePath(FILE_PATH_LITERAL( 348 FilePath(FILE_PATH_LITERAL(
270 "chrome/test/data/extensions/api_test/webrequest/declarative"))); 349 "chrome/test/data/extensions/api_test/webrequest/declarative")));
271 ASSERT_TRUE(test_server.Start()); 350 ASSERT_TRUE(test_server.Start());
272 351
273 TestURLRequestContext context; 352 TestURLRequestContext context;
274 TestDelegate delegate; 353 TestDelegate delegate;
275 TestURLRequest url_request(test_server.GetURL("files/headers.html"), 354 TestURLRequest url_request(test_server.GetURL("files/headers.html"),
276 &delegate, &context); 355 &delegate, &context);
277 url_request.Start(); 356 url_request.Start();
278 MessageLoop::current()->Run(); 357 MessageLoop::current()->Run();
279 358
280 // In all the tests below we assume that the server includes the headers 359 // In all the tests below we assume that the server includes the headers
281 // Custom-Header: custom/value 360 // Custom-Header: custom/value
282 // Custom-Header-B: valueA 361 // Custom-Header-B: valueA
283 // Custom-Header-B: valueB 362 // Custom-Header-B: valueB
284 // Custom-Header-C: valueC, valueD 363 // Custom-Header-C: valueC, valueD
285 // Custom-Header-D: 364 // Custom-Header-D:
286 // in the response, but does not include "Non-existing: void". 365 // in the response, but does not include "Non-existing: void".
287 366
288 std::vector< std::vector<const std::string*> > tests; 367 std::vector< std::vector<const std::string*> > tests;
289 bool result; 368 bool result;
290 369
370 const RequestStage stage = ON_HEADERS_RECEIVED;
371
291 // 1.a. -- All these tests should pass. 372 // 1.a. -- All these tests should pass.
292 const std::string kPassingCondition[] = { 373 const std::string kPassingCondition[] = {
293 keys::kNamePrefixKey, "Custom", 374 keys::kNamePrefixKey, "Custom",
294 keys::kNameSuffixKey, "m-header", // Header names are case insensitive. 375 keys::kNameSuffixKey, "m-header", // Header names are case insensitive.
295 keys::kValueContainsKey, "alu", 376 keys::kValueContainsKey, "alu",
296 keys::kValueEqualsKey, "custom/value" 377 keys::kValueEqualsKey, "custom/value"
297 }; 378 };
298 const size_t kPassingConditionSizes[] = { arraysize(kPassingCondition) }; 379 const size_t kPassingConditionSizes[] = { arraysize(kPassingCondition) };
299 GetArrayAsVector(kPassingCondition, kPassingConditionSizes, 1u, &tests); 380 GetArrayAsVector(kPassingCondition, kPassingConditionSizes, 1u, &tests);
300 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 381 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
301 EXPECT_TRUE(result); 382 EXPECT_TRUE(result);
302 383
303 // 1.b. -- None of the following tests in the discjunction should pass. 384 // 1.b. -- None of the following tests in the discjunction should pass.
304 const std::string kFailCondition[] = { 385 const std::string kFailCondition[] = {
305 keys::kNamePrefixKey, " Custom", // Test 1. 386 keys::kNamePrefixKey, " Custom", // Test 1.
306 keys::kNameContainsKey, " -", // Test 2. 387 keys::kNameContainsKey, " -", // Test 2.
307 keys::kValueSuffixKey, "alu", // Test 3. 388 keys::kValueSuffixKey, "alu", // Test 3.
308 keys::kValueEqualsKey, "custom" // Test 4. 389 keys::kValueEqualsKey, "custom" // Test 4.
309 }; 390 };
310 const size_t kFailConditionSizes[] = { 2u, 2u, 2u, 2u }; 391 const size_t kFailConditionSizes[] = { 2u, 2u, 2u, 2u };
311 GetArrayAsVector(kFailCondition, kFailConditionSizes, 4u, &tests); 392 GetArrayAsVector(kFailCondition, kFailConditionSizes, 4u, &tests);
312 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 393 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
313 EXPECT_FALSE(result); 394 EXPECT_FALSE(result);
314 395
315 // 1.c. -- This should fail (mixing name and value from different headers) 396 // 1.c. -- This should fail (mixing name and value from different headers)
316 const std::string kMixingCondition[] = { 397 const std::string kMixingCondition[] = {
317 keys::kNameSuffixKey, "Header-B", 398 keys::kNameSuffixKey, "Header-B",
318 keys::kValueEqualsKey, "custom/value" 399 keys::kValueEqualsKey, "custom/value"
319 }; 400 };
320 const size_t kMixingConditionSizes[] = { arraysize(kMixingCondition) }; 401 const size_t kMixingConditionSizes[] = { arraysize(kMixingCondition) };
321 GetArrayAsVector(kMixingCondition, kMixingConditionSizes, 1u, &tests); 402 GetArrayAsVector(kMixingCondition, kMixingConditionSizes, 1u, &tests);
322 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 403 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
323 EXPECT_FALSE(result); 404 EXPECT_FALSE(result);
324 405
325 // 1.d. -- Test handling multiple values for one header (both should pass). 406 // 1.d. -- Test handling multiple values for one header (both should pass).
326 const std::string kMoreValues1[] = { 407 const std::string kMoreValues1[] = {
327 keys::kNameEqualsKey, "Custom-header-b", 408 keys::kNameEqualsKey, "Custom-header-b",
328 keys::kValueEqualsKey, "valueA" 409 keys::kValueEqualsKey, "valueA"
329 }; 410 };
330 const size_t kMoreValues1Sizes[] = { arraysize(kMoreValues1) }; 411 const size_t kMoreValues1Sizes[] = { arraysize(kMoreValues1) };
331 GetArrayAsVector(kMoreValues1, kMoreValues1Sizes, 1u, &tests); 412 GetArrayAsVector(kMoreValues1, kMoreValues1Sizes, 1u, &tests);
332 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 413 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
333 EXPECT_TRUE(result); 414 EXPECT_TRUE(result);
334 const std::string kMoreValues2[] = { 415 const std::string kMoreValues2[] = {
335 keys::kNameEqualsKey, "Custom-header-b", 416 keys::kNameEqualsKey, "Custom-header-b",
336 keys::kValueEqualsKey, "valueB" 417 keys::kValueEqualsKey, "valueB"
337 }; 418 };
338 const size_t kMoreValues2Sizes[] = { arraysize(kMoreValues2) }; 419 const size_t kMoreValues2Sizes[] = { arraysize(kMoreValues2) };
339 GetArrayAsVector(kMoreValues2, kMoreValues2Sizes, 1u, &tests); 420 GetArrayAsVector(kMoreValues2, kMoreValues2Sizes, 1u, &tests);
340 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 421 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
341 EXPECT_TRUE(result); 422 EXPECT_TRUE(result);
342 423
343 // 1.e. -- This should fail as conjunction but pass as disjunction. 424 // 1.e. -- This should fail as conjunction but pass as disjunction.
344 const std::string kConflict[] = { 425 const std::string kConflict[] = {
345 keys::kNameSuffixKey, "Header", // True for some header. 426 keys::kNameSuffixKey, "Header", // True for some header.
346 keys::kNameContainsKey, "Header-B" // True for a different header. 427 keys::kNameContainsKey, "Header-B" // True for a different header.
347 }; 428 };
348 // First disjunction, no conflict. 429 // First disjunction, no conflict.
349 const size_t kNoConflictSizes[] = { 2u, 2u }; 430 const size_t kNoConflictSizes[] = { 2u, 2u };
350 GetArrayAsVector(kConflict, kNoConflictSizes, 2u, &tests); 431 GetArrayAsVector(kConflict, kNoConflictSizes, 2u, &tests);
351 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 432 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
352 EXPECT_TRUE(result); 433 EXPECT_TRUE(result);
353 // Then conjunction, conflict. 434 // Then conjunction, conflict.
354 const size_t kConflictSizes[] = { arraysize(kConflict) }; 435 const size_t kConflictSizes[] = { arraysize(kConflict) };
355 GetArrayAsVector(kConflict, kConflictSizes, 1u, &tests); 436 GetArrayAsVector(kConflict, kConflictSizes, 1u, &tests);
356 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 437 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
357 EXPECT_FALSE(result); 438 EXPECT_FALSE(result);
358 439
359 // 1.f. -- This should pass, checking for correct treatment of ',' in values. 440 // 1.f. -- This should pass, checking for correct treatment of ',' in values.
360 const std::string kComma[] = { 441 const std::string kComma[] = {
361 keys::kNameSuffixKey, "Header-C", 442 keys::kNameSuffixKey, "Header-C",
362 keys::kValueEqualsKey, "valueC, valueD" 443 keys::kValueEqualsKey, "valueC, valueD"
363 }; 444 };
364 const size_t kCommaSizes[] = { arraysize(kComma) }; 445 const size_t kCommaSizes[] = { arraysize(kComma) };
365 GetArrayAsVector(kComma, kCommaSizes, 1u, &tests); 446 GetArrayAsVector(kComma, kCommaSizes, 1u, &tests);
366 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 447 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
367 EXPECT_TRUE(result); 448 EXPECT_TRUE(result);
368 449
369 // 1.g. -- This should pass, empty values are values as well. 450 // 1.g. -- This should pass, empty values are values as well.
370 const std::string kEmpty[] = { 451 const std::string kEmpty[] = {
371 keys::kNameEqualsKey, "custom-header-d", 452 keys::kNameEqualsKey, "custom-header-d",
372 keys::kValueEqualsKey, "" 453 keys::kValueEqualsKey, ""
373 }; 454 };
374 const size_t kEmptySizes[] = { arraysize(kEmpty) }; 455 const size_t kEmptySizes[] = { arraysize(kEmpty) };
375 GetArrayAsVector(kEmpty, kEmptySizes, 1u, &tests); 456 GetArrayAsVector(kEmpty, kEmptySizes, 1u, &tests);
376 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 457 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
377 EXPECT_TRUE(result); 458 EXPECT_TRUE(result);
378 459
379 // 1.h. -- Values are case-sensitive, this should fail. 460 // 1.h. -- Values are case-sensitive, this should fail.
380 const std::string kLowercase[] = { 461 const std::string kLowercase[] = {
381 keys::kNameEqualsKey, "Custom-header-b", 462 keys::kNameEqualsKey, "Custom-header-b",
382 keys::kValuePrefixKey, "valueb", // valueb != valueB 463 keys::kValuePrefixKey, "valueb", // valueb != valueB
383 keys::kNameEqualsKey, "Custom-header-b", 464 keys::kNameEqualsKey, "Custom-header-b",
384 keys::kValueSuffixKey, "valueb", 465 keys::kValueSuffixKey, "valueb",
385 keys::kNameEqualsKey, "Custom-header-b", 466 keys::kNameEqualsKey, "Custom-header-b",
386 keys::kValueContainsKey, "valueb", 467 keys::kValueContainsKey, "valueb",
387 keys::kNameEqualsKey, "Custom-header-b", 468 keys::kNameEqualsKey, "Custom-header-b",
388 keys::kValueEqualsKey, "valueb" 469 keys::kValueEqualsKey, "valueb"
389 }; 470 };
390 const size_t kLowercaseSizes[] = { 4u, 4u, 4u, 4u }; // As disjunction. 471 const size_t kLowercaseSizes[] = { 4u, 4u, 4u, 4u }; // As disjunction.
391 GetArrayAsVector(kLowercase, kLowercaseSizes, 4u, &tests); 472 GetArrayAsVector(kLowercase, kLowercaseSizes, 4u, &tests);
392 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 473 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
393 EXPECT_FALSE(result); 474 EXPECT_FALSE(result);
394 475
395 // 1.i. -- Names are case-insensitive, this should pass. 476 // 1.i. -- Names are case-insensitive, this should pass.
396 const std::string kUppercase[] = { 477 const std::string kUppercase[] = {
397 keys::kNamePrefixKey, "CUSTOM-HEADER-B", 478 keys::kNamePrefixKey, "CUSTOM-HEADER-B",
398 keys::kNameSuffixKey, "CUSTOM-HEADER-B", 479 keys::kNameSuffixKey, "CUSTOM-HEADER-B",
399 keys::kNameEqualsKey, "CUSTOM-HEADER-B", 480 keys::kNameEqualsKey, "CUSTOM-HEADER-B",
400 keys::kNameContainsKey, "CUSTOM-HEADER-B" 481 keys::kNameContainsKey, "CUSTOM-HEADER-B"
401 }; 482 };
402 const size_t kUppercaseSizes[] = { arraysize(kUppercase) }; // Conjunction. 483 const size_t kUppercaseSizes[] = { arraysize(kUppercase) }; // Conjunction.
403 GetArrayAsVector(kUppercase, kUppercaseSizes, 1u, &tests); 484 GetArrayAsVector(kUppercase, kUppercaseSizes, 1u, &tests);
404 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 485 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
405 EXPECT_TRUE(result); 486 EXPECT_TRUE(result);
406 487
407 // 2.a. -- This should pass as disjunction, because one of the tests passes. 488 // 2.a. -- This should pass as disjunction, because one of the tests passes.
408 const std::string kDisjunction[] = { 489 const std::string kDisjunction[] = {
409 keys::kNamePrefixKey, "Non-existing", // This one fails. 490 keys::kNamePrefixKey, "Non-existing", // This one fails.
410 keys::kNameSuffixKey, "Non-existing", // This one fails. 491 keys::kNameSuffixKey, "Non-existing", // This one fails.
411 keys::kValueEqualsKey, "void", // This one fails. 492 keys::kValueEqualsKey, "void", // This one fails.
412 keys::kValueContainsKey, "alu" // This passes. 493 keys::kValueContainsKey, "alu" // This passes.
413 }; 494 };
414 const size_t kDisjunctionSizes[] = { 2u, 2u, 2u, 2u }; 495 const size_t kDisjunctionSizes[] = { 2u, 2u, 2u, 2u };
415 GetArrayAsVector(kDisjunction, kDisjunctionSizes, 4u, &tests); 496 GetArrayAsVector(kDisjunction, kDisjunctionSizes, 4u, &tests);
416 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); 497 MatchAndCheck(tests, keys::kResponseHeadersKey, stage, &url_request, &result);
417 EXPECT_TRUE(result); 498 EXPECT_TRUE(result);
418 499
419 // 3.a. -- This should pass. 500 // 3.a. -- This should pass.
420 const std::string kNonExistent[] = { 501 const std::string kNonExistent[] = {
421 keys::kNameEqualsKey, "Non-existing", 502 keys::kNameEqualsKey, "Non-existing",
422 keys::kValueEqualsKey, "void" 503 keys::kValueEqualsKey, "void"
423 }; 504 };
424 const size_t kNonExistentSizes[] = { arraysize(kNonExistent) }; 505 const size_t kNonExistentSizes[] = { arraysize(kNonExistent) };
425 GetArrayAsVector(kNonExistent, kNonExistentSizes, 1u, &tests); 506 GetArrayAsVector(kNonExistent, kNonExistentSizes, 1u, &tests);
426 MatchAndCheck(tests, keys::kExcludeResponseHeadersKey, &url_request, &result); 507 MatchAndCheck(
508 tests, keys::kExcludeResponseHeadersKey, stage, &url_request, &result);
427 EXPECT_TRUE(result); 509 EXPECT_TRUE(result);
428 510
429 // 3.b. -- This should fail. 511 // 3.b. -- This should fail.
430 const std::string kExisting[] = { 512 const std::string kExisting[] = {
431 keys::kNameEqualsKey, "custom-header-b", 513 keys::kNameEqualsKey, "custom-header-b",
432 keys::kValueEqualsKey, "valueB" 514 keys::kValueEqualsKey, "valueB"
433 }; 515 };
434 const size_t kExistingSize[] = { arraysize(kExisting) }; 516 const size_t kExistingSize[] = { arraysize(kExisting) };
435 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); 517 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests);
436 MatchAndCheck(tests, keys::kExcludeResponseHeadersKey, &url_request, &result); 518 MatchAndCheck(
519 tests, keys::kExcludeResponseHeadersKey, stage, &url_request, &result);
437 EXPECT_FALSE(result); 520 EXPECT_FALSE(result);
438 } 521 }
439 522
440 } // namespace extensions 523 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698