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

Side by Side Diff: net/cookies/cookie_store_unittest.h

Issue 2898953008: Implement and test CanonicalCookie::IsCanonical() (Closed)
Patch Set: Add test param to Android Webview cookie test. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #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 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 this->MatchCookieLines( 1271 this->MatchCookieLines(
1272 "a=val33; b=val2", 1272 "a=val33; b=val2",
1273 this->GetCookies(cs, GURL("http://www.google.com/path1"))); 1273 this->GetCookies(cs, GURL("http://www.google.com/path1")));
1274 } 1274 }
1275 this->MatchCookieLines( 1275 this->MatchCookieLines(
1276 "a=val9", this->GetCookies(cs, GURL("http://www.google.com/path2"))); 1276 "a=val9", this->GetCookies(cs, GURL("http://www.google.com/path2")));
1277 this->MatchCookieLines( 1277 this->MatchCookieLines(
1278 "a=val99", this->GetCookies(cs, GURL("http://chromium.org/path1"))); 1278 "a=val99", this->GetCookies(cs, GURL("http://chromium.org/path1")));
1279 } 1279 }
1280 1280
1281 // Note that accepting an empty name is contrary to spec; see
1282 // https://tools.ietf.org/html/rfc6265#section-4.1.1. However, we do it
1283 // for web compatibility; see http://inikulin.github.io/cookie-compat/
1284 // (specifically the "foo" and "=a" tests). This test is present in Chromium
1285 // so that a flag is raised if this behavior is changed.
1286 // On IOS we use the system cookie store which has Safari's behavior, so
1287 // the test is skipped.
1288 TYPED_TEST_P(CookieStoreTest, EmptyName) {
1289 if (TypeParam::forbids_setting_empty_name)
1290 return;
1291
1292 GURL url_google("http://www.google.com/");
1293 CookieStore* cs = this->GetCookieStore();
1294
1295 CookieOptions options;
1296 if (!TypeParam::supports_http_only)
1297 options.set_include_httponly();
1298 EXPECT_TRUE(this->SetCookieWithOptions(cs, url_google, "a", options));
1299 CookieList list = this->GetAllCookiesForURL(cs, url_google);
1300 EXPECT_EQ(1u, list.size());
1301 EXPECT_EQ("", list[0].Name());
1302 EXPECT_EQ("a", list[0].Value());
1303 EXPECT_EQ(1, this->DeleteAll(cs));
1304
1305 EXPECT_TRUE(this->SetCookieWithOptions(cs, url_google, "=b", options));
1306 list = this->GetAllCookiesForURL(cs, url_google);
1307 EXPECT_EQ(1u, list.size());
1308 EXPECT_EQ("", list[0].Name());
1309 EXPECT_EQ("b", list[0].Value());
1310 EXPECT_EQ(1, this->DeleteAll(cs));
1311 }
1312
1281 TYPED_TEST_P(CookieStoreTest, CookieOrdering) { 1313 TYPED_TEST_P(CookieStoreTest, CookieOrdering) {
1282 // Put a random set of cookies into a store and make sure they're returned in 1314 // Put a random set of cookies into a store and make sure they're returned in
1283 // the right order. 1315 // the right order.
1284 // Cookies should be sorted by path length and creation time, as per RFC6265. 1316 // Cookies should be sorted by path length and creation time, as per RFC6265.
1285 CookieStore* cs = this->GetCookieStore(); 1317 CookieStore* cs = this->GetCookieStore();
1286 EXPECT_TRUE( 1318 EXPECT_TRUE(
1287 this->SetCookie(cs, GURL("http://d.c.b.a.google.com/aa/x.html"), "c=1")); 1319 this->SetCookie(cs, GURL("http://d.c.b.a.google.com/aa/x.html"), "c=1"));
1288 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.google.com/aa/bb/cc/x.html"), 1320 EXPECT_TRUE(this->SetCookie(cs, GURL("http://b.a.google.com/aa/bb/cc/x.html"),
1289 "d=1; domain=b.a.google.com")); 1321 "d=1; domain=b.a.google.com"));
1290 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( 1322 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 PathTest, 1508 PathTest,
1477 EmptyExpires, 1509 EmptyExpires,
1478 HttpOnlyTest, 1510 HttpOnlyTest,
1479 TestCookieDeletion, 1511 TestCookieDeletion,
1480 TestDeleteAll, 1512 TestDeleteAll,
1481 TestDeleteAllCreatedBetween, 1513 TestDeleteAllCreatedBetween,
1482 TestDeleteAllCreatedBetweenWithPredicate, 1514 TestDeleteAllCreatedBetweenWithPredicate,
1483 TestSecure, 1515 TestSecure,
1484 NetUtilCookieTest, 1516 NetUtilCookieTest,
1485 OverwritePersistentCookie, 1517 OverwritePersistentCookie,
1518 EmptyName,
1486 CookieOrdering, 1519 CookieOrdering,
1487 GetAllCookiesAsync, 1520 GetAllCookiesAsync,
1488 DeleteCookieAsync, 1521 DeleteCookieAsync,
1489 DeleteCanonicalCookieAsync, 1522 DeleteCanonicalCookieAsync,
1490 DeleteSessionCookie); 1523 DeleteSessionCookie);
1491 1524
1492 } // namespace net 1525 } // namespace net
1493 1526
1494 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ 1527 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_
OLDNEW
« net/cookies/canonical_cookie_unittest.cc ('K') | « net/cookies/cookie_monster_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698