#include "services/network/restricted_cookie_manager.h"
#include <set>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/time/time.h"
#include "base/version.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/functions.h"
#include "net/base/features.h"
#include "net/base/isolation_info.h"
#include "net/base/network_isolation_key.h"
#include "net/base/schemeful_site.h"
#include "net/cookies/canonical_cookie_test_helpers.h"
#include "net/cookies/cookie_constants.h"
#include "net/cookies/cookie_inclusion_status.h"
#include "net/cookies/cookie_monster.h"
#include "net/cookies/cookie_partition_key.h"
#include "net/cookies/cookie_setting_override.h"
#include "net/cookies/cookie_store.h"
#include "net/cookies/cookie_store_test_callbacks.h"
#include "net/cookies/cookie_util.h"
#include "net/cookies/site_for_cookies.h"
#include "net/cookies/test_cookie_access_delegate.h"
#include "net/first_party_sets/first_party_set_metadata.h"
#include "net/first_party_sets/global_first_party_sets.h"
#include "net/storage_access_api/status.h"
#include "services/network/cookie_access_delegate_impl.h"
#include "services/network/cookie_settings.h"
#include "services/network/first_party_sets/first_party_sets_access_delegate.h"
#include "services/network/public/mojom/cookie_access_observer.mojom.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
#include "services/network/public/mojom/restricted_cookie_manager.mojom-shared.h"
#include "services/network/test/test_network_context_client.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/origin.h"
#include "url/url_util.h"
AllOf;
namespace net {
bool operator==(const net::SiteForCookies& a, const net::SiteForCookies& b) { … }
}
namespace network {
namespace {
net::FirstPartySetMetadata ComputeFirstPartySetMetadataSync(
const url::Origin& origin,
const net::CookieStore* cookie_store,
const net::IsolationInfo& isolation_info) { … }
}
class RecordingCookieObserver : public network::mojom::CookieAccessObserver { … };
class RestrictedCookieManagerSync { … };
namespace {
class TestCookieChangeListener : public network::mojom::CookieChangeListener { … };
}
class RestrictedCookieManagerTest
: public testing::TestWithParam<mojom::RestrictedCookieManagerRole> { … };
namespace {
Contains;
ElementsAre;
ElementsAreArray;
IsEmpty;
Not;
UnorderedElementsAre;
CanonicalCookieMatcher;
MATCHER_P5(MatchesCookieOp,
type,
url,
site_for_cookies,
cookie_or_line,
status,
"") { … }
MATCHER_P2(CookieOrLine, string, type, "") { … }
}
TEST_P(RestrictedCookieManagerTest,
GetAllForUrlFromMismatchingIsolationInfoFrameOrigin) { … }
TEST_P(RestrictedCookieManagerTest, CookieVersion) { … }
TEST_P(RestrictedCookieManagerTest, GetAllForUrlBlankFilter) { … }
TEST_P(RestrictedCookieManagerTest, GetAllForUrlEmptyFilter) { … }
TEST_P(RestrictedCookieManagerTest, GetAllForUrlEqualsMatch) { … }
TEST_P(RestrictedCookieManagerTest, GetAllForUrlEqualsMatch_WithStorageAccess) { … }
TEST_P(RestrictedCookieManagerTest, GetAllForUrlStartsWithMatch) { … }
TEST_P(RestrictedCookieManagerTest, GetAllForUrlHttpOnly) { … }
TEST_P(RestrictedCookieManagerTest, GetAllForUrlFromWrongOrigin) { … }
TEST_P(RestrictedCookieManagerTest, GetAllForUrlFromOpaqueOrigin) { … }
TEST_P(RestrictedCookieManagerTest, GetCookieStringFromWrongOrigin) { … }
TEST_P(RestrictedCookieManagerTest, GetAllAdTagged) { … }
TEST_P(RestrictedCookieManagerTest, GetAllForUrlPolicy) { … }
TEST_P(RestrictedCookieManagerTest, FilteredCookieAccessEvents) { … }
TEST_P(RestrictedCookieManagerTest, GetAllForUrlPolicyWarnActual) { … }
TEST_P(RestrictedCookieManagerTest, SetCanonicalCookie) { … }
TEST_P(RestrictedCookieManagerTest, SetCanonicalCookie_WithStorageAccess) { … }
TEST_P(RestrictedCookieManagerTest, SetCanonicalCookieHttpOnly) { … }
TEST_P(RestrictedCookieManagerTest, SetCookieFromString) { … }
TEST_P(RestrictedCookieManagerTest, SetCanonicalCookieFromWrongOrigin) { … }
TEST_P(RestrictedCookieManagerTest, SetCanonicalCookieFromOpaqueOrigin) { … }
TEST_P(RestrictedCookieManagerTest, SetCanonicalCookieWithMismatchingDomain) { … }
TEST_P(RestrictedCookieManagerTest, SetCookieFromStringWrongOrigin) { … }
TEST_P(RestrictedCookieManagerTest, SetCanonicalCookiePolicy) { … }
TEST_P(RestrictedCookieManagerTest, SetCanonicalCookiePolicyWarnActual) { … }
TEST_P(RestrictedCookieManagerTest, SetCanonicalCookieWithInclusionStatus) { … }
TEST_P(RestrictedCookieManagerTest, CookiesEnabledFor) { … }
TEST_P(RestrictedCookieManagerTest, CookiesEnabledFor_WithStorageAccess) { … }
TEST_P(RestrictedCookieManagerTest, SameSiteCookiesSpecialScheme) { … }
TEST_P(RestrictedCookieManagerTest, ChangeDispatch) { … }
TEST_P(RestrictedCookieManagerTest, ChangeSettings) { … }
TEST_P(RestrictedCookieManagerTest, AddChangeListenerFromWrongOrigin) { … }
TEST_P(RestrictedCookieManagerTest, AddChangeListenerFromOpaqueOrigin) { … }
TEST_P(RestrictedCookieManagerTest, ChangeNotificationIncludesAccessSemantics) { … }
TEST_P(RestrictedCookieManagerTest, NoChangeNotificationForNonlegacyCookie) { … }
TEST_P(RestrictedCookieManagerTest, PartitionedCookies) { … }
TEST_P(RestrictedCookieManagerTest, PartitionKeyFromScript) { … }
TEST_P(RestrictedCookieManagerTest, PartitionKeyWithNonce) { … }
INSTANTIATE_TEST_SUITE_P(…);
}