Chromium Code Reviews| Index: net/cookies/cookie_monster_unittest.cc |
| diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc |
| index 08a57ff8d57190fdd39ba9c7a96e7a1131f9fd70..5fbec32f401b9a1ce530e4ea5afd8e0ef720ac14 100644 |
| --- a/net/cookies/cookie_monster_unittest.cc |
| +++ b/net/cookies/cookie_monster_unittest.cc |
| @@ -187,72 +187,73 @@ class CookieMonsterTestBase : public CookieStoreTest<T> { |
| // Domain cookies |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_1, "dom_1", "X", ".harvard.edu", "/", |
| - base::Time(), base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT)); |
| + base::Time(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_2, "dom_2", "X", ".math.harvard.edu", "/", |
| - base::Time(), base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT)); |
| + base::Time(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_3, "dom_3", "X", |
| ".bourbaki.math.harvard.edu", "/", base::Time(), base::Time(), |
| - base::Time(), false, false, false, COOKIE_PRIORITY_DEFAULT)); |
| + base::Time(), false, false, COOKIE_SAME_SITE_DEFAULT, |
| + COOKIE_PRIORITY_DEFAULT)); |
| // Host cookies |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_1, "host_1", "X", std::string(), "/", |
| - base::Time(), base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT)); |
| + base::Time(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_2, "host_2", "X", std::string(), "/", |
| - base::Time(), base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT)); |
| + base::Time(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_3, "host_3", "X", std::string(), "/", |
| - base::Time(), base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT)); |
| + base::Time(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| // http_only cookie |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_2, "httpo_check", "x", std::string(), "/", |
| - base::Time(), base::Time(), base::Time(), false, true, false, |
| - COOKIE_PRIORITY_DEFAULT)); |
| + base::Time(), base::Time(), base::Time(), false, true, |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| // same-site cookie |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_2, "firstp_check", "x", std::string(), |
| - "/", base::Time(), base::Time(), base::Time(), false, false, true, |
| - COOKIE_PRIORITY_DEFAULT)); |
| + "/", base::Time(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_STRICT, COOKIE_PRIORITY_DEFAULT)); |
| // Secure cookies |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_2_secure, "sec_dom", "X", |
| ".math.harvard.edu", "/", base::Time(), base::Time(), base::Time(), |
| - true, false, false, COOKIE_PRIORITY_DEFAULT)); |
| + true, false, COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_2_secure, "sec_host", "X", std::string(), |
| - "/", base::Time(), base::Time(), base::Time(), true, false, false, |
| - COOKIE_PRIORITY_DEFAULT)); |
| + "/", base::Time(), base::Time(), base::Time(), true, false, |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| // Domain path cookies |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_2, "dom_path_1", "X", ".math.harvard.edu", |
| - "/dir1", base::Time(), base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT)); |
| + "/dir1", base::Time(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_2, "dom_path_2", "X", ".math.harvard.edu", |
| "/dir1/dir2", base::Time(), base::Time(), base::Time(), false, false, |
| - false, COOKIE_PRIORITY_DEFAULT)); |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| // Host path cookies |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_2, "host_path_1", "X", std::string(), |
| - "/dir1", base::Time(), base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT)); |
| + "/dir1", base::Time(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| EXPECT_TRUE(this->SetCookieWithDetails( |
| cm, url_top_level_domain_plus_2, "host_path_2", "X", std::string(), |
| "/dir1/dir2", base::Time(), base::Time(), base::Time(), false, false, |
| - false, COOKIE_PRIORITY_DEFAULT)); |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| EXPECT_EQ(14U, this->GetAllCookies(cm).size()); |
| } |
| @@ -621,7 +622,7 @@ struct CookiesInputInfo { |
| const base::Time expiration_time; |
| bool secure; |
| bool http_only; |
| - bool same_site; |
| + CookieSameSite same_site; |
| CookiePriority priority; |
| }; |
| @@ -854,14 +855,14 @@ TEST_F(DeferredCookieTaskTest, DeferredSetCookie) { |
| TEST_F(DeferredCookieTaskTest, DeferredSetAllCookies) { |
| MockSetCookiesCallback set_cookies_callback; |
| CookieList list; |
| - list.push_back(CanonicalCookie(http_www_google_.url(), "A", "B", |
| - http_www_google_.domain(), "/", |
| - base::Time::Now(), base::Time(), base::Time(), |
| - false, true, false, COOKIE_PRIORITY_DEFAULT)); |
| - list.push_back(CanonicalCookie(http_www_google_.url(), "C", "D", |
| - http_www_google_.domain(), "/", |
| - base::Time::Now(), base::Time(), base::Time(), |
| - false, true, false, COOKIE_PRIORITY_DEFAULT)); |
| + list.push_back(CanonicalCookie( |
| + http_www_google_.url(), "A", "B", http_www_google_.domain(), "/", |
| + base::Time::Now(), base::Time(), base::Time(), false, true, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT)); |
|
mmenke
2016/03/11 18:08:31
You're using NONE here, but DEFAULT above. Is the
Mike West
2016/03/14 10:18:54
No. No good reason, here or elsewhere.
|
| + list.push_back(CanonicalCookie( |
| + http_www_google_.url(), "C", "D", http_www_google_.domain(), "/", |
| + base::Time::Now(), base::Time(), base::Time(), false, true, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT)); |
| BeginWith( |
| SetAllCookiesAction(&cookie_monster(), list, &set_cookies_callback)); |
| @@ -909,7 +910,7 @@ TEST_F(DeferredCookieTaskTest, DeferredSetCookieWithDetails) { |
| base::Time(), |
| false, |
| false, |
| - false, |
| + COOKIE_SAME_SITE_DEFAULT, |
| COOKIE_PRIORITY_DEFAULT}; |
| BeginWithForDomainKey( |
| http_www_google_.domain(), |
| @@ -926,7 +927,7 @@ TEST_F(DeferredCookieTaskTest, DeferredSetCookieWithDetails) { |
| base::Time(), |
| false, |
| false, |
| - false, |
| + COOKIE_SAME_SITE_DEFAULT, |
| COOKIE_PRIORITY_DEFAULT}; |
| EXPECT_CALL(set_cookies_callback, Invoke(true)) |
| .WillOnce(SetCookieWithDetailsAction(&cookie_monster(), cookie_info_exp, |
| @@ -1742,15 +1743,15 @@ TEST_F(CookieMonsterTest, UniqueCreationTime) { |
| EXPECT_TRUE(SetCookieWithDetails( |
| cm.get(), http_www_google_.url(), "setCookieWithDetails1", "A", |
| http_www_google_.Format(".%D"), "/", Time(), Time(), Time(), false, false, |
| - false, COOKIE_PRIORITY_DEFAULT)); |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| EXPECT_TRUE(SetCookieWithDetails( |
| cm.get(), http_www_google_.url(), "setCookieWithDetails2", "A", |
| http_www_google_.Format(".%D"), "/", Time(), Time(), Time(), false, false, |
| - false, COOKIE_PRIORITY_DEFAULT)); |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| EXPECT_TRUE(SetCookieWithDetails( |
| cm.get(), http_www_google_.url(), "setCookieWithDetails3", "A", |
| http_www_google_.Format(".%D"), "/", Time(), Time(), Time(), false, false, |
| - false, COOKIE_PRIORITY_DEFAULT)); |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| // Now we check |
| CookieList cookie_list(GetAllCookies(cm.get())); |
| @@ -1810,36 +1811,14 @@ TEST_F(CookieMonsterTest, BackingStoreCommunication) { |
| base::Time expires(base::Time::Now() + base::TimeDelta::FromSeconds(100)); |
| const CookiesInputInfo input_info[] = { |
| - {GURL("http://a.b.google.com"), |
| - "a", |
| - "1", |
| - "", |
| - "/path/to/cookie", |
| - expires, |
| - false, |
| - false, |
| - false, |
| - COOKIE_PRIORITY_DEFAULT}, |
| - {GURL("https://www.google.com"), |
| - "b", |
| - "2", |
| - ".google.com", |
| - "/path/from/cookie", |
| - expires + TimeDelta::FromSeconds(10), |
| - true, |
| - true, |
| - false, |
| - COOKIE_PRIORITY_DEFAULT}, |
| - {GURL("https://google.com"), |
| - "c", |
| - "3", |
| - "", |
| - "/another/path/to/cookie", |
| - base::Time::Now() + base::TimeDelta::FromSeconds(100), |
| - true, |
| - false, |
| - true, |
| - COOKIE_PRIORITY_DEFAULT}}; |
| + {GURL("http://a.b.google.com"), "a", "1", "", "/path/to/cookie", expires, |
| + false, false, COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT}, |
| + {GURL("https://www.google.com"), "b", "2", ".google.com", |
| + "/path/from/cookie", expires + TimeDelta::FromSeconds(10), true, true, |
| + COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT}, |
| + {GURL("https://google.com"), "c", "3", "", "/another/path/to/cookie", |
| + base::Time::Now() + base::TimeDelta::FromSeconds(100), true, false, |
| + COOKIE_SAME_SITE_STRICT, COOKIE_PRIORITY_DEFAULT}}; |
| const int INPUT_DELETE = 1; |
| // Create new cookies and flush them to the store. |
| @@ -1879,7 +1858,7 @@ TEST_F(CookieMonsterTest, BackingStoreCommunication) { |
| output->CreationDate().ToInternalValue()); |
| EXPECT_EQ(input->secure, output->IsSecure()); |
| EXPECT_EQ(input->http_only, output->IsHttpOnly()); |
| - EXPECT_EQ(input->same_site, output->IsSameSite()); |
| + EXPECT_EQ(input->same_site, output->SameSite()); |
| EXPECT_TRUE(output->IsPersistent()); |
| EXPECT_EQ(input->expiration_time.ToInternalValue(), |
| output->ExpiryDate().ToInternalValue()); |
| @@ -2315,18 +2294,18 @@ TEST_F(CookieMonsterTest, SetAllCookies) { |
| EXPECT_TRUE(SetCookie(cm.get(), http_www_google_.url(), "Y=Z; path=/")); |
| CookieList list; |
| - list.push_back(CanonicalCookie(http_www_google_.url(), "A", "B", |
| - http_www_google_.url().host(), "/", |
| - base::Time::Now(), base::Time(), base::Time(), |
| - false, false, false, COOKIE_PRIORITY_DEFAULT)); |
| - list.push_back(CanonicalCookie(http_www_google_.url(), "W", "X", |
| - http_www_google_.url().host(), "/bar", |
| - base::Time::Now(), base::Time(), base::Time(), |
| - false, false, false, COOKIE_PRIORITY_DEFAULT)); |
| - list.push_back(CanonicalCookie(http_www_google_.url(), "Y", "Z", |
| - http_www_google_.url().host(), "/", |
| - base::Time::Now(), base::Time(), base::Time(), |
| - false, false, false, COOKIE_PRIORITY_DEFAULT)); |
| + list.push_back(CanonicalCookie( |
| + http_www_google_.url(), "A", "B", http_www_google_.url().host(), "/", |
| + base::Time::Now(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT)); |
| + list.push_back(CanonicalCookie( |
| + http_www_google_.url(), "W", "X", http_www_google_.url().host(), "/bar", |
| + base::Time::Now(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT)); |
| + list.push_back(CanonicalCookie( |
| + http_www_google_.url(), "Y", "Z", http_www_google_.url().host(), "/", |
| + base::Time::Now(), base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT)); |
| // SetAllCookies must not flush. |
| ASSERT_EQ(0, store->flush_count()); |
| @@ -2360,47 +2339,48 @@ TEST_F(CookieMonsterTest, ComputeCookieDiff) { |
| CanonicalCookie cookie1(http_www_google_.url(), "A", "B", |
| http_www_google_.url().host(), "/", creation_time, |
| - base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
|
mmenke
2016/03/11 18:08:31
And now you're back to none again. Should be cons
|
| CanonicalCookie cookie2(http_www_google_.url(), "C", "D", |
| http_www_google_.url().host(), "/", creation_time, |
| - base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
| CanonicalCookie cookie3(http_www_google_.url(), "E", "F", |
| http_www_google_.url().host(), "/", creation_time, |
| - base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
| CanonicalCookie cookie4(http_www_google_.url(), "G", "H", |
| http_www_google_.url().host(), "/", creation_time, |
| - base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
| CanonicalCookie cookie4_with_new_value( |
| http_www_google_.url(), "G", "iamnew", http_www_google_.url().host(), "/", |
| - creation_time, base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + creation_time, base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
| CanonicalCookie cookie5(http_www_google_.url(), "I", "J", |
| http_www_google_.url().host(), "/", creation_time, |
| - base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
| CanonicalCookie cookie5_with_new_creation_time( |
| http_www_google_.url(), "I", "J", http_www_google_.url().host(), "/", now, |
| - base::Time(), base::Time(), false, false, false, COOKIE_PRIORITY_DEFAULT); |
| + base::Time(), base::Time(), false, false, COOKIE_SAME_SITE_NONE, |
| + COOKIE_PRIORITY_DEFAULT); |
| CanonicalCookie cookie6(http_www_google_.url(), "K", "L", |
| http_www_google_.url().host(), "/foo", creation_time, |
| - base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
| CanonicalCookie cookie6_with_new_path( |
| http_www_google_.url(), "K", "L", http_www_google_.url().host(), "/bar", |
| - creation_time, base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + creation_time, base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
| CanonicalCookie cookie7(http_www_google_.url(), "M", "N", |
| http_www_google_.url().host(), "/foo", creation_time, |
| - base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
| CanonicalCookie cookie7_with_new_path( |
| http_www_google_.url(), "M", "N", http_www_google_.url().host(), "/bar", |
| - creation_time, base::Time(), base::Time(), false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + creation_time, base::Time(), base::Time(), false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
| CookieList old_cookies; |
| old_cookies.push_back(cookie1); |
| @@ -2494,7 +2474,7 @@ TEST_F(CookieMonsterTest, HistogramCheck) { |
| ASSERT_TRUE(SetCookieWithDetails( |
| cm.get(), GURL("http://fake.a.url"), "a", "b", "a.url", "/", base::Time(), |
| base::Time::Now() + base::TimeDelta::FromMinutes(59), base::Time(), false, |
| - false, false, COOKIE_PRIORITY_DEFAULT)); |
| + false, COOKIE_SAME_SITE_DEFAULT, COOKIE_PRIORITY_DEFAULT)); |
| scoped_ptr<base::HistogramSamples> samples2( |
| expired_histogram->SnapshotSamples()); |
| @@ -2616,8 +2596,8 @@ TEST_F(CookieMonsterTest, ControlCharacterPurge) { |
| new CanonicalCookie(url, "baz", |
| "\x05" |
| "boo", |
| - domain, path, now2, later, now2, false, false, false, |
| - COOKIE_PRIORITY_DEFAULT); |
| + domain, path, now2, later, now2, false, false, |
| + COOKIE_SAME_SITE_NONE, COOKIE_PRIORITY_DEFAULT); |
| initial_cookies.push_back(cc); |
| AddCookieToList(domain, "hello=world; path=" + path, now3, &initial_cookies); |