chromium/content/services/auction_worklet/bidder_worklet_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/342213636): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "content/services/auction_worklet/bidder_worklet.h"

#include <stdint.h>

#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/feature_list.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/json/json_writer.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
#include "content/common/features.h"
#include "content/public/common/content_features.h"
#include "content/services/auction_worklet/auction_v8_helper.h"
#include "content/services/auction_worklet/public/cpp/real_time_reporting.h"
#include "content/services/auction_worklet/public/mojom/auction_worklet_service.mojom.h"
#include "content/services/auction_worklet/public/mojom/bidder_worklet.mojom-forward.h"
#include "content/services/auction_worklet/public/mojom/private_aggregation_request.mojom.h"
#include "content/services/auction_worklet/public/mojom/real_time_reporting.mojom.h"
#include "content/services/auction_worklet/worklet_devtools_debug_test_util.h"
#include "content/services/auction_worklet/worklet_test_util.h"
#include "content/services/auction_worklet/worklet_v8_debug_test_util.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_associated_receiver.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/unique_receiver_set.h"
#include "net/http/http_status_code.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/numeric/int128.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/features_generated.h"
#include "third_party/blink/public/common/interest_group/ad_auction_constants.h"
#include "third_party/blink/public/common/interest_group/ad_auction_currencies.h"
#include "third_party/blink/public/common/interest_group/ad_display_size.h"
#include "third_party/blink/public/common/interest_group/interest_group.h"
#include "third_party/blink/public/mojom/interest_group/interest_group_types.mojom.h"
#include "third_party/googletest/src/googlemock/include/gmock/gmock-more-matchers.h"
#include "url/gurl.h"
#include "url/origin.h"
#include "url/url_constants.h"

HasSubstr;
IsEmpty;
StartsWith;
UnorderedElementsAre;

namespace auction_worklet {
namespace {

TaskEnvironment;
PrivateAggregationRequests;
RealTimeReportingContributions;

// This was produced by running wat2wasm on this:
// (module
//  (global (export "test_const") i32 (i32.const 123))
// )
const uint8_t kToyWasm[] =;

const char kWasmUrl[] =;

// Packs kToyWasm into a std::string.
std::string ToyWasm() {}

// Creates generateBid() scripts with the specified result value, in raw
// Javascript. Allows returning generateBid() arguments, arbitrary values,
// incorrect types, etc.
std::string CreateGenerateBidScript(const std::string& raw_return_value,
                                    const std::string& extra_code = "") {}

// Returns a working script, primarily for testing failure cases where it
// should not be run.
static std::string CreateBasicGenerateBidScript() {}

// Returns a working script which executes given `extra_code` as well.
static std::string CreateBasicGenerateBidScriptWithExtraCode(
    const std::string& extra_code) {}

// Creates bidder worklet script with a reportWin() function with the specified
// body, and the default generateBid() function.
std::string CreateReportWinScript(const std::string& function_body) {}

// A GenerateBidClient that takes a callback to call in OnGenerateBid(), and
// optionally one for OnBiddingSignalsReceived(). If no callback for
// OnBiddingSignalsReceived() is provided, just invokes the
// OnBiddingSignalsReceivedCallback immediately.
class GenerateBidClientWithCallbacks : public mojom::GenerateBidClient {};

class BidderWorkletTest : public testing::Test {};

class BidderWorkletTwoThreadsTest : public BidderWorkletTest {};

class BidderWorkletMultiThreadingTest
    : public BidderWorkletTest,
      public testing::WithParamInterface<size_t> {};

INSTANTIATE_TEST_SUITE_P();

class BidderWorkletCustomAdComponentLimitTest : public BidderWorkletTest {};

class BidderWorkletMultiBidDisabledTest : public BidderWorkletTest {};

// kCookieDeprecationFacilitatedTesting disables kFledgeMultiBid.
class BidderWorkletMultiBidAndCookieDeprecationTest : public BidderWorkletTest {};

// Test the case the BidderWorklet pipe is closed before invoking the
// GenerateBidCallback. The invocation of the GenerateBidCallback is not
// observed, since the callback is on the pipe that was just closed. There
// should be no Mojo exception due to destroying the creation callback without
// invoking it.
TEST_F(BidderWorkletTest, PipeClosed) {}

TEST_F(BidderWorkletTest, NetworkError) {}

TEST_F(BidderWorkletTest, CompileError) {}

TEST_F(BidderWorkletTest, GenerateBidReturnValueAd) {}

TEST_F(BidderWorkletTest, GenerateBidReturnValueBid) {}

TEST_F(BidderWorkletTest, GenerateBidReturnBidCurrencyExpectUnspecified) {}

TEST_F(BidderWorkletTest, GenerateBidReturnBidCurrencyExpectCAD) {}

TEST_F(BidderWorkletTest, GenerateBidReturnValueUrl) {}

// Check that accessing `renderUrl` of an entry in the ads array displays a
// warning. Also checks that renderUrl works as expected.
//
// TODO(crbug.com/40266734): Remove this test when the field itself is
// removed.
TEST_F(BidderWorkletTest, AdsRenderUrlDeprecationWarning) {}

// Check that accessing `renderURL` of an entry in the ads array does not
// display a warning.
//
// TODO(crbug.com/40266734): Remove this test when renderUrl is removed.
TEST_F(BidderWorkletTest, AdsRenderUrlNoDeprecationWarning) {}

TEST_F(BidderWorkletTest, GenerateBidReturnValueAdComponents) {}

TEST_F(BidderWorkletCustomAdComponentLimitTest, AdComponentsLimit) {}

// Check that accessing `renderUrl` of an entry in the adComponents array
// displays a warning. Also checks that renderUrl works as expected.
//
// TODO(crbug.com/40266734): Remove this test when the field itself is
// removed.
TEST_F(BidderWorkletTest, AdComponentsRenderUrlDeprecationWarning) {}

// Check that accessing `renderURL` of an entry in the ads array does not
// display a warning.
//
// TODO(crbug.com/40266734): Remove this test when renderUrl is removed.
TEST_F(BidderWorkletTest, AdComponentsRenderUrlNoDeprecationWarning) {}

TEST_F(BidderWorkletTest, GenerateBidModelingSignals) {}

TEST_F(BidderWorkletTest, GenerateBidModelingSignalsNaN) {}

TEST_F(BidderWorkletTest, GenerateBidModelingSignalsInfinity) {}

TEST_F(BidderWorkletTest, GenerateBidModelingSignalsNegative) {}

TEST_F(BidderWorkletTest, GenerateBidModelingSignalsNegativeInfinity) {}

TEST_F(BidderWorkletTest, GenerateBidModelingSignalsNegativeZero) {}

TEST_F(BidderWorkletTest, GenerateBidModelingSignalsPositiveZero) {}

TEST_F(BidderWorkletTest, GenerateBidModelingSignalsNonInteger) {}

TEST_F(BidderWorkletTest, GenerateBidModelingSignalsTooLarge) {}

TEST_F(BidderWorkletTest, GenerateBidModelingSignalsAlmostTooLarge) {}

TEST_F(BidderWorkletTest, GenerateBidReturnValueInvalid) {}

// Test parsing of setBid arguments.
TEST_F(BidderWorkletTest, GenerateBidSetBidThrows) {}

TEST_F(BidderWorkletTest, GenerateBidSetBidNonTermConversion) {}

TEST_F(BidderWorkletMultiBidDisabledTest, GenerateBidMultiBid) {}

// Cookie disabling trial forces multibid off.
TEST_F(BidderWorkletMultiBidAndCookieDeprecationTest, GenerateBidMultiBid) {}

// Make sure that fields that are only available with multibid on aren't
// read when its off.
TEST_F(BidderWorkletMultiBidDisabledTest, ComponentTargetFieldsOnlyMultiBid) {}

// Make sure that fields that are only available with multibid on aren't
// read when its forced off by kCookieDeprecationFacilitatedTesting.
TEST_F(BidderWorkletMultiBidAndCookieDeprecationTest,
       ComponentTargetFieldsOnlyMultiBid) {}

// Make sure that fields that are only available with multibid on are read
// when it's on. This is mostly meant to validate the multibid=off
// version of the testcase; the actual functionality of the fields is tested
// separately.
TEST_F(BidderWorkletTest, ComponentTargetFieldsOnlyMultiBid) {}

TEST_F(BidderWorkletTest, TargetNumAdComponents) {}

TEST_F(BidderWorkletTest, TargetNumAdComponentsKAnon) {}

TEST_F(BidderWorkletTest, TargetAndMandatoryAdComponentsKAnon) {}

TEST_F(BidderWorkletTest, GenerateBidMultiBid) {}

// If multibid is off, even passing an array with 1 element to SetBid() isn't
// available.
TEST_F(BidderWorkletMultiBidDisabledTest, SetBidMultiBid) {}

TEST_F(BidderWorkletTest, SetBidMultiBid) {}

// Make sure Date() is not available when running generateBid().
TEST_F(BidderWorkletTest, GenerateBidDateNotAvailable) {}

TEST_F(BidderWorkletTest, GenerateBidInterestGroupOwner) {}

TEST_F(BidderWorkletTest, GenerateBidInterestGroupName) {}

TEST_F(BidderWorkletTest,
       GenerateBidInterestGroupEnableBiddingSignalsPrioritization) {}

// This is deprecated and slated to be removed, but should work in the meantime.
//
// TODO(crbug.com/41490104): Remove this test when the field itself is
// removed.
TEST_F(BidderWorkletTest,
       GenerateBidInterestGroupUseBiddingSignalsPrioritization) {}

// Check that accessing `useBiddingSignalsPrioritization` displays a warning.
//
// TODO(crbug.com/41490104): Remove this test when the field itself is
// removed.
TEST_F(BidderWorkletTest, UseBiddingSignalsPrioritizationDeprecationWarning) {}

// Check that accessing `enableBiddingSignalsPrioritization` does not display a
// warning.
//
// TODO(crbug.com/41490104): Remove this test when
// useBiddingSignalsPrioritization is removed.
TEST_F(BidderWorkletTest,
       EnableBiddingSignalsPrioritizationNoDeprecationWarning) {}

TEST_F(BidderWorkletTest, GenerateBidInterestGroupPriorityVector) {}

TEST_F(BidderWorkletTest, GenerateBidInterestGroupBiddingLogicUrl) {}

// Check that accessing `biddingLogicUrl` displays a warning.
//
// TODO(crbug.com/40264073): Remove this test when the field itself is
// removed.
TEST_F(BidderWorkletTest, BiddingLogicUrlDeprecationWarning) {}

// Check that accessing `biddingLogicURL` does not display a warning.
//
// TODO(crbug.com/40264073): Remove this test when `biddingLogicUrl` is
// removed.
TEST_F(BidderWorkletTest, BiddingLogicUrlNoDeprecationWarning) {}

TEST_F(BidderWorkletTest, GenerateBidInterestGroupBiddingWasmHelperUrl) {}

// Check that accessing `biddingWasmHelperUrl` displays a warning.
//
// TODO(crbug.com/40264073): Remove this test when the field itself is
// removed.
TEST_F(BidderWorkletTest, BiddingWasmHelperUrlDeprecationWarning) {}

// Check that accessing `biddingWasmHelperURL` does not display a warning.
//
// TODO(crbug.com/40264073): Remove this test when `biddingWasmHelperUrl`
// is removed.
TEST_F(BidderWorkletTest, BiddingWasmHelperUrlNoDeprecationWarning) {}

TEST_F(BidderWorkletTest, GenerateBidInterestGroupUpdateUrl) {}

// Check that accessing `updateUrl` displays a warning.
//
// TODO(crbug.com/40264073): Remove this test when the field itself is
// removed.
TEST_F(BidderWorkletTest, UpdateUrlDeprecationWarning) {}

// Check that accessing `dailyUpdateUrl` displays a warning.
//
// TODO(crbug.com/40258629): Remove this test when the field itself is
// removed.
TEST_F(BidderWorkletTest, DailyUpdateUrlDeprecationWarning) {}

// Check that accessing `updateURL` does not display a warning.
//
// TODO(crbug.com/40264073) and TODO(crbug.com/40258629):
// Remove this test when `dailyUpdateUrl` and `updateUrl` are removed.
TEST_F(BidderWorkletTest, UpdateUrlNoDeprecationWarning) {}

TEST_F(BidderWorkletTest, GenerateBidInterestGroupTrustedBiddingSignalsUrl) {}

// Check that accessing `trustedBiddingSignalsUrl` displays a warning.
//
// TODO(crbug.com/40264073): Remove this test when the field itself is
// removed.
TEST_F(BidderWorkletTest, TrustedBiddingSignalsUrlDeprecationWarning) {}

// Check that accessing `TrustedBiddingSignalsURL` does not display a warning.
//
// TODO(crbug.com/40264073): Remove this test when
// `trustedBiddingSignalsUrl` is removed.
TEST_F(BidderWorkletTest, TrustedBiddingSignalsUrlNoDeprecationWarning) {}

TEST_F(BidderWorkletTest, GenerateBidInterestGroupTrustedBiddingSignalsKeys) {}

TEST_F(BidderWorkletTest, GenerateBidInterestGroupUserBiddingSignals) {}

// Test multiple GenerateBid calls on a single worklet, in parallel. Do this
// twice, once before the worklet has loaded its Javascript, and once after, to
// make sure both cases work.
TEST_P(BidderWorkletMultiThreadingTest, GenerateBidParallel) {}

// Test multiple GenerateBid calls on a single worklet, in parallel, in the case
// the script fails to load.
TEST_P(BidderWorkletMultiThreadingTest, GenerateBidParallelLoadFails) {}

// Test multiple GenerateBid calls on a single worklet, in parallel, in the case
// there are trusted bidding signals.
//
// In this test, the ordering is:
// 1) GenerateBid() calls are made.
// 2) The worklet script load completes.
// 3) The trusted bidding signals are loaded.
TEST_P(BidderWorkletMultiThreadingTest,
       GenerateBidTrustedBiddingSignalsParallelBatched1) {}

// Test multiple GenerateBid calls on a single worklet, in parallel, in the case
// there are trusted bidding signals.
//
// In this test, the ordering is:
// 1) GenerateBid() calls are made
// 2) The trusted bidding signals are loaded.
// 3) The worklet script load completes.
TEST_P(BidderWorkletMultiThreadingTest,
       GenerateBidTrustedBiddingSignalsParallelBatched2) {}

// Test multiple GenerateBid calls on a single worklet, in parallel, in the case
// there are trusted bidding signals.
//
// In this test, the ordering is:
// 1) The worklet script load completes.
// 2) GenerateBid() calls are made.
// 3) The trusted bidding signals are loaded.
TEST_P(BidderWorkletMultiThreadingTest,
       GenerateBidTrustedBiddingSignalsParallelBatched3) {}

// Same as the first batched test, but without batching requests. No need to
// test all not batched order variations.
TEST_P(BidderWorkletMultiThreadingTest,
       GenerateBidTrustedBiddingSignalsParallelNotBatched) {}

// It shouldn't matter the order in which network fetches complete. For each
// required and optional generateBid() URL load prerequisite, ensure that
// generateBid() completes when that URL is the last loaded URL.
TEST_P(BidderWorkletMultiThreadingTest, GenerateBidLoadCompletionOrder) {}

// If multiple worklets request DirectFromSellerSignals, they each get the
// correct signals.
TEST_F(BidderWorkletTest, GenerateBidDirectFromSellerSignalsMultipleWorklets) {}

TEST_F(BidderWorkletTest, GenerateBidAuctionSignals) {}

TEST_F(BidderWorkletTest, GenerateBidPerBuyerSignals) {}

TEST_F(BidderWorkletTest,
       GenerateBidDirectFromSellerSignalsHeaderAdSlotAuctionSignals) {}

TEST_F(BidderWorkletTest,
       GenerateBidDirectFromSellerSignalsHeaderAdSlotPerBuyerSignals) {}

TEST_F(BidderWorkletTest, GenerateBidBrowserSignalSellerOrigin) {}

TEST_F(BidderWorkletTest, GenerateBidBrowserSignalsAdComponentsLimit) {}

TEST_F(BidderWorkletCustomAdComponentLimitTest,
       GenerateBidBrowserSignalsAdComponentsLimit) {}

TEST_F(BidderWorkletMultiBidDisabledTest, GenerateBidMultiBidLimit) {}

TEST_F(BidderWorkletTest, GenerateBidMultiBidLimit) {}

TEST_F(BidderWorkletTest, GenerateBidBrowserSignalTopLevelSellerOrigin) {}

TEST_F(BidderWorkletTest, GenerateBidBrowserSignalTopWindowOrigin) {}

TEST_F(BidderWorkletTest, GenerateBidBrowserSignalJoinCountBidCount) {}

TEST_F(BidderWorkletTest,
       GenerateBidBrowserSignalForDebuggingOnlyInCooldownOrLockout) {}

TEST_F(BidderWorkletTest, GenerateBidAds) {}

// Verify generateBid can see the reporting Ids when
// `selectable_buyer_and_seller_reporting_ids` is present.
TEST_F(BidderWorkletTest, GenerateBidAdsWithAllReportingIds) {}

TEST_F(BidderWorkletTest,
       GenerateBidDoesNotContainSelectedReportingIdsWhenFlagDisabled) {}

TEST_F(BidderWorkletTest, GenerateBidReturnsSelectedReportingId) {}

TEST_F(BidderWorkletTest, GenerateBidWithInvalidSelectedReportingId) {}

// Verify generateBid cannot see the reporting Ids when
// `selectable_buyer_and_seller_reporting_ids` is not present.
TEST_F(BidderWorkletTest, GenerateBidAdsWithoutReportingIds) {}

TEST_F(BidderWorkletTest, GenerateBidAdComponents) {}

// Test behavior of the `allowComponentAuction` output field, which can block
// bids when not set to true and `topLevelSellerOrigin` is non-null.
TEST_F(BidderWorkletTest, GenerateBidAllowComponentAuction) {}

TEST_F(BidderWorkletTest, GenerateBidWasm404) {}

TEST_F(BidderWorkletTest, GenerateBidWasmFailure) {}

TEST_F(BidderWorkletTest, GenerateBidWasm) {}

TEST_F(BidderWorkletTest, WasmReportWin) {}

TEST_F(BidderWorkletTest, WasmReportWin2) {}

TEST_F(BidderWorkletTest, WasmOrdering) {}

// Utility method to create a vector of PreviousWin. Needed because StructPtrs
// don't allow copying.
std::vector<mojom::PreviousWinPtr> CreateWinList(
    const mojom::PreviousWinPtr& win1,
    const mojom::PreviousWinPtr& win2 = mojom::PreviousWinPtr(),
    const mojom::PreviousWinPtr& win3 = mojom::PreviousWinPtr()) {}

TEST_F(BidderWorkletTest, GenerateBidPrevWins) {}

TEST_F(BidderWorkletTest, GenerateBidTrustedBiddingSignals) {}

// With the cross-origin trusted signals flag off, nothing is passed in to the
// cross-original signals parameter.
TEST_F(BidderWorkletTest, CrossOriginTrustedSignalsDisabled) {}

TEST_F(BidderWorkletTest, GenerateBidTrustedBiddingSignalsV1) {}

// Test that when no trusted signals are fetched, generating bids is delayed
// until the OnBiddingSignalsReceivedCallback is invoked.
TEST_F(BidderWorkletTest, GenerateBidOnBiddingSignalsReceivedNoTrustedSignals) {}

// Test that when signals fail to be feteched, OnBiddingSignalsReceived() is
// only invoked after the failed fetch completes, and generating bids is delayed
// until the OnBiddingSignalsReceivedCallback is invoked.
TEST_F(BidderWorkletTest, GenerateBidOnBiddingSignalsReceivedFetchFails) {}

// Test that when signals are successfully fetched, OnBiddingSignalsReceived()
// is only invoked after the fetch completes, and generating bids is delayed
// until the OnBiddingSignalsReceivedCallback is invoked.
TEST_F(BidderWorkletTest,
       GenerateBidOnBiddingSignalsReceivedNoPriorityVectorRequested) {}

// Test that when signals are successfully fetched, but the response includes no
// priority vector. OnBiddingSignalsReceived() is invoked with a empty priority
// vector after the fetch completes, and generating bids is delayed until the
// OnBiddingSignalsReceivedCallback is invoked.
TEST_F(BidderWorkletTest,
       GenerateBidOnBiddingSignalsReceivedNoPriorityVectorReceived) {}

// Same as GenerateBidOnBiddingSignalsReceivedNoPriorityVectorReceived, but
// the priority vector is received, and verified in the signals received
// callback.
TEST_F(BidderWorkletTest,
       GenerateBidOnBiddingSignalsReceivedPriorityVectorReceived) {}

// Same as GenerateBidOnBiddingSignalsReceivedNoPriorityVectorReceived, but the
// updateIfOlderThanMs field is present, but priorityVector is not -- this is
// verified in the signals received callback.
TEST_F(
    BidderWorkletTest,
    GenerateBidOnBiddingSignalsReceivedNoPriorityVectorYesUpdateIfOlderThanMsReceived) {}

// Same as GenerateBidOnBiddingSignalsReceivedNoPriorityVectorReceived, but the
// priorityVector and updateIfOlderThanMs fields are present -- this is verified
// in the signals received callback.
TEST_F(
    BidderWorkletTest,
    GenerateBidOnBiddingSignalsReceivedYesPriorityVectorYesUpdateIfOlderThanMsReceived) {}

// Test that cancelling a GenerateBid() call by deleting the GenerateBidClient
// aborts a pending trusted signals fetch.
TEST_F(BidderWorkletTest, GenerateBidCancelAbortsSignalsFetch) {}

// Test that cancelling a GenerateBid() call by deleting the GenerateBidClient
// when Javascript is running doesn't result in a crash.
TEST_F(BidderWorkletTest, GenerateBidCancelWhileRunningJavascript) {}

TEST_F(BidderWorkletTest, GenerateBidDataVersion) {}

// Even with no trustedBiddingSignalsKeys, the data version should be available.
TEST_F(BidderWorkletTest, GenerateBidDataVersionNoKeys) {}

// Even though the script had set an intermediate result with setBid, the
// returned value should be used instead.
TEST_F(BidderWorkletTest, GenerateBidWithSetBid) {}

TEST_F(BidderWorkletTest, GenerateBidExperimentGroupId) {}

TEST_F(BidderWorkletTest, GenerateBidTimedOut) {}

TEST_F(BidderWorkletTest, GenerateBidPerBuyerTimeOut) {}

// Even though the script timed out, it had set an intermediate result with
// setBid, so we should use that. Note that this test sets `bid_duration` to
// `AuctionV8Helper::kScriptTimeout`, to make sure the full timeout time is
// included in the duration.
TEST_F(BidderWorkletTest, GenerateBidTimedOutWithSetBid) {}

// Test that per-buyer timeout of zero results in no bid produced.
TEST_F(BidderWorkletTest, PerBuyerTimeoutZero) {}

// Test that in the case of multiple setBid() calls, the most recent call takes
// precedence. Note that this test sets `bid_duration` to
// `AuctionV8Helper::kScriptTimeout`, to make sure the full timeout time is
// included in the duration.
TEST_F(BidderWorkletTest, GenerateBidTimedOutWithSetBidTwice) {}

// Even though the script timed out, it had set an intermediate result with
// setBid, so we should use that instead. The bid value should not change if we
// mutate the object passed to setBid after it returns.
TEST_F(BidderWorkletTest, GenerateBidTimedOutWithSetBidMutateAfter) {}

TEST_F(BidderWorkletTest, GenerateBidSetPriority) {}

TEST_F(BidderWorkletTest, GenerateBidSetPrioritySignalsOverrides) {}

TEST_F(BidderWorkletTest, ReportWin) {}

TEST_F(BidderWorkletTest, SendReportToLongUrl) {}

// Turn enforcement of permission policy on contributeToHistogramOnEvent on.
TEST_F(BidderWorkletTest, ContributeToHistogramOnEventPermissionEnforced) {}

// Not enforcing permission policy on contributeToHistogramOnEvent.
// Legacy compatibility mode.
TEST_F(BidderWorkletTest, ContributeToHistogramOnEventPermissionNotEnforced) {}

// Debug win/loss reporting APIs should do nothing when feature
// kBiddingAndScoringDebugReportingAPI is not enabled. It will not fail
// generateBid().
TEST_F(BidderWorkletTest, ForDebuggingOnlyReportsWithDebugFeatureDisabled) {}

TEST_F(BidderWorkletTest, DeleteBeforeReportWinCallback) {}

// Test multiple ReportWin calls on a single worklet, in parallel. Do this
// twice, once before the worklet has loaded its Javascript, and once after, to
// make sure both cases work.
TEST_F(BidderWorkletTest, ReportWinParallel) {}

// Test multiple ReportWin calls on a single worklet, in parallel, in the case
// the worklet script fails to load.
TEST_F(BidderWorkletTest, ReportWinParallelLoadFails) {}

// Make sure Date() is not available when running reportWin().
TEST_F(BidderWorkletTest, ReportWinDateNotAvailable) {}

TEST_F(BidderWorkletTest, ReportWinIsForAdditionalBid) {}

TEST_F(BidderWorkletTest, ReportWinContainsInterestGroupName) {}

TEST_F(BidderWorkletTest, ReportWinContainsBuyerReportingId) {}

TEST_F(BidderWorkletTest, ReportWinContainsBuyerAndSellerReportingId) {}

TEST_F(BidderWorkletTest, ReportWinContainsSelectedBuyerAndSellerReportingId) {}

TEST_F(BidderWorkletTest, ReportWinContainsNoReportingId) {}

TEST_F(BidderWorkletTest, ReportWinDataVersion) {}

// It shouldn't matter the order in which network fetches complete. For each
// required and optional reportWin() URL load prerequisite, ensure that
// reportWin() completes when that URL is the last loaded URL.
TEST_F(BidderWorkletTest, ReportWinLoadCompletionOrder) {}

TEST_F(BidderWorkletTest, ReportWinAuctionSignals) {}

TEST_F(BidderWorkletTest, ReportWinPerBuyerSignals) {}

TEST_F(BidderWorkletTest, ReportWinSellerSignals) {}

TEST_F(BidderWorkletTest,
       ReportWinDirectFromSellerSignalsHeaderAdSlotAuctionSignals) {}

TEST_F(BidderWorkletTest,
       ReportWinDirectFromSellerSignalsHeaderAdSlotPerBuyerSignals) {}

TEST_F(BidderWorkletTest, ReportWinInterestGroupOwner) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalTopWindowOrigin) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalRenderUrl) {}

// Check that accessing `renderUrl` of browserSignals displays a warning.
//
// TODO(crbug.com/40266734): Remove this test when the field itself is
// removed.
TEST_F(BidderWorkletTest, ReportWinBrowserSignalRenderUrlDeprecationWarning) {}

// Check that accessing `renderURL` of browserSignals does not display a
// warning.
//
// TODO(crbug.com/40266734): Remove this test when renderUrl is removed.
TEST_F(BidderWorkletTest, ReportWinBrowserSignalRenderUrlNoDeprecationWarning) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalBid) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalHighestScoringOtherBid) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalBidCurrency) {}

TEST_F(BidderWorkletTest,
       ReportWinBrowserSignalHighestScoringOtherBidCurrency) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalIsHighestScoringOtherBidMe) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalSeller) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalTopLevelSeller) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalModelingSignals) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalJoinCount) {}

TEST_F(BidderWorkletTest, ReportWinBrowserSignalRecency) {}

TEST_F(BidderWorkletTest, ReportWinNoBrowserSignalRecencyForAdditionalBid) {}

TEST_F(BidderWorkletTest, KAnonStatusExposesInReportWinBrowserSignals) {}

// Subsequent runs of the same script should not affect each other. Same is true
// for different scripts, but it follows from the single script case.
//
// TODO(mmenke): The current API only allows each generateBid() method to be
// called once, but each ReportWin() to be called multiple times. When the API
// is updated to allow multiple calls to generateBid(), update this method to
// invoke it multiple times.
TEST_P(BidderWorkletMultiThreadingTest, ScriptIsolation) {}

TEST_F(BidderWorkletTest, PauseOnStart) {}

TEST_F(BidderWorkletTwoThreadsTest, PauseOnStart) {}

TEST_P(BidderWorkletMultiThreadingTest, PauseOnStartDelete) {}

TEST_F(BidderWorkletTest, BasicV8Debug) {}

TEST_F(BidderWorkletTwoThreadsTest, BasicV8Debug) {}

TEST_F(BidderWorkletTest, ParseErrorV8Debug) {}

TEST_F(BidderWorkletTwoThreadsTest, ParseErrorV8Debug) {}

TEST_F(BidderWorkletTest, BasicDevToolsDebug) {}

TEST_F(BidderWorkletTwoThreadsTest, BasicDevToolsDebug) {}

TEST_F(BidderWorkletTest, InstrumentationBreakpoints) {}

TEST_F(BidderWorkletTest, UnloadWhilePaused) {}

TEST_F(BidderWorkletTest, ExecutionModeGroupByOrigin) {}

TEST_F(BidderWorkletTest, ExecutionModeGroupByOriginSaveMultipleGroups) {}
TEST_F(BidderWorkletTest, ExecutionModeFrozenContext) {}

TEST_F(BidderWorkletTest, ExecutionModeFrozenContextFails) {}

TEST_F(BidderWorkletTest, AlwaysReuseBidderContext) {}

// Test that when `kFledgeAlwaysReuseBidderContext` is enabled, odd and even
// `GenerateBid()` calls consistently use separate, dedicated v8 contexts. This
// indicates a round-robin thread selection.
TEST_F(BidderWorkletTwoThreadsTest, AlwaysReuseBidderContext) {}

// Test that cancelling the worklet before it runs but after the execution was
// queued actually cancels the execution. This is done by trying to run a
// while(true) {} script with a timeout that's bigger than the test timeout, so
// if it doesn't get cancelled the *test* will timeout.
TEST_F(BidderWorkletTest, Cancelation) {}

// Test that queued tasks get cancelled at worklet destruction.
TEST_F(BidderWorkletTest, CancelationDtor) {}

// Test that cancelling execution before the script is fetched doesn't run it.
TEST_F(BidderWorkletTest, CancelBeforeFetch) {}

class BidderWorkletBiddingAndScoringDebugReportingAPIEnabledTest
    : public BidderWorkletTest {};

// Test forDebuggingOnly.reportAdAuctionLoss() and
// forDebuggingOnly.reportAdAuctionWin() called in generateBid().
TEST_F(BidderWorkletBiddingAndScoringDebugReportingAPIEnabledTest,
       ForDebuggingOnlyReports) {}

// Test the case the debugging report URLs are exactly match and are just above
// the max URL length. When the length is hit, no errors are produced, but the
// debug report URLs are ignored.
TEST_F(BidderWorkletBiddingAndScoringDebugReportingAPIEnabledTest,
       ForDebuggingOnlyReportsLengthLimit) {}

TEST_F(BidderWorkletBiddingAndScoringDebugReportingAPIEnabledTest,
       ForDebuggingOnlyArgumentTimeout) {}

// Debugging loss/win report URLs should be nullopt if generateBid() parameters
// are invalid.
TEST_F(BidderWorkletBiddingAndScoringDebugReportingAPIEnabledTest,
       ForDebuggingOnlyReportsInvalidGenerateBidParameter) {}

TEST_F(BidderWorkletBiddingAndScoringDebugReportingAPIEnabledTest,
       GenerateBidHasError) {}

TEST_F(BidderWorkletBiddingAndScoringDebugReportingAPIEnabledTest,
       GenerateBidInvalidReturnValue) {}

// Loss report URLs before bidding script times out should be kept.
TEST_F(BidderWorkletBiddingAndScoringDebugReportingAPIEnabledTest,
       GenerateBidTimedOut) {}

TEST_F(BidderWorkletTest, ReportWinRegisterAdBeacon) {}

TEST_F(BidderWorkletTest, ReportWinRegisterAdBeaconLongUrl) {}

class BidderWorkletSharedStorageAPIDisabledTest : public BidderWorkletTest {};

TEST_F(BidderWorkletSharedStorageAPIDisabledTest, SharedStorageNotExposed) {}

class BidderWorkletSharedStorageAPIEnabledTest : public BidderWorkletTest {};

TEST_F(BidderWorkletSharedStorageAPIEnabledTest,
       SharedStorageWriteInGenerateBid) {}

TEST_F(BidderWorkletSharedStorageAPIEnabledTest,
       SharedStorageWriteInReportWin) {}

class BidderWorkletTwoThreadsSharedStorageAPIEnabledTest
    : public BidderWorkletSharedStorageAPIEnabledTest {};

TEST_F(BidderWorkletTwoThreadsSharedStorageAPIEnabledTest,
       SharedStorageWriteInGenerateBid) {}

class BidderWorkletPrivateAggregationEnabledTest : public BidderWorkletTest {};

TEST_F(BidderWorkletPrivateAggregationEnabledTest, GenerateBid) {}

TEST_F(BidderWorkletPrivateAggregationEnabledTest, ReportWin) {}

class BidderWorkletPrivateAggregationDisabledTest : public BidderWorkletTest {};

TEST_F(BidderWorkletPrivateAggregationDisabledTest, GenerateBid) {}

TEST_F(BidderWorkletPrivateAggregationDisabledTest, ReportWin) {}

TEST_F(BidderWorkletTest, KAnonSimulate) {}

TEST_F(BidderWorkletTest, KAnonEnforce) {}

// Test of multi-bid and k-anon: the bids are annotated with their roles
// properly.
TEST_F(BidderWorkletTest, KAnonClassify) {}

// Test for doing a re-run in multi-bid mode: returning only non-k-anon
// bids forces a re-run.
TEST_F(BidderWorkletTest, KAnonRerunMultiBid) {}

// Test for context re-use for k-anon rerun.
TEST_F(BidderWorkletTest, KAnonRerun) {}

TEST_F(BidderWorkletTest,
       BidderWorkletOnlyPassesKAnonSelectableReportingIdsOnRestrictedRun) {}

TEST_F(BidderWorkletTest,
       BidderWorkletRejectsNonKAnonSelectableReportingIdOnRestrictedRun) {}

TEST_F(BidderWorkletTest, IsKAnonURL) {}

TEST_F(BidderWorkletTest, IsKAnonResult) {}

TEST_F(BidderWorkletTest, IsMainAdKAnonResultWithSelectedReportingId) {}

// Test of handling of FinalizeGenerateBid that comes in after the trusted
// signals.
TEST_F(BidderWorkletTest, AsyncFinalizeGenerateBid) {}

// Test of handling of FinalizeGenerateBid that comes in before the trusted
// signals.
TEST_F(BidderWorkletTest, AsyncFinalizeGenerateBid2) {}

class BidderWorkletLatenciesTest : public BidderWorkletTest {};

TEST_F(BidderWorkletLatenciesTest, GenerateBidLatenciesAreReturned) {}

// Tests both reporting latency, and default reporting timeout.
TEST_F(BidderWorkletTest, ReportWinLatency) {}

TEST_F(BidderWorkletTest, ReportWinZeroTimeout) {}

TEST_F(BidderWorkletTest, ReportWinTimeoutFromAuctionConfig) {}

// The sequence when GenerateBidClient gets destroyed w/o getting to
// FinalizeGenerateBid() needs to do some extra cleaning up, so exercise it.
TEST_F(BidderWorkletTest, CloseGenerateBidClientBeforeFinalize) {}

TEST_F(BidderWorkletTest, GenerateBidRenderUrlWithSize) {}

TEST_F(BidderWorkletTest, GenerateBidAdComponentsWithSize) {}

// The requested_ad_size argument to BeginGeneratingBid, which originates from
// the auction config, should be propagated into the bidding logic JS via the
// browserSignals property.
TEST_F(BidderWorkletTest, AuctionRequestedSizeIsPresentInBiddingLogic) {}

TEST_F(BidderWorkletTest,
       AuctionRequestedSizeIsAbsentFromInBiddingLogicWhenNotProvided) {}

class BidderWorkletAdMacroReportingEnabledTest : public BidderWorkletTest {};

TEST_F(BidderWorkletAdMacroReportingEnabledTest, ReportWinRegisterAdMacro) {}

TEST_F(BidderWorkletAdMacroReportingEnabledTest,
       ReportWinRegisterAdMacroInvalidArgs) {}

class BidderWorkletSampleDebugReportsDisabledTest : public BidderWorkletTest {};

TEST_F(BidderWorkletSampleDebugReportsDisabledTest,
       GenerateBidBrowserSignalForDebuggingOnlyInCooldownOrLockout) {}

class BidderWorkletCrossOriginTrustedSignalsTest : public BidderWorkletTest {};

// With the feature on, same-origin trusted signals still come in the same,
// only there is an extra null param.
TEST_F(BidderWorkletCrossOriginTrustedSignalsTest, SameOrigin) {}

// Cross-origin signals (and their version) come in as different parameters
// and fields.
TEST_F(BidderWorkletCrossOriginTrustedSignalsTest, CrossOrigin) {}

class BidderWorkletRealTimeReportingEnabledTest : public BidderWorkletTest {};

TEST_F(BidderWorkletRealTimeReportingEnabledTest, RealTimeReporting) {}

// Real time reporting contributions are allowed when an IG does not bid.
TEST_F(BidderWorkletRealTimeReportingEnabledTest, NoBid) {}

// Real time reporting contributions registered before script timeout are kept.
TEST_F(BidderWorkletRealTimeReportingEnabledTest, ScriptTimeout) {}

// contributeToHistogram's is dropped when the script's latency does not
// exceed the threshold.
TEST_F(BidderWorkletRealTimeReportingEnabledTest,
       NotExceedingLatencyThreshold) {}

// A platform contribution is added when trusted bidding signals server returned
// a non-2xx HTTP response code.
TEST_F(BidderWorkletRealTimeReportingEnabledTest,
       TrustedBiddingSignalNetworkError) {}

// A platform contribution is added when trusted scoring signals server returned
// a non-2xx HTTP response code, even though generateBid() failed.
TEST_F(BidderWorkletRealTimeReportingEnabledTest,
       TrustedBiddingSignalNetworkErrorGenerateBidFailed) {}

}  // namespace
}  // namespace auction_worklet