| 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 "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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 virtual void Flush(const base::Closure& callback) { | 54 virtual void Flush(const base::Closure& callback) { |
| 55 if (!callback.is_null()) | 55 if (!callback.is_null()) |
| 56 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 56 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
| 57 } | 57 } |
| 58 MOCK_METHOD0(SetForceKeepSessionState, void()); | 58 MOCK_METHOD0(SetForceKeepSessionState, void()); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 virtual ~NewMockPersistentCookieStore() {} | 61 virtual ~NewMockPersistentCookieStore() {} |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 const char* kTopLevelDomainPlus1 = "http://www.harvard.edu"; | 64 const char kTopLevelDomainPlus1[] = "http://www.harvard.edu"; |
| 65 const char* kTopLevelDomainPlus2 = "http://www.math.harvard.edu"; | 65 const char kTopLevelDomainPlus2[] = "http://www.math.harvard.edu"; |
| 66 const char* kTopLevelDomainPlus2Secure = "https://www.math.harvard.edu"; | 66 const char kTopLevelDomainPlus2Secure[] = "https://www.math.harvard.edu"; |
| 67 const char* kTopLevelDomainPlus3 = | 67 const char kTopLevelDomainPlus3[] = |
| 68 "http://www.bourbaki.math.harvard.edu"; | 68 "http://www.bourbaki.math.harvard.edu"; |
| 69 const char* kOtherDomain = "http://www.mit.edu"; | 69 const char kOtherDomain[] = "http://www.mit.edu"; |
| 70 const char kUrlGoogleSpecific[] = "http://www.gmail.google.izzle"; | 70 const char kUrlGoogleSpecific[] = "http://www.gmail.google.izzle"; |
| 71 | 71 |
| 72 class GetCookieListCallback : public CookieCallback { | 72 class GetCookieListCallback : public CookieCallback { |
| 73 public: | 73 public: |
| 74 GetCookieListCallback() {} | 74 GetCookieListCallback() {} |
| 75 explicit GetCookieListCallback(Thread* run_in_thread) | 75 explicit GetCookieListCallback(Thread* run_in_thread) |
| 76 : CookieCallback(run_in_thread) {} | 76 : CookieCallback(run_in_thread) {} |
| 77 | 77 |
| 78 void Run(const CookieList& cookies) { | 78 void Run(const CookieList& cookies) { |
| 79 cookies_ = cookies; | 79 cookies_ = cookies; |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 | 1245 |
| 1246 EXPECT_FALSE(FindAndDeleteCookie(cm.get(), "random.host", "E")); | 1246 EXPECT_FALSE(FindAndDeleteCookie(cm.get(), "random.host", "E")); |
| 1247 EXPECT_EQ("A=B; E=F", GetCookies(cm.get(), url_google_)); | 1247 EXPECT_EQ("A=B; E=F", GetCookies(cm.get(), url_google_)); |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 TEST_F(CookieMonsterTest, SetCookieableSchemes) { | 1250 TEST_F(CookieMonsterTest, SetCookieableSchemes) { |
| 1251 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); | 1251 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); |
| 1252 scoped_refptr<CookieMonster> cm_foo(new CookieMonster(NULL, NULL)); | 1252 scoped_refptr<CookieMonster> cm_foo(new CookieMonster(NULL, NULL)); |
| 1253 | 1253 |
| 1254 // Only cm_foo should allow foo:// cookies. | 1254 // Only cm_foo should allow foo:// cookies. |
| 1255 const char* kSchemes[] = {"foo"}; | 1255 const char* const kSchemes[] = {"foo"}; |
| 1256 cm_foo->SetCookieableSchemes(kSchemes, 1); | 1256 cm_foo->SetCookieableSchemes(kSchemes, 1); |
| 1257 | 1257 |
| 1258 GURL foo_url("foo://host/path"); | 1258 GURL foo_url("foo://host/path"); |
| 1259 GURL http_url("http://host/path"); | 1259 GURL http_url("http://host/path"); |
| 1260 | 1260 |
| 1261 EXPECT_TRUE(SetCookie(cm.get(), http_url, "x=1")); | 1261 EXPECT_TRUE(SetCookie(cm.get(), http_url, "x=1")); |
| 1262 EXPECT_FALSE(SetCookie(cm.get(), foo_url, "x=1")); | 1262 EXPECT_FALSE(SetCookie(cm.get(), foo_url, "x=1")); |
| 1263 EXPECT_TRUE(SetCookie(cm_foo.get(), foo_url, "x=1")); | 1263 EXPECT_TRUE(SetCookie(cm_foo.get(), foo_url, "x=1")); |
| 1264 EXPECT_FALSE(SetCookie(cm_foo.get(), http_url, "x=1")); | 1264 EXPECT_FALSE(SetCookie(cm_foo.get(), http_url, "x=1")); |
| 1265 } | 1265 } |
| (...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 scoped_ptr<CookieStore::CookieChangedSubscription> sub1( | 2879 scoped_ptr<CookieStore::CookieChangedSubscription> sub1( |
| 2880 monster()->AddCallbackForCookie(test_url_, "abc", | 2880 monster()->AddCallbackForCookie(test_url_, "abc", |
| 2881 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); | 2881 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); |
| 2882 SetCookie(monster(), test_url_, "abc=def"); | 2882 SetCookie(monster(), test_url_, "abc=def"); |
| 2883 base::MessageLoop::current()->RunUntilIdle(); | 2883 base::MessageLoop::current()->RunUntilIdle(); |
| 2884 EXPECT_EQ(1U, cookies0.size()); | 2884 EXPECT_EQ(1U, cookies0.size()); |
| 2885 EXPECT_EQ(1U, cookies0.size()); | 2885 EXPECT_EQ(1U, cookies0.size()); |
| 2886 } | 2886 } |
| 2887 | 2887 |
| 2888 } // namespace net | 2888 } // namespace net |
| OLD | NEW |