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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 const GURL& url, | 164 const GURL& url, |
165 const std::string& name, | 165 const std::string& name, |
166 const std::string& value, | 166 const std::string& value, |
167 const std::string& domain, | 167 const std::string& domain, |
168 const std::string& path, | 168 const std::string& path, |
169 const base::Time creation_time, | 169 const base::Time creation_time, |
170 const base::Time expiration_time, | 170 const base::Time expiration_time, |
171 const base::Time last_access_time, | 171 const base::Time last_access_time, |
172 bool secure, | 172 bool secure, |
173 bool http_only, | 173 bool http_only, |
174 bool same_site, | 174 CookieSameSite same_site, |
175 CookiePriority priority) { | 175 CookiePriority priority) { |
176 DCHECK(cs); | 176 DCHECK(cs); |
177 ResultSavingCookieCallback<bool> callback; | 177 ResultSavingCookieCallback<bool> callback; |
178 cs->SetCookieWithDetailsAsync( | 178 cs->SetCookieWithDetailsAsync( |
179 url, name, value, domain, path, creation_time, expiration_time, | 179 url, name, value, domain, path, creation_time, expiration_time, |
180 last_access_time, secure, http_only, same_site, | 180 last_access_time, secure, http_only, same_site, |
181 false /* enforces strict secure cookies */, priority, | 181 false /* enforces strict secure cookies */, priority, |
182 base::Bind(&ResultSavingCookieCallback<bool>::Run, | 182 base::Bind(&ResultSavingCookieCallback<bool>::Run, |
183 base::Unretained(&callback))); | 183 base::Unretained(&callback))); |
184 callback.WaitUntilDone(); | 184 callback.WaitUntilDone(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 TYPED_TEST_P(CookieStoreTest, SetCookieWithDetailsAsync) { | 340 TYPED_TEST_P(CookieStoreTest, SetCookieWithDetailsAsync) { |
341 CookieStore* cs = this->GetCookieStore(); | 341 CookieStore* cs = this->GetCookieStore(); |
342 | 342 |
343 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 343 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
344 base::Time one_hour_ago = base::Time::Now() - base::TimeDelta::FromHours(1); | 344 base::Time one_hour_ago = base::Time::Now() - base::TimeDelta::FromHours(1); |
345 base::Time one_hour_from_now = | 345 base::Time one_hour_from_now = |
346 base::Time::Now() + base::TimeDelta::FromHours(1); | 346 base::Time::Now() + base::TimeDelta::FromHours(1); |
347 | 347 |
348 EXPECT_TRUE(this->SetCookieWithDetails( | 348 EXPECT_TRUE(this->SetCookieWithDetails( |
349 cs, this->www_google_foo_.url(), "A", "B", std::string(), "/foo", | 349 cs, this->www_google_foo_.url(), "A", "B", std::string(), "/foo", |
350 one_hour_ago, one_hour_from_now, base::Time(), false, false, false, | 350 one_hour_ago, one_hour_from_now, base::Time(), false, false, |
351 COOKIE_PRIORITY_DEFAULT)); | 351 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); |
352 // Note that for the creation time to be set exactly, without modification, | 352 // Note that for the creation time to be set exactly, without modification, |
353 // it must be different from the one set by the line above. | 353 // it must be different from the one set by the line above. |
354 EXPECT_TRUE(this->SetCookieWithDetails( | 354 EXPECT_TRUE(this->SetCookieWithDetails( |
355 cs, this->www_google_bar_.url(), "C", "D", this->www_google_bar_.domain(), | 355 cs, this->www_google_bar_.url(), "C", "D", this->www_google_bar_.domain(), |
356 "/bar", two_hours_ago, base::Time(), one_hour_ago, false, true, false, | 356 "/bar", two_hours_ago, base::Time(), one_hour_ago, false, true, |
357 COOKIE_PRIORITY_DEFAULT)); | 357 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); |
358 EXPECT_TRUE(this->SetCookieWithDetails( | 358 EXPECT_TRUE(this->SetCookieWithDetails( |
359 cs, this->http_www_google_.url(), "E", "F", std::string(), std::string(), | 359 cs, this->http_www_google_.url(), "E", "F", std::string(), std::string(), |
360 base::Time(), base::Time(), base::Time(), true, false, false, | 360 base::Time(), base::Time(), base::Time(), true, false, |
361 COOKIE_PRIORITY_DEFAULT)); | 361 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); |
362 | 362 |
363 // Test that malformed attributes fail to set the cookie. | 363 // Test that malformed attributes fail to set the cookie. |
364 EXPECT_FALSE(this->SetCookieWithDetails( | 364 EXPECT_FALSE(this->SetCookieWithDetails( |
365 cs, this->www_google_foo_.url(), " A", "B", std::string(), "/foo", | 365 cs, this->www_google_foo_.url(), " A", "B", std::string(), "/foo", |
366 base::Time(), base::Time(), base::Time(), false, false, false, | 366 base::Time(), base::Time(), base::Time(), false, false, |
367 COOKIE_PRIORITY_DEFAULT)); | 367 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); |
368 EXPECT_FALSE(this->SetCookieWithDetails( | 368 EXPECT_FALSE(this->SetCookieWithDetails( |
369 cs, this->www_google_foo_.url(), "A;", "B", std::string(), "/foo", | 369 cs, this->www_google_foo_.url(), "A;", "B", std::string(), "/foo", |
370 base::Time(), base::Time(), base::Time(), false, false, false, | 370 base::Time(), base::Time(), base::Time(), false, false, |
371 COOKIE_PRIORITY_DEFAULT)); | 371 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); |
372 EXPECT_FALSE(this->SetCookieWithDetails( | 372 EXPECT_FALSE(this->SetCookieWithDetails( |
373 cs, this->www_google_foo_.url(), "A=", "B", std::string(), "/foo", | 373 cs, this->www_google_foo_.url(), "A=", "B", std::string(), "/foo", |
374 base::Time(), base::Time(), base::Time(), false, false, false, | 374 base::Time(), base::Time(), base::Time(), false, false, |
375 COOKIE_PRIORITY_DEFAULT)); | 375 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); |
376 EXPECT_FALSE(this->SetCookieWithDetails( | 376 EXPECT_FALSE(this->SetCookieWithDetails( |
377 cs, this->www_google_foo_.url(), "A", "B", "google.ozzzzzzle", "foo", | 377 cs, this->www_google_foo_.url(), "A", "B", "google.ozzzzzzle", "foo", |
378 base::Time(), base::Time(), base::Time(), false, false, false, | 378 base::Time(), base::Time(), base::Time(), false, false, |
379 COOKIE_PRIORITY_DEFAULT)); | 379 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); |
380 EXPECT_FALSE(this->SetCookieWithDetails( | 380 EXPECT_FALSE(this->SetCookieWithDetails( |
381 cs, this->www_google_foo_.url(), "A=", "B", std::string(), "foo", | 381 cs, this->www_google_foo_.url(), "A=", "B", std::string(), "foo", |
382 base::Time(), base::Time(), base::Time(), false, false, false, | 382 base::Time(), base::Time(), base::Time(), false, false, |
383 COOKIE_PRIORITY_DEFAULT)); | 383 CookieSameSite::DEFAULT_MODE, COOKIE_PRIORITY_DEFAULT)); |
384 | 384 |
385 // Get all the cookies for a given URL, regardless of properties. This 'get()' | 385 // Get all the cookies for a given URL, regardless of properties. This 'get()' |
386 // operation shouldn't update the access time, as the test checks that the | 386 // operation shouldn't update the access time, as the test checks that the |
387 // access time is set properly upon creation. Updating the access time would | 387 // access time is set properly upon creation. Updating the access time would |
388 // make that difficult. | 388 // make that difficult. |
389 CookieOptions options; | 389 CookieOptions options; |
390 options.set_include_httponly(); | 390 options.set_include_httponly(); |
391 options.set_include_same_site(); | 391 options.set_include_same_site(); |
392 options.set_do_not_update_access_time(); | 392 options.set_do_not_update_access_time(); |
393 | 393 |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 OverwritePersistentCookie, | 1377 OverwritePersistentCookie, |
1378 CookieOrdering, | 1378 CookieOrdering, |
1379 GetAllCookiesAsync, | 1379 GetAllCookiesAsync, |
1380 DeleteCookieAsync, | 1380 DeleteCookieAsync, |
1381 DeleteCanonicalCookieAsync, | 1381 DeleteCanonicalCookieAsync, |
1382 DeleteSessionCookie); | 1382 DeleteSessionCookie); |
1383 | 1383 |
1384 } // namespace net | 1384 } // namespace net |
1385 | 1385 |
1386 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ | 1386 #endif // NET_COOKIES_COOKIE_STORE_UNITTEST_H_ |
OLD | NEW |