summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fenced-frame/resources/fledge-bidding-logic-with-size.js
blob: 1a22bcec3d6422e4c5d498fcb93f0a205da32bf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// These functions are used by FLEDGE to determine the logic for the ad buyer.
// For our testing purposes, we only need the minimal amount of boilerplate
// code in place to allow them to be invoked properly and move the FLEDGE
// process along. The tests do not deal with reporting results, so we leave
// `reportWin` empty. See `generateURNFromFledge` in "utils.js" to see how
// these files are used.

function generateBid(interestGroup, auctionSignals, perBuyerSignals,
  trustedBiddingSignals, browserSignals) {
  const ad = interestGroup.ads[0];

  // `auctionSignals` controls whether or not component auctions are allowed.
  let allowComponentAuction =
    typeof auctionSignals === 'string' &&
    auctionSignals.includes('bidderAllowsComponentAuction');

  let result = {
    'ad': ad,
    'bid': 1,
    'render': { url: ad.renderUrl, width: "100px", height: "50px" },
    'allowComponentAuction': allowComponentAuction
  };
  if (interestGroup.adComponents && interestGroup.adComponents.length > 0)
    result.adComponents = interestGroup.adComponents.map((component) => {
      return {
        url: component.renderUrl,
        width: "100px",
        height: "50px"
      };
    });
  return result;
}

function reportWin(
  auctionSignals, perBuyerSignals, sellerSignals, browserSignals) {
  return;
}