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/canonical_cookie.h" | 5 #include "net/cookies/canonical_cookie.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/test/histogram_tester.h" | 10 #include "base/test/histogram_tester.h" |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 .IsCanonical()); | 829 .IsCanonical()); |
830 | 830 |
831 // Host cookie with period prefixed domain. | 831 // Host cookie with period prefixed domain. |
832 EXPECT_FALSE(CanonicalCookie("__Host-A", "B", ".x.y", "/", base::Time(), | 832 EXPECT_FALSE(CanonicalCookie("__Host-A", "B", ".x.y", "/", base::Time(), |
833 base::Time(), base::Time(), false, false, | 833 base::Time(), base::Time(), false, false, |
834 CookieSameSite::NO_RESTRICTION, | 834 CookieSameSite::NO_RESTRICTION, |
835 COOKIE_PRIORITY_LOW) | 835 COOKIE_PRIORITY_LOW) |
836 .IsCanonical()); | 836 .IsCanonical()); |
837 } | 837 } |
838 | 838 |
| 839 TEST(CanonicalCookieTest, TestSetCreationDate) { |
| 840 CanonicalCookie cookie("A", "B", "x.y", "/path", base::Time(), base::Time(), |
| 841 base::Time(), false, false, |
| 842 CookieSameSite::NO_RESTRICTION, COOKIE_PRIORITY_LOW); |
| 843 EXPECT_TRUE(cookie.CreationDate().is_null()); |
| 844 |
| 845 base::Time now(base::Time::Now()); |
| 846 cookie.SetCreationDate(now); |
| 847 EXPECT_EQ(now, cookie.CreationDate()); |
| 848 } |
| 849 |
839 TEST(CanonicalCookieTest, TestPrefixHistograms) { | 850 TEST(CanonicalCookieTest, TestPrefixHistograms) { |
840 base::HistogramTester histograms; | 851 base::HistogramTester histograms; |
841 const char kCookiePrefixHistogram[] = "Cookie.CookiePrefix"; | 852 const char kCookiePrefixHistogram[] = "Cookie.CookiePrefix"; |
842 const char kCookiePrefixBlockedHistogram[] = "Cookie.CookiePrefixBlocked"; | 853 const char kCookiePrefixBlockedHistogram[] = "Cookie.CookiePrefixBlocked"; |
843 GURL https_url("https://www.example.test"); | 854 GURL https_url("https://www.example.test"); |
844 base::Time creation_time = base::Time::Now(); | 855 base::Time creation_time = base::Time::Now(); |
845 CookieOptions options; | 856 CookieOptions options; |
846 | 857 |
847 EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Host-A=B;", creation_time, | 858 EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Host-A=B;", creation_time, |
848 options)); | 859 options)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 CanonicalCookie::COOKIE_PREFIX_SECURE, 1); | 891 CanonicalCookie::COOKIE_PREFIX_SECURE, 1); |
881 EXPECT_TRUE(CanonicalCookie::Create(https_url, "__SecureA=B; Path=/; Secure", | 892 EXPECT_TRUE(CanonicalCookie::Create(https_url, "__SecureA=B; Path=/; Secure", |
882 creation_time, options)); | 893 creation_time, options)); |
883 histograms.ExpectBucketCount(kCookiePrefixHistogram, | 894 histograms.ExpectBucketCount(kCookiePrefixHistogram, |
884 CanonicalCookie::COOKIE_PREFIX_SECURE, 2); | 895 CanonicalCookie::COOKIE_PREFIX_SECURE, 2); |
885 histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, | 896 histograms.ExpectBucketCount(kCookiePrefixBlockedHistogram, |
886 CanonicalCookie::COOKIE_PREFIX_SECURE, 1); | 897 CanonicalCookie::COOKIE_PREFIX_SECURE, 1); |
887 } | 898 } |
888 | 899 |
889 } // namespace net | 900 } // namespace net |
OLD | NEW |