#include "components/content_settings/browser/page_specific_content_settings.h"
#include <optional>
#include <string>
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "components/browsing_data/content/browsing_data_helper.h"
#include "components/content_settings/browser/test_page_specific_content_settings_delegate.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/features.h"
#include "components/security_state/core/security_state.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/browser/cookie_access_details.h"
#include "content/public/browser/trust_token_access_details.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/mock_navigation_handle.h"
#include "content/public/test/navigation_handle_observer.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_access_result.h"
#include "net/cookies/cookie_options.h"
#include "net/shared_dictionary/shared_dictionary_isolation_key.h"
#include "services/network/public/mojom/shared_dictionary_access_observer.mojom.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"
namespace content_settings {
StorageType;
namespace {
constexpr int kTopicsAPITestTaxonomyVersion = …;
class MockSiteDataObserver
: public PageSpecificContentSettings::SiteDataObserver { … };
class MockPageSpecificContentSettingsDelegate
: public TestPageSpecificContentSettingsDelegate { … };
blink::StorageKey CreateUnpartitionedStorageKey(const GURL& url) { … }
}
class PageSpecificContentSettingsTest
: public content::RenderViewHostTestHarness { … };
TEST_F(PageSpecificContentSettingsTest, BlockedContent) { … }
TEST_F(PageSpecificContentSettingsTest, BlockedFileSystems) { … }
TEST_F(PageSpecificContentSettingsTest, AllowedContent) { … }
TEST_F(PageSpecificContentSettingsTest, AllowlistJavaScript) { … }
TEST_F(PageSpecificContentSettingsTest, InterestGroupJoin) { … }
TEST_F(PageSpecificContentSettingsTest, BrowsingDataAccessed) { … }
TEST_F(PageSpecificContentSettingsTest, EmptyCookieList) { … }
TEST_F(PageSpecificContentSettingsTest, BlockedThirdPartyCookie) { … }
TEST_F(PageSpecificContentSettingsTest, SiteDataObserver) { … }
TEST_F(PageSpecificContentSettingsTest, BrowsingDataModelTrustToken) { … }
TEST_F(PageSpecificContentSettingsTest,
BrowsingDataModelTrustTokenPendingNavigation) { … }
TEST_F(PageSpecificContentSettingsTest, BrowsingDataModelSharedDictionary) { … }
TEST_F(PageSpecificContentSettingsTest,
BrowsingDataModelSharedDictionaryBlocked) { … }
TEST_F(PageSpecificContentSettingsTest,
BrowsingDataModelSharedDictionaryPendingNavigation) { … }
TEST_F(PageSpecificContentSettingsTest,
BrowsingDataModelSharedDictionaryPendingNavigationBlocked) { … }
#if !BUILDFLAG(IS_IOS)
TEST_F(PageSpecificContentSettingsTest,
IndicatorChangedOnContentSettingChange) { … }
#endif
TEST_F(PageSpecificContentSettingsTest, AllowedSitesCountedFromBothModels) { … }
TEST_F(PageSpecificContentSettingsTest, BrowsingDataModelStorageAccess) { … }
class PageSpecificContentSettingsWithPrerenderTest
: public PageSpecificContentSettingsTest { … };
TEST_F(PageSpecificContentSettingsWithPrerenderTest, SiteDataAccessed) { … }
TEST_F(PageSpecificContentSettingsWithPrerenderTest,
DelegateUpdatesSentAfterActivation) { … }
TEST_F(PageSpecificContentSettingsWithPrerenderTest,
UpdateLocationBarAfterActivation) { … }
TEST_F(PageSpecificContentSettingsWithPrerenderTest, ContentAllowedAndBlocked) { … }
TEST_F(PageSpecificContentSettingsTest, Topics) { … }
class PageSpecificContentSettingsWithFencedFrameTest
: public PageSpecificContentSettingsTest { … };
TEST_F(PageSpecificContentSettingsWithFencedFrameTest, SiteDataAccessed) { … }
TEST_F(PageSpecificContentSettingsWithFencedFrameTest, DelegateUpdatesSent) { … }
TEST_F(PageSpecificContentSettingsWithFencedFrameTest,
ContentAllowedAndBlocked) { … }
TEST_F(PageSpecificContentSettingsTest,
MediaIndicatorsBlockedDoNotOverrideInUse) { … }
TEST_F(PageSpecificContentSettingsTest, MediaIndicatorsMinHoldDurationDelay) { … }
TEST_F(PageSpecificContentSettingsTest, AlmostExpiredMinHoldDurationDelay) { … }
TEST_F(PageSpecificContentSettingsTest,
MediaIndicatorsHoldAfterUseDurationDelay) { … }
TEST_F(PageSpecificContentSettingsTest,
MediaIndicatorsReenableCameraWhileMinHoldDurationDelay) { … }
TEST_F(PageSpecificContentSettingsTest, GetLastUsedTimeLocalTimeTest) { … }
TEST_F(PageSpecificContentSettingsTest, GetLastUsedReturnsDefaultTimeTest) { … }
TEST_F(PageSpecificContentSettingsTest, GetLastUsedReturnCorrectTimeTest) { … }
TEST_F(PageSpecificContentSettingsTest, MediaBlockedIndicatorsDismissDelay) { … }
TEST_F(PageSpecificContentSettingsTest,
MediaIndicatorsDoNotDismissIfOpenedDelay) { … }
TEST_F(PageSpecificContentSettingsTest, MediaBlockedStateIsResetIfMediaUsed) { … }
class PageSpecificContentSettingsIframeTest
: public PageSpecificContentSettingsTest { … };
TEST_F(PageSpecificContentSettingsIframeTest, SecondaryUrlBlocked) { … }
TEST_F(PageSpecificContentSettingsIframeTest, UnrelatedSecondaryUrlBlocked) { … }
TEST_F(PageSpecificContentSettingsIframeTest, PrimarySecondaryIdentical) { … }
}