#include <memory>
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "content/browser/cookie_store/cookie_store_manager.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/browser/service_worker/fake_embedded_worker_instance_client.h"
#include "content/browser/service_worker/fake_service_worker.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/common/content_client.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_utils.h"
#include "content/test/storage_partition_test_helpers.h"
#include "content/test/test_content_browser_client.h"
#include "mojo/public/cpp/test_support/fake_message_dispatch_context.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "net/base/features.h"
#include "net/cookies/cookie_access_result.h"
#include "net/cookies/cookie_constants.h"
#include "net/cookies/cookie_util.h"
#include "services/network/public/cpp/features.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/service_worker/service_worker.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_event_status.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration_options.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content {
namespace {
class CookieStoreSync { … };
const char kExampleScope[] = …;
const char kExampleWorkerScript[] = …;
const char kGoogleScope[] = …;
const char kGoogleWorkerScript[] = …;
const char kLegacyScope[] = …;
const char kLegacyWorkerScript[] = …;
const char kThirdPartyTopLevelSite[] = …;
const base::UnguessableToken kStorageKeyNonce = …;
class CookieStoreWorkerTestHelper : public EmbeddedWorkerTestHelper { … };
}
class CookieStoreManagerTest
: public testing::Test,
public TestContentBrowserClient,
public testing::WithParamInterface<
testing::tuple<bool ,
bool >> { … };
const int64_t CookieStoreManagerTest::kInvalidRegistrationId;
namespace {
bool CookieChangeSubscriptionLessThan(
const blink::mojom::CookieChangeSubscriptionPtr& lhs,
const blink::mojom::CookieChangeSubscriptionPtr& rhs) { … }
TEST_P(CookieStoreManagerTest, NoSubscriptions) { … }
TEST_P(CookieStoreManagerTest, AddSubscriptions_EmptyInput) { … }
TEST_P(CookieStoreManagerTest, AddSubscriptions_OneSubscription) { … }
TEST_P(CookieStoreManagerTest, AddSubscriptions_WrongScopeOrigin) { … }
TEST_P(CookieStoreManagerTest, AddSubscriptions_NonexistentRegistrationId) { … }
TEST_P(CookieStoreManagerTest, AddSubscriptions_WrongRegistrationOrigin) { … }
TEST_P(CookieStoreManagerTest, AddSubscriptionsMultipleWorkers) { … }
TEST_P(CookieStoreManagerTest, AddSubscriptions_MultipleSubscriptions) { … }
TEST_P(CookieStoreManagerTest, AddSubscriptions_MultipleAddsAcrossRestart) { … }
TEST_P(CookieStoreManagerTest, RemoveSubscriptions_EmptyVector) { … }
TEST_P(CookieStoreManagerTest, RemoveSubscriptions_OneExistingSubscription) { … }
TEST_P(CookieStoreManagerTest, RemoveSubscriptions_OneNonexistingSubscription) { … }
TEST_P(CookieStoreManagerTest, RemoveSubscriptions_NonexistentRegistrationId) { … }
TEST_P(CookieStoreManagerTest, RemoveSubscriptions_WrongRegistrationOrigin) { … }
TEST_P(CookieStoreManagerTest, RemoveSubscriptions_MultipleWorkers) { … }
TEST_P(CookieStoreManagerTest, RemoveSubscriptions_MultipleSubscriptionsLeft) { … }
TEST_P(CookieStoreManagerTest, RemoveSubscriptions_OneSubscriptionLeft) { … }
TEST_P(CookieStoreManagerTest, OneCookieChange) { … }
TEST_P(CookieStoreManagerTest, OneCookieChangeLegacy) { … }
TEST_P(CookieStoreManagerTest, CookieChangeNameStartsWith) { … }
TEST_P(CookieStoreManagerTest, CookieChangeNameStartsWithLegacy) { … }
TEST_P(CookieStoreManagerTest, CookieChangeUrl) { … }
TEST_P(CookieStoreManagerTest, CookieChangeUrlLegacy) { … }
TEST_P(CookieStoreManagerTest, HttpOnlyCookieChange) { … }
TEST_P(CookieStoreManagerTest, HttpOnlyCookieChangeLegacy) { … }
TEST_P(CookieStoreManagerTest, CookieChangeForDeletion) { … }
TEST_P(CookieStoreManagerTest, CookieChangeForOverwrite) { … }
TEST_P(CookieStoreManagerTest, GetSubscriptionsFromWrongOrigin) { … }
TEST_F(CookieStoreManagerTest, UnTrustworthyOrigin) { … }
TEST_F(CookieStoreManagerTest, PartitionedWorker_FirstPartyPartition) { … }
TEST_P(CookieStoreManagerTest, PartitionedWorker_ThirdPartyPartition) { … }
TEST_F(CookieStoreManagerTest, PartitionedWorker_NoncedPartition) { … }
TEST_P(CookieStoreManagerTest, PartitionedWorkerBlocksThirdPartyCookies) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}