#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
#include <stdint.h>
#include <memory>
#include <set>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/json/values_util.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/scoped_path_override.h"
#include "base/test/simple_test_clock.h"
#include "base/test/test_future.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
#include "base/uuid.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/autocomplete/zero_suggest_cache_service_factory.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/autofill/strike_database_factory.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_constants.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/dips/dips_service.h"
#include "chrome/browser/dips/dips_service_factory.h"
#include "chrome/browser/domain_reliability/service_factory.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_core_service_impl.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/file_system_access/chrome_file_system_access_permission_context.h"
#include "chrome/browser/file_system_access/file_system_access_permission_context_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/language/url_language_histogram_factory.h"
#include "chrome/browser/media/webrtc/media_device_salt_service_factory.h"
#include "chrome/browser/password_manager/account_password_store_factory.h"
#include "chrome/browser/password_manager/profile_password_store_factory.h"
#include "chrome/browser/permissions/permission_actions_history_factory.h"
#include "chrome/browser/permissions/permission_decision_auto_blocker_factory.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_settings_factory.h"
#include "chrome/browser/reading_list/reading_list_model_factory.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/safe_browsing/verdict_cache_manager_factory.h"
#include "chrome/browser/segmentation_platform/segmentation_platform_service_factory.h"
#include "chrome/browser/segmentation_platform/ukm_data_manager_test_utils.h"
#include "chrome/browser/segmentation_platform/ukm_database_client.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/test_signin_client_builder.h"
#include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/browser/ssl/stateful_ssl_host_state_delegate_factory.h"
#include "chrome/browser/storage/durable_storage_permission_context.h"
#include "chrome/browser/subresource_filter/subresource_filter_profile_context_factory.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/tpcd/metadata/manager_factory.h"
#include "chrome/browser/translate/chrome_translate_client.h"
#include "chrome/browser/trusted_vault/trusted_vault_service_factory.h"
#include "chrome/browser/webdata_services/web_data_service_factory.h"
#include "chrome/browser/webid/federated_identity_permission_context.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/fake_profile_manager.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/autofill/core/browser/address_data_manager.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/payments_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/personal_data_manager_test_utils.h"
#include "components/autofill/core/browser/strike_databases/strike_database.h"
#include "components/autofill/core/browser/test_autofill_clock.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
#include "components/browsing_data/content/browsing_data_helper.h"
#include "components/browsing_data/core/browsing_data_utils.h"
#include "components/client_hints/common/client_hints.h"
#include "components/content_settings/core/browser/content_settings_info.h"
#include "components/content_settings/core/browser/content_settings_registry.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/browser/website_settings_info.h"
#include "components/content_settings/core/browser/website_settings_registry.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_constraints.h"
#include "components/content_settings/core/common/content_settings_metadata.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_utils.h"
#include "components/custom_handlers/protocol_handler.h"
#include "components/custom_handlers/protocol_handler_registry.h"
#include "components/custom_handlers/test_protocol_handler_registry_delegate.h"
#include "components/domain_reliability/clear_mode.h"
#include "components/domain_reliability/monitor.h"
#include "components/favicon/core/favicon_service.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/common/pref_names.h"
#include "components/language/core/browser/url_language_histogram.h"
#include "components/media_device_salt/media_device_salt_service.h"
#include "components/omnibox/browser/omnibox_prefs.h"
#include "components/omnibox/browser/zero_suggest_cache_service.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/os_crypt/sync/os_crypt_mocker.h"
#include "components/password_manager/core/browser/password_manager_test_utils.h"
#include "components/password_manager/core/browser/password_store/mock_password_store_interface.h"
#include "components/password_manager/core/browser/password_store/mock_smart_bubble_stats_store.h"
#include "components/password_manager/core/browser/password_store/password_store_consumer.h"
#include "components/password_manager/core/browser/password_store/password_store_interface.h"
#include "components/payments/content/mock_payment_manifest_web_data_service.h"
#include "components/performance_manager/public/user_tuning/prefs.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_actions_history.h"
#include "components/permissions/permission_decision_auto_blocker.h"
#include "components/permissions/permission_request_enums.h"
#include "components/permissions/permission_uma_util.h"
#include "components/permissions/permission_util.h"
#include "components/permissions/request_type.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/privacy_sandbox_attestations.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/scoped_privacy_sandbox_attestations.h"
#include "components/privacy_sandbox/privacy_sandbox_settings.h"
#include "components/privacy_sandbox/privacy_sandbox_test_util.h"
#include "components/reading_list/core/mock_reading_list_model_observer.h"
#include "components/reading_list/core/reading_list_model.h"
#include "components/safe_browsing/core/browser/verdict_cache_manager.h"
#include "components/security_interstitials/content/stateful_ssl_host_state_delegate.h"
#include "components/segmentation_platform/public/features.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "components/site_isolation/pref_names.h"
#include "components/sync/test/test_sync_service.h"
#include "components/tpcd/metadata/browser/manager.h"
#include "components/tpcd/metadata/browser/parser.h"
#include "components/tpcd/metadata/browser/prefs.h"
#include "components/tpcd/metadata/browser/test_support.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/browser/background_tracing_manager.h"
#include "content/public/browser/browser_context.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/network_service_instance.h"
#include "content/public/browser/origin_trials_controller_delegate.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_features.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_utils.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/features.h"
#include "net/base/isolation_info.h"
#include "net/base/network_anonymization_key.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_access_result.h"
#include "net/cookies/cookie_partition_key_collection.h"
#include "net/http/http_auth.h"
#include "net/http/http_auth_cache.h"
#include "net/http/http_transaction_factory.h"
#include "net/net_buildflags.h"
#include "net/reporting/reporting_target_type.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_test_util.h"
#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h"
#include "services/network/network_context.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "third_party/blink/public/common/origin_trials/scoped_test_origin_trial_policy.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/favicon_size.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "url/scheme_host_port.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#include "chrome/browser/android/customtabs/chrome_origin_verifier.h"
#include "chrome/browser/android/search_permissions/search_permissions_service.h"
#include "chrome/browser/android/webapps/webapp_registry.h"
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#include "chrome/browser/ui/android/tab_model/tab_model_test_helper.h"
#include "components/password_manager/core/browser/split_stores_and_local_upm.h"
#include "testing/gmock/include/gmock/gmock.h"
#else
#include "chrome/browser/user_education/browser_feature_promo_storage_service.h"
#include "chrome/browser/user_education/user_education_service.h"
#include "chrome/browser/user_education/user_education_service_factory.h"
#include "content/public/browser/host_zoom_map.h"
#endif
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_LACROS)
#include "base/test/test_future.h"
#include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h"
#include "chrome/browser/web_applications/isolated_web_apps/get_controlled_frame_partition_command.h"
#include "chrome/browser/web_applications/locks/app_lock.h"
#include "chrome/browser/web_applications/test/fake_web_app_provider.h"
#include "chrome/browser/web_applications/test/web_app_install_test_utils.h"
#include "chrome/browser/web_applications/test/web_app_test_utils.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_command_scheduler.h"
#include "chrome/browser/web_applications/web_app_sync_bridge.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h"
#include "chromeos/ash/components/dbus/attestation/fake_attestation_client.h"
#include "chromeos/dbus/tpm_manager/fake_tpm_manager_client.h"
#include "components/account_id/account_id.h"
#include "components/user_manager/scoped_user_manager.h"
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include "components/crash/core/app/crashpad.h"
#include "components/upload_list/crash_upload_list.h"
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/mock_extension_special_storage_policy.h"
#endif
#if BUILDFLAG(ENABLE_PLUGINS)
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#include "chrome/browser/plugins/plugin_utils.h"
#endif
#if BUILDFLAG(ENABLE_REPORTING)
#include <optional>
#include "base/containers/flat_map.h"
#include "base/unguessable_token.h"
#include "net/network_error_logging/network_error_logging_service.h"
#include "net/reporting/reporting_browsing_data_remover.h"
#include "net/reporting/reporting_policy.h"
#include "net/reporting/reporting_service.h"
#endif
#if BUILDFLAG(ENABLE_NACL)
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/common/buildflags.h"
#endif
TestFuture;
BrowsingDataFilterBuilder;
DomainReliabilityClearMode;
DomainReliabilityMonitor;
_;
ByRef;
Eq;
FloatEq;
Invoke;
IsEmpty;
MakeMatcher;
Matcher;
MatcherInterface;
MatchResultListener;
Return;
SizeIs;
UnorderedElementsAre;
WithArg;
WithArgs;
constants;
namespace {
constexpr int kTopicsAPITestTaxonomyVersion = …;
const char kTestRegisterableDomain1[] = …;
const char kTestRegisterableDomain3[] = …;
const char kTestRealm[] = …;
#if BUILDFLAG(ENABLE_EXTENSIONS)
const uint64_t kExtension = …;
#endif
const uint64_t kProtected = …;
const uint64_t kUnprotected = …;
template <int index, typename T>
auto MoveArgToFuture(TestFuture<T>* future) { … }
#if BUILDFLAG(IS_ANDROID)
class TestWebappRegistry : public WebappRegistry {
public:
TestWebappRegistry() : WebappRegistry() {}
void UnregisterWebappsForUrls(
const base::RepeatingCallback<bool(const GURL&)>& url_filter) override {
}
void ClearWebappHistoryForUrls(
const base::RepeatingCallback<bool(const GURL&)>& url_filter) override {
}
};
class MockTabModel : public TestTabModel {
public:
explicit MockTabModel(TestingProfile* profile) : TestTabModel(profile) {}
MOCK_METHOD(void,
CloseTabsNavigatedInTimeWindow,
(const base::Time& begin_time, const base::Time& end_time),
(override));
};
#endif
class RemoveCookieTester { … };
class RemoveSafeBrowsingCookieTester : public RemoveCookieTester { … };
class RemoveHistoryTester { … };
class RemoveFaviconTester { … };
class RemoveUkmDataTester { … };
std::unique_ptr<KeyedService> BuildProtocolHandlerRegistry(
content::BrowserContext* context) { … }
class ClearDomainReliabilityTester { … };
class RemoveDIPSEventsTester { … };
class RemoveSecurePaymentConfirmationCredentialsTester { … };
class RemovePermissionPromptCountsTest { … };
namespace {
class TestTpcdManagerDelegate : public tpcd::metadata::Manager::Delegate { … };
}
class RemoveTpcdMetadataCohortsTester { … };
class ProbablySameFilterMatcher
: public MatcherInterface<
const base::RepeatingCallback<bool(const GURL&)>&> { … };
inline Matcher<const base::RepeatingCallback<bool(const GURL&)>&>
ProbablySameFilter(const base::RepeatingCallback<bool(const GURL&)>& filter) { … }
bool ProbablySameFilters(
const base::RepeatingCallback<bool(const GURL&)>& filter1,
const base::RepeatingCallback<bool(const GURL&)>& filter2) { … }
base::Time AnHourAgo() { … }
class RemoveDownloadsTester { … };
base::RepeatingCallback<bool(const GURL&)> CreateUrlFilterFromOriginFilter(
const base::RepeatingCallback<bool(const url::Origin&)>& origin_filter) { … }
class RemoveAutofillTester { … };
std::unique_ptr<KeyedService> BuildSyncService(
content::BrowserContext* context) { … }
}
#if BUILDFLAG(ENABLE_REPORTING)
class MockReportingService : public net::ReportingService { … };
class MockNetworkErrorLoggingService : public net::NetworkErrorLoggingService { … };
#endif
namespace autofill {
class StrikeDatabaseTester { … };
}
#if BUILDFLAG(ENABLE_NACL)
class ScopedNaClBrowserDelegate {
public:
~ScopedNaClBrowserDelegate() { nacl::NaClBrowser::ClearAndDeleteDelegate(); }
void Init(ProfileManager* profile_manager) {
nacl::NaClBrowser::SetDelegate(
std::make_unique<NaClBrowserDelegateImpl>(profile_manager));
}
};
#endif
class ChromeBrowsingDataRemoverDelegateTest : public testing::Test { … };
#if !BUILDFLAG(IS_ANDROID)
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
ClearUserEducationSessionHistory) { … }
#endif
#if BUILDFLAG(ENABLE_REPORTING)
class ChromeBrowsingDataRemoverDelegateWithReportingServiceTest
: public ChromeBrowsingDataRemoverDelegateTest { … };
class ChromeBrowsingDataRemoverDelegateWithNELServiceTest
: public ChromeBrowsingDataRemoverDelegateTest { … };
#endif
class ChromeBrowsingDataRemoverDelegateWithPasswordsTest
: public ChromeBrowsingDataRemoverDelegateTest { … };
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DISABLED_RemoveSafeBrowsingCookieForever) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DISABLED_RemoveSafeBrowsingCookieLastHour) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DISABLED_RemoveSafeBrowsingCookieForeverWithPredicate) { … }
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_LACROS)
TEST_F(ChromeBrowsingDataRemoverDelegateTest, ClearWebAppData) { … }
class IsolatedWebAppChromeBrowsingDataRemoverDelegateTest
: public ChromeBrowsingDataRemoverDelegateTest { … };
bool operator==(
const IsolatedWebAppChromeBrowsingDataRemoverDelegateTest::RemovalInfo& a,
const IsolatedWebAppChromeBrowsingDataRemoverDelegateTest::RemovalInfo& b) { … }
TEST_F(IsolatedWebAppChromeBrowsingDataRemoverDelegateTest, ClearData) { … }
TEST_F(IsolatedWebAppChromeBrowsingDataRemoverDelegateTest,
ForwardClearDataParameterToControlledFrame) { … }
TEST_F(IsolatedWebAppChromeBrowsingDataRemoverDelegateTest,
FilterOriginRespected) { … }
TEST_F(IsolatedWebAppChromeBrowsingDataRemoverDelegateTest, AppCookiesDeleted) { … }
TEST_F(IsolatedWebAppChromeBrowsingDataRemoverDelegateTest,
TimeRangeSpecified) { … }
#endif
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveHistoryForever) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveHistoryForLastHour) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveHistoryForOlderThan30Days) { … }
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveHistoryProhibited) {
RemoveHistoryTester tester;
ASSERT_TRUE(tester.Init(GetProfile()));
PrefService* prefs = GetProfile()->GetPrefs();
prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false);
base::Time two_hours_ago = base::Time::Now() - base::Hours(2);
const GURL kOrigin1("http://host1.com:1");
const GURL kOrigin2("http://host2.com:1");
tester.AddHistory(kOrigin1, base::Time::Now());
tester.AddHistory(kOrigin2, two_hours_ago);
ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1));
ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2));
BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(),
constants::DATA_TYPE_HISTORY, false);
EXPECT_EQ(constants::DATA_TYPE_HISTORY, GetRemovalMask());
EXPECT_EQ(content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB,
GetOriginTypeMask());
EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1));
EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2));
}
TEST_F(ChromeBrowsingDataRemoverDelegateWithPasswordsTest,
RemoveMultipleTypesHistoryProhibited) {
PrefService* prefs = GetProfile()->GetPrefs();
prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false);
const GURL kOrigin1("http://host1.com:1");
RemoveHistoryTester history_tester;
ASSERT_TRUE(history_tester.Init(GetProfile()));
history_tester.AddHistory(kOrigin1, base::Time::Now());
ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1));
ExpectRemoveLoginsByURLAndTime(profile_password_store());
uint64_t removal_mask =
constants::DATA_TYPE_HISTORY | constants::DATA_TYPE_PASSWORDS;
BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), removal_mask,
false);
EXPECT_EQ(removal_mask, GetRemovalMask());
EXPECT_EQ(content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB,
GetOriginTypeMask());
EXPECT_TRUE(history_tester.HistoryContainsURL(kOrigin1));
}
#endif
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveExternalProtocolData) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemovePersistentIsolatedOrigins) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveFaviconsForever) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, ExpireBookmarkFavicons) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, DeleteBookmarks) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, ClearReadingList) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, DeleteBookmarkHistory) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DeleteBookmarksDoesNothingWhenModelNotLoaded) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DISABLED_TimeBasedHistoryRemoval) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(ChromeBrowsingDataRemoverDelegateTest, DeleteTabs) {
::testing::NiceMock<MockTabModel> tab_model(GetProfile());
TabModelList::AddTabModel(&tab_model);
ASSERT_EQ(1u, TabModelList::models().size());
base::Time two_hours_ago = base::Time::Now() - base::Hours(2);
EXPECT_CALL(tab_model,
CloseTabsNavigatedInTimeWindow(two_hours_ago, base::Time::Max()))
.Times(1);
BlockUntilBrowsingDataRemoved(two_hours_ago, base::Time::Max(),
chrome_browsing_data_remover::DATA_TYPE_TABS,
false);
EXPECT_EQ(chrome_browsing_data_remover::DATA_TYPE_TABS, GetRemovalMask());
}
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DeleteTabs_WithArchivedTabModelPresent) {
::testing::NiceMock<MockTabModel> tab_model(GetProfile());
TabModelList::AddTabModel(&tab_model);
::testing::NiceMock<MockTabModel> archived_tab_model(GetProfile());
TabModelList::SetArchivedTabModel(&archived_tab_model);
ASSERT_EQ(1u, TabModelList::models().size());
base::Time two_hours_ago = base::Time::Now() - base::Hours(2);
EXPECT_CALL(tab_model,
CloseTabsNavigatedInTimeWindow(two_hours_ago, base::Time::Max()))
.Times(1);
EXPECT_CALL(archived_tab_model,
CloseTabsNavigatedInTimeWindow(two_hours_ago, base::Time::Max()))
.Times(1);
BlockUntilBrowsingDataRemoved(two_hours_ago, base::Time::Max(),
chrome_browsing_data_remover::DATA_TYPE_TABS,
false);
EXPECT_EQ(chrome_browsing_data_remover::DATA_TYPE_TABS, GetRemovalMask());
}
#endif
class ChromeBrowsingDataRemoverDelegateEnabledUkmDatabaseTest
: public ChromeBrowsingDataRemoverDelegateTest { … };
TEST_F(ChromeBrowsingDataRemoverDelegateEnabledUkmDatabaseTest, RemoveUkmUrls) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, AutofillRemovalLastHour) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, AutofillRemovalOlderThan30Days) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, AutofillRemovalEverything) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
StrikeDatabaseEmptyOnAutofillRemoveEverything) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, ZeroSuggestPrefsBasedCacheClear) { … }
#if !BUILDFLAG(IS_ANDROID)
TEST_F(ChromeBrowsingDataRemoverDelegateTest, ZeroSuggestInMemoryCacheClear) { … }
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
ContentProtectionPlatformKeysRemoval) {
auto user_manager = std::make_unique<ash::FakeChromeUserManager>();
auto* user =
user_manager->AddUser(AccountId::FromUserEmail("[email protected]"));
user_manager->UserLoggedIn(user->GetAccountId(), user->username_hash(),
false, false);
user_manager::ScopedUserManager user_manager_enabler(std::move(user_manager));
ash::AttestationClient::InitializeFake();
BlockUntilBrowsingDataRemoved(
base::Time(), base::Time::Max(),
content::BrowsingDataRemover::DATA_TYPE_MEDIA_LICENSES, false);
const std::vector<::attestation::DeleteKeysRequest>& history =
ash::AttestationClient::Get()->GetTestInterface()->delete_keys_history();
EXPECT_EQ(history.size(), 1u);
ash::AttestationClient::Shutdown();
}
#endif
TEST_F(ChromeBrowsingDataRemoverDelegateTest, DomainReliability_Null) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, DomainReliability_Beacons) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DISABLED_DomainReliability_Beacons_WithFilter) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, DomainReliability_Contexts) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DomainReliability_Contexts_WithFilter) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, DomainReliability_ContextsWin) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DomainReliability_ProtectedOrigins) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DISABLED_DomainReliability_NoMonitor) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveDownloads) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithPasswordsTest,
RemovePasswordStatistics) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithPasswordsTest,
DISABLED_RemovePasswordStatisticsByOrigin) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithPasswordsTest,
RemovePasswordsByTimeOnly) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithPasswordsTest,
DISABLED_RemovePasswordsByOrigin) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithPasswordsTest,
RemovingProfileStorePasswordsTrackedInAPref) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithPasswordsTest, DisableAutoSignIn) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithPasswordsTest,
DisableAutoSignInAfterRemovingPasswords) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithPasswordsTest,
DisableAutoSignInCrossSiteClearSiteData) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
RemoveContentSettingsWithPreserveFilter) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveContentSettings) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveProtocolHandler) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveSelectedClientHints) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveAllClientHints) { … }
#if !BUILDFLAG(IS_ANDROID)
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveZoomLevel) { … }
#endif
#if !BUILDFLAG(IS_ANDROID)
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveTabDiscardExceptionsList) { … }
#endif
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveTranslateBlocklist) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveDurablePermission) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
DurablePermissionIsPartOfEmbedderDOMStorage) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveFederatedContentSettings) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
ClearHttpAuthCache_RemovePasswords) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveFledgeJoinSettings) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveTopicSettings) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveDIPSEventsForLastHour) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, RemoveDIPSEventsByType) { … }
class ChromeBrowsingDataRemoverDelegateBlockPromptsTest
: public ChromeBrowsingDataRemoverDelegateTest { … };
TEST_F(ChromeBrowsingDataRemoverDelegateBlockPromptsTest,
ClearPermissionPromptCounts) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
LanguageHistogramClearedOnClearingCompleteHistory) { … }
#if BUILDFLAG(ENABLE_EXTENSIONS)
TEST_F(ChromeBrowsingDataRemoverDelegateTest, OriginTypeMasks) { … }
#endif
TEST_F(ChromeBrowsingDataRemoverDelegateTest, OriginTypeMasksNoPolicy) { … }
#if BUILDFLAG(ENABLE_REPORTING)
TEST_F(ChromeBrowsingDataRemoverDelegateTest, ReportingCache_NoService) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithReportingServiceTest,
ReportingCache) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithReportingServiceTest,
DISABLED_ReportingCache_WithFilter) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest, NetworkErrorLogging_NoDelegate) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithNELServiceTest,
NetworkErrorLogging_History) { … }
#endif
TEST_F(ChromeBrowsingDataRemoverDelegateTest, AllTypesAreGettingDeleted) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(ChromeBrowsingDataRemoverDelegateTest, WipeOriginVerifierData) {
int before = customtabs::ChromeOriginVerifier::
GetClearBrowsingDataCallCountForTesting();
BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
constants::DATA_TYPE_HISTORY, false);
EXPECT_EQ(before + 1, customtabs::ChromeOriginVerifier::
GetClearBrowsingDataCallCountForTesting());
}
#endif
#if BUILDFLAG(IS_CHROMEOS)
TEST_F(ChromeBrowsingDataRemoverDelegateTest, WipeCrashData) {
base::ScopedPathOverride override_crash_dumps(chrome::DIR_CRASH_DUMPS);
base::FilePath crash_dir_path;
base::PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dir_path);
base::FilePath upload_log_path =
crash_dir_path.AppendASCII(CrashUploadList::kReporterLogFilename);
constexpr char kCrashEntry1[] = "12345,abc\n";
constexpr char kCrashEntry2[] = "67890,def\n";
std::string initial_contents = kCrashEntry1;
initial_contents.append(kCrashEntry2);
ASSERT_TRUE(base::WriteFile(upload_log_path, initial_contents));
BlockUntilBrowsingDataRemoved(base::Time::FromTimeT(67890u),
base::Time::Max(), constants::DATA_TYPE_HISTORY,
false);
std::string contents;
base::ReadFileToString(upload_log_path, &contents);
EXPECT_EQ(kCrashEntry1, contents);
BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
constants::DATA_TYPE_HISTORY, false);
EXPECT_FALSE(base::PathExists(upload_log_path));
}
#endif
TEST_F(ChromeBrowsingDataRemoverDelegateTest, WipeCustomDictionaryData) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
WipeNotificationPermissionPromptOutcomesData) { … }
class ChromeBrowsingDataRemoverDelegateWithAccountPasswordsTest
: public ChromeBrowsingDataRemoverDelegateWithPasswordsTest { … };
TEST_F(ChromeBrowsingDataRemoverDelegateWithAccountPasswordsTest,
DisableAutoSignInAfterRemovingPasswords) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithAccountPasswordsTest,
RemovePasswordsByTimeOnly_WithAccountStore) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithAccountPasswordsTest,
RemoveAccountPasswordsByTimeOnly_WithAccountStore) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateWithAccountPasswordsTest,
RemovingAccountStorePasswordsTrackedInAPref) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
GetDomainsForDeferredCookieDeletion) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
RemoveSecurePaymentConfirmationCredentials) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
PageLoadTokenClearedOnCookieDeleted) { … }
#if !BUILDFLAG(IS_ANDROID)
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
RevokeActiveFileSystemPermission) { … }
#endif
TEST_F(ChromeBrowsingDataRemoverDelegateTest,
Call_OnTopicsDataAccessibleSinceUpdated_WhenClearingMostCookies) { … }
TEST_F(
ChromeBrowsingDataRemoverDelegateTest,
DontCall_OnTopicsDataAccessibleSinceUpdated_WhenOnlyClearingPartitionedCookies) { … }
class ChromeBrowsingDataRemoverDelegateOriginTrialsTest
: public ChromeBrowsingDataRemoverDelegateTest { … };
TEST_F(ChromeBrowsingDataRemoverDelegateOriginTrialsTest,
PersistentOriginTrialsAreDeleted) { … }
class ChromeBrowsingDataRemoverDelegateMediaDeviceSaltTest
: public ChromeBrowsingDataRemoverDelegateTest { … };
TEST_F(ChromeBrowsingDataRemoverDelegateMediaDeviceSaltTest, RemoveAllSalts) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateMediaDeviceSaltTest, PreserveOneSalt) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateMediaDeviceSaltTest, RemoveOneSalt) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateMediaDeviceSaltTest,
RemoveBasedOnTime) { … }
class ChromeBrowsingDataRemoverDelegateTpcdMetadataTest
: public ChromeBrowsingDataRemoverDelegateTest { … };
TEST_F(ChromeBrowsingDataRemoverDelegateTpcdMetadataTest, ResetAllCohorts) { … }
TEST_F(ChromeBrowsingDataRemoverDelegateTpcdMetadataTest,
ResetAllCohort_PreserveSome) { … }
namespace {
constexpr char kPrimaryUrl[] = …;
constexpr char kSecondaryUrl[] = …;
constexpr char kUnrelatedPrimaryUrl[] = …;
constexpr char kUnrelatedSecondaryUrl[] = …;
enum class FilterOrigins { … };
const ContentSettingPatternSource kExpectedSettingDefault(
ContentSettingsPattern::Wildcard(),
ContentSettingsPattern::Wildcard(),
content_settings::ContentSettingToValue(CONTENT_SETTING_ASK),
content_settings::ProviderType::kDefaultProvider,
false);
}
class ChromeBrowsingDataRemoverDelegateRelatedWebsiteSetsTest
: public ChromeBrowsingDataRemoverDelegateTest,
public testing::WithParamInterface<
std::tuple<bool,
ContentSettingsType,
FilterOrigins,
content_settings::mojom::SessionModel>> { … };
TEST_P(ChromeBrowsingDataRemoverDelegateRelatedWebsiteSetsTest,
RemoveRelatedWebsiteSetsPermissions) { … }
INSTANTIATE_TEST_SUITE_P(…);