| 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // exactly. This matches IE/Firefox, even though it seems a bit wrong. | 502 // exactly. This matches IE/Firefox, even though it seems a bit wrong. |
| 503 EXPECT_FALSE(this->SetCookie(cs.get(), url_ip, "b=2; domain=1.2.3.3")); | 503 EXPECT_FALSE(this->SetCookie(cs.get(), url_ip, "b=2; domain=1.2.3.3")); |
| 504 this->MatchCookieLines(std::string(), this->GetCookies(cs.get(), url_ip)); | 504 this->MatchCookieLines(std::string(), this->GetCookies(cs.get(), url_ip)); |
| 505 EXPECT_TRUE(this->SetCookie(cs.get(), url_ip, "b=2; domain=1.2.3.4")); | 505 EXPECT_TRUE(this->SetCookie(cs.get(), url_ip, "b=2; domain=1.2.3.4")); |
| 506 this->MatchCookieLines("b=2", this->GetCookies(cs.get(), url_ip)); | 506 this->MatchCookieLines("b=2", this->GetCookies(cs.get(), url_ip)); |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 | 509 |
| 510 // Test host cookies, and setting of cookies on TLD. | 510 // Test host cookies, and setting of cookies on TLD. |
| 511 TYPED_TEST_P(CookieStoreTest, TestNonDottedAndTLD) { | 511 TYPED_TEST_P(CookieStoreTest, TestNonDottedAndTLD) { |
| 512 { | 512 if (TypeParam::supports_non_dotted_domains) { |
| 513 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 513 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
| 514 GURL url("http://com/"); | 514 GURL url("http://com/"); |
| 515 // Allow setting on "com", (but only as a host cookie). | 515 // Allow setting on "com", (but only as a host cookie). |
| 516 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1")); | 516 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1")); |
| 517 EXPECT_FALSE(this->SetCookie(cs.get(), url, "b=2; domain=.com")); | 517 EXPECT_FALSE(this->SetCookie(cs.get(), url, "b=2; domain=.com")); |
| 518 | 518 |
| 519 this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url)); | 519 this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url)); |
| 520 // Make sure it doesn't show up for a normal .com, it should be a host | 520 // Make sure it doesn't show up for a normal .com, it should be a host |
| 521 // not a domain cookie. | 521 // not a domain cookie. |
| 522 this->MatchCookieLines( | 522 this->MatchCookieLines( |
| 523 std::string(), | 523 std::string(), |
| 524 this->GetCookies(cs.get(), GURL("http://hopefully-no-cookies.com/"))); | 524 this->GetCookies(cs.get(), GURL("http://hopefully-no-cookies.com/"))); |
| 525 if (TypeParam::supports_non_dotted_domains) { | 525 this->MatchCookieLines(std::string(), |
| 526 this->MatchCookieLines(std::string(), | 526 this->GetCookies(cs.get(), GURL("http://.com/"))); |
| 527 this->GetCookies(cs.get(), GURL("http://.com/"))); | |
| 528 } | |
| 529 } | 527 } |
| 530 | 528 |
| 531 if (TypeParam::supports_non_dotted_domains) { | 529 if (TypeParam::supports_non_dotted_domains) { |
| 532 // Exact matches between the domain attribute and the host are treated as | 530 // Exact matches between the domain attribute and the host are treated as |
| 533 // host cookies, not domain cookies. | 531 // host cookies, not domain cookies. |
| 534 scoped_refptr<CookieStore> cs(this->GetCookieStore()); | 532 scoped_refptr<CookieStore> cs(this->GetCookieStore()); |
| 535 GURL url("http://com/"); | 533 GURL url("http://com/"); |
| 536 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1; domain=com")); | 534 EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1; domain=com")); |
| 537 | 535 |
| 538 this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url)); | 536 this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url)); |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest, | 1273 REGISTER_TYPED_TEST_CASE_P(MultiThreadedCookieStoreTest, |
| 1276 ThreadCheckGetCookies, | 1274 ThreadCheckGetCookies, |
| 1277 ThreadCheckGetCookiesWithOptions, | 1275 ThreadCheckGetCookiesWithOptions, |
| 1278 ThreadCheckSetCookieWithOptions, | 1276 ThreadCheckSetCookieWithOptions, |
| 1279 ThreadCheckDeleteCookie, | 1277 ThreadCheckDeleteCookie, |
| 1280 ThreadCheckDeleteSessionCookies); | 1278 ThreadCheckDeleteSessionCookies); |
| 1281 | 1279 |
| 1282 } // namespace net | 1280 } // namespace net |
| 1283 | 1281 |
| 1284 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ | 1282 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ |
| OLD | NEW |