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 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 5 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 | 279 |
280 scoped_refptr<CannedBrowsingDataCookieHelper> helper( | 280 scoped_refptr<CannedBrowsingDataCookieHelper> helper( |
281 new CannedBrowsingDataCookieHelper( | 281 new CannedBrowsingDataCookieHelper( |
282 testing_profile_->GetRequestContext())); | 282 testing_profile_->GetRequestContext())); |
283 | 283 |
284 ASSERT_TRUE(helper->empty()); | 284 ASSERT_TRUE(helper->empty()); |
285 helper->AddChangedCookie(origin, origin, "A=1", net::CookieOptions()); | 285 helper->AddChangedCookie(origin, origin, "A=1", net::CookieOptions()); |
286 helper->AddChangedCookie(origin, origin, "A=1; Domain=.www.google.com", | 286 helper->AddChangedCookie(origin, origin, "A=1; Domain=.www.google.com", |
287 net::CookieOptions()); | 287 net::CookieOptions()); |
288 // Try adding invalid cookies that will be ignored. | 288 // Try adding invalid cookies that will be ignored. |
289 helper->AddChangedCookie(origin, origin, std::string(), net::CookieOptions()); | 289 helper->AddChangedCookie(origin, origin, "C=not http; HttpOnly", |
mmenke
2016/08/17 16:23:17
Why is this an invalid cookie? I'm not seeing why
jww
2016/08/17 16:57:08
To accept HTTP-only cookies, you have to set a spe
| |
290 helper->AddChangedCookie(origin, | 290 net::CookieOptions()); |
291 origin, | 291 helper->AddChangedCookie(origin, origin, "C=bad guy; Domain=wrongdomain.com", |
292 "C=bad guy; Domain=wrongdomain.com", | |
293 net::CookieOptions()); | 292 net::CookieOptions()); |
294 | 293 |
295 helper->StartFetching( | 294 helper->StartFetching( |
296 base::Bind(&BrowsingDataCookieHelperTest::CannedDomainCookieCallback, | 295 base::Bind(&BrowsingDataCookieHelperTest::CannedDomainCookieCallback, |
297 base::Unretained(this))); | 296 base::Unretained(this))); |
298 cookie = cookie_list_; | 297 cookie = cookie_list_; |
299 | 298 |
300 helper->Reset(); | 299 helper->Reset(); |
301 ASSERT_TRUE(helper->empty()); | 300 ASSERT_TRUE(helper->empty()); |
302 | 301 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 // "A=1; | 488 // "A=1; |
490 // "A=3; Domain=www.google.com" | 489 // "A=3; Domain=www.google.com" |
491 // Add a domain cookie and check if it increases the cookie count. | 490 // Add a domain cookie and check if it increases the cookie count. |
492 helper->AddChangedCookie(frame2_url, frame1_url, | 491 helper->AddChangedCookie(frame2_url, frame1_url, |
493 cookie_pair4 + "; Domain=" + cookie_domain, | 492 cookie_pair4 + "; Domain=" + cookie_domain, |
494 net::CookieOptions()); | 493 net::CookieOptions()); |
495 EXPECT_EQ(5U, helper->GetCookieCount()); | 494 EXPECT_EQ(5U, helper->GetCookieCount()); |
496 } | 495 } |
497 | 496 |
498 } // namespace | 497 } // namespace |
OLD | NEW |