#include <memory>
#include <utility>
#include <vector>
#include "base/barrier_closure.h"
#include "base/containers/contains.h"
#include "base/location.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "components/attribution_reporting/constants.h"
#include "components/attribution_reporting/destination_set.h"
#include "components/attribution_reporting/event_trigger_data.h"
#include "components/attribution_reporting/os_registration.h"
#include "components/attribution_reporting/registration_eligibility.mojom.h"
#include "components/attribution_reporting/source_registration.h"
#include "components/attribution_reporting/source_type.mojom.h"
#include "components/attribution_reporting/suitable_origin.h"
#include "components/attribution_reporting/test_utils.h"
#include "components/attribution_reporting/trigger_registration.h"
#include "content/browser/attribution_reporting/attribution_data_host_manager_impl.h"
#include "content/browser/attribution_reporting/attribution_manager.h"
#include "content/browser/attribution_reporting/attribution_manager_impl.h"
#include "content/browser/attribution_reporting/attribution_os_level_manager.h"
#include "content/browser/attribution_reporting/attribution_test_utils.h"
#include "content/browser/attribution_reporting/attribution_trigger.h"
#include "content/browser/attribution_reporting/os_registration.h"
#include "content/browser/attribution_reporting/test/mock_attribution_host.h"
#include "content/browser/attribution_reporting/test/mock_attribution_manager.h"
#include "content/browser/attribution_reporting/test/mock_content_browser_client.h"
#include "content/browser/attribution_reporting/test/source_observer.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/storage_partition_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_content_browser_client.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_frame_navigation_observer.h"
#include "content/public/test/test_navigation_throttle.h"
#include "content/public/test/test_navigation_throttle_inserter.h"
#include "content/shell/browser/shell.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "net/base/net_errors.h"
#include "net/base/schemeful_site.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "services/network/public/cpp/features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/navigation/impression.h"
#include "third_party/blink/public/mojom/fenced_frame/fenced_frame.mojom.h"
#include "url/gurl.h"
namespace content {
namespace {
DestinationSet;
EventTriggerData;
SourceRegistration;
SuitableOrigin;
TriggerRegistration;
RegistrationEligibility;
SourceType;
EmbeddedTestServer;
_;
AllOf;
ElementsAre;
Field;
Property;
StrictMock;
kAttributionReportingRegisterSourceHeader;
constexpr char kRegistrationMethod[] = …;
}
class AttributionSrcBrowserTest : public ContentBrowserTest,
public ::testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest, SourceRegistered) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
SourceRegisteredViaEligibilityHeader) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest, ForegroundRegistration) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
AttributionSrcWindowOpen_MultipleFeatures_RequestsAll) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
AttributionSrcWindowOpen_URLEncoded_SourceRegistered) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
AttributionSrcWindowOpen_RetainsOriginalURLCase) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
AttributionSrcWindowOpen_NonAsciiUrl) { … }
IN_PROC_BROWSER_TEST_P(
AttributionSrcBrowserTest,
AttributionSrcWindowOpenNoUserGesture_NoBackgroundRequestNoImpression) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
AttributionSrcImgRedirect_MultipleSourcesRegistered) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
AttributionSrcImgRedirect_InvalidJsonIgnored) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
AttributionSrcImgSlowResponse_SourceRegistered) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
NoReferrerPolicy_UsesDefault) { … }
class AttributionSrcCrossAppWebDisabledBrowserTest
: public AttributionSrcBrowserTest { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(AttributionSrcCrossAppWebDisabledBrowserTest,
Img_SetsAttributionReportingEligibleHeader) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
UntrustworthyUrl_DoesNotSetEligibleHeader) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
ReferrerPolicy_RespectsDocument) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
BasicTrigger_TriggerRegistered) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
PermissionsPolicyDisabled_SourceNotRegistered) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
AttributionSrcImg_InvalidTriggerJsonIgnored) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
ImgNoneSupported_EligibleHeaderNotSet) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
ResponseReceivedInDetachedFrame_NoCrash) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
ForegroundNavigationRedirectCancelled_SourceRegistered) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcBrowserTest,
MultipleBackgroundRequest_AllRegistered) { … }
class AttributionSrcPrerenderBrowserTest : public AttributionSrcBrowserTest { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(AttributionSrcPrerenderBrowserTest,
SourceNotRegisteredOnPrerender) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcPrerenderBrowserTest,
SourceRegisteredOnActivatedPrerender) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcPrerenderBrowserTest,
SubresourceTriggerNotRegisteredOnPrerender) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcPrerenderBrowserTest,
SubresourceTriggerRegisteredOnActivatedPrerender) { … }
class AttributionSrcFencedFrameBrowserTest : public AttributionSrcBrowserTest { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(AttributionSrcFencedFrameBrowserTest,
DefaultMode_SourceNotRegistered) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcFencedFrameBrowserTest,
OpaqueAdsMode_SourceRegistered) { … }
class AttributionSrcCrossAppWebEnabledBrowserTest
: public AttributionSrcBrowserTest { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(AttributionSrcCrossAppWebEnabledBrowserTest,
Img_SetsSupportHeader) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcCrossAppWebEnabledBrowserTest,
Subresource_Register) { … }
IN_PROC_BROWSER_TEST_P(
AttributionSrcCrossAppWebEnabledBrowserTest,
OsLevelEnabledPostRendererInitialization_SetsSupportHeader) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcCrossAppWebEnabledBrowserTest,
OsRegistration_Register) { … }
IN_PROC_BROWSER_TEST_P(AttributionSrcCrossAppWebEnabledBrowserTest,
WebAndOsHeadersAndPreferOs_OsRegistered) { … }
}