| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <time.h> | 5 #include <time.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/platform_thread.h" | 10 #include "base/platform_thread.h" |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // Create a persistent cookie. | 681 // Create a persistent cookie. |
| 682 EXPECT_TRUE(cm.SetCookie(url_google, | 682 EXPECT_TRUE(cm.SetCookie(url_google, |
| 683 std::string(kValidCookieLine) + | 683 std::string(kValidCookieLine) + |
| 684 "; expires=Mon, 18-Apr-22 22:50:13 GMT")); | 684 "; expires=Mon, 18-Apr-22 22:50:13 GMT")); |
| 685 EXPECT_EQ("A=B", cm.GetCookies(url_google)); | 685 EXPECT_EQ("A=B", cm.GetCookies(url_google)); |
| 686 // Delete it via Expires. | 686 // Delete it via Expires. |
| 687 EXPECT_TRUE(cm.SetCookie(url_google, | 687 EXPECT_TRUE(cm.SetCookie(url_google, |
| 688 std::string(kValidCookieLine) + | 688 std::string(kValidCookieLine) + |
| 689 "; expires=Mon, 18-Apr-1977 22:50:13 GMT")); | 689 "; expires=Mon, 18-Apr-1977 22:50:13 GMT")); |
| 690 EXPECT_EQ("", cm.GetCookies(url_google)); | 690 EXPECT_EQ("", cm.GetCookies(url_google)); |
| 691 |
| 692 // Create a persistent cookie. |
| 693 EXPECT_TRUE(cm.SetCookie(url_google, |
| 694 std::string(kValidCookieLine) + |
| 695 "; expires=Mon, 18-Apr-22 22:50:13 GMT")); |
| 696 EXPECT_EQ("A=B", cm.GetCookies(url_google)); |
| 697 // Delete it via Expires, with a unix epoch of 0. |
| 698 EXPECT_TRUE(cm.SetCookie(url_google, |
| 699 std::string(kValidCookieLine) + |
| 700 "; expires=Thu, 1-Jan-1970 00:00:00 GMT")); |
| 701 EXPECT_EQ("", cm.GetCookies(url_google)); |
| 691 } | 702 } |
| 692 | 703 |
| 693 TEST(CookieMonsterTest, TestCookieDeleteAll) { | 704 TEST(CookieMonsterTest, TestCookieDeleteAll) { |
| 694 GURL url_google(kUrlGoogle); | 705 GURL url_google(kUrlGoogle); |
| 695 net::CookieMonster cm; | 706 net::CookieMonster cm; |
| 696 net::CookieOptions options; | 707 net::CookieOptions options; |
| 697 options.set_include_httponly(); | 708 options.set_include_httponly(); |
| 698 | 709 |
| 699 EXPECT_TRUE(cm.SetCookie(url_google, kValidCookieLine)); | 710 EXPECT_TRUE(cm.SetCookie(url_google, kValidCookieLine)); |
| 700 EXPECT_EQ("A=B", cm.GetCookies(url_google)); | 711 EXPECT_EQ("A=B", cm.GetCookies(url_google)); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 GURL foo_url("foo://host/path"); | 950 GURL foo_url("foo://host/path"); |
| 940 GURL http_url("http://host/path"); | 951 GURL http_url("http://host/path"); |
| 941 | 952 |
| 942 EXPECT_TRUE(cm.SetCookie(http_url, "x=1")); | 953 EXPECT_TRUE(cm.SetCookie(http_url, "x=1")); |
| 943 EXPECT_FALSE(cm.SetCookie(foo_url, "x=1")); | 954 EXPECT_FALSE(cm.SetCookie(foo_url, "x=1")); |
| 944 EXPECT_TRUE(cm_foo.SetCookie(foo_url, "x=1")); | 955 EXPECT_TRUE(cm_foo.SetCookie(foo_url, "x=1")); |
| 945 EXPECT_FALSE(cm_foo.SetCookie(http_url, "x=1")); | 956 EXPECT_FALSE(cm_foo.SetCookie(http_url, "x=1")); |
| 946 } | 957 } |
| 947 | 958 |
| 948 // TODO test overwrite cookie | 959 // TODO test overwrite cookie |
| OLD | NEW |