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 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 this->MatchCookieLines( | 1272 this->MatchCookieLines( |
1273 "a=val33; b=val2", | 1273 "a=val33; b=val2", |
1274 this->GetCookies(cs, GURL("http://www.foo.com/path1"))); | 1274 this->GetCookies(cs, GURL("http://www.foo.com/path1"))); |
1275 } | 1275 } |
1276 this->MatchCookieLines( | 1276 this->MatchCookieLines( |
1277 "a=val9", this->GetCookies(cs, GURL("http://www.foo.com/path2"))); | 1277 "a=val9", this->GetCookies(cs, GURL("http://www.foo.com/path2"))); |
1278 this->MatchCookieLines( | 1278 this->MatchCookieLines( |
1279 "a=val99", this->GetCookies(cs, GURL("http://chromium.org/path1"))); | 1279 "a=val99", this->GetCookies(cs, GURL("http://chromium.org/path1"))); |
1280 } | 1280 } |
1281 | 1281 |
| 1282 // Note that accepting an empty name is contrary to spec; see |
| 1283 // https://tools.ietf.org/html/rfc6265#section-4.1.1. However, we do it |
| 1284 // for web compatibility; see http://inikulin.github.io/cookie-compat/ |
| 1285 // (specifically the "foo" and "=a" tests). This test is present in Chromium |
| 1286 // so that a flag is raised if this behavior is changed. |
| 1287 // On IOS we use the system cookie store which has Safari's behavior, so |
| 1288 // the test is skipped. |
| 1289 TYPED_TEST_P(CookieStoreTest, EmptyName) { |
| 1290 if (TypeParam::forbids_setting_empty_name) |
| 1291 return; |
| 1292 |
| 1293 GURL url_foo("http://www.foo.com/"); |
| 1294 CookieStore* cs = this->GetCookieStore(); |
| 1295 |
| 1296 CookieOptions options; |
| 1297 if (!TypeParam::supports_http_only) |
| 1298 options.set_include_httponly(); |
| 1299 EXPECT_TRUE(this->SetCookieWithOptions(cs, url_foo, "a", options)); |
| 1300 CookieList list = this->GetAllCookiesForURL(cs, url_foo); |
| 1301 EXPECT_EQ(1u, list.size()); |
| 1302 EXPECT_EQ("", list[0].Name()); |
| 1303 EXPECT_EQ("a", list[0].Value()); |
| 1304 EXPECT_EQ(1, this->DeleteAll(cs)); |
| 1305 |
| 1306 EXPECT_TRUE(this->SetCookieWithOptions(cs, url_foo, "=b", options)); |
| 1307 list = this->GetAllCookiesForURL(cs, url_foo); |
| 1308 EXPECT_EQ(1u, list.size()); |
| 1309 EXPECT_EQ("", list[0].Name()); |
| 1310 EXPECT_EQ("b", list[0].Value()); |
| 1311 EXPECT_EQ(1, this->DeleteAll(cs)); |
| 1312 } |
| 1313 |
1282 TYPED_TEST_P(CookieStoreTest, CookieOrdering) { | 1314 TYPED_TEST_P(CookieStoreTest, CookieOrdering) { |
1283 // Put a random set of cookies into a store and make sure they're returned in | 1315 // Put a random set of cookies into a store and make sure they're returned in |
1284 // the right order. | 1316 // the right order. |
1285 // Cookies should be sorted by path length and creation time, as per RFC6265. | 1317 // Cookies should be sorted by path length and creation time, as per RFC6265. |
1286 CookieStore* cs = this->GetCookieStore(); | 1318 CookieStore* cs = this->GetCookieStore(); |
1287 EXPECT_TRUE( | 1319 EXPECT_TRUE( |
1288 this->SetCookie(cs, GURL("http://d.c.b.a.foo.com/aa/x.html"), "c=1")); | 1320 this->SetCookie(cs, GURL("http://d.c.b.a.foo.com/aa/x.html"), "c=1")); |
1289 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.foo.com/aa/bb/cc/x.html"), | 1321 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.foo.com/aa/bb/cc/x.html"), |
1290 "d=1; domain=b.a.foo.com")); | 1322 "d=1; domain=b.a.foo.com")); |
1291 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( | 1323 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 PathTest, | 1501 PathTest, |
1470 EmptyExpires, | 1502 EmptyExpires, |
1471 HttpOnlyTest, | 1503 HttpOnlyTest, |
1472 TestCookieDeletion, | 1504 TestCookieDeletion, |
1473 TestDeleteAll, | 1505 TestDeleteAll, |
1474 TestDeleteAllCreatedBetween, | 1506 TestDeleteAllCreatedBetween, |
1475 TestDeleteAllCreatedBetweenWithPredicate, | 1507 TestDeleteAllCreatedBetweenWithPredicate, |
1476 TestSecure, | 1508 TestSecure, |
1477 NetUtilCookieTest, | 1509 NetUtilCookieTest, |
1478 OverwritePersistentCookie, | 1510 OverwritePersistentCookie, |
| 1511 EmptyName, |
1479 CookieOrdering, | 1512 CookieOrdering, |
1480 GetAllCookiesAsync, | 1513 GetAllCookiesAsync, |
1481 DeleteCookieAsync, | 1514 DeleteCookieAsync, |
1482 DeleteCanonicalCookieAsync, | 1515 DeleteCanonicalCookieAsync, |
1483 DeleteSessionCookie); | 1516 DeleteSessionCookie); |
1484 | 1517 |
1485 } // namespace net | 1518 } // namespace net |
1486 | 1519 |
1487 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ | 1520 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ |
OLD | NEW |