chromium/content/browser/browsing_data/browsing_data_remover_impl_unittest.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/browsing_data/browsing_data_remover_impl.h"

#include <stddef.h>
#include <stdint.h>

#include <list>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/gmock_callback_support.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/browsing_data_filter_builder.h"
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/browsing_data_remover_delegate.h"
#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/dom_storage_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/storage_partition_config.h"
#include "content/public/browser/storage_usage_info.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/browsing_data_remover_test_util.h"
#include "content/public/test/mock_download_manager.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_storage_partition.h"
#include "content/public/test/test_utils.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_deletion_info.h"
#include "net/cookies/cookie_store.h"
#include "net/http/http_network_session.h"
#include "net/http/http_transaction_factory.h"
#include "ppapi/buildflags/buildflags.h"
#include "services/network/cookie_manager.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/test/test_network_context.h"
#include "storage/browser/test/mock_special_storage_policy.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "url/origin.h"

RunOnceClosure;
_;
ByRef;
Eq;
Invoke;
IsEmpty;
MakeMatcher;
Matcher;
MatcherInterface;
MatchResultListener;
Not;
Return;
SizeIs;
StrictMock;
Truly;
UnorderedElementsAre;
WithArgs;
CookieDeletionFilterPtr;

namespace content {

namespace {

struct StoragePartitionRemovalData {};

net::CanonicalCookie CreateCookieWithHost(const url::Origin& origin) {}

class StoragePartitionRemovalTestStoragePartition
    : public TestStoragePartition {};

// Custom matcher to test the equivalence of two URL filters. Since those are
// blackbox predicates, we can only approximate the equivalence by testing
// whether the filter give the same answer for several URLs. This is currently
// good enough for our testing purposes, to distinguish deletelists and
// preservelists, empty and non-empty filters and such.
//
// TODO(msramek): BrowsingDataRemover and some of its backends support URL
// filters, but its constructor currently only takes a single URL and constructs
// its own url filter. If an url filter was directly passed to
// BrowsingDataRemover (what should eventually be the case), we can use the same
// instance in the test as well, and thus simply test
// base::RepeatingCallback::Equals() in this matcher.
class ProbablySameFilterMatcher
    : public MatcherInterface<
          const base::RepeatingCallback<bool(const GURL&)>&> {};

inline Matcher<const base::RepeatingCallback<bool(const GURL&)>&>
ProbablySameFilter(base::RepeatingCallback<bool(const GURL&)> filter) {}

base::Time AnHourAgo() {}

bool FilterMatchesCookie(const CookieDeletionFilterPtr& filter,
                         const net::CanonicalCookie& cookie) {}

class TestBrowsingDataRemoverDelegate
    : public content::BrowsingDataRemoverDelegate {};

}  // namespace

// Testers -------------------------------------------------------------------

class RemoveDownloadsTester {};

// Test Class ----------------------------------------------------------------

class BrowsingDataRemoverImplTest : public testing::Test {};

// Tests ---------------------------------------------------------------------

TEST_F(BrowsingDataRemoverImplTest, RemoveCookieForever) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveCookieLastHour) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveCookiesDomainPreserveList) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveUnprotectedLocalStorageForever) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveProtectedLocalStorageForever) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveLocalStorageForLastWeek) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveMultipleTypes) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForeverBoth) {}

TEST_F(BrowsingDataRemoverImplTest,
       RemoveQuotaManagedDataForeverOnlyTemporary) {}

TEST_F(BrowsingDataRemoverImplTest,
       RemoveQuotaManagedDataForeverOnlyPersistent) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForeverNeither) {}

TEST_F(BrowsingDataRemoverImplTest,
       RemoveQuotaManagedDataForeverSpecificOrigin) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForLastHour) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForLastWeek) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedUnprotectedOrigins) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedProtectedSpecificOrigin) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedProtectedOrigins) {}

TEST_F(BrowsingDataRemoverImplTest,
       RemoveQuotaManagedIgnoreExtensionsAndDevTools) {}

class InspectableCompletionObserver
    : public BrowsingDataRemoverCompletionObserver {};

TEST_F(BrowsingDataRemoverImplTest, CompletionInhibition) {}

TEST_F(BrowsingDataRemoverImplTest, EarlyShutdown) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveDownloadsByTimeOnly) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveDownloadsByOrigin) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveCodeCache) {}

TEST_F(BrowsingDataRemoverImplTest,
       RemoveShaderCacheAndInterstGroupPermissionsCache) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveAttributionReporting) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveAggregationServiceData) {}

TEST_F(BrowsingDataRemoverImplTest, RemovePrivateAggregationData) {}

class MultipleTasksObserver {};

TEST_F(BrowsingDataRemoverImplTest, MultipleTasks) {}

// Scheduling multiple identical deletions should immediately execute the first
// deletion and merge all following deletions.
TEST_F(BrowsingDataRemoverImplTest, MultipleIdenticalTasks) {}

// BrowsingDataRemoverTest.MultipleTasks, tests that the tasks are not mixed up
// and they are executed in a correct order. However, the completion inhibitor
// kept synchronizing the execution in order to verify the parameters.
// This test demonstrates that even running the tasks without inhibition is
// executed correctly and doesn't crash.
TEST_F(BrowsingDataRemoverImplTest, MultipleTasksInQuickSuccession) {}

namespace {
class MockNetworkContext : public network::TestNetworkContext {};
}  // namespace

TEST_F(BrowsingDataRemoverImplTest, ClearsTrustTokens) {}

TEST_F(BrowsingDataRemoverImplTest, PreservesTrustTokens) {}

TEST_F(BrowsingDataRemoverImplTest, ClearsTrustTokensForSite) {}

TEST_F(BrowsingDataRemoverImplTest, ClearsTrustTokensForSiteDespiteTimeRange) {}

TEST_F(BrowsingDataRemoverImplTest, DeferCookieDeletion) {}

// Tests that the failed_data_types mask is correctly plumbed from the embedder
// delegate to the observer's OnBrowsingDataRemoverDone() method.
TEST_F(BrowsingDataRemoverImplTest, FailedDataTypes) {}

TEST_F(BrowsingDataRemoverImplTest, RemoveStorageBucketsAndReply) {}

TEST_F(BrowsingDataRemoverImplTest, NonDefaultStoragePartitionInFilter) {}

TEST_F(BrowsingDataRemoverImplTest, DeleteInterestGroupsWhenClearingCookies) {}

TEST_F(BrowsingDataRemoverImplTest,
       IfPartitionedCookiesOnlyDontDeleteInterestGroupsWhenClearingCookies) {}

class BrowsingDataRemoverImplSharedStorageTest
    : public BrowsingDataRemoverImplTest {};

TEST_F(BrowsingDataRemoverImplSharedStorageTest,
       RemoveUnprotectedSharedStorageForever) {}

TEST_F(BrowsingDataRemoverImplSharedStorageTest,
       RemoveProtectedSharedStorageForever) {}

TEST_F(BrowsingDataRemoverImplSharedStorageTest,
       RemoveSharedStorageForLastWeek) {}

}  // namespace content