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

Side by Side Diff: net/cookies/cookie_monster_unittest.cc

Issue 876973003: Implement the "first-party-only" cookie flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tiny bug. Created 5 years, 10 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 #include "net/cookies/cookie_store_unittest.h" 5 #include "net/cookies/cookie_store_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 bool SetCookieWithDetails(CookieMonster* cm, 146 bool SetCookieWithDetails(CookieMonster* cm,
147 const GURL& url, 147 const GURL& url,
148 const std::string& name, 148 const std::string& name,
149 const std::string& value, 149 const std::string& value,
150 const std::string& domain, 150 const std::string& domain,
151 const std::string& path, 151 const std::string& path,
152 const base::Time& expiration_time, 152 const base::Time& expiration_time,
153 bool secure, 153 bool secure,
154 bool http_only, 154 bool http_only,
155 bool first_party,
155 CookiePriority priority) { 156 CookiePriority priority) {
156 DCHECK(cm); 157 DCHECK(cm);
157 ResultSavingCookieCallback<bool> callback; 158 ResultSavingCookieCallback<bool> callback;
158 cm->SetCookieWithDetailsAsync( 159 cm->SetCookieWithDetailsAsync(
159 url, name, value, domain, path, expiration_time, secure, http_only, 160 url, name, value, domain, path, expiration_time, secure, http_only,
160 priority, base::Bind(&ResultSavingCookieCallback<bool>::Run, 161 first_party, priority,
161 base::Unretained(&callback))); 162 base::Bind(&ResultSavingCookieCallback<bool>::Run,
163 base::Unretained(&callback)));
162 RunFor(kTimeout); 164 RunFor(kTimeout);
163 EXPECT_TRUE(callback.did_run()); 165 EXPECT_TRUE(callback.did_run());
164 return callback.result(); 166 return callback.result();
165 } 167 }
166 168
167 int DeleteAll(CookieMonster* cm) { 169 int DeleteAll(CookieMonster* cm) {
168 DCHECK(cm); 170 DCHECK(cm);
169 ResultSavingCookieCallback<int> callback; 171 ResultSavingCookieCallback<int> callback;
170 cm->DeleteAllAsync(base::Bind(&ResultSavingCookieCallback<int>::Run, 172 cm->DeleteAllAsync(base::Bind(&ResultSavingCookieCallback<int>::Run,
171 base::Unretained(&callback))); 173 base::Unretained(&callback)));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 GURL url_top_level_domain_plus_2_secure(kTopLevelDomainPlus2Secure); 235 GURL url_top_level_domain_plus_2_secure(kTopLevelDomainPlus2Secure);
234 GURL url_top_level_domain_plus_3(kTopLevelDomainPlus3); 236 GURL url_top_level_domain_plus_3(kTopLevelDomainPlus3);
235 GURL url_other(kOtherDomain); 237 GURL url_other(kOtherDomain);
236 238
237 DeleteAll(cm.get()); 239 DeleteAll(cm.get());
238 240
239 // Static population for probe: 241 // Static population for probe:
240 // * Three levels of domain cookie (.b.a, .c.b.a, .d.c.b.a) 242 // * Three levels of domain cookie (.b.a, .c.b.a, .d.c.b.a)
241 // * Three levels of host cookie (w.b.a, w.c.b.a, w.d.c.b.a) 243 // * Three levels of host cookie (w.b.a, w.c.b.a, w.d.c.b.a)
242 // * http_only cookie (w.c.b.a) 244 // * http_only cookie (w.c.b.a)
245 // * first-party cookie (w.c.b.a)
243 // * Two secure cookies (.c.b.a, w.c.b.a) 246 // * Two secure cookies (.c.b.a, w.c.b.a)
244 // * Two domain path cookies (.c.b.a/dir1, .c.b.a/dir1/dir2) 247 // * Two domain path cookies (.c.b.a/dir1, .c.b.a/dir1/dir2)
245 // * Two host path cookies (w.c.b.a/dir1, w.c.b.a/dir1/dir2) 248 // * Two host path cookies (w.c.b.a/dir1, w.c.b.a/dir1/dir2)
246 249
247 // Domain cookies 250 // Domain cookies
248 EXPECT_TRUE(this->SetCookieWithDetails( 251 EXPECT_TRUE(this->SetCookieWithDetails(
249 cm.get(), url_top_level_domain_plus_1, "dom_1", "X", ".harvard.edu", 252 cm.get(), url_top_level_domain_plus_1, "dom_1", "X", ".harvard.edu",
250 "/", base::Time(), false, false, COOKIE_PRIORITY_DEFAULT)); 253 "/", base::Time(), false, false, false, COOKIE_PRIORITY_DEFAULT));
251 EXPECT_TRUE(this->SetCookieWithDetails( 254 EXPECT_TRUE(this->SetCookieWithDetails(
252 cm.get(), url_top_level_domain_plus_2, "dom_2", "X", 255 cm.get(), url_top_level_domain_plus_2, "dom_2", "X",
253 ".math.harvard.edu", "/", base::Time(), false, false, 256 ".math.harvard.edu", "/", base::Time(), false, false, false,
254 COOKIE_PRIORITY_DEFAULT)); 257 COOKIE_PRIORITY_DEFAULT));
255 EXPECT_TRUE(this->SetCookieWithDetails( 258 EXPECT_TRUE(this->SetCookieWithDetails(
256 cm.get(), url_top_level_domain_plus_3, "dom_3", "X", 259 cm.get(), url_top_level_domain_plus_3, "dom_3", "X",
257 ".bourbaki.math.harvard.edu", "/", base::Time(), false, false, 260 ".bourbaki.math.harvard.edu", "/", base::Time(), false, false, false,
258 COOKIE_PRIORITY_DEFAULT)); 261 COOKIE_PRIORITY_DEFAULT));
259 262
260 // Host cookies 263 // Host cookies
261 EXPECT_TRUE(this->SetCookieWithDetails( 264 EXPECT_TRUE(this->SetCookieWithDetails(
262 cm.get(), url_top_level_domain_plus_1, "host_1", "X", std::string(), 265 cm.get(), url_top_level_domain_plus_1, "host_1", "X", std::string(),
263 "/", base::Time(), false, false, COOKIE_PRIORITY_DEFAULT)); 266 "/", base::Time(), false, false, false, COOKIE_PRIORITY_DEFAULT));
264 EXPECT_TRUE(this->SetCookieWithDetails( 267 EXPECT_TRUE(this->SetCookieWithDetails(
265 cm.get(), url_top_level_domain_plus_2, "host_2", "X", std::string(), 268 cm.get(), url_top_level_domain_plus_2, "host_2", "X", std::string(),
266 "/", base::Time(), false, false, COOKIE_PRIORITY_DEFAULT)); 269 "/", base::Time(), false, false, false, COOKIE_PRIORITY_DEFAULT));
267 EXPECT_TRUE(this->SetCookieWithDetails( 270 EXPECT_TRUE(this->SetCookieWithDetails(
268 cm.get(), url_top_level_domain_plus_3, "host_3", "X", std::string(), 271 cm.get(), url_top_level_domain_plus_3, "host_3", "X", std::string(),
269 "/", base::Time(), false, false, COOKIE_PRIORITY_DEFAULT)); 272 "/", base::Time(), false, false, false, COOKIE_PRIORITY_DEFAULT));
270 273
271 // Http_only cookie 274 // http_only cookie
272 EXPECT_TRUE(this->SetCookieWithDetails( 275 EXPECT_TRUE(this->SetCookieWithDetails(
273 cm.get(), url_top_level_domain_plus_2, "httpo_check", "X", 276 cm.get(), url_top_level_domain_plus_2, "httpo_check", "x",
274 std::string(), "/", base::Time(), false, true, 277 std::string(), "/", base::Time(), false, true, false,
278 COOKIE_PRIORITY_DEFAULT));
279
280 // first-party cookie
281 EXPECT_TRUE(this->SetCookieWithDetails(
282 cm.get(), url_top_level_domain_plus_2, "firstp_check", "x",
283 std::string(), "/", base::Time(), false, false, true,
275 COOKIE_PRIORITY_DEFAULT)); 284 COOKIE_PRIORITY_DEFAULT));
276 285
277 // Secure cookies 286 // Secure cookies
278 EXPECT_TRUE(this->SetCookieWithDetails( 287 EXPECT_TRUE(this->SetCookieWithDetails(
279 cm.get(), url_top_level_domain_plus_2_secure, "sec_dom", "X", 288 cm.get(), url_top_level_domain_plus_2_secure, "sec_dom", "X",
280 ".math.harvard.edu", "/", base::Time(), true, false, 289 ".math.harvard.edu", "/", base::Time(), true, false, false,
281 COOKIE_PRIORITY_DEFAULT)); 290 COOKIE_PRIORITY_DEFAULT));
282 EXPECT_TRUE(this->SetCookieWithDetails( 291 EXPECT_TRUE(this->SetCookieWithDetails(
283 cm.get(), url_top_level_domain_plus_2_secure, "sec_host", "X", 292 cm.get(), url_top_level_domain_plus_2_secure, "sec_host", "X",
284 std::string(), "/", base::Time(), true, false, 293 std::string(), "/", base::Time(), true, false, false,
285 COOKIE_PRIORITY_DEFAULT)); 294 COOKIE_PRIORITY_DEFAULT));
286 295
287 // Domain path cookies 296 // Domain path cookies
288 EXPECT_TRUE(this->SetCookieWithDetails( 297 EXPECT_TRUE(this->SetCookieWithDetails(
289 cm.get(), url_top_level_domain_plus_2, "dom_path_1", "X", 298 cm.get(), url_top_level_domain_plus_2, "dom_path_1", "X",
290 ".math.harvard.edu", "/dir1", base::Time(), false, false, 299 ".math.harvard.edu", "/dir1", base::Time(), false, false, false,
291 COOKIE_PRIORITY_DEFAULT)); 300 COOKIE_PRIORITY_DEFAULT));
292 EXPECT_TRUE(this->SetCookieWithDetails( 301 EXPECT_TRUE(this->SetCookieWithDetails(
293 cm.get(), url_top_level_domain_plus_2, "dom_path_2", "X", 302 cm.get(), url_top_level_domain_plus_2, "dom_path_2", "X",
294 ".math.harvard.edu", "/dir1/dir2", base::Time(), false, false, 303 ".math.harvard.edu", "/dir1/dir2", base::Time(), false, false, false,
295 COOKIE_PRIORITY_DEFAULT)); 304 COOKIE_PRIORITY_DEFAULT));
296 305
297 // Host path cookies 306 // Host path cookies
298 EXPECT_TRUE(this->SetCookieWithDetails( 307 EXPECT_TRUE(this->SetCookieWithDetails(
299 cm.get(), url_top_level_domain_plus_2, "host_path_1", "X", 308 cm.get(), url_top_level_domain_plus_2, "host_path_1", "X",
300 std::string(), "/dir1", base::Time(), false, false, 309 std::string(), "/dir1", base::Time(), false, false, false,
301 COOKIE_PRIORITY_DEFAULT)); 310 COOKIE_PRIORITY_DEFAULT));
302 EXPECT_TRUE(this->SetCookieWithDetails( 311 EXPECT_TRUE(this->SetCookieWithDetails(
303 cm.get(), url_top_level_domain_plus_2, "host_path_2", "X", 312 cm.get(), url_top_level_domain_plus_2, "host_path_2", "X",
304 std::string(), "/dir1/dir2", base::Time(), false, false, 313 std::string(), "/dir1/dir2", base::Time(), false, false, false,
305 COOKIE_PRIORITY_DEFAULT)); 314 COOKIE_PRIORITY_DEFAULT));
306 315
307 EXPECT_EQ(13U, this->GetAllCookies(cm.get()).size()); 316 EXPECT_EQ(14U, this->GetAllCookies(cm.get()).size());
308 } 317 }
309 318
310 Time GetFirstCookieAccessDate(CookieMonster* cm) { 319 Time GetFirstCookieAccessDate(CookieMonster* cm) {
311 const CookieList all_cookies(this->GetAllCookies(cm)); 320 const CookieList all_cookies(this->GetAllCookies(cm));
312 return all_cookies.front().LastAccessDate(); 321 return all_cookies.front().LastAccessDate();
313 } 322 }
314 323
315 bool FindAndDeleteCookie(CookieMonster* cm, 324 bool FindAndDeleteCookie(CookieMonster* cm,
316 const std::string& domain, 325 const std::string& domain,
317 const std::string& name) { 326 const std::string& name) {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 596
588 struct CookiesInputInfo { 597 struct CookiesInputInfo {
589 const GURL url; 598 const GURL url;
590 const std::string name; 599 const std::string name;
591 const std::string value; 600 const std::string value;
592 const std::string domain; 601 const std::string domain;
593 const std::string path; 602 const std::string path;
594 const base::Time expiration_time; 603 const base::Time expiration_time;
595 bool secure; 604 bool secure;
596 bool http_only; 605 bool http_only;
606 bool first_party;
597 CookiePriority priority; 607 CookiePriority priority;
598 }; 608 };
599 609
600 ACTION(QuitCurrentMessageLoop) { 610 ACTION(QuitCurrentMessageLoop) {
601 base::MessageLoop::current()->PostTask(FROM_HERE, 611 base::MessageLoop::current()->PostTask(FROM_HERE,
602 base::MessageLoop::QuitClosure()); 612 base::MessageLoop::QuitClosure());
603 } 613 }
604 614
605 // TODO(erikwright): When the synchronous helpers 'GetCookies' etc. are removed, 615 // TODO(erikwright): When the synchronous helpers 'GetCookies' etc. are removed,
606 // rename these, removing the 'Action' suffix. 616 // rename these, removing the 'Action' suffix.
(...skipping 12 matching lines...) Expand all
619 cookie_monster, 629 cookie_monster,
620 delete_begin, 630 delete_begin,
621 delete_end, 631 delete_end,
622 callback) { 632 callback) {
623 cookie_monster->DeleteAllCreatedBetweenAsync(delete_begin, delete_end, 633 cookie_monster->DeleteAllCreatedBetweenAsync(delete_begin, delete_end,
624 callback->AsCallback()); 634 callback->AsCallback());
625 } 635 }
626 ACTION_P3(SetCookieWithDetailsAction, cookie_monster, cc, callback) { 636 ACTION_P3(SetCookieWithDetailsAction, cookie_monster, cc, callback) {
627 cookie_monster->SetCookieWithDetailsAsync( 637 cookie_monster->SetCookieWithDetailsAsync(
628 cc.url, cc.name, cc.value, cc.domain, cc.path, cc.expiration_time, 638 cc.url, cc.name, cc.value, cc.domain, cc.path, cc.expiration_time,
629 cc.secure, cc.http_only, cc.priority, callback->AsCallback()); 639 cc.secure, cc.http_only, cc.first_party, cc.priority,
640 callback->AsCallback());
630 } 641 }
631 642
632 ACTION_P2(GetAllCookiesAction, cookie_monster, callback) { 643 ACTION_P2(GetAllCookiesAction, cookie_monster, callback) {
633 cookie_monster->GetAllCookiesAsync(callback->AsCallback()); 644 cookie_monster->GetAllCookiesAsync(callback->AsCallback());
634 } 645 }
635 646
636 ACTION_P3(DeleteAllForHostAction, cookie_monster, url, callback) { 647 ACTION_P3(DeleteAllForHostAction, cookie_monster, url, callback) {
637 cookie_monster->DeleteAllForHostAsync(url, callback->AsCallback()); 648 cookie_monster->DeleteAllForHostAsync(url, callback->AsCallback());
638 } 649 }
639 650
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 MockSetCookiesCallback set_cookies_callback; 846 MockSetCookiesCallback set_cookies_callback;
836 847
837 CookiesInputInfo cookie_info = {url_google_foo_, 848 CookiesInputInfo cookie_info = {url_google_foo_,
838 "A", 849 "A",
839 "B", 850 "B",
840 std::string(), 851 std::string(),
841 "/foo", 852 "/foo",
842 base::Time(), 853 base::Time(),
843 false, 854 false,
844 false, 855 false,
856 false,
845 COOKIE_PRIORITY_DEFAULT}; 857 COOKIE_PRIORITY_DEFAULT};
846 BeginWithForDomainKey( 858 BeginWithForDomainKey(
847 "google.izzle", SetCookieWithDetailsAction(&cookie_monster(), cookie_info, 859 "google.izzle", SetCookieWithDetailsAction(&cookie_monster(), cookie_info,
848 &set_cookies_callback)); 860 &set_cookies_callback));
849 861
850 WaitForLoadCall(); 862 WaitForLoadCall();
851 863
852 CookiesInputInfo cookie_info_exp = {url_google_foo_, 864 CookiesInputInfo cookie_info_exp = {url_google_foo_,
853 "A", 865 "A",
854 "B", 866 "B",
855 std::string(), 867 std::string(),
856 "/foo", 868 "/foo",
857 base::Time(), 869 base::Time(),
858 false, 870 false,
859 false, 871 false,
872 false,
860 COOKIE_PRIORITY_DEFAULT}; 873 COOKIE_PRIORITY_DEFAULT};
861 EXPECT_CALL(set_cookies_callback, Invoke(true)) 874 EXPECT_CALL(set_cookies_callback, Invoke(true))
862 .WillOnce(SetCookieWithDetailsAction(&cookie_monster(), cookie_info_exp, 875 .WillOnce(SetCookieWithDetailsAction(&cookie_monster(), cookie_info_exp,
863 &set_cookies_callback)); 876 &set_cookies_callback));
864 EXPECT_CALL(set_cookies_callback, Invoke(true)) 877 EXPECT_CALL(set_cookies_callback, Invoke(true))
865 .WillOnce(QuitCurrentMessageLoop()); 878 .WillOnce(QuitCurrentMessageLoop());
866 879
867 CompleteLoadingAndWait(); 880 CompleteLoadingAndWait();
868 } 881 }
869 882
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 EXPECT_EQ("a", delegate->changes()[1].first.Name()); 1543 EXPECT_EQ("a", delegate->changes()[1].first.Name());
1531 EXPECT_EQ("val2", delegate->changes()[1].first.Value()); 1544 EXPECT_EQ("val2", delegate->changes()[1].first.Value());
1532 delegate->reset(); 1545 delegate->reset();
1533 } 1546 }
1534 1547
1535 TEST_F(CookieMonsterTest, SetCookieWithDetails) { 1548 TEST_F(CookieMonsterTest, SetCookieWithDetails) {
1536 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); 1549 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1537 1550
1538 EXPECT_TRUE(SetCookieWithDetails(cm.get(), url_google_foo_, "A", "B", 1551 EXPECT_TRUE(SetCookieWithDetails(cm.get(), url_google_foo_, "A", "B",
1539 std::string(), "/foo", base::Time(), false, 1552 std::string(), "/foo", base::Time(), false,
1540 false, COOKIE_PRIORITY_DEFAULT)); 1553 false, false, COOKIE_PRIORITY_DEFAULT));
1541 EXPECT_TRUE(SetCookieWithDetails(cm.get(), url_google_bar_, "C", "D", 1554 EXPECT_TRUE(SetCookieWithDetails(cm.get(), url_google_bar_, "C", "D",
1542 "google.izzle", "/bar", base::Time(), false, 1555 "google.izzle", "/bar", base::Time(), false,
1543 true, COOKIE_PRIORITY_DEFAULT));
1544 EXPECT_TRUE(SetCookieWithDetails(cm.get(), url_google_, "E", "F",
1545 std::string(), std::string(), base::Time(),
1546 true, false, COOKIE_PRIORITY_DEFAULT)); 1556 true, false, COOKIE_PRIORITY_DEFAULT));
1557 EXPECT_TRUE(SetCookieWithDetails(
1558 cm.get(), url_google_, "E", "F", std::string(), std::string(),
1559 base::Time(), true, false, false, COOKIE_PRIORITY_DEFAULT));
1547 1560
1548 // Test that malformed attributes fail to set the cookie. 1561 // Test that malformed attributes fail to set the cookie.
1549 EXPECT_FALSE(SetCookieWithDetails(cm.get(), url_google_foo_, " A", "B", 1562 EXPECT_FALSE(SetCookieWithDetails(cm.get(), url_google_foo_, " A", "B",
1550 std::string(), "/foo", base::Time(), false, 1563 std::string(), "/foo", base::Time(), false,
1551 false, COOKIE_PRIORITY_DEFAULT)); 1564 false, false, COOKIE_PRIORITY_DEFAULT));
1552 EXPECT_FALSE(SetCookieWithDetails(cm.get(), url_google_foo_, "A;", "B", 1565 EXPECT_FALSE(SetCookieWithDetails(cm.get(), url_google_foo_, "A;", "B",
1553 std::string(), "/foo", base::Time(), false, 1566 std::string(), "/foo", base::Time(), false,
1554 false, COOKIE_PRIORITY_DEFAULT)); 1567 false, false, COOKIE_PRIORITY_DEFAULT));
1555 EXPECT_FALSE(SetCookieWithDetails(cm.get(), url_google_foo_, "A=", "B", 1568 EXPECT_FALSE(SetCookieWithDetails(cm.get(), url_google_foo_, "A=", "B",
1556 std::string(), "/foo", base::Time(), false, 1569 std::string(), "/foo", base::Time(), false,
1557 false, COOKIE_PRIORITY_DEFAULT)); 1570 false, false, COOKIE_PRIORITY_DEFAULT));
1558 EXPECT_FALSE(SetCookieWithDetails(cm.get(), url_google_foo_, "A", "B", 1571 EXPECT_FALSE(SetCookieWithDetails(cm.get(), url_google_foo_, "A", "B",
1559 "google.ozzzzzzle", "foo", base::Time(), 1572 "google.ozzzzzzle", "foo", base::Time(),
1560 false, false, COOKIE_PRIORITY_DEFAULT)); 1573 false, false, false,
1574 COOKIE_PRIORITY_DEFAULT));
1561 EXPECT_FALSE(SetCookieWithDetails(cm.get(), url_google_foo_, "A=", "B", 1575 EXPECT_FALSE(SetCookieWithDetails(cm.get(), url_google_foo_, "A=", "B",
1562 std::string(), "foo", base::Time(), false, 1576 std::string(), "foo", base::Time(), false,
1563 false, COOKIE_PRIORITY_DEFAULT)); 1577 false, false, COOKIE_PRIORITY_DEFAULT));
1564 1578
1565 CookieList cookies = GetAllCookiesForURL(cm.get(), url_google_foo_); 1579 CookieList cookies = GetAllCookiesForURL(cm.get(), url_google_foo_);
1566 CookieList::iterator it = cookies.begin(); 1580 CookieList::iterator it = cookies.begin();
1567 1581
1568 ASSERT_TRUE(it != cookies.end()); 1582 ASSERT_TRUE(it != cookies.end());
1569 EXPECT_EQ("A", it->Name()); 1583 EXPECT_EQ("A", it->Name());
1570 EXPECT_EQ("B", it->Value()); 1584 EXPECT_EQ("B", it->Value());
1571 EXPECT_EQ("www.google.izzle", it->Domain()); 1585 EXPECT_EQ("www.google.izzle", it->Domain());
1572 EXPECT_EQ("/foo", it->Path()); 1586 EXPECT_EQ("/foo", it->Path());
1573 EXPECT_FALSE(it->IsPersistent()); 1587 EXPECT_FALSE(it->IsPersistent());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 EXPECT_EQ("dom_1=X; dom_2=X; host_2=X; sec_dom=X; sec_host=X", 1634 EXPECT_EQ("dom_1=X; dom_2=X; host_2=X; sec_dom=X; sec_host=X",
1621 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure))); 1635 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure)));
1622 EXPECT_EQ("dom_1=X; host_1=X", 1636 EXPECT_EQ("dom_1=X; host_1=X",
1623 GetCookies(cm.get(), GURL(kTopLevelDomainPlus1))); 1637 GetCookies(cm.get(), GURL(kTopLevelDomainPlus1)));
1624 EXPECT_EQ( 1638 EXPECT_EQ(
1625 "dom_path_2=X; host_path_2=X; dom_path_1=X; host_path_1=X; " 1639 "dom_path_2=X; host_path_2=X; dom_path_1=X; host_path_1=X; "
1626 "dom_1=X; dom_2=X; host_2=X; sec_dom=X; sec_host=X", 1640 "dom_1=X; dom_2=X; host_2=X; sec_dom=X; sec_host=X",
1627 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure + 1641 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure +
1628 std::string("/dir1/dir2/xxx")))); 1642 std::string("/dir1/dir2/xxx"))));
1629 1643
1630 EXPECT_EQ(5, DeleteAllForHost(cm.get(), GURL(kTopLevelDomainPlus2))); 1644 EXPECT_EQ(6, DeleteAllForHost(cm.get(), GURL(kTopLevelDomainPlus2)));
1631 EXPECT_EQ(8U, GetAllCookies(cm.get()).size()); 1645 EXPECT_EQ(8U, GetAllCookies(cm.get()).size());
1632 1646
1633 EXPECT_EQ("dom_1=X; dom_2=X; dom_3=X; host_3=X", 1647 EXPECT_EQ("dom_1=X; dom_2=X; dom_3=X; host_3=X",
1634 GetCookies(cm.get(), GURL(kTopLevelDomainPlus3))); 1648 GetCookies(cm.get(), GURL(kTopLevelDomainPlus3)));
1635 EXPECT_EQ("dom_1=X; dom_2=X; sec_dom=X", 1649 EXPECT_EQ("dom_1=X; dom_2=X; sec_dom=X",
1636 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure))); 1650 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure)));
1637 EXPECT_EQ("dom_1=X; host_1=X", 1651 EXPECT_EQ("dom_1=X; host_1=X",
1638 GetCookies(cm.get(), GURL(kTopLevelDomainPlus1))); 1652 GetCookies(cm.get(), GURL(kTopLevelDomainPlus1)));
1639 EXPECT_EQ("dom_path_2=X; dom_path_1=X; dom_1=X; dom_2=X; sec_dom=X", 1653 EXPECT_EQ("dom_path_2=X; dom_path_1=X; dom_1=X; dom_2=X; sec_dom=X",
1640 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure + 1654 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure +
1641 std::string("/dir1/dir2/xxx")))); 1655 std::string("/dir1/dir2/xxx"))));
1642 1656
1643 PopulateCmForDeleteAllForHost(cm); 1657 PopulateCmForDeleteAllForHost(cm);
1644 EXPECT_EQ(5, DeleteAllForHost(cm.get(), GURL(kTopLevelDomainPlus2Secure))); 1658 EXPECT_EQ(6, DeleteAllForHost(cm.get(), GURL(kTopLevelDomainPlus2Secure)));
1645 EXPECT_EQ(8U, GetAllCookies(cm.get()).size()); 1659 EXPECT_EQ(8U, GetAllCookies(cm.get()).size());
1646 1660
1647 EXPECT_EQ("dom_1=X; dom_2=X; dom_3=X; host_3=X", 1661 EXPECT_EQ("dom_1=X; dom_2=X; dom_3=X; host_3=X",
1648 GetCookies(cm.get(), GURL(kTopLevelDomainPlus3))); 1662 GetCookies(cm.get(), GURL(kTopLevelDomainPlus3)));
1649 EXPECT_EQ("dom_1=X; dom_2=X; sec_dom=X", 1663 EXPECT_EQ("dom_1=X; dom_2=X; sec_dom=X",
1650 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure))); 1664 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure)));
1651 EXPECT_EQ("dom_1=X; host_1=X", 1665 EXPECT_EQ("dom_1=X; host_1=X",
1652 GetCookies(cm.get(), GURL(kTopLevelDomainPlus1))); 1666 GetCookies(cm.get(), GURL(kTopLevelDomainPlus1)));
1653 EXPECT_EQ("dom_path_2=X; dom_path_1=X; dom_1=X; dom_2=X; sec_dom=X", 1667 EXPECT_EQ("dom_path_2=X; dom_path_1=X; dom_1=X; dom_2=X; sec_dom=X",
1654 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure + 1668 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure +
1655 std::string("/dir1/dir2/xxx")))); 1669 std::string("/dir1/dir2/xxx"))));
1656 1670
1657 PopulateCmForDeleteAllForHost(cm); 1671 PopulateCmForDeleteAllForHost(cm);
1658 EXPECT_EQ(5, DeleteAllForHost(cm.get(), GURL(kTopLevelDomainPlus2Secure + 1672 EXPECT_EQ(6, DeleteAllForHost(cm.get(), GURL(kTopLevelDomainPlus2Secure +
1659 std::string("/dir1/xxx")))); 1673 std::string("/dir1/xxx"))));
1660 EXPECT_EQ(8U, GetAllCookies(cm.get()).size()); 1674 EXPECT_EQ(8U, GetAllCookies(cm.get()).size());
1661 1675
1662 EXPECT_EQ("dom_1=X; dom_2=X; dom_3=X; host_3=X", 1676 EXPECT_EQ("dom_1=X; dom_2=X; dom_3=X; host_3=X",
1663 GetCookies(cm.get(), GURL(kTopLevelDomainPlus3))); 1677 GetCookies(cm.get(), GURL(kTopLevelDomainPlus3)));
1664 EXPECT_EQ("dom_1=X; dom_2=X; sec_dom=X", 1678 EXPECT_EQ("dom_1=X; dom_2=X; sec_dom=X",
1665 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure))); 1679 GetCookies(cm.get(), GURL(kTopLevelDomainPlus2Secure)));
1666 EXPECT_EQ("dom_1=X; host_1=X", 1680 EXPECT_EQ("dom_1=X; host_1=X",
1667 GetCookies(cm.get(), GURL(kTopLevelDomainPlus1))); 1681 GetCookies(cm.get(), GURL(kTopLevelDomainPlus1)));
1668 EXPECT_EQ("dom_path_2=X; dom_path_1=X; dom_1=X; dom_2=X; sec_dom=X", 1682 EXPECT_EQ("dom_path_2=X; dom_path_1=X; dom_1=X; dom_2=X; sec_dom=X",
(...skipping 20 matching lines...) Expand all
1689 SetCookie(cm.get(), url_google_, "SetCookie3=A"); 1703 SetCookie(cm.get(), url_google_, "SetCookie3=A");
1690 1704
1691 SetCookieWithOptions(cm.get(), url_google_, "setCookieWithOptions1=A", 1705 SetCookieWithOptions(cm.get(), url_google_, "setCookieWithOptions1=A",
1692 options); 1706 options);
1693 SetCookieWithOptions(cm.get(), url_google_, "setCookieWithOptions2=A", 1707 SetCookieWithOptions(cm.get(), url_google_, "setCookieWithOptions2=A",
1694 options); 1708 options);
1695 SetCookieWithOptions(cm.get(), url_google_, "setCookieWithOptions3=A", 1709 SetCookieWithOptions(cm.get(), url_google_, "setCookieWithOptions3=A",
1696 options); 1710 options);
1697 1711
1698 SetCookieWithDetails(cm.get(), url_google_, "setCookieWithDetails1", "A", 1712 SetCookieWithDetails(cm.get(), url_google_, "setCookieWithDetails1", "A",
1699 ".google.com", "/", Time(), false, false, 1713 ".google.com", "/", Time(), false, false, false,
1700 COOKIE_PRIORITY_DEFAULT); 1714 COOKIE_PRIORITY_DEFAULT);
1701 SetCookieWithDetails(cm.get(), url_google_, "setCookieWithDetails2", "A", 1715 SetCookieWithDetails(cm.get(), url_google_, "setCookieWithDetails2", "A",
1702 ".google.com", "/", Time(), false, false, 1716 ".google.com", "/", Time(), false, false, false,
1703 COOKIE_PRIORITY_DEFAULT); 1717 COOKIE_PRIORITY_DEFAULT);
1704 SetCookieWithDetails(cm.get(), url_google_, "setCookieWithDetails3", "A", 1718 SetCookieWithDetails(cm.get(), url_google_, "setCookieWithDetails3", "A",
1705 ".google.com", "/", Time(), false, false, 1719 ".google.com", "/", Time(), false, false, false,
1706 COOKIE_PRIORITY_DEFAULT); 1720 COOKIE_PRIORITY_DEFAULT);
1707 1721
1708 // Now we check 1722 // Now we check
1709 CookieList cookie_list(GetAllCookies(cm.get())); 1723 CookieList cookie_list(GetAllCookies(cm.get()));
1710 typedef std::map<int64, CanonicalCookie> TimeCookieMap; 1724 typedef std::map<int64, CanonicalCookie> TimeCookieMap;
1711 TimeCookieMap check_map; 1725 TimeCookieMap check_map;
1712 for (CookieList::const_iterator it = cookie_list.begin(); 1726 for (CookieList::const_iterator it = cookie_list.begin();
1713 it != cookie_list.end(); it++) { 1727 it != cookie_list.end(); it++) {
1714 const int64 creation_date = it->CreationDate().ToInternalValue(); 1728 const int64 creation_date = it->CreationDate().ToInternalValue();
1715 TimeCookieMap::const_iterator existing_cookie_it( 1729 TimeCookieMap::const_iterator existing_cookie_it(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 1777
1764 const CookiesInputInfo input_info[] = { 1778 const CookiesInputInfo input_info[] = {
1765 {GURL("http://a.b.google.com"), 1779 {GURL("http://a.b.google.com"),
1766 "a", 1780 "a",
1767 "1", 1781 "1",
1768 "", 1782 "",
1769 "/path/to/cookie", 1783 "/path/to/cookie",
1770 expires, 1784 expires,
1771 false, 1785 false,
1772 false, 1786 false,
1787 false,
1773 COOKIE_PRIORITY_DEFAULT}, 1788 COOKIE_PRIORITY_DEFAULT},
1774 {GURL("https://www.google.com"), 1789 {GURL("https://www.google.com"),
1775 "b", 1790 "b",
1776 "2", 1791 "2",
1777 ".google.com", 1792 ".google.com",
1778 "/path/from/cookie", 1793 "/path/from/cookie",
1779 expires + TimeDelta::FromSeconds(10), 1794 expires + TimeDelta::FromSeconds(10),
1780 true, 1795 true,
1781 true, 1796 true,
1797 false,
1782 COOKIE_PRIORITY_DEFAULT}, 1798 COOKIE_PRIORITY_DEFAULT},
1783 {GURL("https://google.com"), 1799 {GURL("https://google.com"),
1784 "c", 1800 "c",
1785 "3", 1801 "3",
1786 "", 1802 "",
1787 "/another/path/to/cookie", 1803 "/another/path/to/cookie",
1788 base::Time::Now() + base::TimeDelta::FromSeconds(100), 1804 base::Time::Now() + base::TimeDelta::FromSeconds(100),
1789 true, 1805 true,
1790 false, 1806 false,
1807 true,
1791 COOKIE_PRIORITY_DEFAULT}}; 1808 COOKIE_PRIORITY_DEFAULT}};
1792 const int INPUT_DELETE = 1; 1809 const int INPUT_DELETE = 1;
1793 1810
1794 // Create new cookies and flush them to the store. 1811 // Create new cookies and flush them to the store.
1795 { 1812 {
1796 scoped_refptr<CookieMonster> cmout(new CookieMonster(store.get(), NULL)); 1813 scoped_refptr<CookieMonster> cmout(new CookieMonster(store.get(), NULL));
1797 for (const CookiesInputInfo* p = input_info; 1814 for (const CookiesInputInfo* p = input_info;
1798 p < &input_info[arraysize(input_info)]; p++) { 1815 p < &input_info[arraysize(input_info)]; p++) {
1799 EXPECT_TRUE(SetCookieWithDetails(cmout.get(), p->url, p->name, p->value, 1816 EXPECT_TRUE(SetCookieWithDetails(cmout.get(), p->url, p->name, p->value,
1800 p->domain, p->path, p->expiration_time, 1817 p->domain, p->path, p->expiration_time,
1801 p->secure, p->http_only, p->priority)); 1818 p->secure, p->http_only, p->first_party,
1819 p->priority));
1802 } 1820 }
1803 GURL del_url(input_info[INPUT_DELETE] 1821 GURL del_url(input_info[INPUT_DELETE]
1804 .url.Resolve(input_info[INPUT_DELETE].path) 1822 .url.Resolve(input_info[INPUT_DELETE].path)
1805 .spec()); 1823 .spec());
1806 DeleteCookie(cmout.get(), del_url, input_info[INPUT_DELETE].name); 1824 DeleteCookie(cmout.get(), del_url, input_info[INPUT_DELETE].name);
1807 } 1825 }
1808 1826
1809 // Create a new cookie monster and make sure that everything is correct 1827 // Create a new cookie monster and make sure that everything is correct
1810 { 1828 {
1811 scoped_refptr<CookieMonster> cmin(new CookieMonster(store.get(), NULL)); 1829 scoped_refptr<CookieMonster> cmin(new CookieMonster(store.get(), NULL));
1812 CookieList cookies(GetAllCookies(cmin.get())); 1830 CookieList cookies(GetAllCookies(cmin.get()));
1813 ASSERT_EQ(2u, cookies.size()); 1831 ASSERT_EQ(2u, cookies.size());
1814 // Ordering is path length, then creation time. So second cookie 1832 // Ordering is path length, then creation time. So second cookie
1815 // will come first, and we need to swap them. 1833 // will come first, and we need to swap them.
1816 std::swap(cookies[0], cookies[1]); 1834 std::swap(cookies[0], cookies[1]);
1817 for (int output_index = 0; output_index < 2; output_index++) { 1835 for (int output_index = 0; output_index < 2; output_index++) {
1818 int input_index = output_index * 2; 1836 int input_index = output_index * 2;
1819 const CookiesInputInfo* input = &input_info[input_index]; 1837 const CookiesInputInfo* input = &input_info[input_index];
1820 const CanonicalCookie* output = &cookies[output_index]; 1838 const CanonicalCookie* output = &cookies[output_index];
1821 1839
1822 EXPECT_EQ(input->name, output->Name()); 1840 EXPECT_EQ(input->name, output->Name());
1823 EXPECT_EQ(input->value, output->Value()); 1841 EXPECT_EQ(input->value, output->Value());
1824 EXPECT_EQ(input->url.host(), output->Domain()); 1842 EXPECT_EQ(input->url.host(), output->Domain());
1825 EXPECT_EQ(input->path, output->Path()); 1843 EXPECT_EQ(input->path, output->Path());
1826 EXPECT_LE(current.ToInternalValue(), 1844 EXPECT_LE(current.ToInternalValue(),
1827 output->CreationDate().ToInternalValue()); 1845 output->CreationDate().ToInternalValue());
1828 EXPECT_EQ(input->secure, output->IsSecure()); 1846 EXPECT_EQ(input->secure, output->IsSecure());
1829 EXPECT_EQ(input->http_only, output->IsHttpOnly()); 1847 EXPECT_EQ(input->http_only, output->IsHttpOnly());
1848 EXPECT_EQ(input->first_party, output->IsFirstParty());
1830 EXPECT_TRUE(output->IsPersistent()); 1849 EXPECT_TRUE(output->IsPersistent());
1831 EXPECT_EQ(input->expiration_time.ToInternalValue(), 1850 EXPECT_EQ(input->expiration_time.ToInternalValue(),
1832 output->ExpiryDate().ToInternalValue()); 1851 output->ExpiryDate().ToInternalValue());
1833 } 1852 }
1834 } 1853 }
1835 } 1854 }
1836 1855
1837 TEST_F(CookieMonsterTest, CookieListOrdering) { 1856 TEST_F(CookieMonsterTest, CookieListOrdering) {
1838 // Put a random set of cookies into a monster and make sure 1857 // Put a random set of cookies into a monster and make sure
1839 // they're returned in the right order. 1858 // they're returned in the right order.
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 // since the histogram should have been initialized by the CM construction 2113 // since the histogram should have been initialized by the CM construction
2095 // above. 2114 // above.
2096 base::HistogramBase* expired_histogram = base::Histogram::FactoryGet( 2115 base::HistogramBase* expired_histogram = base::Histogram::FactoryGet(
2097 "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50, 2116 "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50,
2098 base::Histogram::kUmaTargetedHistogramFlag); 2117 base::Histogram::kUmaTargetedHistogramFlag);
2099 2118
2100 scoped_ptr<base::HistogramSamples> samples1( 2119 scoped_ptr<base::HistogramSamples> samples1(
2101 expired_histogram->SnapshotSamples()); 2120 expired_histogram->SnapshotSamples());
2102 ASSERT_TRUE(SetCookieWithDetails( 2121 ASSERT_TRUE(SetCookieWithDetails(
2103 cm.get(), GURL("http://fake.a.url"), "a", "b", "a.url", "/", 2122 cm.get(), GURL("http://fake.a.url"), "a", "b", "a.url", "/",
2104 base::Time::Now() + base::TimeDelta::FromMinutes(59), false, false, 2123 base::Time::Now() + base::TimeDelta::FromMinutes(59), false, false, false,
2105 COOKIE_PRIORITY_DEFAULT)); 2124 COOKIE_PRIORITY_DEFAULT));
2106 2125
2107 scoped_ptr<base::HistogramSamples> samples2( 2126 scoped_ptr<base::HistogramSamples> samples2(
2108 expired_histogram->SnapshotSamples()); 2127 expired_histogram->SnapshotSamples());
2109 EXPECT_EQ(samples1->TotalCount() + 1, samples2->TotalCount()); 2128 EXPECT_EQ(samples1->TotalCount() + 1, samples2->TotalCount());
2110 2129
2111 // kValidCookieLine creates a session cookie. 2130 // kValidCookieLine creates a session cookie.
2112 ASSERT_TRUE(SetCookie(cm.get(), url_google_, kValidCookieLine)); 2131 ASSERT_TRUE(SetCookie(cm.get(), url_google_, kValidCookieLine));
2113 2132
2114 scoped_ptr<base::HistogramSamples> samples3( 2133 scoped_ptr<base::HistogramSamples> samples3(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 ResultSavingCookieCallback<bool>* callback) { 2170 ResultSavingCookieCallback<bool>* callback) {
2152 // Define the parameters here instead of in the calling fucntion. 2171 // Define the parameters here instead of in the calling fucntion.
2153 // The maximum number of parameters for Bind function is 6. 2172 // The maximum number of parameters for Bind function is 6.
2154 std::string name = "A"; 2173 std::string name = "A";
2155 std::string value = "B"; 2174 std::string value = "B";
2156 std::string domain = std::string(); 2175 std::string domain = std::string();
2157 std::string path = "/foo"; 2176 std::string path = "/foo";
2158 base::Time expiration_time = base::Time(); 2177 base::Time expiration_time = base::Time();
2159 bool secure = false; 2178 bool secure = false;
2160 bool http_only = false; 2179 bool http_only = false;
2180 bool first_party = false;
2161 CookiePriority priority = COOKIE_PRIORITY_DEFAULT; 2181 CookiePriority priority = COOKIE_PRIORITY_DEFAULT;
2162 cm->SetCookieWithDetailsAsync( 2182 cm->SetCookieWithDetailsAsync(
2163 url, name, value, domain, path, expiration_time, secure, http_only, 2183 url, name, value, domain, path, expiration_time, secure, http_only,
2164 priority, base::Bind(&ResultSavingCookieCallback<bool>::Run, 2184 first_party, priority,
2165 base::Unretained(callback))); 2185 base::Bind(&ResultSavingCookieCallback<bool>::Run,
2186 base::Unretained(callback)));
2166 } 2187 }
2167 2188
2168 void DeleteAllCreatedBetweenTask(CookieMonster* cm, 2189 void DeleteAllCreatedBetweenTask(CookieMonster* cm,
2169 const base::Time& delete_begin, 2190 const base::Time& delete_begin,
2170 const base::Time& delete_end, 2191 const base::Time& delete_end,
2171 ResultSavingCookieCallback<int>* callback) { 2192 ResultSavingCookieCallback<int>* callback) {
2172 cm->DeleteAllCreatedBetweenAsync( 2193 cm->DeleteAllCreatedBetweenAsync(
2173 delete_begin, delete_end, 2194 delete_begin, delete_end,
2174 base::Bind(&ResultSavingCookieCallback<int>::Run, 2195 base::Bind(&ResultSavingCookieCallback<int>::Run,
2175 base::Unretained(callback))); 2196 base::Unretained(callback)));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2281 ASSERT_TRUE(it != callback.cookies().end()); 2302 ASSERT_TRUE(it != callback.cookies().end());
2282 EXPECT_EQ("www.google.izzle", it->Domain()); 2303 EXPECT_EQ("www.google.izzle", it->Domain());
2283 EXPECT_EQ("A", it->Name()); 2304 EXPECT_EQ("A", it->Name());
2284 ASSERT_TRUE(++it == callback.cookies().end()); 2305 ASSERT_TRUE(++it == callback.cookies().end());
2285 } 2306 }
2286 2307
2287 TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckSetCookieWithDetails) { 2308 TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckSetCookieWithDetails) {
2288 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); 2309 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
2289 EXPECT_TRUE(SetCookieWithDetails(cm.get(), url_google_foo_, "A", "B", 2310 EXPECT_TRUE(SetCookieWithDetails(cm.get(), url_google_foo_, "A", "B",
2290 std::string(), "/foo", base::Time(), false, 2311 std::string(), "/foo", base::Time(), false,
2291 false, COOKIE_PRIORITY_DEFAULT)); 2312 false, false, COOKIE_PRIORITY_DEFAULT));
2292 ResultSavingCookieCallback<bool> callback(&other_thread_); 2313 ResultSavingCookieCallback<bool> callback(&other_thread_);
2293 base::Closure task = 2314 base::Closure task =
2294 base::Bind(&net::MultiThreadedCookieMonsterTest::SetCookieWithDetailsTask, 2315 base::Bind(&net::MultiThreadedCookieMonsterTest::SetCookieWithDetailsTask,
2295 base::Unretained(this), cm, url_google_foo_, &callback); 2316 base::Unretained(this), cm, url_google_foo_, &callback);
2296 RunOnOtherThread(task); 2317 RunOnOtherThread(task);
2297 EXPECT_TRUE(callback.did_run()); 2318 EXPECT_TRUE(callback.did_run());
2298 EXPECT_TRUE(callback.result()); 2319 EXPECT_TRUE(callback.result());
2299 } 2320 }
2300 2321
2301 TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteAllCreatedBetween) { 2322 TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteAllCreatedBetween) {
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2548 const std::string path("/path"); 2569 const std::string path("/path");
2549 2570
2550 scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore); 2571 scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore);
2551 2572
2552 std::vector<CanonicalCookie*> initial_cookies; 2573 std::vector<CanonicalCookie*> initial_cookies;
2553 2574
2554 AddCookieToList(domain, "foo=bar; path=" + path, now1, &initial_cookies); 2575 AddCookieToList(domain, "foo=bar; path=" + path, now1, &initial_cookies);
2555 2576
2556 // We have to manually build this cookie because it contains a control 2577 // We have to manually build this cookie because it contains a control
2557 // character, and our cookie line parser rejects control characters. 2578 // character, and our cookie line parser rejects control characters.
2558 CanonicalCookie* cc = new CanonicalCookie( 2579 CanonicalCookie* cc =
2559 url, "baz", 2580 new CanonicalCookie(url, "baz",
2560 "\x05" 2581 "\x05"
2561 "boo", 2582 "boo",
2562 domain, path, now2, later, now2, false, false, COOKIE_PRIORITY_DEFAULT); 2583 domain, path, now2, later, now2, false, false, false,
2584 COOKIE_PRIORITY_DEFAULT);
2563 initial_cookies.push_back(cc); 2585 initial_cookies.push_back(cc);
2564 2586
2565 AddCookieToList(domain, "hello=world; path=" + path, now3, &initial_cookies); 2587 AddCookieToList(domain, "hello=world; path=" + path, now3, &initial_cookies);
2566 2588
2567 // Inject our initial cookies into the mock PersistentCookieStore. 2589 // Inject our initial cookies into the mock PersistentCookieStore.
2568 store->SetLoadExpectation(true, initial_cookies); 2590 store->SetLoadExpectation(true, initial_cookies);
2569 2591
2570 scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL)); 2592 scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
2571 2593
2572 EXPECT_EQ("foo=bar; hello=world", GetCookies(cm.get(), url)); 2594 EXPECT_EQ("foo=bar; hello=world", GetCookies(cm.get(), url));
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2722 monster()->AddCallbackForCookie( 2744 monster()->AddCallbackForCookie(
2723 test_url_, "abc", 2745 test_url_, "abc",
2724 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); 2746 base::Bind(&RecordCookieChanges, &cookies1, nullptr)));
2725 SetCookie(monster(), test_url_, "abc=def"); 2747 SetCookie(monster(), test_url_, "abc=def");
2726 base::MessageLoop::current()->RunUntilIdle(); 2748 base::MessageLoop::current()->RunUntilIdle();
2727 EXPECT_EQ(1U, cookies0.size()); 2749 EXPECT_EQ(1U, cookies0.size());
2728 EXPECT_EQ(1U, cookies0.size()); 2750 EXPECT_EQ(1U, cookies0.size());
2729 } 2751 }
2730 2752
2731 } // namespace net 2753 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698