Home | History | Annotate | Download | only in base

Lines Matching refs:cm

33 // Helper for DeleteAllForHost test; repopulates CM with same layout
42 void PopulateCmForDeleteAllForHost(scoped_refptr<CookieMonster> cm) {
49 cm->DeleteAll(true);
60 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_1,
63 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_2,
66 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_3,
72 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_1,
75 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_2,
78 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_3,
83 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_2,
88 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_2_secure,
91 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_2_secure,
96 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_2,
100 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_2,
106 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_2,
110 EXPECT_TRUE(cm->SetCookieWithDetails(url_top_level_domain_plus_2,
115 EXPECT_EQ(13U, cm->GetAllCookies().size());
372 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
373 EXPECT_TRUE(cm->SetCookie(url_google, "A=B"));
374 EXPECT_EQ("A=B", cm->GetCookies(url_google));
375 EXPECT_TRUE(cm->SetCookie(url_google, "C=D; domain=.google.izzle"));
376 EXPECT_EQ("A=B; C=D", cm->GetCookies(url_google));
380 EXPECT_EQ("C=D", cm->GetCookies(GURL("http://foo.www.google.izzle")));
383 EXPECT_TRUE(cm->SetCookie(url_google, "E=F; domain=.www.google.izzle"));
384 EXPECT_EQ("A=B; C=D; E=F", cm->GetCookies(url_google));
388 EXPECT_TRUE(cm->SetCookie(url_google, "G=H; domain=www.google.izzle"));
389 EXPECT_EQ("A=B; C=D; E=F; G=H", cm->GetCookies(url_google));
392 EXPECT_FALSE(cm->SetCookie(url_google, "I=J; domain=.izzle"));
393 EXPECT_EQ("", cm->GetCookies(GURL("http://a.izzle")));
394 EXPECT_FALSE(cm->SetCookie(url_google, "K=L; domain=.bla.www.google.izzle"));
396 cm->GetCookies(GURL("http://bla.www.google.izzle")));
397 EXPECT_EQ("A=B; C=D; E=F; G=H", cm->GetCookies(url_google));
408 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
411 EXPECT_FALSE(cm->SetCookie(url_google, "a=1; domain=.www.google.com."));
412 EXPECT_FALSE(cm->SetCookie(url_google, "b=2; domain=.www.google.com.."));
413 EXPECT_EQ("", cm->GetCookies(url_google));
424 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
430 EXPECT_TRUE(cm->SetCookie(url_abcd, "a=1; domain=.a.b.c.d.com"));
431 EXPECT_TRUE(cm->SetCookie(url_abcd, "b=2; domain=.b.c.d.com"));
432 EXPECT_TRUE(cm->SetCookie(url_abcd, "c=3; domain=.c.d.com"));
433 EXPECT_TRUE(cm->SetCookie(url_abcd, "d=4; domain=.d.com"));
435 EXPECT_EQ("a=1; b=2; c=3; d=4", cm->GetCookies(url_abcd));
436 EXPECT_EQ("b=2; c=3; d=4", cm->GetCookies(url_bcd));
437 EXPECT_EQ("c=3; d=4", cm->GetCookies(url_cd));
438 EXPECT_EQ("d=4", cm->GetCookies(url_d));
441 EXPECT_TRUE(cm->SetCookie(url_bcd, "X=bcd; domain=.b.c.d.com"));
442 EXPECT_TRUE(cm->SetCookie(url_bcd, "X=cd; domain=.c.d.com"));
443 EXPECT_EQ("b=2; c=3; d=4; X=bcd; X=cd", cm->GetCookies(url_bcd));
444 EXPECT_EQ("c=3; d=4; X=cd", cm->GetCookies(url_cd));
459 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
463 EXPECT_FALSE(cm->SetCookie(url_foobar, "a=1; domain=.yo.foo.bar.com"));
465 EXPECT_FALSE(cm->SetCookie(url_foobar, "b=2; domain=.foo.com"));
466 EXPECT_FALSE(cm->SetCookie(url_foobar, "c=3; domain=.bar.foo.com"));
469 EXPECT_FALSE(cm->SetCookie(url_foobar, "d=4; domain=.foo.bar.com.net"));
472 EXPECT_FALSE(cm->SetCookie(url_foobar, "e=5; domain=ar.com"));
475 EXPECT_FALSE(cm->SetCookie(url_foobar, "f=6; domain=."));
476 EXPECT_FALSE(cm->SetCookie(url_foobar, "g=7; domain=/"));
477 EXPECT_FALSE(cm->SetCookie(url_foobar, "h=8; domain=http://foo.bar.com"));
478 EXPECT_FALSE(cm->SetCookie(url_foobar, "i=9; domain=..foo.bar.com"));
479 EXPECT_FALSE(cm->SetCookie(url_foobar, "j=10; domain=..bar.com"));
483 EXPECT_FALSE(cm->SetCookie(url_foobar, "k=11; domain=.foo.bar.com?blah"));
484 EXPECT_FALSE(cm->SetCookie(url_foobar, "l=12; domain=.foo.bar.com/blah"));
485 EXPECT_FALSE(cm->SetCookie(url_foobar, "m=13; domain=.foo.bar.com:80"));
486 EXPECT_FALSE(cm->SetCookie(url_foobar, "n=14; domain=.foo.bar.com:"));
487 EXPECT_FALSE(cm->SetCookie(url_foobar, "o=15; domain=.foo.bar.com#sup"));
489 EXPECT_EQ("", cm->GetCookies(url_foobar));
499 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
501 EXPECT_FALSE(cm->SetCookie(url_foocom, "a=1; domain=.foo.com.com.com"));
502 EXPECT_EQ("", cm->GetCookies(url_foocom));
511 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
514 EXPECT_TRUE(cm->SetCookie(url_hosted, "sawAd=1; domain=filefront.com"));
515 EXPECT_EQ("sawAd=1", cm->GetCookies(url_hosted));
516 EXPECT_EQ("sawAd=1", cm->GetCookies(url_filefront));
520 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
522 EXPECT_TRUE(cm->SetCookie(url, "a=1; domain=www.google.com"));
523 EXPECT_EQ("a=1", cm->GetCookies(url));
524 EXPECT_EQ("a=1", cm->GetCookies(GURL("http://sub.www.google.com")));
525 EXPECT_EQ("", cm->GetCookies(GURL("http://something-else.com")));
532 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
534 EXPECT_TRUE(cm->SetCookie(url_google, "a=1; domain=.GOOGLE.COM"));
535 EXPECT_TRUE(cm->SetCookie(url_google, "b=2; domain=.wWw.gOOgLE.coM"));
536 EXPECT_EQ("a=1; b=2", cm->GetCookies(url_google));
542 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
543 EXPECT_TRUE(cm->SetCookie(url_ip, kValidCookieLine));
544 EXPECT_EQ("A=B", cm->GetCookies(url_ip));
548 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
549 EXPECT_FALSE(cm->SetCookie(url_ip, "b=2; domain=.1.2.3.4"));
550 EXPECT_FALSE(cm->SetCookie(url_ip, "c=3; domain=.3.4"));
551 EXPECT_EQ("", cm->GetCookies(url_ip));
554 EXPECT_FALSE(cm->SetCookie(url_ip, "b=2; domain=1.2.3.3"));
555 EXPECT_EQ("", cm->GetCookies(url_ip));
556 EXPECT_TRUE(cm->SetCookie(url_ip, "b=2; domain=1.2.3.4"));
557 EXPECT_EQ("b=2", cm->GetCookies(url_ip));
564 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
567 EXPECT_TRUE(cm->SetCookie(url, "a=1"));
568 EXPECT_FALSE(cm->SetCookie(url, "b=2; domain=.com"));
569 EXPECT_FALSE(cm->SetCookie(url, "c=3; domain=com"));
570 EXPECT_EQ("a=1", cm->GetCookies(url));
573 EXPECT_EQ("", cm->GetCookies(GURL("http://hopefully-no-cookies.com/")));
574 EXPECT_EQ("", cm->GetCookies(GURL("http://.com/")));
578 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
580 EXPECT_TRUE(cm->SetCookie(url, "a=1"));
581 EXPECT_EQ("a=1", cm->GetCookies(url));
582 EXPECT_EQ("", cm->GetCookies(GURL("http://hopefully-no-cookies.com./")));
586 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
588 EXPECT_FALSE(cm->SetCookie(url, "a=1; domain=.b"));
589 EXPECT_FALSE(cm->SetCookie(url, "b=2; domain=b"));
590 EXPECT_EQ("", cm->GetCookies(url));
594 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
596 EXPECT_FALSE(cm->SetCookie(url, "a=1; domain=.com"));
597 EXPECT_FALSE(cm->SetCookie(url, "b=2; domain=com"));
598 EXPECT_EQ("", cm->GetCookies(url));
602 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
604 EXPECT_FALSE(cm->SetCookie(url, "a=1; domain=.co.uk"));
605 EXPECT_FALSE(cm->SetCookie(url, "b=2; domain=.uk"));
606 EXPECT_EQ("", cm->GetCookies(url));
607 EXPECT_EQ("", cm->GetCookies(GURL("http://something-else.co.uk")));
608 EXPECT_EQ("", cm->GetCookies(GURL("http://something-else.uk")));
612 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
614 EXPECT_TRUE(cm->SetCookie(url, "a=1"));
615 EXPECT_FALSE(cm->SetCookie(url, "b=2; domain=.b"));
616 EXPECT_FALSE(cm->SetCookie(url, "c=3; domain=b"));
617 EXPECT_EQ("a=1", cm->GetCookies(url));
624 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
627 EXPECT_TRUE(cm->SetCookie(url, "a=1"));
628 EXPECT_EQ("a=1", cm->GetCookies(url));
632 EXPECT_FALSE(cm->SetCookie(url, "b=2; domain=.www.google.com."));
633 EXPECT_EQ("a=1", cm->GetCookies(url));
635 EXPECT_TRUE(cm->SetCookie(url_with_dot, "b=2; domain=.google.com."));
636 EXPECT_EQ("b=2", cm->GetCookies(url_with_dot));
639 EXPECT_EQ(cm->GetCookies(GURL("http://hopefully-no-cookies.com/")), "");
640 EXPECT_EQ("", cm->GetCookies(GURL("http://.com/")));
644 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
645 EXPECT_FALSE(cm->SetCookie(GURL(kUrlFtp), kValidCookieLine));
649 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
650 EXPECT_TRUE(cm->SetCookie(GURL(kUrlGoogle), kValidDomainCookieLine));
651 EXPECT_EQ("", cm->GetCookies(GURL(kUrlFtp)));
656 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
657 EXPECT_TRUE(cm->SetCookie(GURL(url), "A=B; path=/wee"));
658 EXPECT_EQ("A=B", cm->GetCookies(GURL(url + "/wee")));
659 EXPECT_EQ("A=B", cm->GetCookies(GURL(url + "/wee/")));
660 EXPECT_EQ("A=B", cm->GetCookies(GURL(url + "/wee/war")));
661 EXPECT_EQ("A=B", cm->GetCookies(GURL(url + "/wee/war/more/more")));
662 EXPECT_EQ("", cm->GetCookies(GURL(url + "/weehee")));
663 EXPECT_EQ("", cm->GetCookies(GURL(url + "/")));
666 EXPECT_TRUE(cm->SetCookie(GURL(url), "A=C; path="));
667 EXPECT_EQ("A=B; A=C", cm->GetCookies(GURL(url + "/wee")));
668 EXPECT_EQ("A=C", cm->GetCookies(GURL(url + "/")));
673 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
678 EXPECT_TRUE(cm->SetCookieWithOptions(url_google, "A=B; httponly", options));
681 EXPECT_EQ("", cm->GetCookies(url_google));
682 EXPECT_EQ("A=B", cm->GetCookiesWithOptions(url_google, options));
685 EXPECT_FALSE(cm->SetCookie(url_google, "A=C"));
686 EXPECT_EQ("", cm->GetCookies(url_google));
687 EXPECT_EQ("A=B", cm->GetCookiesWithOptions(url_google, options));
688 EXPECT_TRUE(cm->SetCookieWithOptions(url_google, "A=C", options));
689 EXPECT_EQ("A=C", cm->GetCookies(url_google));
692 EXPECT_FALSE(cm->SetCookie(url_google, "B=A; httponly"));
693 EXPECT_EQ("A=C", cm->GetCookiesWithOptions(url_google, options));
694 EXPECT_TRUE(cm->SetCookieWithOptions(url_google, "B=A; httponly", options));
695 EXPECT_EQ("A=C; B=A", cm->GetCookiesWithOptions(url_google, options));
696 EXPECT_EQ("A=C", cm->GetCookies(url_google));
815 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
818 EXPECT_TRUE(cm->SetCookie(url_google, kValidCookieLine));
819 EXPECT_EQ("A=B", cm->GetCookies(url_google));
821 EXPECT_TRUE(cm->SetCookie(url_google,
823 EXPECT_EQ("", cm->GetCookies(url_google));
826 EXPECT_TRUE(cm->SetCookie(url_google, kValidCookieLine));
827 EXPECT_EQ("A=B", cm->GetCookies(url_google));
829 EXPECT_TRUE(cm->SetCookie(url_google,
832 EXPECT_EQ("", cm->GetCookies(url_google));
835 EXPECT_TRUE(cm->SetCookie(url_google,
841 EXPECT_EQ("A=B", cm->GetCookies(url_google));
843 EXPECT_TRUE(cm->SetCookie(url_google,
847 EXPECT_EQ("", cm->GetCookies(url_google));
850 EXPECT_TRUE(cm->SetCookie(url_google,
855 EXPECT_EQ("A=B", cm->GetCookies(url_google));
857 EXPECT_TRUE(cm->SetCookie(url_google,
862 EXPECT_EQ("", cm->GetCookies(url_google));
865 EXPECT_TRUE(cm->SetCookie(url_google,
870 EXPECT_EQ("A=B", cm->GetCookies(url_google));
872 EXPECT_TRUE(cm->SetCookie(url_google,
877 EXPECT_EQ("", cm->GetCookies(url_google));
884 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
888 EXPECT_TRUE(cm->SetCookie(url_google, kValidCookieLine));
889 EXPECT_EQ("A=B", cm->GetCookies(url_google));
891 EXPECT_TRUE(cm->SetCookieWithOptions(url_google, "C=D; httponly", options));
892 EXPECT_EQ("A=B; C=D", cm->GetCookiesWithOptions(url_google, options));
894 EXPECT_EQ(2, cm->DeleteAll(false));
895 EXPECT_EQ("", cm->GetCookiesWithOptions(url_google, options));
900 EXPECT_TRUE(cm->SetCookie(url_google,
906 EXPECT_EQ(1, cm->DeleteAll(true)); // sync_to_store = true.
910 EXPECT_EQ("", cm->GetCookiesWithOptions(url_google, options));
915 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
919 EXPECT_EQ(0, cm->DeleteAllCreatedAfter(now - TimeDelta::FromDays(99), false));
922 EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google, "T-0=Now", now));
923 EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google, "T-1=Yesterday",
925 EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google, "T-2=DayBefore",
929 EXPECT_EQ(1, cm->DeleteAllCreatedAfter(now, false));
931 EXPECT_EQ(1, cm->DeleteAllCreatedAfter(now - TimeDelta::FromDays(1), false));
933 EXPECT_EQ(1, cm->DeleteAllCreatedAfter(now - TimeDelta::FromDays(99), false));
936 EXPECT_EQ(0, cm->DeleteAllCreatedAfter(Time(), false));
938 EXPECT_EQ(0, cm->DeleteAll(false));
943 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
947 EXPECT_EQ(0, cm->DeleteAllCreatedAfter(now - TimeDelta::FromDays(99), false));
950 EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google, "T-0=Now", now));
951 EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google, "T-1=Yesterday",
953 EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google, "T-2=DayBefore",
955 EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google, "T-3=ThreeDays",
957 EXPECT_TRUE(cm->SetCookieWithCreationTime(url_google, "T-7=LastWeek",
961 EXPECT_EQ(2, cm->DeleteAllCreatedBetween(now - TimeDelta::FromDays(3),
967 EXPECT_EQ(1, cm->DeleteAllCreatedBetween(now - TimeDelta::FromDays(2),
972 EXPECT_EQ(1, cm->DeleteAllCreatedBetween(now - TimeDelta::FromDays(7),
977 EXPECT_EQ(1, cm->DeleteAllCreatedAfter(Time(), false));
980 EXPECT_EQ(0, cm->DeleteAll(false));
986 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
988 EXPECT_TRUE(cm->SetCookie(url_google, "A=B"));
989 EXPECT_EQ("A=B", cm->GetCookies(url_google));
990 EXPECT_EQ("A=B", cm->GetCookies(url_google_secure));
992 EXPECT_TRUE(cm->SetCookie(url_google_secure, "A=B; secure"));
994 EXPECT_EQ("", cm->GetCookies(url_google));
995 EXPECT_EQ("A=B", cm->GetCookies(url_google_secure));
997 EXPECT_TRUE(cm->SetCookie(url_google_secure, "D=E; secure"));
998 EXPECT_EQ("", cm->GetCookies(url_google));
999 EXPECT_EQ("A=B; D=E", cm->GetCookies(url_google_secure));
1001 EXPECT_TRUE(cm->SetCookie(url_google_secure, "A=B"));
1003 EXPECT_EQ("A=B", cm->GetCookies(url_google));
1004 EXPECT_EQ("D=E; A=B", cm->GetCookies(url_google_secure));
1007 static Time GetFirstCookieAccessDate(CookieMonster* cm) {
1008 const CookieList all_cookies(cm->GetAllCookies());
1016 scoped_refptr<CookieMonster> cm(
1019 EXPECT_TRUE(cm->SetCookie(url_google, "A=B"));
1020 const Time last_access_date(GetFirstCookieAccessDate(cm));
1024 EXPECT_EQ("A=B", cm->GetCookies(url_google));
1025 EXPECT_TRUE(last_access_date == GetFirstCookieAccessDate(cm));
1029 EXPECT_EQ("A=B", cm->GetCookies(url_google));
1030 EXPECT_FALSE(last_access_date == GetFirstCookieAccessDate(cm));
1046 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1047 cm->SetExpiryAndKeyScheme(key_scheme);
1050 EXPECT_TRUE(cm->SetCookie(url_google, cookie));
1051 std::string cookies = cm->GetCookies(url_google);
1068 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1069 cm->SetExpiryAndKeyScheme(key_scheme);
1072 EXPECT_TRUE(cm->SetCookie(url_google, cookie_general));
1074 EXPECT_TRUE(cm->SetCookie(url_google_specific, cookie_specific));
1075 std::string cookies_general = cm->GetCookies(url_google);
1077 std::string cookies_specific = cm->GetCookies(url_google_specific);
1090 std::string cookies_general = cm->GetCookies(url_google);
1091 std::string cookies_specific = cm->GetCookies(url_google_specific);
1124 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1126 EXPECT_TRUE(cm->SetCookie(test_url, "foo=bar"));
1127 std::string value = cm->GetCookies(test_url);
1131 EXPECT_TRUE(cm->SetCookie(test_url, "x=1"));
1132 EXPECT_TRUE(cm->SetCookie(test_url, "y=2"));
1134 std::string result = cm->GetCookies(test_url);
1140 static bool FindAndDeleteCookie(CookieMonster* cm,
1143 CookieList cookies = cm->GetAllCookies();
1147 return cm->DeleteCanonicalCookie(*it);
1154 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1156 EXPECT_TRUE(cm->SetCookie(url_google, "A=B"));
1157 EXPECT_TRUE(cm->SetCookie(url_google, "C=D"));
1158 EXPECT_TRUE(cm->SetCookie(url_google, "E=F"));
1159 EXPECT_EQ("A=B; C=D; E=F", cm->GetCookies(url_google));
1161 EXPECT_TRUE(FindAndDeleteCookie(cm, url_google.host(), "C"));
1162 EXPECT_EQ("A=B; E=F", cm->GetCookies(url_google));
1164 EXPECT_FALSE(FindAndDeleteCookie(cm, "random.host", "E"));
1165 EXPECT_EQ("A=B; E=F", cm->GetCookies(url_google));
1169 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1179 EXPECT_TRUE(cm->SetCookie(http_url, "x=1"));
1180 EXPECT_FALSE(cm->SetCookie(foo_url, "x=1"));
1189 scoped_refptr<CookieMonster> cm(
1196 EXPECT_TRUE(cm->SetCookieWithOptions(url_google, "A=B; httponly", options));
1197 EXPECT_TRUE(cm->SetCookieWithOptions(url_google,
1200 EXPECT_TRUE(cm->SetCookieWithOptions(url_google_secure,
1204 const Time last_access_date(GetFirstCookieAccessDate(cm));
1209 CookieList cookies = cm->GetAllCookiesForURL(url_google);
1224 cm->GetAllCookiesForURLWithOptions(url_google, CookieOptions());
1234 cookies = cm->GetAllCookiesForURL(url_google_secure);
1252 EXPECT_TRUE(last_access_date == GetFirstCookieAccessDate(cm));
1260 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1263 EXPECT_TRUE(cm->SetCookieWithOptions(url_google_foo,
1266 EXPECT_TRUE(cm->SetCookieWithOptions(url_google_bar,
1269 EXPECT_TRUE(cm->SetCookieWithOptions(url_google,
1273 CookieList cookies = cm->GetAllCookiesForURL(url_google_foo);
1286 cookies = cm->GetAllCookiesForURL(url_google_bar);
1301 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1304 EXPECT_TRUE(cm->SetCookie(url_google, "A=A1; path=/"));
1305 EXPECT_TRUE(cm->SetCookie(url_google, "A=A2; path=/foo"));
1306 EXPECT_TRUE(cm->SetCookie(url_google, "A=A3; path=/bar"));
1307 EXPECT_TRUE(cm->SetCookie(url_google, "B=B1; path=/"));
1308 EXPECT_TRUE(cm->SetCookie(url_google, "B=B2; path=/foo"));
1309 EXPECT_TRUE(cm->SetCookie(url_google, "B=B3; path=/bar"));
1311 cm->DeleteCookie(GURL(std::string(kUrlGoogle) + "/foo/bar"), "A");
1313 CookieList cookies = cm->GetAllCookies();
1330 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
1334 cm->SetCookie(url_google, "a=val1; path=/path1; "
1341 cm->SetCookie(url_google, "b=val1; path=/path1; "
1351 cm->SetCookieWithOptions(url_google,
1360 EXPECT_TRUE(cm->SetCookie(url_google,
1369 EXPECT_TRUE(cm->SetCookie(url_google,
1378 EXPECT_TRUE(cm->SetCookie(url_chromium,
1384 EXPECT_EQ("a=val33", cm->GetCookies(GURL("http://www.google.com/path1")));
1385 EXPECT_EQ("a=val9", cm->GetCookies(GURL("http://www.google.com/path2")));
1386 EXPECT_EQ("a=val99", cm->GetCookies(GURL("http://chromium.org/path1")));
1455 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
1459 EXPECT_EQ("X=3; Y=a", cm->GetCookies(GURL("http://www.google.com/")));
1464 cm->GetCookies(GURL("http://www.google.com/2/x")));
1506 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
1508 CookieList list(cm->GetAllCookies());
1525 scoped_refptr<CookieMonster> cm(new CookieMonster(store, delegate));
1527 EXPECT_TRUE(cm->SetCookie(url_google, "A=B"));
1528 EXPECT_TRUE(cm->SetCookie(url_google, "C=D"));
1529 EXPECT_TRUE(cm->SetCookie(url_google, "E=F"));
1530 EXPECT_EQ("A=B; C=D; E=F", cm->GetCookies(url_google));
1546 EXPECT_TRUE(FindAndDeleteCookie(cm, url_google.host(), "C"));
1547 EXPECT_EQ("A=B; E=F", cm->GetCookies(url_google));
1555 EXPECT_FALSE(FindAndDeleteCookie(cm, "random.host", "E"));
1556 EXPECT_EQ("A=B; E=F", cm->GetCookies(url_google));
1561 cm->SetCookie(url_google, "a=val1; path=/path1; "
1577 cm->SetCookieWithOptions(url_google,
1602 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1604 EXPECT_TRUE(cm->SetCookieWithDetails(
1607 EXPECT_TRUE(cm->SetCookieWithDetails(
1610 EXPECT_TRUE(cm->SetCookieWithDetails(
1615 EXPECT_FALSE(cm->SetCookieWithDetails(
1618 EXPECT_FALSE(cm->SetCookieWithDetails(
1621 EXPECT_FALSE(cm->SetCookieWithDetails(
1624 EXPECT_FALSE(cm->SetCookieWithDetails(
1627 EXPECT_FALSE(cm->SetCookieWithDetails(
1631 CookieList cookies = cm->GetAllCookiesForURL(url_google_foo);
1645 cookies = cm->GetAllCookiesForURL(url_google_bar);
1658 cookies = cm->GetAllCookiesForURL(url_google_secure);
1673 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1683 PopulateCmForDeleteAllForHost(cm);
1685 cm->GetCookies(GURL(kTopLevelDomainPlus3)));
1687 cm->GetCookies(GURL(kTopLevelDomainPlus2Secure)));
1688 EXPECT_EQ("dom_1=X; host_1=X", cm->GetCookies(GURL(kTopLevelDomainPlus1)));
1691 cm->GetCookies(GURL(kTopLevelDomainPlus2Secure +
1694 EXPECT_EQ(5, cm->DeleteAllForHost(GURL(kTopLevelDomainPlus2)));
1695 EXPECT_EQ(8U, cm->GetAllCookies().size());
1698 cm->GetCookies(GURL(kTopLevelDomainPlus3)));
1700 cm->GetCookies(GURL(kTopLevelDomainPlus2Secure)));
1701 EXPECT_EQ("dom_1=X; host_1=X", cm->GetCookies(GURL(kTopLevelDomainPlus1)));
1703 cm->GetCookies(GURL(kTopLevelDomainPlus2Secure +
1706 PopulateCmForDeleteAllForHost(cm);
1707 EXPECT_EQ(5, cm->DeleteAllForHost(GURL(kTopLevelDomainPlus2Secure)));
1708 EXPECT_EQ(8U, cm->GetAllCookies().size());
1711 cm->GetCookies(GURL(kTopLevelDomainPlus3)));
1713 cm->GetCookies(GURL(kTopLevelDomainPlus2Secure)));
1714 EXPECT_EQ("dom_1=X; host_1=X", cm->GetCookies(GURL(kTopLevelDomainPlus1)));
1716 cm->GetCookies(GURL(kTopLevelDomainPlus2Secure +
1719 PopulateCmForDeleteAllForHost(cm);
1720 EXPECT_EQ(5, cm->DeleteAllForHost(GURL(kTopLevelDomainPlus2Secure +
1722 EXPECT_EQ(8U, cm->GetAllCookies().size());
1725 cm->GetCookies(GURL(kTopLevelDomainPlus3)));
1727 cm->GetCookies(GURL(kTopLevelDomainPlus2Secure)));
1728 EXPECT_EQ("dom_1=X; host_1=X", cm->GetCookies(GURL(kTopLevelDomainPlus1)));
1730 cm->GetCookies(GURL(kTopLevelDomainPlus2Secure +
1736 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1751 cm->SetCookie(url_google, "SetCookie1=A");
1752 cm->SetCookie(url_google, "SetCookie2=A");
1753 cm->SetCookie(url_google, "SetCookie3=A");
1760 cm->SetCookies(url_google, cookie_lines);
1769 cm->SetCookiesWithOptions(url_google, cookie_lines, options);
1772 cm->SetCookieWithOptions(url_google, "setCookieWithOptions1=A", options);
1773 cm->SetCookieWithOptions(url_google, "setCookieWithOptions2=A", options);
1774 cm->SetCookieWithOptions(url_google, "setCookieWithOptions3=A", options);
1776 cm->SetCookieWithDetails(url_google, "setCookieWithDetails1", "A",
1778 cm->SetCookieWithDetails(url_google, "setCookieWithDetails2", "A",
1780 cm->SetCookieWithDetails(url_google, "setCookieWithDetails3", "A",
1784 CookieList cookie_list(cm->GetAllCookies());
1808 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1811 if (cm->expiry_and_key_scheme_ ==
1813 EXPECT_EQ("google.com", cm->GetKey("www.google.com"));
1814 EXPECT_EQ("google.izzie", cm->GetKey("www.google.izzie"));
1815 EXPECT_EQ("google.izzie", cm->GetKey(".google.izzie"));
1816 EXPECT_EQ("bbc.co.uk", cm->GetKey("bbc.co.uk"));
1817 EXPECT_EQ("bbc.co.uk", cm->GetKey("a.b.c.d.bbc.co.uk"));
1818 EXPECT_EQ("apple.com", cm->GetKey("a.b.c.d.apple.com"));
1819 EXPECT_EQ("apple.izzie", cm->GetKey("a.b.c.d.apple.izzie"));
1823 EXPECT_EQ("co.uk", cm->GetKey("co.uk"));
1825 EXPECT_EQ(extension_name, cm->GetKey(extension_name));
1826 EXPECT_EQ("com", cm->GetKey("com"));
1827 EXPECT_EQ("hostalias", cm->GetKey("hostalias"));
1828 EXPECT_EQ("localhost", cm->GetKey("localhost"));
1908 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1909 EXPECT_TRUE(cm->SetCookie(GURL("http://d.c.b.a.google.com/aa/x.html"),
1911 EXPECT_TRUE(cm->SetCookie(GURL("http://b.a.google.com/aa/bb/cc/x.html"),
1913 EXPECT_TRUE(cm->SetCookie(GURL("http://b.a.google.com/aa/bb/cc/x.html"),
1915 EXPECT_TRUE(cm->SetCookie(GURL("http://c.b.a.google.com/aa/bb/cc/x.html"),
1917 EXPECT_TRUE(cm->SetCookie(GURL("http://d.c.b.a.google.com/aa/bb/x.html"),
1919 EXPECT_TRUE(cm->SetCookie(GURL("http://news.bbc.co.uk/midpath/x.html"),
1922 cm->GetCookiesWithOptions(
1927 CookieList cookies(cm->GetAllCookiesForURL(
1939 CookieList cookies(cm->GetAllCookies());
1951 // Function for creating a CM with a number of cookies in it,
1954 CookieMonster* cm(new CookieMonster(NULL, NULL));
1956 cm->SetCookie(GURL(StringPrintf("http://h%05d.izzle", i)), "a=1");
1957 return cm;
1970 scoped_refptr<CookieMonster> cm(
1972 EXPECT_EQ(CookieMonster::kMaxCookies * 2, cm->GetAllCookies().size());
1973 cm
1974 EXPECT_EQ(CookieMonster::kMaxCookies * 2 + 1, cm->GetAllCookies().size());
2029 scoped_refptr<CookieMonster> cm(
2033 cm->SetExpiryAndKeyScheme(schemes[recent_scheme]);
2035 static_cast<int>(cm->GetAllCookies().size()))
2038 cm->SetCookie(GURL("http://newdomain.com"), "b=2");
2040 static_cast<int>((cm->GetAllCookies().size())))
2050 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
2055 ASSERT_TRUE(cm->SetCookieWithOptions(url_google,
2060 CookieList cookie_list = cm->GetAllCookies();
2065 ASSERT_TRUE(cm->SetCookieWithOptions(url_google,
2070 cookie_list = cm->GetAllCookies();
2077 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
2078 cm->SetKeepExpiredCookies();
2082 ASSERT_TRUE(cm->SetCookieWithOptions(url_google,
2087 CookieList cookie_list = cm->GetAllCookies();
2091 ASSERT_TRUE(cm->SetCookieWithOptions(url_google,
2097 cookie_list = cm->GetAllCookies();
2158 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
2164 cm->FlushStore(NewRunnableMethod(counter.get(), &CallbackCounter::Callback));
2171 cm->FlushStore(NULL);
2178 cm->GetAllCookies(); // Force init.
2179 cm->FlushStore(NewRunnableMethod(counter.get(), &CallbackCounter::Callback));
2186 cm->FlushStore(NULL);
2193 cm = new CookieMonster(NULL, NULL);
2194 cm->GetAllCookies(); // Force init.
2195 cm->FlushStore(NULL);
2200 cm->FlushStore(NewRunnableMethod(counter.get(), &CallbackCounter::Callback));
2237 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
2239 // since the histogram should have been initialized by the CM construction
2248 ASSERT_TRUE(cm->SetCookieWithDetails(
2260 ASSERT_TRUE(cm->SetCookie(url_google, kValidCookieLine));