OLD | NEW |
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 #ifndef NET_COOKIES_COOKIE_STORE_UNITTEST_H_ | 5 #ifndef NET_COOKIES_COOKIE_STORE_UNITTEST_H_ |
6 #define NET_COOKIES_COOKIE_STORE_UNITTEST_H_ | 6 #define NET_COOKIES_COOKIE_STORE_UNITTEST_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 using base::Thread; | 36 using base::Thread; |
37 | 37 |
38 const int kTimeout = 1000; | 38 const int kTimeout = 1000; |
39 | 39 |
40 const char kValidCookieLine[] = "A=B; path=/"; | 40 const char kValidCookieLine[] = "A=B; path=/"; |
41 | 41 |
42 // The CookieStoreTestTraits must have the following members: | 42 // The CookieStoreTestTraits must have the following members: |
43 // struct CookieStoreTestTraits { | 43 // struct CookieStoreTestTraits { |
44 // // Factory function. Will be called at most once per test. | 44 // // Factory function. Will be called at most once per test. |
45 // static scoped_refptr<CookieStore> Create(); | 45 // static scoped_ptr<CookieStore> Create(); |
46 // | 46 // |
47 // // The cookie store supports cookies with the exclude_httponly() option. | 47 // // The cookie store supports cookies with the exclude_httponly() option. |
48 // static const bool supports_http_only; | 48 // static const bool supports_http_only; |
49 // | 49 // |
50 // // The cookie store is able to make the difference between the ".com" | 50 // // The cookie store is able to make the difference between the ".com" |
51 // // and the "com" domains. | 51 // // and the "com" domains. |
52 // static const bool supports_non_dotted_domains; | 52 // static const bool supports_non_dotted_domains; |
53 // | 53 // |
54 // // The cookie store does not fold domains with trailing dots (so "com." and | 54 // // The cookie store does not fold domains with trailing dots (so "com." and |
55 // "com" are different domains). | 55 // "com" are different domains). |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 int DeleteAll(CookieStore* cs) { | 271 int DeleteAll(CookieStore* cs) { |
272 DCHECK(cs); | 272 DCHECK(cs); |
273 ResultSavingCookieCallback<int> callback; | 273 ResultSavingCookieCallback<int> callback; |
274 cs->DeleteAllAsync(base::Bind(&ResultSavingCookieCallback<int>::Run, | 274 cs->DeleteAllAsync(base::Bind(&ResultSavingCookieCallback<int>::Run, |
275 base::Unretained(&callback))); | 275 base::Unretained(&callback))); |
276 callback.WaitUntilDone(); | 276 callback.WaitUntilDone(); |
277 return callback.result(); | 277 return callback.result(); |
278 } | 278 } |
279 | 279 |
280 // Returns the CookieStore for the test - each test only uses one CookieStore. | 280 // Returns the CookieStore for the test - each test only uses one CookieStore. |
281 scoped_refptr<CookieStore> GetCookieStore() { | 281 CookieStore* GetCookieStore() { |
282 if (!cookie_store_) | 282 if (!cookie_store_) |
283 cookie_store_ = CookieStoreTestTraits::Create(); | 283 cookie_store_ = CookieStoreTestTraits::Create(); |
284 return cookie_store_; | 284 return cookie_store_.get(); |
285 } | 285 } |
286 | 286 |
287 // Compares two cookie lines. | 287 // Compares two cookie lines. |
288 void MatchCookieLines(const std::string& line1, const std::string& line2) { | 288 void MatchCookieLines(const std::string& line1, const std::string& line2) { |
289 EXPECT_EQ(TokenizeCookieLine(line1), TokenizeCookieLine(line2)); | 289 EXPECT_EQ(TokenizeCookieLine(line1), TokenizeCookieLine(line2)); |
290 } | 290 } |
291 | 291 |
292 // Check the cookie line by polling until equality or a timeout is reached. | 292 // Check the cookie line by polling until equality or a timeout is reached. |
293 void MatchCookieLineWithTimeout(CookieStore* cs, | 293 void MatchCookieLineWithTimeout(CookieStore* cs, |
294 const GURL& url, | 294 const GURL& url, |
(...skipping 30 matching lines...) Expand all Loading... |
325 private: | 325 private: |
326 // Returns a set of strings of type "name=value". Fails in case of duplicate. | 326 // Returns a set of strings of type "name=value". Fails in case of duplicate. |
327 std::set<std::string> TokenizeCookieLine(const std::string& line) { | 327 std::set<std::string> TokenizeCookieLine(const std::string& line) { |
328 std::set<std::string> tokens; | 328 std::set<std::string> tokens; |
329 base::StringTokenizer tokenizer(line, " ;"); | 329 base::StringTokenizer tokenizer(line, " ;"); |
330 while (tokenizer.GetNext()) | 330 while (tokenizer.GetNext()) |
331 EXPECT_TRUE(tokens.insert(tokenizer.token()).second); | 331 EXPECT_TRUE(tokens.insert(tokenizer.token()).second); |
332 return tokens; | 332 return tokens; |
333 } | 333 } |
334 | 334 |
335 scoped_refptr<CookieStore> cookie_store_; | 335 scoped_ptr<CookieStore> cookie_store_; |
336 }; | 336 }; |
337 | 337 |
338 TYPED_TEST_CASE_P(CookieStoreTest); | 338 TYPED_TEST_CASE_P(CookieStoreTest); |
339 | 339 |
340 TYPED_TEST_P(CookieStoreTest, SetCookieWithDetailsAsync) { | 340 TYPED_TEST_P(CookieStoreTest, SetCookieWithDetailsAsync) { |
341 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 341 CookieStore* cs = this->GetCookieStore(); |
342 | 342 |
343 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 343 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
344 base::Time one_hour_ago = base::Time::Now() - base::TimeDelta::FromHours(1); | 344 base::Time one_hour_ago = base::Time::Now() - base::TimeDelta::FromHours(1); |
345 base::Time one_hour_from_now = | 345 base::Time one_hour_from_now = |
346 base::Time::Now() + base::TimeDelta::FromHours(1); | 346 base::Time::Now() + base::TimeDelta::FromHours(1); |
347 | 347 |
348 EXPECT_TRUE(this->SetCookieWithDetails( | 348 EXPECT_TRUE(this->SetCookieWithDetails( |
349 cs.get(), this->www_google_foo_.url(), "A", "B", std::string(), "/foo", | 349 cs, this->www_google_foo_.url(), "A", "B", std::string(), "/foo", |
350 one_hour_ago, one_hour_from_now, base::Time(), false, false, false, | 350 one_hour_ago, one_hour_from_now, base::Time(), false, false, false, |
351 COOKIE_PRIORITY_DEFAULT)); | 351 COOKIE_PRIORITY_DEFAULT)); |
352 // Note that for the creation time to be set exactly, without modification, | 352 // Note that for the creation time to be set exactly, without modification, |
353 // it must be different from the one set by the line above. | 353 // it must be different from the one set by the line above. |
354 EXPECT_TRUE(this->SetCookieWithDetails( | 354 EXPECT_TRUE(this->SetCookieWithDetails( |
355 cs.get(), this->www_google_bar_.url(), "C", "D", | 355 cs, this->www_google_bar_.url(), "C", "D", this->www_google_bar_.domain(), |
356 this->www_google_bar_.domain(), "/bar", two_hours_ago, base::Time(), | 356 "/bar", two_hours_ago, base::Time(), one_hour_ago, false, true, false, |
357 one_hour_ago, false, true, false, COOKIE_PRIORITY_DEFAULT)); | 357 COOKIE_PRIORITY_DEFAULT)); |
358 EXPECT_TRUE(this->SetCookieWithDetails( | 358 EXPECT_TRUE(this->SetCookieWithDetails( |
359 cs.get(), this->http_www_google_.url(), "E", "F", std::string(), | 359 cs, this->http_www_google_.url(), "E", "F", std::string(), std::string(), |
360 std::string(), base::Time(), base::Time(), base::Time(), true, false, | 360 base::Time(), base::Time(), base::Time(), true, false, false, |
361 false, COOKIE_PRIORITY_DEFAULT)); | 361 COOKIE_PRIORITY_DEFAULT)); |
362 | 362 |
363 // Test that malformed attributes fail to set the cookie. | 363 // Test that malformed attributes fail to set the cookie. |
364 EXPECT_FALSE(this->SetCookieWithDetails( | 364 EXPECT_FALSE(this->SetCookieWithDetails( |
365 cs.get(), this->www_google_foo_.url(), " A", "B", std::string(), "/foo", | 365 cs, this->www_google_foo_.url(), " A", "B", std::string(), "/foo", |
366 base::Time(), base::Time(), base::Time(), false, false, false, | 366 base::Time(), base::Time(), base::Time(), false, false, false, |
367 COOKIE_PRIORITY_DEFAULT)); | 367 COOKIE_PRIORITY_DEFAULT)); |
368 EXPECT_FALSE(this->SetCookieWithDetails( | 368 EXPECT_FALSE(this->SetCookieWithDetails( |
369 cs.get(), this->www_google_foo_.url(), "A;", "B", std::string(), "/foo", | 369 cs, this->www_google_foo_.url(), "A;", "B", std::string(), "/foo", |
370 base::Time(), base::Time(), base::Time(), false, false, false, | 370 base::Time(), base::Time(), base::Time(), false, false, false, |
371 COOKIE_PRIORITY_DEFAULT)); | 371 COOKIE_PRIORITY_DEFAULT)); |
372 EXPECT_FALSE(this->SetCookieWithDetails( | 372 EXPECT_FALSE(this->SetCookieWithDetails( |
373 cs.get(), this->www_google_foo_.url(), "A=", "B", std::string(), "/foo", | 373 cs, this->www_google_foo_.url(), "A=", "B", std::string(), "/foo", |
374 base::Time(), base::Time(), base::Time(), false, false, false, | 374 base::Time(), base::Time(), base::Time(), false, false, false, |
375 COOKIE_PRIORITY_DEFAULT)); | 375 COOKIE_PRIORITY_DEFAULT)); |
376 EXPECT_FALSE(this->SetCookieWithDetails( | 376 EXPECT_FALSE(this->SetCookieWithDetails( |
377 cs.get(), this->www_google_foo_.url(), "A", "B", "google.ozzzzzzle", | 377 cs, this->www_google_foo_.url(), "A", "B", "google.ozzzzzzle", "foo", |
378 "foo", base::Time(), base::Time(), base::Time(), false, false, false, | 378 base::Time(), base::Time(), base::Time(), false, false, false, |
379 COOKIE_PRIORITY_DEFAULT)); | 379 COOKIE_PRIORITY_DEFAULT)); |
380 EXPECT_FALSE(this->SetCookieWithDetails( | 380 EXPECT_FALSE(this->SetCookieWithDetails( |
381 cs.get(), this->www_google_foo_.url(), "A=", "B", std::string(), "foo", | 381 cs, this->www_google_foo_.url(), "A=", "B", std::string(), "foo", |
382 base::Time(), base::Time(), base::Time(), false, false, false, | 382 base::Time(), base::Time(), base::Time(), false, false, false, |
383 COOKIE_PRIORITY_DEFAULT)); | 383 COOKIE_PRIORITY_DEFAULT)); |
384 | 384 |
385 // Get all the cookies for a given URL, regardless of properties. This 'get()' | 385 // Get all the cookies for a given URL, regardless of properties. This 'get()' |
386 // operation shouldn't update the access time, as the test checks that the | 386 // operation shouldn't update the access time, as the test checks that the |
387 // access time is set properly upon creation. Updating the access time would | 387 // access time is set properly upon creation. Updating the access time would |
388 // make that difficult. | 388 // make that difficult. |
389 CookieOptions options; | 389 CookieOptions options; |
390 options.set_include_httponly(); | 390 options.set_include_httponly(); |
391 options.set_include_same_site(); | 391 options.set_include_same_site(); |
392 options.set_do_not_update_access_time(); | 392 options.set_do_not_update_access_time(); |
393 | 393 |
394 CookieList cookies = this->GetCookieListWithOptions( | 394 CookieList cookies = |
395 cs.get(), this->www_google_foo_.url(), options); | 395 this->GetCookieListWithOptions(cs, this->www_google_foo_.url(), options); |
396 CookieList::iterator it = cookies.begin(); | 396 CookieList::iterator it = cookies.begin(); |
397 | 397 |
398 ASSERT_TRUE(it != cookies.end()); | 398 ASSERT_TRUE(it != cookies.end()); |
399 EXPECT_EQ("A", it->Name()); | 399 EXPECT_EQ("A", it->Name()); |
400 EXPECT_EQ("B", it->Value()); | 400 EXPECT_EQ("B", it->Value()); |
401 EXPECT_EQ(this->www_google_foo_.host(), it->Domain()); | 401 EXPECT_EQ(this->www_google_foo_.host(), it->Domain()); |
402 EXPECT_EQ("/foo", it->Path()); | 402 EXPECT_EQ("/foo", it->Path()); |
403 EXPECT_EQ(one_hour_ago, it->CreationDate()); | 403 EXPECT_EQ(one_hour_ago, it->CreationDate()); |
404 EXPECT_TRUE(it->IsPersistent()); | 404 EXPECT_TRUE(it->IsPersistent()); |
405 // Expect expiration date is in the right range. Some cookie implementations | 405 // Expect expiration date is in the right range. Some cookie implementations |
406 // may not record it with millisecond accuracy. | 406 // may not record it with millisecond accuracy. |
407 EXPECT_LE((one_hour_from_now - it->ExpiryDate()).magnitude().InSeconds(), 5); | 407 EXPECT_LE((one_hour_from_now - it->ExpiryDate()).magnitude().InSeconds(), 5); |
408 // Some CookieStores don't store last access date. | 408 // Some CookieStores don't store last access date. |
409 if (!it->LastAccessDate().is_null()) | 409 if (!it->LastAccessDate().is_null()) |
410 EXPECT_EQ(one_hour_ago, it->LastAccessDate()); | 410 EXPECT_EQ(one_hour_ago, it->LastAccessDate()); |
411 EXPECT_FALSE(it->IsSecure()); | 411 EXPECT_FALSE(it->IsSecure()); |
412 EXPECT_FALSE(it->IsHttpOnly()); | 412 EXPECT_FALSE(it->IsHttpOnly()); |
413 | 413 |
414 ASSERT_TRUE(++it == cookies.end()); | 414 ASSERT_TRUE(++it == cookies.end()); |
415 | 415 |
416 // Verify that the cookie was set as 'httponly' by passing in a CookieOptions | 416 // Verify that the cookie was set as 'httponly' by passing in a CookieOptions |
417 // that excludes them and getting an empty result. | 417 // that excludes them and getting an empty result. |
418 if (TypeParam::supports_http_only) { | 418 if (TypeParam::supports_http_only) { |
419 cookies = this->GetCookieListWithOptions( | 419 cookies = this->GetCookieListWithOptions(cs, this->www_google_bar_.url(), |
420 cs.get(), this->www_google_bar_.url(), CookieOptions()); | 420 CookieOptions()); |
421 it = cookies.begin(); | 421 it = cookies.begin(); |
422 ASSERT_TRUE(it == cookies.end()); | 422 ASSERT_TRUE(it == cookies.end()); |
423 } | 423 } |
424 | 424 |
425 // Get the cookie using the wide open |options|: | 425 // Get the cookie using the wide open |options|: |
426 cookies = this->GetCookieListWithOptions( | 426 cookies = |
427 cs.get(), this->www_google_bar_.url(), options); | 427 this->GetCookieListWithOptions(cs, this->www_google_bar_.url(), options); |
428 it = cookies.begin(); | 428 it = cookies.begin(); |
429 | 429 |
430 ASSERT_TRUE(it != cookies.end()); | 430 ASSERT_TRUE(it != cookies.end()); |
431 EXPECT_EQ("C", it->Name()); | 431 EXPECT_EQ("C", it->Name()); |
432 EXPECT_EQ("D", it->Value()); | 432 EXPECT_EQ("D", it->Value()); |
433 EXPECT_EQ(this->www_google_bar_.Format(".%D"), it->Domain()); | 433 EXPECT_EQ(this->www_google_bar_.Format(".%D"), it->Domain()); |
434 EXPECT_EQ("/bar", it->Path()); | 434 EXPECT_EQ("/bar", it->Path()); |
435 EXPECT_EQ(two_hours_ago, it->CreationDate()); | 435 EXPECT_EQ(two_hours_ago, it->CreationDate()); |
436 EXPECT_FALSE(it->IsPersistent()); | 436 EXPECT_FALSE(it->IsPersistent()); |
437 // Some CookieStores don't store last access date. | 437 // Some CookieStores don't store last access date. |
438 if (!it->LastAccessDate().is_null()) | 438 if (!it->LastAccessDate().is_null()) |
439 EXPECT_EQ(one_hour_ago, it->LastAccessDate()); | 439 EXPECT_EQ(one_hour_ago, it->LastAccessDate()); |
440 EXPECT_FALSE(it->IsSecure()); | 440 EXPECT_FALSE(it->IsSecure()); |
441 EXPECT_TRUE(it->IsHttpOnly()); | 441 EXPECT_TRUE(it->IsHttpOnly()); |
442 | 442 |
443 EXPECT_TRUE(++it == cookies.end()); | 443 EXPECT_TRUE(++it == cookies.end()); |
444 | 444 |
445 cookies = this->GetCookieListWithOptions( | 445 cookies = this->GetCookieListWithOptions(cs, this->https_www_google_.url(), |
446 cs.get(), this->https_www_google_.url(), options); | 446 options); |
447 it = cookies.begin(); | 447 it = cookies.begin(); |
448 | 448 |
449 ASSERT_TRUE(it != cookies.end()); | 449 ASSERT_TRUE(it != cookies.end()); |
450 EXPECT_EQ("E", it->Name()); | 450 EXPECT_EQ("E", it->Name()); |
451 EXPECT_EQ("F", it->Value()); | 451 EXPECT_EQ("F", it->Value()); |
452 EXPECT_EQ("/", it->Path()); | 452 EXPECT_EQ("/", it->Path()); |
453 EXPECT_EQ(this->https_www_google_.host(), it->Domain()); | 453 EXPECT_EQ(this->https_www_google_.host(), it->Domain()); |
454 // Cookie should have its creation time set, and be in a reasonable range. | 454 // Cookie should have its creation time set, and be in a reasonable range. |
455 EXPECT_LE((base::Time::Now() - it->CreationDate()).magnitude().InMinutes(), | 455 EXPECT_LE((base::Time::Now() - it->CreationDate()).magnitude().InMinutes(), |
456 2); | 456 2); |
457 EXPECT_FALSE(it->IsPersistent()); | 457 EXPECT_FALSE(it->IsPersistent()); |
458 // Some CookieStores don't store last access date. | 458 // Some CookieStores don't store last access date. |
459 if (!it->LastAccessDate().is_null()) | 459 if (!it->LastAccessDate().is_null()) |
460 EXPECT_EQ(it->CreationDate(), it->LastAccessDate()); | 460 EXPECT_EQ(it->CreationDate(), it->LastAccessDate()); |
461 EXPECT_TRUE(it->IsSecure()); | 461 EXPECT_TRUE(it->IsSecure()); |
462 EXPECT_FALSE(it->IsHttpOnly()); | 462 EXPECT_FALSE(it->IsHttpOnly()); |
463 | 463 |
464 EXPECT_TRUE(++it == cookies.end()); | 464 EXPECT_TRUE(++it == cookies.end()); |
465 } | 465 } |
466 | 466 |
467 TYPED_TEST_P(CookieStoreTest, DomainTest) { | 467 TYPED_TEST_P(CookieStoreTest, DomainTest) { |
468 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 468 CookieStore* cs = this->GetCookieStore(); |
469 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B")); | 469 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), "A=B")); |
470 this->MatchCookieLines( | 470 this->MatchCookieLines("A=B", |
471 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 471 this->GetCookies(cs, this->http_www_google_.url())); |
472 EXPECT_TRUE( | 472 EXPECT_TRUE( |
473 this->SetCookie(cs.get(), this->http_www_google_.url(), | 473 this->SetCookie(cs, this->http_www_google_.url(), |
474 this->http_www_google_.Format("C=D; domain=.%D"))); | 474 this->http_www_google_.Format("C=D; domain=.%D"))); |
475 this->MatchCookieLines( | 475 this->MatchCookieLines("A=B; C=D", |
476 "A=B; C=D", this->GetCookies(cs.get(), this->http_www_google_.url())); | 476 this->GetCookies(cs, this->http_www_google_.url())); |
477 | 477 |
478 // Verify that A=B was set as a host cookie rather than a domain | 478 // Verify that A=B was set as a host cookie rather than a domain |
479 // cookie -- should not be accessible from a sub sub-domain. | 479 // cookie -- should not be accessible from a sub sub-domain. |
480 this->MatchCookieLines( | 480 this->MatchCookieLines( |
481 "C=D", | 481 "C=D", this->GetCookies( |
482 this->GetCookies( | 482 cs, GURL(this->http_www_google_.Format("http://foo.www.%D")))); |
483 cs.get(), GURL(this->http_www_google_.Format("http://foo.www.%D")))); | |
484 | 483 |
485 // Test and make sure we find domain cookies on the same domain. | 484 // Test and make sure we find domain cookies on the same domain. |
486 EXPECT_TRUE( | 485 EXPECT_TRUE( |
487 this->SetCookie(cs.get(), this->http_www_google_.url(), | 486 this->SetCookie(cs, this->http_www_google_.url(), |
488 this->http_www_google_.Format("E=F; domain=.www.%D"))); | 487 this->http_www_google_.Format("E=F; domain=.www.%D"))); |
489 this->MatchCookieLines( | 488 this->MatchCookieLines("A=B; C=D; E=F", |
490 "A=B; C=D; E=F", | 489 this->GetCookies(cs, this->http_www_google_.url())); |
491 this->GetCookies(cs.get(), this->http_www_google_.url())); | |
492 | 490 |
493 // Test setting a domain= that doesn't start w/ a dot, should | 491 // Test setting a domain= that doesn't start w/ a dot, should |
494 // treat it as a domain cookie, as if there was a pre-pended dot. | 492 // treat it as a domain cookie, as if there was a pre-pended dot. |
495 EXPECT_TRUE( | 493 EXPECT_TRUE( |
496 this->SetCookie(cs.get(), this->http_www_google_.url(), | 494 this->SetCookie(cs, this->http_www_google_.url(), |
497 this->http_www_google_.Format("G=H; domain=www.%D"))); | 495 this->http_www_google_.Format("G=H; domain=www.%D"))); |
498 this->MatchCookieLines( | 496 this->MatchCookieLines("A=B; C=D; E=F; G=H", |
499 "A=B; C=D; E=F; G=H", | 497 this->GetCookies(cs, this->http_www_google_.url())); |
500 this->GetCookies(cs.get(), this->http_www_google_.url())); | |
501 | 498 |
502 // Test domain enforcement, should fail on a sub-domain or something too deep. | 499 // Test domain enforcement, should fail on a sub-domain or something too deep. |
503 EXPECT_FALSE( | 500 EXPECT_FALSE( |
504 this->SetCookie(cs.get(), this->http_www_google_.url(), | 501 this->SetCookie(cs, this->http_www_google_.url(), |
505 this->http_www_google_.Format("I=J; domain=.%R"))); | 502 this->http_www_google_.Format("I=J; domain=.%R"))); |
506 this->MatchCookieLines( | 503 this->MatchCookieLines( |
507 std::string(), | 504 std::string(), |
508 this->GetCookies(cs.get(), | 505 this->GetCookies(cs, GURL(this->http_www_google_.Format("http://a.%R")))); |
509 GURL(this->http_www_google_.Format("http://a.%R")))); | |
510 EXPECT_FALSE(this->SetCookie( | 506 EXPECT_FALSE(this->SetCookie( |
511 cs.get(), this->http_www_google_.url(), | 507 cs, this->http_www_google_.url(), |
512 this->http_www_google_.Format("K=L; domain=.bla.www.%D"))); | 508 this->http_www_google_.Format("K=L; domain=.bla.www.%D"))); |
513 this->MatchCookieLines( | 509 this->MatchCookieLines( |
514 "C=D; E=F; G=H", | 510 "C=D; E=F; G=H", |
515 this->GetCookies( | 511 this->GetCookies( |
516 cs.get(), GURL(this->http_www_google_.Format("http://bla.www.%D")))); | 512 cs, GURL(this->http_www_google_.Format("http://bla.www.%D")))); |
517 this->MatchCookieLines( | 513 this->MatchCookieLines("A=B; C=D; E=F; G=H", |
518 "A=B; C=D; E=F; G=H", | 514 this->GetCookies(cs, this->http_www_google_.url())); |
519 this->GetCookies(cs.get(), this->http_www_google_.url())); | |
520 } | 515 } |
521 | 516 |
522 // FireFox recognizes domains containing trailing periods as valid. | 517 // FireFox recognizes domains containing trailing periods as valid. |
523 // IE and Safari do not. Assert the expected policy here. | 518 // IE and Safari do not. Assert the expected policy here. |
524 TYPED_TEST_P(CookieStoreTest, DomainWithTrailingDotTest) { | 519 TYPED_TEST_P(CookieStoreTest, DomainWithTrailingDotTest) { |
525 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 520 CookieStore* cs = this->GetCookieStore(); |
526 EXPECT_FALSE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 521 EXPECT_FALSE(this->SetCookie(cs, this->http_www_google_.url(), |
527 "a=1; domain=.www.google.com.")); | 522 "a=1; domain=.www.google.com.")); |
528 EXPECT_FALSE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 523 EXPECT_FALSE(this->SetCookie(cs, this->http_www_google_.url(), |
529 "b=2; domain=.www.google.com..")); | 524 "b=2; domain=.www.google.com..")); |
530 this->MatchCookieLines( | 525 this->MatchCookieLines(std::string(), |
531 std::string(), this->GetCookies(cs.get(), this->http_www_google_.url())); | 526 this->GetCookies(cs, this->http_www_google_.url())); |
532 } | 527 } |
533 | 528 |
534 // Test that cookies can bet set on higher level domains. | 529 // Test that cookies can bet set on higher level domains. |
535 TYPED_TEST_P(CookieStoreTest, ValidSubdomainTest) { | 530 TYPED_TEST_P(CookieStoreTest, ValidSubdomainTest) { |
536 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 531 CookieStore* cs = this->GetCookieStore(); |
537 GURL url_abcd("http://a.b.c.d.com"); | 532 GURL url_abcd("http://a.b.c.d.com"); |
538 GURL url_bcd("http://b.c.d.com"); | 533 GURL url_bcd("http://b.c.d.com"); |
539 GURL url_cd("http://c.d.com"); | 534 GURL url_cd("http://c.d.com"); |
540 GURL url_d("http://d.com"); | 535 GURL url_d("http://d.com"); |
541 | 536 |
542 EXPECT_TRUE(this->SetCookie(cs.get(), url_abcd, "a=1; domain=.a.b.c.d.com")); | 537 EXPECT_TRUE(this->SetCookie(cs, url_abcd, "a=1; domain=.a.b.c.d.com")); |
543 EXPECT_TRUE(this->SetCookie(cs.get(), url_abcd, "b=2; domain=.b.c.d.com")); | 538 EXPECT_TRUE(this->SetCookie(cs, url_abcd, "b=2; domain=.b.c.d.com")); |
544 EXPECT_TRUE(this->SetCookie(cs.get(), url_abcd, "c=3; domain=.c.d.com")); | 539 EXPECT_TRUE(this->SetCookie(cs, url_abcd, "c=3; domain=.c.d.com")); |
545 EXPECT_TRUE(this->SetCookie(cs.get(), url_abcd, "d=4; domain=.d.com")); | 540 EXPECT_TRUE(this->SetCookie(cs, url_abcd, "d=4; domain=.d.com")); |
546 | 541 |
547 this->MatchCookieLines("a=1; b=2; c=3; d=4", | 542 this->MatchCookieLines("a=1; b=2; c=3; d=4", this->GetCookies(cs, url_abcd)); |
548 this->GetCookies(cs.get(), url_abcd)); | 543 this->MatchCookieLines("b=2; c=3; d=4", this->GetCookies(cs, url_bcd)); |
549 this->MatchCookieLines("b=2; c=3; d=4", this->GetCookies(cs.get(), url_bcd)); | 544 this->MatchCookieLines("c=3; d=4", this->GetCookies(cs, url_cd)); |
550 this->MatchCookieLines("c=3; d=4", this->GetCookies(cs.get(), url_cd)); | 545 this->MatchCookieLines("d=4", this->GetCookies(cs, url_d)); |
551 this->MatchCookieLines("d=4", this->GetCookies(cs.get(), url_d)); | |
552 | 546 |
553 // Check that the same cookie can exist on different sub-domains. | 547 // Check that the same cookie can exist on different sub-domains. |
554 EXPECT_TRUE(this->SetCookie(cs.get(), url_bcd, "X=bcd; domain=.b.c.d.com")); | 548 EXPECT_TRUE(this->SetCookie(cs, url_bcd, "X=bcd; domain=.b.c.d.com")); |
555 EXPECT_TRUE(this->SetCookie(cs.get(), url_bcd, "X=cd; domain=.c.d.com")); | 549 EXPECT_TRUE(this->SetCookie(cs, url_bcd, "X=cd; domain=.c.d.com")); |
556 this->MatchCookieLines("b=2; c=3; d=4; X=bcd; X=cd", | 550 this->MatchCookieLines("b=2; c=3; d=4; X=bcd; X=cd", |
557 this->GetCookies(cs.get(), url_bcd)); | 551 this->GetCookies(cs, url_bcd)); |
558 this->MatchCookieLines("c=3; d=4; X=cd", this->GetCookies(cs.get(), url_cd)); | 552 this->MatchCookieLines("c=3; d=4; X=cd", this->GetCookies(cs, url_cd)); |
559 } | 553 } |
560 | 554 |
561 // Test that setting a cookie which specifies an invalid domain has | 555 // Test that setting a cookie which specifies an invalid domain has |
562 // no side-effect. An invalid domain in this context is one which does | 556 // no side-effect. An invalid domain in this context is one which does |
563 // not match the originating domain. | 557 // not match the originating domain. |
564 TYPED_TEST_P(CookieStoreTest, InvalidDomainTest) { | 558 TYPED_TEST_P(CookieStoreTest, InvalidDomainTest) { |
565 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 559 CookieStore* cs = this->GetCookieStore(); |
566 GURL url_foobar("http://foo.bar.com"); | 560 GURL url_foobar("http://foo.bar.com"); |
567 | 561 |
568 // More specific sub-domain than allowed. | 562 // More specific sub-domain than allowed. |
569 EXPECT_FALSE( | 563 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "a=1; domain=.yo.foo.bar.com")); |
570 this->SetCookie(cs.get(), url_foobar, "a=1; domain=.yo.foo.bar.com")); | 564 |
571 | 565 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "b=2; domain=.foo.com")); |
572 EXPECT_FALSE(this->SetCookie(cs.get(), url_foobar, "b=2; domain=.foo.com")); | 566 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "c=3; domain=.bar.foo.com")); |
573 EXPECT_FALSE( | |
574 this->SetCookie(cs.get(), url_foobar, "c=3; domain=.bar.foo.com")); | |
575 | 567 |
576 // Different TLD, but the rest is a substring. | 568 // Different TLD, but the rest is a substring. |
577 EXPECT_FALSE( | 569 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "d=4; domain=.foo.bar.com.net")); |
578 this->SetCookie(cs.get(), url_foobar, "d=4; domain=.foo.bar.com.net")); | |
579 | 570 |
580 // A substring that isn't really a parent domain. | 571 // A substring that isn't really a parent domain. |
581 EXPECT_FALSE(this->SetCookie(cs.get(), url_foobar, "e=5; domain=ar.com")); | 572 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "e=5; domain=ar.com")); |
582 | 573 |
583 // Completely invalid domains: | 574 // Completely invalid domains: |
584 EXPECT_FALSE(this->SetCookie(cs.get(), url_foobar, "f=6; domain=.")); | 575 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "f=6; domain=.")); |
585 EXPECT_FALSE(this->SetCookie(cs.get(), url_foobar, "g=7; domain=/")); | 576 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "g=7; domain=/")); |
586 EXPECT_FALSE( | 577 EXPECT_FALSE( |
587 this->SetCookie(cs.get(), url_foobar, "h=8; domain=http://foo.bar.com")); | 578 this->SetCookie(cs, url_foobar, "h=8; domain=http://foo.bar.com")); |
588 EXPECT_FALSE( | 579 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "i=9; domain=..foo.bar.com")); |
589 this->SetCookie(cs.get(), url_foobar, "i=9; domain=..foo.bar.com")); | 580 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "j=10; domain=..bar.com")); |
590 EXPECT_FALSE(this->SetCookie(cs.get(), url_foobar, "j=10; domain=..bar.com")); | |
591 | 581 |
592 // Make sure there isn't something quirky in the domain canonicalization | 582 // Make sure there isn't something quirky in the domain canonicalization |
593 // that supports full URL semantics. | 583 // that supports full URL semantics. |
594 EXPECT_FALSE( | 584 EXPECT_FALSE( |
595 this->SetCookie(cs.get(), url_foobar, "k=11; domain=.foo.bar.com?blah")); | 585 this->SetCookie(cs, url_foobar, "k=11; domain=.foo.bar.com?blah")); |
596 EXPECT_FALSE( | 586 EXPECT_FALSE( |
597 this->SetCookie(cs.get(), url_foobar, "l=12; domain=.foo.bar.com/blah")); | 587 this->SetCookie(cs, url_foobar, "l=12; domain=.foo.bar.com/blah")); |
598 EXPECT_FALSE( | 588 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "m=13; domain=.foo.bar.com:80")); |
599 this->SetCookie(cs.get(), url_foobar, "m=13; domain=.foo.bar.com:80")); | 589 EXPECT_FALSE(this->SetCookie(cs, url_foobar, "n=14; domain=.foo.bar.com:")); |
600 EXPECT_FALSE( | 590 EXPECT_FALSE( |
601 this->SetCookie(cs.get(), url_foobar, "n=14; domain=.foo.bar.com:")); | 591 this->SetCookie(cs, url_foobar, "o=15; domain=.foo.bar.com#sup")); |
602 EXPECT_FALSE( | 592 |
603 this->SetCookie(cs.get(), url_foobar, "o=15; domain=.foo.bar.com#sup")); | 593 this->MatchCookieLines(std::string(), this->GetCookies(cs, url_foobar)); |
604 | |
605 this->MatchCookieLines(std::string(), this->GetCookies(cs.get(), url_foobar)); | |
606 } | 594 } |
607 | 595 |
608 // Make sure the cookie code hasn't gotten its subdomain string handling | 596 // Make sure the cookie code hasn't gotten its subdomain string handling |
609 // reversed, missed a suffix check, etc. It's important here that the two | 597 // reversed, missed a suffix check, etc. It's important here that the two |
610 // hosts below have the same domain + registry. | 598 // hosts below have the same domain + registry. |
611 TYPED_TEST_P(CookieStoreTest, InvalidDomainSameDomainAndRegistry) { | 599 TYPED_TEST_P(CookieStoreTest, InvalidDomainSameDomainAndRegistry) { |
612 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 600 CookieStore* cs = this->GetCookieStore(); |
613 GURL url_foocom("http://foo.com.com"); | 601 GURL url_foocom("http://foo.com.com"); |
614 EXPECT_FALSE( | 602 EXPECT_FALSE(this->SetCookie(cs, url_foocom, "a=1; domain=.foo.com.com.com")); |
615 this->SetCookie(cs.get(), url_foocom, "a=1; domain=.foo.com.com.com")); | 603 this->MatchCookieLines(std::string(), this->GetCookies(cs, url_foocom)); |
616 this->MatchCookieLines(std::string(), this->GetCookies(cs.get(), url_foocom)); | |
617 } | 604 } |
618 | 605 |
619 // Setting the domain without a dot on a parent domain should add a domain | 606 // Setting the domain without a dot on a parent domain should add a domain |
620 // cookie. | 607 // cookie. |
621 TYPED_TEST_P(CookieStoreTest, DomainWithoutLeadingDotParentDomain) { | 608 TYPED_TEST_P(CookieStoreTest, DomainWithoutLeadingDotParentDomain) { |
622 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 609 CookieStore* cs = this->GetCookieStore(); |
623 GURL url_hosted("http://manage.hosted.filefront.com"); | 610 GURL url_hosted("http://manage.hosted.filefront.com"); |
624 GURL url_filefront("http://www.filefront.com"); | 611 GURL url_filefront("http://www.filefront.com"); |
625 EXPECT_TRUE( | 612 EXPECT_TRUE(this->SetCookie(cs, url_hosted, "sawAd=1; domain=filefront.com")); |
626 this->SetCookie(cs.get(), url_hosted, "sawAd=1; domain=filefront.com")); | 613 this->MatchCookieLines("sawAd=1", this->GetCookies(cs, url_hosted)); |
627 this->MatchCookieLines("sawAd=1", this->GetCookies(cs.get(), url_hosted)); | 614 this->MatchCookieLines("sawAd=1", this->GetCookies(cs, url_filefront)); |
628 this->MatchCookieLines("sawAd=1", this->GetCookies(cs.get(), url_filefront)); | |
629 } | 615 } |
630 | 616 |
631 // Even when the specified domain matches the domain of the URL exactly, treat | 617 // Even when the specified domain matches the domain of the URL exactly, treat |
632 // it as setting a domain cookie. | 618 // it as setting a domain cookie. |
633 TYPED_TEST_P(CookieStoreTest, DomainWithoutLeadingDotSameDomain) { | 619 TYPED_TEST_P(CookieStoreTest, DomainWithoutLeadingDotSameDomain) { |
634 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 620 CookieStore* cs = this->GetCookieStore(); |
635 GURL url("http://www.google.com"); | 621 GURL url("http://www.google.com"); |
636 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1; domain=www.google.com")); | 622 EXPECT_TRUE(this->SetCookie(cs, url, "a=1; domain=www.google.com")); |
637 this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url)); | 623 this->MatchCookieLines("a=1", this->GetCookies(cs, url)); |
638 this->MatchCookieLines( | 624 this->MatchCookieLines( |
639 "a=1", this->GetCookies(cs.get(), GURL("http://sub.www.google.com"))); | 625 "a=1", this->GetCookies(cs, GURL("http://sub.www.google.com"))); |
640 this->MatchCookieLines( | 626 this->MatchCookieLines( |
641 std::string(), | 627 std::string(), this->GetCookies(cs, GURL("http://something-else.com"))); |
642 this->GetCookies(cs.get(), GURL("http://something-else.com"))); | |
643 } | 628 } |
644 | 629 |
645 // Test that the domain specified in cookie string is treated case-insensitive | 630 // Test that the domain specified in cookie string is treated case-insensitive |
646 TYPED_TEST_P(CookieStoreTest, CaseInsensitiveDomainTest) { | 631 TYPED_TEST_P(CookieStoreTest, CaseInsensitiveDomainTest) { |
647 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 632 CookieStore* cs = this->GetCookieStore(); |
648 GURL url("http://www.google.com"); | 633 GURL url("http://www.google.com"); |
649 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1; domain=.GOOGLE.COM")); | 634 EXPECT_TRUE(this->SetCookie(cs, url, "a=1; domain=.GOOGLE.COM")); |
650 EXPECT_TRUE(this->SetCookie(cs.get(), url, "b=2; domain=.wWw.gOOgLE.coM")); | 635 EXPECT_TRUE(this->SetCookie(cs, url, "b=2; domain=.wWw.gOOgLE.coM")); |
651 this->MatchCookieLines("a=1; b=2", this->GetCookies(cs.get(), url)); | 636 this->MatchCookieLines("a=1; b=2", this->GetCookies(cs, url)); |
652 } | 637 } |
653 | 638 |
654 TYPED_TEST_P(CookieStoreTest, TestIpAddress) { | 639 TYPED_TEST_P(CookieStoreTest, TestIpAddress) { |
655 GURL url_ip("http://1.2.3.4/weee"); | 640 GURL url_ip("http://1.2.3.4/weee"); |
656 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 641 CookieStore* cs = this->GetCookieStore(); |
657 EXPECT_TRUE(this->SetCookie(cs.get(), url_ip, kValidCookieLine)); | 642 EXPECT_TRUE(this->SetCookie(cs, url_ip, kValidCookieLine)); |
658 this->MatchCookieLines("A=B", this->GetCookies(cs.get(), url_ip)); | 643 this->MatchCookieLines("A=B", this->GetCookies(cs, url_ip)); |
659 } | 644 } |
660 | 645 |
661 // IP addresses should not be able to set domain cookies. | 646 // IP addresses should not be able to set domain cookies. |
662 TYPED_TEST_P(CookieStoreTest, TestIpAddressNoDomainCookies) { | 647 TYPED_TEST_P(CookieStoreTest, TestIpAddressNoDomainCookies) { |
663 GURL url_ip("http://1.2.3.4/weee"); | 648 GURL url_ip("http://1.2.3.4/weee"); |
664 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 649 CookieStore* cs = this->GetCookieStore(); |
665 EXPECT_FALSE(this->SetCookie(cs.get(), url_ip, "b=2; domain=.1.2.3.4")); | 650 EXPECT_FALSE(this->SetCookie(cs, url_ip, "b=2; domain=.1.2.3.4")); |
666 EXPECT_FALSE(this->SetCookie(cs.get(), url_ip, "c=3; domain=.3.4")); | 651 EXPECT_FALSE(this->SetCookie(cs, url_ip, "c=3; domain=.3.4")); |
667 this->MatchCookieLines(std::string(), this->GetCookies(cs.get(), url_ip)); | 652 this->MatchCookieLines(std::string(), this->GetCookies(cs, url_ip)); |
668 // It should be allowed to set a cookie if domain= matches the IP address | 653 // It should be allowed to set a cookie if domain= matches the IP address |
669 // exactly. This matches IE/Firefox, even though it seems a bit wrong. | 654 // exactly. This matches IE/Firefox, even though it seems a bit wrong. |
670 EXPECT_FALSE(this->SetCookie(cs.get(), url_ip, "b=2; domain=1.2.3.3")); | 655 EXPECT_FALSE(this->SetCookie(cs, url_ip, "b=2; domain=1.2.3.3")); |
671 this->MatchCookieLines(std::string(), this->GetCookies(cs.get(), url_ip)); | 656 this->MatchCookieLines(std::string(), this->GetCookies(cs, url_ip)); |
672 EXPECT_TRUE(this->SetCookie(cs.get(), url_ip, "b=2; domain=1.2.3.4")); | 657 EXPECT_TRUE(this->SetCookie(cs, url_ip, "b=2; domain=1.2.3.4")); |
673 this->MatchCookieLines("b=2", this->GetCookies(cs.get(), url_ip)); | 658 this->MatchCookieLines("b=2", this->GetCookies(cs, url_ip)); |
674 } | 659 } |
675 | 660 |
676 // Test a TLD setting cookies on itself. | 661 // Test a TLD setting cookies on itself. |
677 TYPED_TEST_P(CookieStoreTest, TestTLD) { | 662 TYPED_TEST_P(CookieStoreTest, TestTLD) { |
678 if (!TypeParam::supports_non_dotted_domains) | 663 if (!TypeParam::supports_non_dotted_domains) |
679 return; | 664 return; |
680 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 665 CookieStore* cs = this->GetCookieStore(); |
681 GURL url("http://com/"); | 666 GURL url("http://com/"); |
682 | 667 |
683 // Allow setting on "com", (but only as a host cookie). | 668 // Allow setting on "com", (but only as a host cookie). |
684 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1")); | 669 EXPECT_TRUE(this->SetCookie(cs, url, "a=1")); |
685 // Domain cookies can't be set. | 670 // Domain cookies can't be set. |
686 EXPECT_FALSE(this->SetCookie(cs.get(), url, "b=2; domain=.com")); | 671 EXPECT_FALSE(this->SetCookie(cs, url, "b=2; domain=.com")); |
687 // Exact matches between the domain attribute and the host are treated as | 672 // Exact matches between the domain attribute and the host are treated as |
688 // host cookies, not domain cookies. | 673 // host cookies, not domain cookies. |
689 EXPECT_TRUE(this->SetCookie(cs.get(), url, "c=3; domain=com")); | 674 EXPECT_TRUE(this->SetCookie(cs, url, "c=3; domain=com")); |
690 | 675 |
691 this->MatchCookieLines("a=1; c=3", this->GetCookies(cs.get(), url)); | 676 this->MatchCookieLines("a=1; c=3", this->GetCookies(cs, url)); |
692 | 677 |
693 // Make sure they don't show up for a normal .com, they should be host, | 678 // Make sure they don't show up for a normal .com, they should be host, |
694 // domain, cookies. | 679 // domain, cookies. |
695 this->MatchCookieLines( | 680 this->MatchCookieLines( |
696 std::string(), | 681 std::string(), |
697 this->GetCookies(cs.get(), GURL("http://hopefully-no-cookies.com/"))); | 682 this->GetCookies(cs, GURL("http://hopefully-no-cookies.com/"))); |
698 this->MatchCookieLines(std::string(), | 683 this->MatchCookieLines(std::string(), |
699 this->GetCookies(cs.get(), GURL("http://.com/"))); | 684 this->GetCookies(cs, GURL("http://.com/"))); |
700 } | 685 } |
701 | 686 |
702 // http://com. should be treated the same as http://com. | 687 // http://com. should be treated the same as http://com. |
703 TYPED_TEST_P(CookieStoreTest, TestTLDWithTerminalDot) { | 688 TYPED_TEST_P(CookieStoreTest, TestTLDWithTerminalDot) { |
704 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 689 CookieStore* cs = this->GetCookieStore(); |
705 GURL url("http://com./index.html"); | 690 GURL url("http://com./index.html"); |
706 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1")); | 691 EXPECT_TRUE(this->SetCookie(cs, url, "a=1")); |
707 EXPECT_FALSE(this->SetCookie(cs.get(), url, "b=2; domain=.com.")); | 692 EXPECT_FALSE(this->SetCookie(cs, url, "b=2; domain=.com.")); |
708 this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url)); | 693 this->MatchCookieLines("a=1", this->GetCookies(cs, url)); |
709 this->MatchCookieLines( | 694 this->MatchCookieLines( |
710 std::string(), | 695 std::string(), |
711 this->GetCookies(cs.get(), GURL("http://hopefully-no-cookies.com./"))); | 696 this->GetCookies(cs, GURL("http://hopefully-no-cookies.com./"))); |
712 } | 697 } |
713 | 698 |
714 TYPED_TEST_P(CookieStoreTest, TestSubdomainSettingCookiesOnUnknownTLD) { | 699 TYPED_TEST_P(CookieStoreTest, TestSubdomainSettingCookiesOnUnknownTLD) { |
715 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 700 CookieStore* cs = this->GetCookieStore(); |
716 GURL url("http://a.b"); | 701 GURL url("http://a.b"); |
717 EXPECT_FALSE(this->SetCookie(cs.get(), url, "a=1; domain=.b")); | 702 EXPECT_FALSE(this->SetCookie(cs, url, "a=1; domain=.b")); |
718 EXPECT_FALSE(this->SetCookie(cs.get(), url, "b=2; domain=b")); | 703 EXPECT_FALSE(this->SetCookie(cs, url, "b=2; domain=b")); |
719 this->MatchCookieLines(std::string(), this->GetCookies(cs.get(), url)); | 704 this->MatchCookieLines(std::string(), this->GetCookies(cs, url)); |
720 } | 705 } |
721 | 706 |
722 TYPED_TEST_P(CookieStoreTest, TestSubdomainSettingCookiesOnKnownTLD) { | 707 TYPED_TEST_P(CookieStoreTest, TestSubdomainSettingCookiesOnKnownTLD) { |
723 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 708 CookieStore* cs = this->GetCookieStore(); |
724 GURL url("http://google.com"); | 709 GURL url("http://google.com"); |
725 EXPECT_FALSE(this->SetCookie(cs.get(), url, "a=1; domain=.com")); | 710 EXPECT_FALSE(this->SetCookie(cs, url, "a=1; domain=.com")); |
726 EXPECT_FALSE(this->SetCookie(cs.get(), url, "b=2; domain=com")); | 711 EXPECT_FALSE(this->SetCookie(cs, url, "b=2; domain=com")); |
727 this->MatchCookieLines(std::string(), this->GetCookies(cs.get(), url)); | 712 this->MatchCookieLines(std::string(), this->GetCookies(cs, url)); |
728 } | 713 } |
729 | 714 |
730 TYPED_TEST_P(CookieStoreTest, TestSubdomainSettingCookiesOnKnownDottedTLD) { | 715 TYPED_TEST_P(CookieStoreTest, TestSubdomainSettingCookiesOnKnownDottedTLD) { |
731 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 716 CookieStore* cs = this->GetCookieStore(); |
732 GURL url("http://google.co.uk"); | 717 GURL url("http://google.co.uk"); |
733 EXPECT_FALSE(this->SetCookie(cs.get(), url, "a=1; domain=.co.uk")); | 718 EXPECT_FALSE(this->SetCookie(cs, url, "a=1; domain=.co.uk")); |
734 EXPECT_FALSE(this->SetCookie(cs.get(), url, "b=2; domain=.uk")); | 719 EXPECT_FALSE(this->SetCookie(cs, url, "b=2; domain=.uk")); |
735 this->MatchCookieLines(std::string(), this->GetCookies(cs.get(), url)); | 720 this->MatchCookieLines(std::string(), this->GetCookies(cs, url)); |
736 this->MatchCookieLines( | 721 this->MatchCookieLines( |
737 std::string(), | 722 std::string(), this->GetCookies(cs, GURL("http://something-else.co.uk"))); |
738 this->GetCookies(cs.get(), GURL("http://something-else.co.uk"))); | 723 this->MatchCookieLines( |
739 this->MatchCookieLines( | 724 std::string(), this->GetCookies(cs, GURL("http://something-else.uk"))); |
740 std::string(), | |
741 this->GetCookies(cs.get(), GURL("http://something-else.uk"))); | |
742 } | 725 } |
743 | 726 |
744 // Intranet URLs should only be able to set host cookies. | 727 // Intranet URLs should only be able to set host cookies. |
745 TYPED_TEST_P(CookieStoreTest, TestSettingCookiesOnUnknownTLD) { | 728 TYPED_TEST_P(CookieStoreTest, TestSettingCookiesOnUnknownTLD) { |
746 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 729 CookieStore* cs = this->GetCookieStore(); |
747 GURL url("http://b"); | 730 GURL url("http://b"); |
748 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1")); | 731 EXPECT_TRUE(this->SetCookie(cs, url, "a=1")); |
749 EXPECT_FALSE(this->SetCookie(cs.get(), url, "b=2; domain=.b")); | 732 EXPECT_FALSE(this->SetCookie(cs, url, "b=2; domain=.b")); |
750 this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url)); | 733 this->MatchCookieLines("a=1", this->GetCookies(cs, url)); |
751 } | 734 } |
752 | 735 |
753 // Exact matches between the domain attribute and an intranet host are | 736 // Exact matches between the domain attribute and an intranet host are |
754 // treated as host cookies, not domain cookies. | 737 // treated as host cookies, not domain cookies. |
755 TYPED_TEST_P(CookieStoreTest, TestSettingCookiesWithHostDomainOnUnknownTLD) { | 738 TYPED_TEST_P(CookieStoreTest, TestSettingCookiesWithHostDomainOnUnknownTLD) { |
756 if (!TypeParam::supports_non_dotted_domains) | 739 if (!TypeParam::supports_non_dotted_domains) |
757 return; | 740 return; |
758 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 741 CookieStore* cs = this->GetCookieStore(); |
759 GURL url("http://b"); | 742 GURL url("http://b"); |
760 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1; domain=b")); | 743 EXPECT_TRUE(this->SetCookie(cs, url, "a=1; domain=b")); |
761 | 744 |
762 this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url)); | 745 this->MatchCookieLines("a=1", this->GetCookies(cs, url)); |
763 | 746 |
764 // Make sure it doesn't show up for an intranet subdomain, it should be | 747 // Make sure it doesn't show up for an intranet subdomain, it should be |
765 // a host, not domain, cookie. | 748 // a host, not domain, cookie. |
766 this->MatchCookieLines( | 749 this->MatchCookieLines( |
767 std::string(), | 750 std::string(), |
768 this->GetCookies(cs.get(), GURL("http://hopefully-no-cookies.b/"))); | 751 this->GetCookies(cs, GURL("http://hopefully-no-cookies.b/"))); |
769 this->MatchCookieLines(std::string(), | 752 this->MatchCookieLines(std::string(), |
770 this->GetCookies(cs.get(), GURL("http://.b/"))); | 753 this->GetCookies(cs, GURL("http://.b/"))); |
771 } | 754 } |
772 | 755 |
773 // Test reading/writing cookies when the domain ends with a period, | 756 // Test reading/writing cookies when the domain ends with a period, |
774 // as in "www.google.com." | 757 // as in "www.google.com." |
775 TYPED_TEST_P(CookieStoreTest, TestHostEndsWithDot) { | 758 TYPED_TEST_P(CookieStoreTest, TestHostEndsWithDot) { |
776 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 759 CookieStore* cs = this->GetCookieStore(); |
777 GURL url("http://www.google.com"); | 760 GURL url("http://www.google.com"); |
778 GURL url_with_dot("http://www.google.com."); | 761 GURL url_with_dot("http://www.google.com."); |
779 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1")); | 762 EXPECT_TRUE(this->SetCookie(cs, url, "a=1")); |
780 this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url)); | 763 this->MatchCookieLines("a=1", this->GetCookies(cs, url)); |
781 | 764 |
782 // Do not share cookie space with the dot version of domain. | 765 // Do not share cookie space with the dot version of domain. |
783 // Note: this is not what FireFox does, but it _is_ what IE+Safari do. | 766 // Note: this is not what FireFox does, but it _is_ what IE+Safari do. |
784 if (TypeParam::preserves_trailing_dots) { | 767 if (TypeParam::preserves_trailing_dots) { |
785 EXPECT_FALSE( | 768 EXPECT_FALSE(this->SetCookie(cs, url, "b=2; domain=.www.google.com.")); |
786 this->SetCookie(cs.get(), url, "b=2; domain=.www.google.com.")); | 769 this->MatchCookieLines("a=1", this->GetCookies(cs, url)); |
787 this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url)); | 770 EXPECT_TRUE(this->SetCookie(cs, url_with_dot, "b=2; domain=.google.com.")); |
788 EXPECT_TRUE( | 771 this->MatchCookieLines("b=2", this->GetCookies(cs, url_with_dot)); |
789 this->SetCookie(cs.get(), url_with_dot, "b=2; domain=.google.com.")); | |
790 this->MatchCookieLines("b=2", this->GetCookies(cs.get(), url_with_dot)); | |
791 } else { | 772 } else { |
792 EXPECT_TRUE( | 773 EXPECT_TRUE(this->SetCookie(cs, url, "b=2; domain=.www.google.com.")); |
793 this->SetCookie(cs.get(), url, "b=2; domain=.www.google.com.")); | 774 this->MatchCookieLines("a=1 b=2", this->GetCookies(cs, url)); |
794 this->MatchCookieLines("a=1 b=2", this->GetCookies(cs.get(), url)); | |
795 // Setting this cookie should fail, since the trailing dot on the domain | 775 // Setting this cookie should fail, since the trailing dot on the domain |
796 // isn't preserved, and then the domain mismatches the URL. | 776 // isn't preserved, and then the domain mismatches the URL. |
797 EXPECT_FALSE( | 777 EXPECT_FALSE(this->SetCookie(cs, url_with_dot, "b=2; domain=.google.com.")); |
798 this->SetCookie(cs.get(), url_with_dot, "b=2; domain=.google.com.")); | |
799 } | 778 } |
800 | 779 |
801 // Make sure there weren't any side effects. | 780 // Make sure there weren't any side effects. |
802 this->MatchCookieLines( | 781 this->MatchCookieLines( |
803 std::string(), | 782 std::string(), |
804 this->GetCookies(cs.get(), GURL("http://hopefully-no-cookies.com/"))); | 783 this->GetCookies(cs, GURL("http://hopefully-no-cookies.com/"))); |
805 this->MatchCookieLines(std::string(), | 784 this->MatchCookieLines(std::string(), |
806 this->GetCookies(cs.get(), GURL("http://.com/"))); | 785 this->GetCookies(cs, GURL("http://.com/"))); |
807 } | 786 } |
808 | 787 |
809 TYPED_TEST_P(CookieStoreTest, InvalidScheme) { | 788 TYPED_TEST_P(CookieStoreTest, InvalidScheme) { |
810 if (!TypeParam::filters_schemes) | 789 if (!TypeParam::filters_schemes) |
811 return; | 790 return; |
812 | 791 |
813 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 792 CookieStore* cs = this->GetCookieStore(); |
814 EXPECT_FALSE( | 793 EXPECT_FALSE(this->SetCookie(cs, this->ftp_google_.url(), kValidCookieLine)); |
815 this->SetCookie(cs.get(), this->ftp_google_.url(), kValidCookieLine)); | |
816 } | 794 } |
817 | 795 |
818 TYPED_TEST_P(CookieStoreTest, InvalidScheme_Read) { | 796 TYPED_TEST_P(CookieStoreTest, InvalidScheme_Read) { |
819 if (!TypeParam::filters_schemes) | 797 if (!TypeParam::filters_schemes) |
820 return; | 798 return; |
821 | 799 |
822 const std::string kValidDomainCookieLine = | 800 const std::string kValidDomainCookieLine = |
823 this->http_www_google_.Format("A=B; path=/; domain=%D"); | 801 this->http_www_google_.Format("A=B; path=/; domain=%D"); |
824 | 802 |
825 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 803 CookieStore* cs = this->GetCookieStore(); |
826 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 804 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), |
827 kValidDomainCookieLine)); | 805 kValidDomainCookieLine)); |
828 this->MatchCookieLines(std::string(), | 806 this->MatchCookieLines(std::string(), |
829 this->GetCookies(cs.get(), this->ftp_google_.url())); | 807 this->GetCookies(cs, this->ftp_google_.url())); |
830 EXPECT_EQ(0U, this->GetCookieListWithOptions( | 808 EXPECT_EQ(0U, this->GetCookieListWithOptions(cs, this->ftp_google_.url(), |
831 cs.get(), this->ftp_google_.url(), CookieOptions()) | 809 CookieOptions()) |
832 .size()); | 810 .size()); |
833 } | 811 } |
834 | 812 |
835 TYPED_TEST_P(CookieStoreTest, PathTest) { | 813 TYPED_TEST_P(CookieStoreTest, PathTest) { |
836 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 814 CookieStore* cs = this->GetCookieStore(); |
837 std::string url("http://www.google.izzle"); | 815 std::string url("http://www.google.izzle"); |
838 EXPECT_TRUE(this->SetCookie(cs.get(), GURL(url), "A=B; path=/wee")); | 816 EXPECT_TRUE(this->SetCookie(cs, GURL(url), "A=B; path=/wee")); |
839 this->MatchCookieLines("A=B", this->GetCookies(cs.get(), GURL(url + "/wee"))); | 817 this->MatchCookieLines("A=B", this->GetCookies(cs, GURL(url + "/wee"))); |
840 this->MatchCookieLines("A=B", | 818 this->MatchCookieLines("A=B", this->GetCookies(cs, GURL(url + "/wee/"))); |
841 this->GetCookies(cs.get(), GURL(url + "/wee/"))); | 819 this->MatchCookieLines("A=B", this->GetCookies(cs, GURL(url + "/wee/war"))); |
842 this->MatchCookieLines("A=B", | |
843 this->GetCookies(cs.get(), GURL(url + "/wee/war"))); | |
844 this->MatchCookieLines( | 820 this->MatchCookieLines( |
845 "A=B", this->GetCookies(cs.get(), GURL(url + "/wee/war/more/more"))); | 821 "A=B", this->GetCookies(cs, GURL(url + "/wee/war/more/more"))); |
846 if (!TypeParam::has_path_prefix_bug) | 822 if (!TypeParam::has_path_prefix_bug) |
847 this->MatchCookieLines(std::string(), | 823 this->MatchCookieLines(std::string(), |
848 this->GetCookies(cs.get(), GURL(url + "/weehee"))); | 824 this->GetCookies(cs, GURL(url + "/weehee"))); |
849 this->MatchCookieLines(std::string(), | 825 this->MatchCookieLines(std::string(), this->GetCookies(cs, GURL(url + "/"))); |
850 this->GetCookies(cs.get(), GURL(url + "/"))); | |
851 | 826 |
852 // If we add a 0 length path, it should default to / | 827 // If we add a 0 length path, it should default to / |
853 EXPECT_TRUE(this->SetCookie(cs.get(), GURL(url), "A=C; path=")); | 828 EXPECT_TRUE(this->SetCookie(cs, GURL(url), "A=C; path=")); |
854 this->MatchCookieLines("A=B; A=C", | 829 this->MatchCookieLines("A=B; A=C", this->GetCookies(cs, GURL(url + "/wee"))); |
855 this->GetCookies(cs.get(), GURL(url + "/wee"))); | 830 this->MatchCookieLines("A=C", this->GetCookies(cs, GURL(url + "/"))); |
856 this->MatchCookieLines("A=C", this->GetCookies(cs.get(), GURL(url + "/"))); | |
857 } | 831 } |
858 | 832 |
859 TYPED_TEST_P(CookieStoreTest, EmptyExpires) { | 833 TYPED_TEST_P(CookieStoreTest, EmptyExpires) { |
860 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 834 CookieStore* cs = this->GetCookieStore(); |
861 CookieOptions options; | 835 CookieOptions options; |
862 if (!TypeParam::supports_http_only) | 836 if (!TypeParam::supports_http_only) |
863 options.set_include_httponly(); | 837 options.set_include_httponly(); |
864 GURL url("http://www7.ipdl.inpit.go.jp/Tokujitu/tjkta.ipdl?N0000=108"); | 838 GURL url("http://www7.ipdl.inpit.go.jp/Tokujitu/tjkta.ipdl?N0000=108"); |
865 std::string set_cookie_line = | 839 std::string set_cookie_line = |
866 "ACSTM=20130308043820420042; path=/; domain=ipdl.inpit.go.jp; Expires="; | 840 "ACSTM=20130308043820420042; path=/; domain=ipdl.inpit.go.jp; Expires="; |
867 std::string cookie_line = "ACSTM=20130308043820420042"; | 841 std::string cookie_line = "ACSTM=20130308043820420042"; |
868 | 842 |
869 this->SetCookieWithOptions(cs.get(), url, set_cookie_line, options); | 843 this->SetCookieWithOptions(cs, url, set_cookie_line, options); |
870 this->MatchCookieLines(cookie_line, | 844 this->MatchCookieLines(cookie_line, |
871 this->GetCookiesWithOptions(cs.get(), url, options)); | 845 this->GetCookiesWithOptions(cs, url, options)); |
872 | 846 |
873 options.set_server_time(base::Time::Now() - base::TimeDelta::FromHours(1)); | 847 options.set_server_time(base::Time::Now() - base::TimeDelta::FromHours(1)); |
874 this->SetCookieWithOptions(cs.get(), url, set_cookie_line, options); | 848 this->SetCookieWithOptions(cs, url, set_cookie_line, options); |
875 this->MatchCookieLines(cookie_line, | 849 this->MatchCookieLines(cookie_line, |
876 this->GetCookiesWithOptions(cs.get(), url, options)); | 850 this->GetCookiesWithOptions(cs, url, options)); |
877 | 851 |
878 options.set_server_time(base::Time::Now() + base::TimeDelta::FromHours(1)); | 852 options.set_server_time(base::Time::Now() + base::TimeDelta::FromHours(1)); |
879 this->SetCookieWithOptions(cs.get(), url, set_cookie_line, options); | 853 this->SetCookieWithOptions(cs, url, set_cookie_line, options); |
880 this->MatchCookieLines(cookie_line, | 854 this->MatchCookieLines(cookie_line, |
881 this->GetCookiesWithOptions(cs.get(), url, options)); | 855 this->GetCookiesWithOptions(cs, url, options)); |
882 } | 856 } |
883 | 857 |
884 TYPED_TEST_P(CookieStoreTest, HttpOnlyTest) { | 858 TYPED_TEST_P(CookieStoreTest, HttpOnlyTest) { |
885 if (!TypeParam::supports_http_only) | 859 if (!TypeParam::supports_http_only) |
886 return; | 860 return; |
887 | 861 |
888 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 862 CookieStore* cs = this->GetCookieStore(); |
889 CookieOptions options; | 863 CookieOptions options; |
890 options.set_include_httponly(); | 864 options.set_include_httponly(); |
891 | 865 |
892 // Create a httponly cookie. | 866 // Create a httponly cookie. |
893 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), | 867 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->http_www_google_.url(), |
894 "A=B; httponly", options)); | 868 "A=B; httponly", options)); |
895 | 869 |
896 // Check httponly read protection. | 870 // Check httponly read protection. |
897 this->MatchCookieLines( | 871 this->MatchCookieLines(std::string(), |
898 std::string(), this->GetCookies(cs.get(), this->http_www_google_.url())); | 872 this->GetCookies(cs, this->http_www_google_.url())); |
899 this->MatchCookieLines( | 873 this->MatchCookieLines("A=B", this->GetCookiesWithOptions( |
900 "A=B", this->GetCookiesWithOptions(cs.get(), this->http_www_google_.url(), | 874 cs, this->http_www_google_.url(), options)); |
901 options)); | |
902 | 875 |
903 // Check httponly overwrite protection. | 876 // Check httponly overwrite protection. |
904 EXPECT_FALSE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=C")); | 877 EXPECT_FALSE(this->SetCookie(cs, this->http_www_google_.url(), "A=C")); |
905 this->MatchCookieLines( | 878 this->MatchCookieLines(std::string(), |
906 std::string(), this->GetCookies(cs.get(), this->http_www_google_.url())); | 879 this->GetCookies(cs, this->http_www_google_.url())); |
907 this->MatchCookieLines( | 880 this->MatchCookieLines("A=B", this->GetCookiesWithOptions( |
908 "A=B", this->GetCookiesWithOptions(cs.get(), this->http_www_google_.url(), | 881 cs, this->http_www_google_.url(), options)); |
909 options)); | 882 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->http_www_google_.url(), |
910 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), | |
911 "A=C", options)); | 883 "A=C", options)); |
912 this->MatchCookieLines( | 884 this->MatchCookieLines("A=C", |
913 "A=C", this->GetCookies(cs.get(), this->http_www_google_.url())); | 885 this->GetCookies(cs, this->http_www_google_.url())); |
914 | 886 |
915 // Check httponly create protection. | 887 // Check httponly create protection. |
916 EXPECT_FALSE( | 888 EXPECT_FALSE( |
917 this->SetCookie(cs.get(), this->http_www_google_.url(), "B=A; httponly")); | 889 this->SetCookie(cs, this->http_www_google_.url(), "B=A; httponly")); |
| 890 this->MatchCookieLines("A=C", this->GetCookiesWithOptions( |
| 891 cs, this->http_www_google_.url(), options)); |
| 892 EXPECT_TRUE(this->SetCookieWithOptions(cs, this->http_www_google_.url(), |
| 893 "B=A; httponly", options)); |
918 this->MatchCookieLines( | 894 this->MatchCookieLines( |
919 "A=C", this->GetCookiesWithOptions(cs.get(), this->http_www_google_.url(), | 895 "A=C; B=A", |
920 options)); | 896 this->GetCookiesWithOptions(cs, this->http_www_google_.url(), options)); |
921 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), this->http_www_google_.url(), | 897 this->MatchCookieLines("A=C", |
922 "B=A; httponly", options)); | 898 this->GetCookies(cs, this->http_www_google_.url())); |
923 this->MatchCookieLines("A=C; B=A", | |
924 this->GetCookiesWithOptions( | |
925 cs.get(), this->http_www_google_.url(), options)); | |
926 this->MatchCookieLines( | |
927 "A=C", this->GetCookies(cs.get(), this->http_www_google_.url())); | |
928 } | 899 } |
929 | 900 |
930 TYPED_TEST_P(CookieStoreTest, TestCookieDeletion) { | 901 TYPED_TEST_P(CookieStoreTest, TestCookieDeletion) { |
931 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 902 CookieStore* cs = this->GetCookieStore(); |
932 | 903 |
933 // Create a session cookie. | 904 // Create a session cookie. |
934 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 905 EXPECT_TRUE( |
935 kValidCookieLine)); | 906 this->SetCookie(cs, this->http_www_google_.url(), kValidCookieLine)); |
936 this->MatchCookieLines( | 907 this->MatchCookieLines("A=B", |
937 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 908 this->GetCookies(cs, this->http_www_google_.url())); |
938 // Delete it via Max-Age. | 909 // Delete it via Max-Age. |
939 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 910 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), |
940 std::string(kValidCookieLine) + "; max-age=0")); | 911 std::string(kValidCookieLine) + "; max-age=0")); |
941 this->MatchCookieLineWithTimeout(cs.get(), this->http_www_google_.url(), | 912 this->MatchCookieLineWithTimeout(cs, this->http_www_google_.url(), |
942 std::string()); | 913 std::string()); |
943 | 914 |
944 // Create a session cookie. | 915 // Create a session cookie. |
945 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 916 EXPECT_TRUE( |
946 kValidCookieLine)); | 917 this->SetCookie(cs, this->http_www_google_.url(), kValidCookieLine)); |
947 this->MatchCookieLines( | 918 this->MatchCookieLines("A=B", |
948 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 919 this->GetCookies(cs, this->http_www_google_.url())); |
949 // Delete it via Expires. | 920 // Delete it via Expires. |
950 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 921 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), |
951 std::string(kValidCookieLine) + | 922 std::string(kValidCookieLine) + |
952 "; expires=Mon, 18-Apr-1977 22:50:13 GMT")); | 923 "; expires=Mon, 18-Apr-1977 22:50:13 GMT")); |
953 this->MatchCookieLines( | 924 this->MatchCookieLines(std::string(), |
954 std::string(), this->GetCookies(cs.get(), this->http_www_google_.url())); | 925 this->GetCookies(cs, this->http_www_google_.url())); |
955 | 926 |
956 // Create a persistent cookie. | 927 // Create a persistent cookie. |
957 EXPECT_TRUE(this->SetCookie( | 928 EXPECT_TRUE(this->SetCookie( |
958 cs.get(), this->http_www_google_.url(), | 929 cs, this->http_www_google_.url(), |
959 std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-22 22:50:13 GMT")); | 930 std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-22 22:50:13 GMT")); |
960 | 931 |
961 this->MatchCookieLines( | 932 this->MatchCookieLines("A=B", |
962 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 933 this->GetCookies(cs, this->http_www_google_.url())); |
963 // Delete it via Max-Age. | 934 // Delete it via Max-Age. |
964 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 935 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), |
965 std::string(kValidCookieLine) + "; max-age=0")); | 936 std::string(kValidCookieLine) + "; max-age=0")); |
966 this->MatchCookieLineWithTimeout(cs.get(), this->http_www_google_.url(), | 937 this->MatchCookieLineWithTimeout(cs, this->http_www_google_.url(), |
967 std::string()); | 938 std::string()); |
968 | 939 |
969 // Create a persistent cookie. | 940 // Create a persistent cookie. |
970 EXPECT_TRUE(this->SetCookie( | 941 EXPECT_TRUE(this->SetCookie( |
971 cs.get(), this->http_www_google_.url(), | 942 cs, this->http_www_google_.url(), |
972 std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-22 22:50:13 GMT")); | 943 std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-22 22:50:13 GMT")); |
973 this->MatchCookieLines( | 944 this->MatchCookieLines("A=B", |
974 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 945 this->GetCookies(cs, this->http_www_google_.url())); |
975 // Delete it via Expires. | 946 // Delete it via Expires. |
976 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 947 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), |
977 std::string(kValidCookieLine) + | 948 std::string(kValidCookieLine) + |
978 "; expires=Mon, 18-Apr-1977 22:50:13 GMT")); | 949 "; expires=Mon, 18-Apr-1977 22:50:13 GMT")); |
979 this->MatchCookieLines( | 950 this->MatchCookieLines(std::string(), |
980 std::string(), this->GetCookies(cs.get(), this->http_www_google_.url())); | 951 this->GetCookies(cs, this->http_www_google_.url())); |
981 | 952 |
982 // Create a persistent cookie. | 953 // Create a persistent cookie. |
983 EXPECT_TRUE(this->SetCookie( | 954 EXPECT_TRUE(this->SetCookie( |
984 cs.get(), this->http_www_google_.url(), | 955 cs, this->http_www_google_.url(), |
985 std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-22 22:50:13 GMT")); | 956 std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-22 22:50:13 GMT")); |
986 this->MatchCookieLines( | 957 this->MatchCookieLines("A=B", |
987 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 958 this->GetCookies(cs, this->http_www_google_.url())); |
988 // Check that it is not deleted with significant enough clock skew. | 959 // Check that it is not deleted with significant enough clock skew. |
989 base::Time server_time; | 960 base::Time server_time; |
990 EXPECT_TRUE(base::Time::FromString("Sun, 17-Apr-1977 22:50:13 GMT", | 961 EXPECT_TRUE(base::Time::FromString("Sun, 17-Apr-1977 22:50:13 GMT", |
991 &server_time)); | 962 &server_time)); |
992 EXPECT_TRUE(this->SetCookieWithServerTime( | 963 EXPECT_TRUE(this->SetCookieWithServerTime( |
993 cs.get(), this->http_www_google_.url(), | 964 cs, this->http_www_google_.url(), |
994 std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-1977 22:50:13 GMT", | 965 std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-1977 22:50:13 GMT", |
995 server_time)); | 966 server_time)); |
996 this->MatchCookieLines( | 967 this->MatchCookieLines("A=B", |
997 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 968 this->GetCookies(cs, this->http_www_google_.url())); |
998 | 969 |
999 // Create a persistent cookie. | 970 // Create a persistent cookie. |
1000 EXPECT_TRUE(this->SetCookie( | 971 EXPECT_TRUE(this->SetCookie( |
1001 cs.get(), this->http_www_google_.url(), | 972 cs, this->http_www_google_.url(), |
1002 std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-22 22:50:13 GMT")); | 973 std::string(kValidCookieLine) + "; expires=Mon, 18-Apr-22 22:50:13 GMT")); |
1003 this->MatchCookieLines( | 974 this->MatchCookieLines("A=B", |
1004 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 975 this->GetCookies(cs, this->http_www_google_.url())); |
1005 // Delete it via Expires, with a unix epoch of 0. | 976 // Delete it via Expires, with a unix epoch of 0. |
1006 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 977 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), |
1007 std::string(kValidCookieLine) + | 978 std::string(kValidCookieLine) + |
1008 "; expires=Thu, 1-Jan-1970 00:00:00 GMT")); | 979 "; expires=Thu, 1-Jan-1970 00:00:00 GMT")); |
1009 this->MatchCookieLines( | 980 this->MatchCookieLines(std::string(), |
1010 std::string(), this->GetCookies(cs.get(), this->http_www_google_.url())); | 981 this->GetCookies(cs, this->http_www_google_.url())); |
1011 } | 982 } |
1012 | 983 |
1013 TYPED_TEST_P(CookieStoreTest, TestDeleteAll) { | 984 TYPED_TEST_P(CookieStoreTest, TestDeleteAll) { |
1014 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 985 CookieStore* cs = this->GetCookieStore(); |
1015 | 986 |
1016 // Set a session cookie. | 987 // Set a session cookie. |
1017 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 988 EXPECT_TRUE( |
1018 kValidCookieLine)); | 989 this->SetCookie(cs, this->http_www_google_.url(), kValidCookieLine)); |
1019 EXPECT_EQ("A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 990 EXPECT_EQ("A=B", this->GetCookies(cs, this->http_www_google_.url())); |
1020 | 991 |
1021 // Set a persistent cookie. | 992 // Set a persistent cookie. |
1022 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 993 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), |
1023 "C=D; expires=Mon, 18-Apr-22 22:50:13 GMT")); | 994 "C=D; expires=Mon, 18-Apr-22 22:50:13 GMT")); |
1024 | 995 |
1025 EXPECT_EQ(2u, this->GetAllCookies(cs.get()).size()); | 996 EXPECT_EQ(2u, this->GetAllCookies(cs).size()); |
1026 | 997 |
1027 // Delete both, and make sure it works | 998 // Delete both, and make sure it works |
1028 EXPECT_EQ(2, this->DeleteAll(cs.get())); | 999 EXPECT_EQ(2, this->DeleteAll(cs)); |
1029 EXPECT_EQ(0u, this->GetAllCookies(cs.get()).size()); | 1000 EXPECT_EQ(0u, this->GetAllCookies(cs).size()); |
1030 } | 1001 } |
1031 | 1002 |
1032 TYPED_TEST_P(CookieStoreTest, TestDeleteAllCreatedBetween) { | 1003 TYPED_TEST_P(CookieStoreTest, TestDeleteAllCreatedBetween) { |
1033 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1004 CookieStore* cs = this->GetCookieStore(); |
1034 const base::Time last_month = base::Time::Now() - | 1005 const base::Time last_month = base::Time::Now() - |
1035 base::TimeDelta::FromDays(30); | 1006 base::TimeDelta::FromDays(30); |
1036 const base::Time last_minute = base::Time::Now() - | 1007 const base::Time last_minute = base::Time::Now() - |
1037 base::TimeDelta::FromMinutes(1); | 1008 base::TimeDelta::FromMinutes(1); |
1038 const base::Time next_minute = base::Time::Now() + | 1009 const base::Time next_minute = base::Time::Now() + |
1039 base::TimeDelta::FromMinutes(1); | 1010 base::TimeDelta::FromMinutes(1); |
1040 const base::Time next_month = base::Time::Now() + | 1011 const base::Time next_month = base::Time::Now() + |
1041 base::TimeDelta::FromDays(30); | 1012 base::TimeDelta::FromDays(30); |
1042 | 1013 |
1043 // Add a cookie. | 1014 // Add a cookie. |
1044 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B")); | 1015 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), "A=B")); |
1045 // Check that the cookie is in the store. | 1016 // Check that the cookie is in the store. |
1046 this->MatchCookieLines( | 1017 this->MatchCookieLines("A=B", |
1047 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 1018 this->GetCookies(cs, this->http_www_google_.url())); |
1048 | 1019 |
1049 // Remove cookies in empty intervals. | 1020 // Remove cookies in empty intervals. |
1050 EXPECT_EQ(0, this->DeleteCreatedBetween(cs.get(), last_month, last_minute)); | 1021 EXPECT_EQ(0, this->DeleteCreatedBetween(cs, last_month, last_minute)); |
1051 EXPECT_EQ(0, this->DeleteCreatedBetween(cs.get(), next_minute, next_month)); | 1022 EXPECT_EQ(0, this->DeleteCreatedBetween(cs, next_minute, next_month)); |
1052 // Check that the cookie is still there. | 1023 // Check that the cookie is still there. |
1053 this->MatchCookieLines( | 1024 this->MatchCookieLines("A=B", |
1054 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 1025 this->GetCookies(cs, this->http_www_google_.url())); |
1055 | 1026 |
1056 // Remove the cookie with an interval defined by two dates. | 1027 // Remove the cookie with an interval defined by two dates. |
1057 EXPECT_EQ(1, this->DeleteCreatedBetween(cs.get(), last_minute, next_minute)); | 1028 EXPECT_EQ(1, this->DeleteCreatedBetween(cs, last_minute, next_minute)); |
1058 // Check that the cookie disappeared. | 1029 // Check that the cookie disappeared. |
1059 this->MatchCookieLines( | 1030 this->MatchCookieLines(std::string(), |
1060 std::string(), this->GetCookies(cs.get(), this->http_www_google_.url())); | 1031 this->GetCookies(cs, this->http_www_google_.url())); |
1061 | 1032 |
1062 // Add another cookie. | 1033 // Add another cookie. |
1063 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "C=D")); | 1034 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), "C=D")); |
1064 // Check that the cookie is in the store. | 1035 // Check that the cookie is in the store. |
1065 this->MatchCookieLines( | 1036 this->MatchCookieLines("C=D", |
1066 "C=D", this->GetCookies(cs.get(), this->http_www_google_.url())); | 1037 this->GetCookies(cs, this->http_www_google_.url())); |
1067 | 1038 |
1068 // Remove the cookie with a null ending time. | 1039 // Remove the cookie with a null ending time. |
1069 EXPECT_EQ(1, this->DeleteCreatedBetween(cs.get(), last_minute, base::Time())); | 1040 EXPECT_EQ(1, this->DeleteCreatedBetween(cs, last_minute, base::Time())); |
1070 // Check that the cookie disappeared. | 1041 // Check that the cookie disappeared. |
1071 this->MatchCookieLines( | 1042 this->MatchCookieLines(std::string(), |
1072 std::string(), this->GetCookies(cs.get(), this->http_www_google_.url())); | 1043 this->GetCookies(cs, this->http_www_google_.url())); |
1073 } | 1044 } |
1074 | 1045 |
1075 TYPED_TEST_P(CookieStoreTest, TestDeleteAllCreatedBetweenForHost) { | 1046 TYPED_TEST_P(CookieStoreTest, TestDeleteAllCreatedBetweenForHost) { |
1076 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1047 CookieStore* cs = this->GetCookieStore(); |
1077 GURL url_not_google("http://www.notgoogle.com"); | 1048 GURL url_not_google("http://www.notgoogle.com"); |
1078 base::Time now = base::Time::Now(); | 1049 base::Time now = base::Time::Now(); |
1079 | 1050 |
1080 // These 3 cookies match the time range and host. | 1051 // These 3 cookies match the time range and host. |
1081 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B")); | 1052 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), "A=B")); |
1082 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "C=D")); | 1053 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), "C=D")); |
1083 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "Y=Z")); | 1054 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), "Y=Z")); |
1084 | 1055 |
1085 // This cookie does not match host. | 1056 // This cookie does not match host. |
1086 EXPECT_TRUE(this->SetCookie(cs.get(), url_not_google, "E=F")); | 1057 EXPECT_TRUE(this->SetCookie(cs, url_not_google, "E=F")); |
1087 | 1058 |
1088 // Delete cookies. | 1059 // Delete cookies. |
1089 EXPECT_EQ( | 1060 EXPECT_EQ(3, // Deletes A=B, C=D, Y=Z |
1090 3, // Deletes A=B, C=D, Y=Z | 1061 this->DeleteAllCreatedBetweenForHost(cs, now, base::Time::Max(), |
1091 this->DeleteAllCreatedBetweenForHost(cs.get(), now, base::Time::Max(), | 1062 this->http_www_google_.url())); |
1092 this->http_www_google_.url())); | |
1093 } | 1063 } |
1094 | 1064 |
1095 TYPED_TEST_P(CookieStoreTest, TestSecure) { | 1065 TYPED_TEST_P(CookieStoreTest, TestSecure) { |
1096 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1066 CookieStore* cs = this->GetCookieStore(); |
1097 | 1067 |
1098 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B")); | 1068 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), "A=B")); |
1099 this->MatchCookieLines( | 1069 this->MatchCookieLines("A=B", |
1100 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 1070 this->GetCookies(cs, this->http_www_google_.url())); |
1101 this->MatchCookieLines( | 1071 this->MatchCookieLines("A=B", |
1102 "A=B", this->GetCookies(cs.get(), this->https_www_google_.url())); | 1072 this->GetCookies(cs, this->https_www_google_.url())); |
1103 | 1073 |
1104 EXPECT_TRUE(this->SetCookie(cs.get(), this->https_www_google_.url(), | 1074 EXPECT_TRUE( |
1105 "A=B; secure")); | 1075 this->SetCookie(cs, this->https_www_google_.url(), "A=B; secure")); |
1106 // The secure should overwrite the non-secure. | 1076 // The secure should overwrite the non-secure. |
1107 this->MatchCookieLines( | 1077 this->MatchCookieLines(std::string(), |
1108 std::string(), | 1078 this->GetCookies(cs, this->http_www_google_.url())); |
1109 this->GetCookies(cs.get(), this->http_www_google_.url())); | 1079 this->MatchCookieLines("A=B", |
1110 this->MatchCookieLines( | 1080 this->GetCookies(cs, this->https_www_google_.url())); |
1111 "A=B", this->GetCookies(cs.get(), this->https_www_google_.url())); | |
1112 | 1081 |
1113 EXPECT_TRUE(this->SetCookie(cs.get(), this->https_www_google_.url(), | 1082 EXPECT_TRUE( |
1114 "D=E; secure")); | 1083 this->SetCookie(cs, this->https_www_google_.url(), "D=E; secure")); |
1115 this->MatchCookieLines( | 1084 this->MatchCookieLines(std::string(), |
1116 std::string(), | 1085 this->GetCookies(cs, this->http_www_google_.url())); |
1117 this->GetCookies(cs.get(), this->http_www_google_.url())); | 1086 this->MatchCookieLines("A=B; D=E", |
1118 this->MatchCookieLines( | 1087 this->GetCookies(cs, this->https_www_google_.url())); |
1119 "A=B; D=E", this->GetCookies(cs.get(), this->https_www_google_.url())); | |
1120 | 1088 |
1121 EXPECT_TRUE( | 1089 EXPECT_TRUE(this->SetCookie(cs, this->https_www_google_.url(), "A=B")); |
1122 this->SetCookie(cs.get(), this->https_www_google_.url(), "A=B")); | |
1123 // The non-secure should overwrite the secure. | 1090 // The non-secure should overwrite the secure. |
1124 this->MatchCookieLines( | 1091 this->MatchCookieLines("A=B", |
1125 "A=B", this->GetCookies(cs.get(), this->http_www_google_.url())); | 1092 this->GetCookies(cs, this->http_www_google_.url())); |
1126 this->MatchCookieLines( | 1093 this->MatchCookieLines("D=E; A=B", |
1127 "D=E; A=B", this->GetCookies(cs.get(), this->https_www_google_.url())); | 1094 this->GetCookies(cs, this->https_www_google_.url())); |
1128 } | 1095 } |
1129 | 1096 |
1130 static const int kLastAccessThresholdMilliseconds = 200; | 1097 static const int kLastAccessThresholdMilliseconds = 200; |
1131 | 1098 |
1132 // Formerly NetUtilTest.CookieTest back when we used wininet's cookie handling. | 1099 // Formerly NetUtilTest.CookieTest back when we used wininet's cookie handling. |
1133 TYPED_TEST_P(CookieStoreTest, NetUtilCookieTest) { | 1100 TYPED_TEST_P(CookieStoreTest, NetUtilCookieTest) { |
1134 const GURL test_url("http://mojo.jojo.google.izzle/"); | 1101 const GURL test_url("http://mojo.jojo.google.izzle/"); |
1135 | 1102 |
1136 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1103 CookieStore* cs = this->GetCookieStore(); |
1137 | 1104 |
1138 EXPECT_TRUE(this->SetCookie(cs.get(), test_url, "foo=bar")); | 1105 EXPECT_TRUE(this->SetCookie(cs, test_url, "foo=bar")); |
1139 std::string value = this->GetCookies(cs.get(), test_url); | 1106 std::string value = this->GetCookies(cs, test_url); |
1140 this->MatchCookieLines("foo=bar", value); | 1107 this->MatchCookieLines("foo=bar", value); |
1141 | 1108 |
1142 // test that we can retrieve all cookies: | 1109 // test that we can retrieve all cookies: |
1143 EXPECT_TRUE(this->SetCookie(cs.get(), test_url, "x=1")); | 1110 EXPECT_TRUE(this->SetCookie(cs, test_url, "x=1")); |
1144 EXPECT_TRUE(this->SetCookie(cs.get(), test_url, "y=2")); | 1111 EXPECT_TRUE(this->SetCookie(cs, test_url, "y=2")); |
1145 | 1112 |
1146 std::string result = this->GetCookies(cs.get(), test_url); | 1113 std::string result = this->GetCookies(cs, test_url); |
1147 EXPECT_FALSE(result.empty()); | 1114 EXPECT_FALSE(result.empty()); |
1148 EXPECT_NE(result.find("x=1"), std::string::npos) << result; | 1115 EXPECT_NE(result.find("x=1"), std::string::npos) << result; |
1149 EXPECT_NE(result.find("y=2"), std::string::npos) << result; | 1116 EXPECT_NE(result.find("y=2"), std::string::npos) << result; |
1150 } | 1117 } |
1151 | 1118 |
1152 TYPED_TEST_P(CookieStoreTest, OverwritePersistentCookie) { | 1119 TYPED_TEST_P(CookieStoreTest, OverwritePersistentCookie) { |
1153 GURL url_google("http://www.google.com/"); | 1120 GURL url_google("http://www.google.com/"); |
1154 GURL url_chromium("http://chromium.org"); | 1121 GURL url_chromium("http://chromium.org"); |
1155 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1122 CookieStore* cs = this->GetCookieStore(); |
1156 | 1123 |
1157 // Insert a cookie "a" for path "/path1" | 1124 // Insert a cookie "a" for path "/path1" |
1158 EXPECT_TRUE(this->SetCookie(cs.get(), | 1125 EXPECT_TRUE(this->SetCookie(cs, url_google, |
1159 url_google, | |
1160 "a=val1; path=/path1; " | 1126 "a=val1; path=/path1; " |
1161 "expires=Mon, 18-Apr-22 22:50:13 GMT")); | 1127 "expires=Mon, 18-Apr-22 22:50:13 GMT")); |
1162 | 1128 |
1163 // Insert a cookie "b" for path "/path1" | 1129 // Insert a cookie "b" for path "/path1" |
1164 EXPECT_TRUE(this->SetCookie(cs.get(), | 1130 EXPECT_TRUE(this->SetCookie(cs, url_google, |
1165 url_google, | |
1166 "b=val1; path=/path1; " | 1131 "b=val1; path=/path1; " |
1167 "expires=Mon, 18-Apr-22 22:50:14 GMT")); | 1132 "expires=Mon, 18-Apr-22 22:50:14 GMT")); |
1168 | 1133 |
1169 // Insert a cookie "b" for path "/path1", that is httponly. This should | 1134 // Insert a cookie "b" for path "/path1", that is httponly. This should |
1170 // overwrite the non-http-only version. | 1135 // overwrite the non-http-only version. |
1171 CookieOptions allow_httponly; | 1136 CookieOptions allow_httponly; |
1172 allow_httponly.set_include_httponly(); | 1137 allow_httponly.set_include_httponly(); |
1173 EXPECT_TRUE(this->SetCookieWithOptions(cs.get(), | 1138 EXPECT_TRUE(this->SetCookieWithOptions(cs, url_google, |
1174 url_google, | |
1175 "b=val2; path=/path1; httponly; " | 1139 "b=val2; path=/path1; httponly; " |
1176 "expires=Mon, 18-Apr-22 22:50:14 GMT", | 1140 "expires=Mon, 18-Apr-22 22:50:14 GMT", |
1177 allow_httponly)); | 1141 allow_httponly)); |
1178 | 1142 |
1179 // Insert a cookie "a" for path "/path1". This should overwrite. | 1143 // Insert a cookie "a" for path "/path1". This should overwrite. |
1180 EXPECT_TRUE(this->SetCookie(cs.get(), | 1144 EXPECT_TRUE(this->SetCookie(cs, url_google, |
1181 url_google, | |
1182 "a=val33; path=/path1; " | 1145 "a=val33; path=/path1; " |
1183 "expires=Mon, 18-Apr-22 22:50:14 GMT")); | 1146 "expires=Mon, 18-Apr-22 22:50:14 GMT")); |
1184 | 1147 |
1185 // Insert a cookie "a" for path "/path2". This should NOT overwrite | 1148 // Insert a cookie "a" for path "/path2". This should NOT overwrite |
1186 // cookie "a", since the path is different. | 1149 // cookie "a", since the path is different. |
1187 EXPECT_TRUE(this->SetCookie(cs.get(), | 1150 EXPECT_TRUE(this->SetCookie(cs, url_google, |
1188 url_google, | |
1189 "a=val9; path=/path2; " | 1151 "a=val9; path=/path2; " |
1190 "expires=Mon, 18-Apr-22 22:50:14 GMT")); | 1152 "expires=Mon, 18-Apr-22 22:50:14 GMT")); |
1191 | 1153 |
1192 // Insert a cookie "a" for path "/path1", but this time for "chromium.org". | 1154 // Insert a cookie "a" for path "/path1", but this time for "chromium.org". |
1193 // Although the name and path match, the hostnames do not, so shouldn't | 1155 // Although the name and path match, the hostnames do not, so shouldn't |
1194 // overwrite. | 1156 // overwrite. |
1195 EXPECT_TRUE(this->SetCookie(cs.get(), | 1157 EXPECT_TRUE(this->SetCookie(cs, url_chromium, |
1196 url_chromium, | |
1197 "a=val99; path=/path1; " | 1158 "a=val99; path=/path1; " |
1198 "expires=Mon, 18-Apr-22 22:50:14 GMT")); | 1159 "expires=Mon, 18-Apr-22 22:50:14 GMT")); |
1199 | 1160 |
1200 if (TypeParam::supports_http_only) { | 1161 if (TypeParam::supports_http_only) { |
1201 this->MatchCookieLines( | 1162 this->MatchCookieLines( |
1202 "a=val33", | 1163 "a=val33", this->GetCookies(cs, GURL("http://www.google.com/path1"))); |
1203 this->GetCookies(cs.get(), GURL("http://www.google.com/path1"))); | |
1204 } else { | 1164 } else { |
1205 this->MatchCookieLines( | 1165 this->MatchCookieLines( |
1206 "a=val33; b=val2", | 1166 "a=val33; b=val2", |
1207 this->GetCookies(cs.get(), GURL("http://www.google.com/path1"))); | 1167 this->GetCookies(cs, GURL("http://www.google.com/path1"))); |
1208 } | 1168 } |
1209 this->MatchCookieLines( | 1169 this->MatchCookieLines( |
1210 "a=val9", | 1170 "a=val9", this->GetCookies(cs, GURL("http://www.google.com/path2"))); |
1211 this->GetCookies(cs.get(), GURL("http://www.google.com/path2"))); | |
1212 this->MatchCookieLines( | 1171 this->MatchCookieLines( |
1213 "a=val99", this->GetCookies(cs.get(), GURL("http://chromium.org/path1"))); | 1172 "a=val99", this->GetCookies(cs, GURL("http://chromium.org/path1"))); |
1214 } | 1173 } |
1215 | 1174 |
1216 TYPED_TEST_P(CookieStoreTest, CookieOrdering) { | 1175 TYPED_TEST_P(CookieStoreTest, CookieOrdering) { |
1217 // Put a random set of cookies into a store and make sure they're returned in | 1176 // Put a random set of cookies into a store and make sure they're returned in |
1218 // the right order. | 1177 // the right order. |
1219 // Cookies should be sorted by path length and creation time, as per RFC6265. | 1178 // Cookies should be sorted by path length and creation time, as per RFC6265. |
1220 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1179 CookieStore* cs = this->GetCookieStore(); |
1221 EXPECT_TRUE(this->SetCookie( | 1180 EXPECT_TRUE( |
1222 cs.get(), GURL("http://d.c.b.a.google.com/aa/x.html"), "c=1")); | 1181 this->SetCookie(cs, GURL("http://d.c.b.a.google.com/aa/x.html"), "c=1")); |
1223 EXPECT_TRUE(this->SetCookie(cs.get(), | 1182 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.google.com/aa/bb/cc/x.html"), |
1224 GURL("http://b.a.google.com/aa/bb/cc/x.html"), | |
1225 "d=1; domain=b.a.google.com")); | 1183 "d=1; domain=b.a.google.com")); |
1226 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( | 1184 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( |
1227 TypeParam::creation_time_granularity_in_ms)); | 1185 TypeParam::creation_time_granularity_in_ms)); |
1228 EXPECT_TRUE(this->SetCookie(cs.get(), | 1186 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.google.com/aa/bb/cc/x.html"), |
1229 GURL("http://b.a.google.com/aa/bb/cc/x.html"), | |
1230 "a=4; domain=b.a.google.com")); | 1187 "a=4; domain=b.a.google.com")); |
1231 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( | 1188 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( |
1232 TypeParam::creation_time_granularity_in_ms)); | 1189 TypeParam::creation_time_granularity_in_ms)); |
1233 EXPECT_TRUE(this->SetCookie(cs.get(), | 1190 EXPECT_TRUE(this->SetCookie(cs, |
1234 GURL("http://c.b.a.google.com/aa/bb/cc/x.html"), | 1191 GURL("http://c.b.a.google.com/aa/bb/cc/x.html"), |
1235 "e=1; domain=c.b.a.google.com")); | 1192 "e=1; domain=c.b.a.google.com")); |
1236 EXPECT_TRUE(this->SetCookie( | 1193 EXPECT_TRUE(this->SetCookie( |
1237 cs.get(), GURL("http://d.c.b.a.google.com/aa/bb/x.html"), "b=1")); | 1194 cs, GURL("http://d.c.b.a.google.com/aa/bb/x.html"), "b=1")); |
1238 EXPECT_TRUE(this->SetCookie( | 1195 EXPECT_TRUE(this->SetCookie(cs, GURL("http://news.bbc.co.uk/midpath/x.html"), |
1239 cs.get(), GURL("http://news.bbc.co.uk/midpath/x.html"), "g=10")); | 1196 "g=10")); |
1240 EXPECT_EQ("d=1; a=4; e=1; b=1; c=1", | 1197 EXPECT_EQ( |
1241 this->GetCookies(cs.get(), | 1198 "d=1; a=4; e=1; b=1; c=1", |
1242 GURL("http://d.c.b.a.google.com/aa/bb/cc/dd"))); | 1199 this->GetCookies(cs, GURL("http://d.c.b.a.google.com/aa/bb/cc/dd"))); |
1243 | 1200 |
1244 CookieOptions options; | 1201 CookieOptions options; |
1245 CookieList cookies = this->GetCookieListWithOptions( | 1202 CookieList cookies = this->GetCookieListWithOptions( |
1246 cs.get(), GURL("http://d.c.b.a.google.com/aa/bb/cc/dd"), options); | 1203 cs, GURL("http://d.c.b.a.google.com/aa/bb/cc/dd"), options); |
1247 CookieList::const_iterator it = cookies.begin(); | 1204 CookieList::const_iterator it = cookies.begin(); |
1248 | 1205 |
1249 ASSERT_TRUE(it != cookies.end()); | 1206 ASSERT_TRUE(it != cookies.end()); |
1250 EXPECT_EQ("d", it->Name()); | 1207 EXPECT_EQ("d", it->Name()); |
1251 | 1208 |
1252 ASSERT_TRUE(++it != cookies.end()); | 1209 ASSERT_TRUE(++it != cookies.end()); |
1253 EXPECT_EQ("a", it->Name()); | 1210 EXPECT_EQ("a", it->Name()); |
1254 | 1211 |
1255 ASSERT_TRUE(++it != cookies.end()); | 1212 ASSERT_TRUE(++it != cookies.end()); |
1256 EXPECT_EQ("e", it->Name()); | 1213 EXPECT_EQ("e", it->Name()); |
1257 | 1214 |
1258 ASSERT_TRUE(++it != cookies.end()); | 1215 ASSERT_TRUE(++it != cookies.end()); |
1259 EXPECT_EQ("b", it->Name()); | 1216 EXPECT_EQ("b", it->Name()); |
1260 | 1217 |
1261 ASSERT_TRUE(++it != cookies.end()); | 1218 ASSERT_TRUE(++it != cookies.end()); |
1262 EXPECT_EQ("c", it->Name()); | 1219 EXPECT_EQ("c", it->Name()); |
1263 | 1220 |
1264 EXPECT_TRUE(++it == cookies.end()); | 1221 EXPECT_TRUE(++it == cookies.end()); |
1265 } | 1222 } |
1266 | 1223 |
1267 // Check that GetAllCookiesAsync returns cookies from multiple domains, in the | 1224 // Check that GetAllCookiesAsync returns cookies from multiple domains, in the |
1268 // correct order. | 1225 // correct order. |
1269 TYPED_TEST_P(CookieStoreTest, GetAllCookiesAsync) { | 1226 TYPED_TEST_P(CookieStoreTest, GetAllCookiesAsync) { |
1270 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1227 CookieStore* cs = this->GetCookieStore(); |
1271 | 1228 |
1272 EXPECT_TRUE( | 1229 EXPECT_TRUE( |
1273 this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B; path=/a")); | 1230 this->SetCookie(cs, this->http_www_google_.url(), "A=B; path=/a")); |
1274 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_foo_com_.url(), "C=D;/")); | 1231 EXPECT_TRUE(this->SetCookie(cs, this->http_foo_com_.url(), "C=D;/")); |
1275 EXPECT_TRUE( | 1232 EXPECT_TRUE(this->SetCookie(cs, this->http_bar_com_.url(), "E=F; path=/bar")); |
1276 this->SetCookie(cs.get(), this->http_bar_com_.url(), "E=F; path=/bar")); | |
1277 | 1233 |
1278 // Check cookies for url. | 1234 // Check cookies for url. |
1279 CookieList cookies = this->GetAllCookies(cs.get()); | 1235 CookieList cookies = this->GetAllCookies(cs); |
1280 CookieList::const_iterator it = cookies.begin(); | 1236 CookieList::const_iterator it = cookies.begin(); |
1281 | 1237 |
1282 ASSERT_TRUE(it != cookies.end()); | 1238 ASSERT_TRUE(it != cookies.end()); |
1283 EXPECT_EQ(this->http_bar_com_.host(), it->Domain()); | 1239 EXPECT_EQ(this->http_bar_com_.host(), it->Domain()); |
1284 EXPECT_EQ("/bar", it->Path()); | 1240 EXPECT_EQ("/bar", it->Path()); |
1285 EXPECT_EQ("E", it->Name()); | 1241 EXPECT_EQ("E", it->Name()); |
1286 EXPECT_EQ("F", it->Value()); | 1242 EXPECT_EQ("F", it->Value()); |
1287 | 1243 |
1288 ASSERT_TRUE(++it != cookies.end()); | 1244 ASSERT_TRUE(++it != cookies.end()); |
1289 EXPECT_EQ(this->http_www_google_.host(), it->Domain()); | 1245 EXPECT_EQ(this->http_www_google_.host(), it->Domain()); |
1290 EXPECT_EQ("/a", it->Path()); | 1246 EXPECT_EQ("/a", it->Path()); |
1291 EXPECT_EQ("A", it->Name()); | 1247 EXPECT_EQ("A", it->Name()); |
1292 EXPECT_EQ("B", it->Value()); | 1248 EXPECT_EQ("B", it->Value()); |
1293 | 1249 |
1294 ASSERT_TRUE(++it != cookies.end()); | 1250 ASSERT_TRUE(++it != cookies.end()); |
1295 EXPECT_EQ(this->http_foo_com_.host(), it->Domain()); | 1251 EXPECT_EQ(this->http_foo_com_.host(), it->Domain()); |
1296 EXPECT_EQ("/", it->Path()); | 1252 EXPECT_EQ("/", it->Path()); |
1297 EXPECT_EQ("C", it->Name()); | 1253 EXPECT_EQ("C", it->Name()); |
1298 EXPECT_EQ("D", it->Value()); | 1254 EXPECT_EQ("D", it->Value()); |
1299 | 1255 |
1300 ASSERT_TRUE(++it == cookies.end()); | 1256 ASSERT_TRUE(++it == cookies.end()); |
1301 } | 1257 } |
1302 | 1258 |
1303 TYPED_TEST_P(CookieStoreTest, DeleteCookieAsync) { | 1259 TYPED_TEST_P(CookieStoreTest, DeleteCookieAsync) { |
1304 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1260 CookieStore* cs = this->GetCookieStore(); |
1305 | 1261 |
1306 EXPECT_TRUE( | 1262 EXPECT_TRUE( |
1307 this->SetCookie(cs.get(), this->http_www_google_.url(), "A=A1; path=/")); | 1263 this->SetCookie(cs, this->http_www_google_.url(), "A=A1; path=/")); |
1308 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | |
1309 "A=A2; path=/foo")); | |
1310 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | |
1311 "A=A3; path=/bar")); | |
1312 EXPECT_TRUE( | 1264 EXPECT_TRUE( |
1313 this->SetCookie(cs.get(), this->http_www_google_.url(), "B=B1; path=/")); | 1265 this->SetCookie(cs, this->http_www_google_.url(), "A=A2; path=/foo")); |
1314 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 1266 EXPECT_TRUE( |
1315 "B=B2; path=/foo")); | 1267 this->SetCookie(cs, this->http_www_google_.url(), "A=A3; path=/bar")); |
1316 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 1268 EXPECT_TRUE( |
1317 "B=B3; path=/bar")); | 1269 this->SetCookie(cs, this->http_www_google_.url(), "B=B1; path=/")); |
| 1270 EXPECT_TRUE( |
| 1271 this->SetCookie(cs, this->http_www_google_.url(), "B=B2; path=/foo")); |
| 1272 EXPECT_TRUE( |
| 1273 this->SetCookie(cs, this->http_www_google_.url(), "B=B3; path=/bar")); |
1318 | 1274 |
1319 this->DeleteCookie(cs.get(), this->http_www_google_.AppendPath("foo/bar"), | 1275 this->DeleteCookie(cs, this->http_www_google_.AppendPath("foo/bar"), "A"); |
1320 "A"); | |
1321 | 1276 |
1322 CookieList cookies = this->GetAllCookies(cs.get()); | 1277 CookieList cookies = this->GetAllCookies(cs); |
1323 size_t expected_size = 4; | 1278 size_t expected_size = 4; |
1324 EXPECT_EQ(expected_size, cookies.size()); | 1279 EXPECT_EQ(expected_size, cookies.size()); |
1325 for (const auto& cookie : cookies) { | 1280 for (const auto& cookie : cookies) { |
1326 EXPECT_NE("A1", cookie.Value()); | 1281 EXPECT_NE("A1", cookie.Value()); |
1327 EXPECT_NE("A2", cookie.Value()); | 1282 EXPECT_NE("A2", cookie.Value()); |
1328 } | 1283 } |
1329 } | 1284 } |
1330 | 1285 |
1331 TYPED_TEST_P(CookieStoreTest, DeleteCanonicalCookieAsync) { | 1286 TYPED_TEST_P(CookieStoreTest, DeleteCanonicalCookieAsync) { |
1332 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1287 CookieStore* cs = this->GetCookieStore(); |
1333 | 1288 |
1334 // Set two cookies with the same name, and make sure both are set. | 1289 // Set two cookies with the same name, and make sure both are set. |
1335 EXPECT_TRUE( | 1290 EXPECT_TRUE( |
1336 this->SetCookie(cs.get(), this->http_www_google_.url(), "A=B;Path=/foo")); | 1291 this->SetCookie(cs, this->http_www_google_.url(), "A=B;Path=/foo")); |
1337 EXPECT_TRUE( | 1292 EXPECT_TRUE( |
1338 this->SetCookie(cs.get(), this->http_www_google_.url(), "A=C;Path=/bar")); | 1293 this->SetCookie(cs, this->http_www_google_.url(), "A=C;Path=/bar")); |
1339 EXPECT_EQ(2u, this->GetAllCookies(cs.get()).size()); | 1294 EXPECT_EQ(2u, this->GetAllCookies(cs).size()); |
1340 EXPECT_EQ("A=B", this->GetCookies(cs.get(), this->www_google_foo_.url())); | 1295 EXPECT_EQ("A=B", this->GetCookies(cs, this->www_google_foo_.url())); |
1341 EXPECT_EQ("A=C", this->GetCookies(cs.get(), this->www_google_bar_.url())); | 1296 EXPECT_EQ("A=C", this->GetCookies(cs, this->www_google_bar_.url())); |
1342 | 1297 |
1343 // Delete the "/foo" cookie, and make sure only it was deleted. | 1298 // Delete the "/foo" cookie, and make sure only it was deleted. |
1344 CookieList cookies = this->GetCookieListWithOptions( | 1299 CookieList cookies = this->GetCookieListWithOptions( |
1345 cs.get(), this->www_google_foo_.url(), CookieOptions()); | 1300 cs, this->www_google_foo_.url(), CookieOptions()); |
1346 ASSERT_EQ(1u, cookies.size()); | 1301 ASSERT_EQ(1u, cookies.size()); |
1347 EXPECT_EQ(1, this->DeleteCanonicalCookie(cs.get(), cookies[0])); | 1302 EXPECT_EQ(1, this->DeleteCanonicalCookie(cs, cookies[0])); |
1348 EXPECT_EQ(1u, this->GetAllCookies(cs.get()).size()); | 1303 EXPECT_EQ(1u, this->GetAllCookies(cs).size()); |
1349 EXPECT_EQ("", this->GetCookies(cs.get(), this->www_google_foo_.url())); | 1304 EXPECT_EQ("", this->GetCookies(cs, this->www_google_foo_.url())); |
1350 EXPECT_EQ("A=C", this->GetCookies(cs.get(), this->www_google_bar_.url())); | 1305 EXPECT_EQ("A=C", this->GetCookies(cs, this->www_google_bar_.url())); |
1351 | 1306 |
1352 // Deleting the "/foo" cookie again should fail. | 1307 // Deleting the "/foo" cookie again should fail. |
1353 EXPECT_EQ(0, this->DeleteCanonicalCookie(cs.get(), cookies[0])); | 1308 EXPECT_EQ(0, this->DeleteCanonicalCookie(cs, cookies[0])); |
1354 | 1309 |
1355 // Try to delete the "/bar" cookie after overwriting it with a new cookie. | 1310 // Try to delete the "/bar" cookie after overwriting it with a new cookie. |
1356 cookies = this->GetCookieListWithOptions( | 1311 cookies = this->GetCookieListWithOptions(cs, this->www_google_bar_.url(), |
1357 cs.get(), this->www_google_bar_.url(), CookieOptions()); | 1312 CookieOptions()); |
1358 ASSERT_EQ(1u, cookies.size()); | 1313 ASSERT_EQ(1u, cookies.size()); |
1359 EXPECT_TRUE( | 1314 EXPECT_TRUE( |
1360 this->SetCookie(cs.get(), this->http_www_google_.url(), "A=D;Path=/bar")); | 1315 this->SetCookie(cs, this->http_www_google_.url(), "A=D;Path=/bar")); |
1361 EXPECT_EQ(0, this->DeleteCanonicalCookie(cs.get(), cookies[0])); | 1316 EXPECT_EQ(0, this->DeleteCanonicalCookie(cs, cookies[0])); |
1362 EXPECT_EQ(1u, this->GetAllCookies(cs.get()).size()); | 1317 EXPECT_EQ(1u, this->GetAllCookies(cs).size()); |
1363 EXPECT_EQ("A=D", this->GetCookies(cs.get(), this->www_google_bar_.url())); | 1318 EXPECT_EQ("A=D", this->GetCookies(cs, this->www_google_bar_.url())); |
1364 | 1319 |
1365 // Delete the new "/bar" cookie. | 1320 // Delete the new "/bar" cookie. |
1366 cookies = this->GetCookieListWithOptions( | 1321 cookies = this->GetCookieListWithOptions(cs, this->www_google_bar_.url(), |
1367 cs.get(), this->www_google_bar_.url(), CookieOptions()); | 1322 CookieOptions()); |
1368 ASSERT_EQ(1u, cookies.size()); | 1323 ASSERT_EQ(1u, cookies.size()); |
1369 EXPECT_EQ(1, this->DeleteCanonicalCookie(cs.get(), cookies[0])); | 1324 EXPECT_EQ(1, this->DeleteCanonicalCookie(cs, cookies[0])); |
1370 EXPECT_EQ(0u, this->GetAllCookies(cs.get()).size()); | 1325 EXPECT_EQ(0u, this->GetAllCookies(cs).size()); |
1371 EXPECT_EQ("", this->GetCookies(cs.get(), this->www_google_bar_.url())); | 1326 EXPECT_EQ("", this->GetCookies(cs, this->www_google_bar_.url())); |
1372 } | 1327 } |
1373 | 1328 |
1374 TYPED_TEST_P(CookieStoreTest, DeleteSessionCookie) { | 1329 TYPED_TEST_P(CookieStoreTest, DeleteSessionCookie) { |
1375 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 1330 CookieStore* cs = this->GetCookieStore(); |
1376 // Create a session cookie and a persistent cookie. | 1331 // Create a session cookie and a persistent cookie. |
1377 EXPECT_TRUE(this->SetCookie(cs.get(), this->http_www_google_.url(), | 1332 EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), |
1378 std::string(kValidCookieLine))); | 1333 std::string(kValidCookieLine))); |
1379 EXPECT_TRUE(this->SetCookie( | 1334 EXPECT_TRUE(this->SetCookie( |
1380 cs.get(), this->http_www_google_.url(), | 1335 cs, this->http_www_google_.url(), |
1381 this->http_www_google_.Format("C=D; path=/; domain=%D;" | 1336 this->http_www_google_.Format("C=D; path=/; domain=%D;" |
1382 "expires=Mon, 18-Apr-22 22:50:13 GMT"))); | 1337 "expires=Mon, 18-Apr-22 22:50:13 GMT"))); |
1383 this->MatchCookieLines( | 1338 this->MatchCookieLines("A=B; C=D", |
1384 "A=B; C=D", this->GetCookies(cs.get(), this->http_www_google_.url())); | 1339 this->GetCookies(cs, this->http_www_google_.url())); |
1385 // Delete the session cookie. | 1340 // Delete the session cookie. |
1386 this->DeleteSessionCookies(cs.get()); | 1341 this->DeleteSessionCookies(cs); |
1387 // Check that the session cookie has been deleted but not the persistent one. | 1342 // Check that the session cookie has been deleted but not the persistent one. |
1388 EXPECT_EQ("C=D", this->GetCookies(cs.get(), this->http_www_google_.url())); | 1343 EXPECT_EQ("C=D", this->GetCookies(cs, this->http_www_google_.url())); |
1389 } | 1344 } |
1390 | 1345 |
1391 REGISTER_TYPED_TEST_CASE_P(CookieStoreTest, | 1346 REGISTER_TYPED_TEST_CASE_P(CookieStoreTest, |
1392 SetCookieWithDetailsAsync, | 1347 SetCookieWithDetailsAsync, |
1393 DomainTest, | 1348 DomainTest, |
1394 DomainWithTrailingDotTest, | 1349 DomainWithTrailingDotTest, |
1395 ValidSubdomainTest, | 1350 ValidSubdomainTest, |
1396 InvalidDomainTest, | 1351 InvalidDomainTest, |
1397 InvalidDomainSameDomainAndRegistry, | 1352 InvalidDomainSameDomainAndRegistry, |
1398 DomainWithoutLeadingDotParentDomain, | 1353 DomainWithoutLeadingDotParentDomain, |
(...skipping 23 matching lines...) Expand all Loading... |
1422 OverwritePersistentCookie, | 1377 OverwritePersistentCookie, |
1423 CookieOrdering, | 1378 CookieOrdering, |
1424 GetAllCookiesAsync, | 1379 GetAllCookiesAsync, |
1425 DeleteCookieAsync, | 1380 DeleteCookieAsync, |
1426 DeleteCanonicalCookieAsync, | 1381 DeleteCanonicalCookieAsync, |
1427 DeleteSessionCookie); | 1382 DeleteSessionCookie); |
1428 | 1383 |
1429 } // namespace net | 1384 } // namespace net |
1430 | 1385 |
1431 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ | 1386 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ |
OLD | NEW |