Commit 77288150 authored by Dylan Cutler's avatar Dylan Cutler Committed by Chromium LUCI CQ

Get //content/tests:content_unittests to pass if CanonicalCookie's

constructor is private.

This is part of a larger cleanup effort to make CanonicalCookie's
constructor private.

This CL was verified by building/running the unit test suite when
CanonicalCookie's constructor was locally changed to have a private
constructor.

Bug: 1102874
Change-Id: I1faa1b63e96091642c1a92ac8142b9de22c7d310
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2569941Reviewed-by: default avatarMaksim Orlovich <morlovich@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarLily Chen <chlily@chromium.org>
Commit-Queue: Dylan Cutler <dylancutler@google.com>
Cr-Commit-Position: refs/heads/master@{#835697}
parent 67bd6cdd
......@@ -137,11 +137,11 @@ struct StoragePartitionRemovalData {
};
net::CanonicalCookie CreateCookieWithHost(const url::Origin& origin) {
std::unique_ptr<net::CanonicalCookie> cookie(
std::make_unique<net::CanonicalCookie>(
std::unique_ptr<net::CanonicalCookie> cookie =
net::CanonicalCookie::CreateUnsafeCookieForTesting(
"A", "1", origin.host(), "/", base::Time::Now(), base::Time::Now(),
base::Time(), false, false, net::CookieSameSite::NO_RESTRICTION,
net::COOKIE_PRIORITY_MEDIUM, false));
net::COOKIE_PRIORITY_MEDIUM, false);
EXPECT_TRUE(cookie);
return *cookie;
}
......
......@@ -37,13 +37,13 @@ void CreateCookieForTest(
net::CookieOptions options;
options.set_same_site_cookie_context(cookie_context);
bool result_out;
net::CanonicalCookie cookie(cookie_name, "1", cookie_domain, "/",
base::Time(), base::Time(), base::Time(),
is_cookie_secure, false, same_site,
auto cookie = net::CanonicalCookie::CreateUnsafeCookieForTesting(
cookie_name, "1", cookie_domain, "/", base::Time(), base::Time(),
base::Time(), is_cookie_secure, false, same_site,
net::COOKIE_PRIORITY_LOW, false);
GetCookieManager(browser_context)
->SetCanonicalCookie(
cookie, net::cookie_util::SimulatedCookieSource(cookie, "https"),
*cookie, net::cookie_util::SimulatedCookieSource(*cookie, "https"),
options,
base::BindLambdaForTesting([&](net::CookieAccessResult result) {
result_out = result.status.IsInclude();
......
......@@ -217,12 +217,12 @@ TEST_F(SameSiteDataRemoverImplTest, TestCookieRemovalUnaffectedByParameters) {
net::CookieOptions options;
options.set_include_httponly();
bool result_out = false;
net::CanonicalCookie cookie1("TestCookie1", "20", "google.com", "/",
base::Time::Now(), base::Time(), base::Time(),
true, true, net::CookieSameSite::NO_RESTRICTION,
auto cookie1 = net::CanonicalCookie::CreateUnsafeCookieForTesting(
"TestCookie1", "20", "google.com", "/", base::Time::Now(), base::Time(),
base::Time(), true, true, net::CookieSameSite::NO_RESTRICTION,
net::COOKIE_PRIORITY_HIGH, /*same_party=*/true);
cookie_manager->SetCanonicalCookie(
cookie1, net::cookie_util::SimulatedCookieSource(cookie1, "https"),
*cookie1, net::cookie_util::SimulatedCookieSource(*cookie1, "https"),
options, base::BindLambdaForTesting([&](net::CookieAccessResult result) {
result_out = result.status.IsInclude();
run_loop1.Quit();
......@@ -236,12 +236,12 @@ TEST_F(SameSiteDataRemoverImplTest, TestCookieRemovalUnaffectedByParameters) {
net::CookieOptions::SameSiteCookieContext::ContextType::
SAME_SITE_LAX));
result_out = false;
net::CanonicalCookie cookie2("TestCookie2", "10", "gmail.google.com", "/",
base::Time(), base::Time::Max(), base::Time(),
false, true, net::CookieSameSite::LAX_MODE,
net::COOKIE_PRIORITY_HIGH, false);
auto cookie2 = net::CanonicalCookie::CreateUnsafeCookieForTesting(
"TestCookie2", "10", "gmail.google.com", "/", base::Time(),
base::Time::Max(), base::Time(), false, true,
net::CookieSameSite::LAX_MODE, net::COOKIE_PRIORITY_HIGH, false);
cookie_manager->SetCanonicalCookie(
cookie2, net::cookie_util::SimulatedCookieSource(cookie2, "https"),
*cookie2, net::cookie_util::SimulatedCookieSource(*cookie2, "https"),
options, base::BindLambdaForTesting([&](net::CookieAccessResult result) {
result_out = result.status.IsInclude();
run_loop2.Quit();
......
......@@ -303,7 +303,8 @@ class CookieStoreManagerTest
const char* value,
const char* domain,
const char* path) {
return SetCanonicalCookie(net::CanonicalCookie(
return SetCanonicalCookie(
*net::CanonicalCookie::CreateUnsafeCookieForTesting(
name, value, domain, path, base::Time(), base::Time(), base::Time(),
/* secure = */ true,
/* httponly = */ false, net::CookieSameSite::NO_RESTRICTION,
......@@ -311,9 +312,11 @@ class CookieStoreManagerTest
}
bool DeleteCookie(const char* name, const char* domain, const char* path) {
return SetCanonicalCookie(net::CanonicalCookie(
return SetCanonicalCookie(
*net::CanonicalCookie::CreateUnsafeCookieForTesting(
name, /* value = */ "", domain, path, /* creation = */ base::Time(),
/* expiration = */ base::Time::Min(), /* last_access = */ base::Time(),
/* expiration = */ base::Time::Min(),
/* last_access = */ base::Time(),
/* secure = */ true, /* httponly = */ false,
net::CookieSameSite::NO_RESTRICTION, net::COOKIE_PRIORITY_DEFAULT,
/* same_party = */ false));
......@@ -1557,7 +1560,8 @@ TEST_P(CookieStoreManagerTest, HttpOnlyCookieChange) {
if (reset_context_during_test())
ResetServiceWorkerContext();
ASSERT_TRUE(SetCanonicalCookie(net::CanonicalCookie(
ASSERT_TRUE(
SetCanonicalCookie(*net::CanonicalCookie::CreateUnsafeCookieForTesting(
"cookie-name-1", "cookie-value-1", "example.com", "/", base::Time(),
base::Time(), base::Time(),
/* secure = */ true,
......@@ -1567,7 +1571,8 @@ TEST_P(CookieStoreManagerTest, HttpOnlyCookieChange) {
EXPECT_EQ(0u, worker_test_helper_->changes().size());
worker_test_helper_->changes().clear();
ASSERT_TRUE(SetCanonicalCookie(net::CanonicalCookie(
ASSERT_TRUE(
SetCanonicalCookie(*net::CanonicalCookie::CreateUnsafeCookieForTesting(
"cookie-name-2", "cookie-value-2", "example.com", "/", base::Time(),
base::Time(), base::Time(),
/* secure = */ true,
......@@ -1612,7 +1617,8 @@ TEST_P(CookieStoreManagerTest, HttpOnlyCookieChangeLegacy) {
if (reset_context_during_test())
ResetServiceWorkerContext();
ASSERT_TRUE(SetCanonicalCookie(net::CanonicalCookie(
ASSERT_TRUE(
SetCanonicalCookie(*net::CanonicalCookie::CreateUnsafeCookieForTesting(
"cookie-name-1", "cookie-value-1", "legacy.com", "/", base::Time(),
base::Time(), base::Time(),
/* secure = */ false,
......@@ -1622,7 +1628,8 @@ TEST_P(CookieStoreManagerTest, HttpOnlyCookieChangeLegacy) {
EXPECT_EQ(0u, worker_test_helper_->changes().size());
worker_test_helper_->changes().clear();
ASSERT_TRUE(SetCanonicalCookie(net::CanonicalCookie(
ASSERT_TRUE(
SetCanonicalCookie(*net::CanonicalCookie::CreateUnsafeCookieForTesting(
"cookie-name-2", "cookie-value-2", "legacy.com", "/", base::Time(),
base::Time(), base::Time(),
/* secure = */ false,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment