#include "content/browser/interest_group/ad_auction_headers_util.h"
#include <functional>
#include <string>
#include <string_view>
#include "base/base64url.h"
#include "base/memory/scoped_refptr.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "content/browser/interest_group/ad_auction_page_data.h"
#include "content/browser/interest_group/header_direct_from_seller_signals.h"
#include "content/browser/interest_group/interest_group_features.h"
#include "content/browser/loader/subresource_proxying_url_loader_service.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_renderer_host.h"
#include "content/test/test_render_frame_host.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_version.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
#include "services/network/public/cpp/resource_request.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content {
namespace {
constexpr char kLegitimateAdAuctionResponse[] = …;
constexpr char kLegitimateAdAuctionSignals[] = …;
std::string Base64UrlDecode(std::string_view input) { … }
class InterceptingContentBrowserClient : public ContentBrowserClient { … };
blink::ParsedPermissionsPolicy CreatePermissivePolicy() { … }
blink::ParsedPermissionsPolicy CreateRestrictivePolicy() { … }
}
class IsAdAuctionHeadersEligibleTest
: public RenderViewHostTestHarness,
public testing::WithParamInterface<bool> { … };
TEST_P(IsAdAuctionHeadersEligibleTest, RequestIsEligible) { … }
TEST_P(IsAdAuctionHeadersEligibleTest, NotEligibleDueToUntrustworthyOrigin) { … }
TEST_P(IsAdAuctionHeadersEligibleTest, NotEligibleDueToOpaqueOrigin) { … }
TEST_P(IsAdAuctionHeadersEligibleTest, NotEligibleDueToInactiveFrame) { … }
TEST_P(IsAdAuctionHeadersEligibleTest, NotEligibleDueToPermissionsPolicy) { … }
TEST_P(IsAdAuctionHeadersEligibleTest,
NotEligibleDueToInterestGroupAPINotAllowed) { … }
INSTANTIATE_TEST_SUITE_P(…);
class IsAdAuctionHeadersEligibleForNavigationTest
: public RenderViewHostTestHarness { … };
TEST_F(IsAdAuctionHeadersEligibleForNavigationTest, RequestIsEligible) { … }
TEST_F(IsAdAuctionHeadersEligibleForNavigationTest, DisabledByFeature) { … }
TEST_F(IsAdAuctionHeadersEligibleForNavigationTest,
NotEligibleDueToUntrustworthyOrigin) { … }
TEST_F(IsAdAuctionHeadersEligibleForNavigationTest,
NotEligibleDueToNonChildFrameProvided) { … }
TEST_F(IsAdAuctionHeadersEligibleForNavigationTest,
NotEligibleDueToOpaqueOrigin) { … }
TEST_F(IsAdAuctionHeadersEligibleForNavigationTest,
NotEligibleDueToInactiveFrame) { … }
TEST_F(IsAdAuctionHeadersEligibleForNavigationTest,
NotEligibleDueToPermissionsPolicy) { … }
TEST_F(IsAdAuctionHeadersEligibleForNavigationTest,
NotEligibleDueToInterestGroupAPINotAllowed) { … }
class ProcessAdAuctionResponseHeadersTest : public RenderViewHostTestHarness { … };
TEST_F(ProcessAdAuctionResponseHeadersTest,
MultipleAdAuctionResults_AllWitnessed) { … }
TEST_F(ProcessAdAuctionResponseHeadersTest,
InvalidAdAuctionResultResponseHeader) { … }
TEST_F(ProcessAdAuctionResponseHeadersTest, AdAuctionSignalsResponseHeader) { … }
TEST_F(ProcessAdAuctionResponseHeadersTest,
AdAuctionSignalsResponseHeaderTooLong) { … }
TEST_F(ProcessAdAuctionResponseHeadersTest, AdditionalBid) { … }
TEST_F(ProcessAdAuctionResponseHeadersTest,
AdditionalBid_MultipleNoncesAndMultipleBidsPerNonce) { … }
TEST_F(ProcessAdAuctionResponseHeadersTest,
AdditionalBid_InvalidHeaderSkipped) { … }
TEST(RemoveAdAuctionResponseHeadersTest,
SignalsAndAdditionalBidHeadersAreRemoved) { … }
}