summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fledge/tentative/score-ad-browser-signals.https.window.js
blob: f20412cfc7857279ff7aabfbfd68d825be5d8051 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// META: script=/resources/testdriver.js
// META: script=/common/utils.js
// META: script=resources/fledge-util.sub.js
// META: script=/common/subset-tests.js
// META: timeout=long

"use strict;"

// These tests focus on the browserSignals argument passed to scoreAd().

subsetTest(promise_test, async test => {
  const uuid = generateUuid(test);

  let biddingLogicURL = createBiddingScriptURL(
    {
      generateBid:
        `
          return {
            bid: 1,
            render: { url: interestGroup.ads[0].renderURL,
                      width: '100sw',
                      height: '50px' }
          };
        `
    });

  let decisionLogicURL = createDecisionScriptURL(uuid,
    {
      scoreAd:
        `
          if (!browserSignals.hasOwnProperty('renderSize')) {
            throw 'Missing renderSize member in browserSignals.';
          }
          if (browserSignals.renderSize.width !== '100sw' ||
              browserSignals.renderSize.height !== '50px') {
            throw 'Incorrect renderSize width or height.';
          }
      `
    }
  );

  await joinGroupAndRunBasicFledgeTestExpectingWinner(
    test,
    {
      uuid: uuid,
      interestGroupOverrides: {
        name: uuid,
        biddingLogicURL: biddingLogicURL,
        ads: [{ renderURL: createRenderURL(uuid), sizeGroup: 'group1' }],
        adSizes: { 'size1': { width: '100sw', height: '50px' } },
        sizeGroups: { 'group1': ['size1'] }
      },
      auctionConfigOverrides: {
        decisionLogicURL: decisionLogicURL
      }
    });
}, 'ScoreAd browserSignals renderSize test.');