summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fledge/tentative/interest-group-passed-to-generate-bid.https.window.js
blob: 2fb346bbe3ba14f0f7577de0111aba270cc87955 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
// 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
// META: variant=?1-5
// META: variant=?6-10
// META: variant=?11-15
// META: variant=?16-20
// META: variant=?21-25
// META: variant=?26-30
// META: variant=?31-35
// META: variant=?36-40
// META: variant=?41-45
// META: variant=?46-50
// META: variant=?51-55
// META: variant=?56-60
// META: variant=?61-65
// META: variant=?66-70
// META: variant=?71-75
// META: variant=?76-80
// META: variant=?81-85

"use strict;"

// These tests focus on making sure InterestGroup fields are passed to generateBid(),
// and are normalized if necessary. This test does not check the behaviors of the
// fields.

// Modifies "ads". Replaces "REPLACE_WITH_UUID" in all "renderURL" fields of
// objects in "ads" array with "uuid". Generated ad URLs have embedded
// UUIDs to prevent InterestGroups unexpectedly left over from one test from
// messing up another test, but these tests need ad URLs before the UUID is
// generated. To get around that, "REPLACE_WITH_UUID" is used in place of UUIDs
// and then this is used to replace them with the real UUID.
function updateAdRenderURLs(ads, uuid) {
  for (let i = 0; i < ads.length; ++i) {
    let ad = ads[i];
    ad.renderURL = ad.renderURL.replace('REPLACE_WITH_UUID', uuid);
  }
}

const makeTest = ({
  // Test name.
  name,
  // InterestGroup field name.
  fieldName,
  // InterestGroup field value, both expected in worklets and the value used
  // when joining the interest group. If undefined, value will not be set in
  // interestGroup, and will be expected to also not be set in the
  // interestGroup passed to generateBid().
  fieldValue,
  // Additional values to use in the InterestGroup passed to joinInterestGroup().
  // If it contains a value for the key specified in `fieldName`, takes
  // precedent over `fieldValue`.
  interestGroupOverrides = {}
}) => {
  subsetTest(promise_test, async test => {
    const uuid = generateUuid(test);

    // It's not strictly necessary to replace UUIDs in "adComponents", but do it for consistency.
    if (fieldName === 'ads' || fieldName === 'adComponents' && fieldValue) {
      updateAdRenderURLs(fieldValue, uuid);
    }

    if (interestGroupOverrides.ads) {
      updateAdRenderURLs(interestGroupOverrides.ads, uuid);
    }

    if (interestGroupOverrides.adComponents) {
      updateAdRenderURLs(interestGroupOverrides.adComponents, uuid);
    }

    if (!(fieldName in interestGroupOverrides) && fieldValue !== undefined)
      interestGroupOverrides[fieldName] = fieldValue;

    let comparison = `deepEquals(interestGroup["${fieldName}"], ${JSON.stringify(fieldValue)})`;
    // In the case it's undefined, require value not to be set.
    if (fieldValue === undefined)
      comparison = `!("${fieldName}" in interestGroup)`;

    // Prefer to use `interestGroupOverrides.owner` if present. Treat it as a URL
    // and then convert it to an origin because one test passes in a URL.
    let origin = location.origin;
    if (interestGroupOverrides.owner)
      origin = new URL(interestGroupOverrides.owner).origin;

    interestGroupOverrides.biddingLogicURL =
        createBiddingScriptURL(
            { origin: origin,
              generateBid:
                  `// Delete deprecated "renderUrl" fields from ads and adComponents, if
                  // present.
                  for (let field in interestGroup) {
                    if (field === "ads" || field === "adComponents") {
                      for (let i = 0; i < interestGroup[field].length; ++i) {
                        let ad = interestGroup[field][i];
                        delete ad.renderUrl;
                      }
                    }
                  }
                  if (!${comparison})
                    throw "Unexpected value: " + JSON.stringify(interestGroup["${fieldName}"]);`
            });
    if (origin !== location.origin) {
      await joinCrossOriginInterestGroup(test, uuid, origin, interestGroupOverrides);
    } else {
      await joinInterestGroup(test, uuid, interestGroupOverrides);
    }

    await runBasicFledgeTestExpectingWinner(test, uuid, {interestGroupBuyers: [origin]});
  }, name);
};

makeTest({
  name: 'InterestGroup.owner.',
  fieldName: 'owner',
  fieldValue: OTHER_ORIGIN1
});

makeTest({
  name: 'InterestGroup.owner with non-normalized origin.',
  fieldName: 'owner',
  fieldValue: OTHER_ORIGIN1,
  interestGroupOverrides: {owner: ` ${OTHER_ORIGIN1.toUpperCase()} `}
});

makeTest({
  name: 'InterestGroup.owner is URL.',
  fieldName: 'owner',
  fieldValue: OTHER_ORIGIN1,
  interestGroupOverrides: {owner: OTHER_ORIGIN1 + '/Foopy'}
});

makeTest({
  name: 'InterestGroup.name.',
  fieldName: 'name',
  fieldValue: 'Jim'
});

makeTest({
  name: 'InterestGroup.name with unicode characters.',
  fieldName: 'name',
  fieldValue: '\u2665'
});

makeTest({
  name: 'InterestGroup.name with empty name.',
  fieldName: 'name',
  fieldValue: ''
});

makeTest({
  name: 'InterestGroup.name with unpaired surrogate characters, which should be replaced with "\\uFFFD".',
  fieldName: 'name',
  fieldValue: '\uFFFD,\uFFFD',
  interestGroupOverrides: {name: '\uD800,\uDBF0'}
});

// Since "biddingLogicURL" contains the script itself inline, can't include the entire URL
// in the script for an equality check. Instead, replace the "generateBid" query parameter
// in the URL with an empty value before comparing it. This doesn't just delete the entire
// query parameter to make sure that's correctly passed in.
subsetTest(promise_test,async test => {
  const uuid = generateUuid(test);

  let biddingScriptBaseURL = createBiddingScriptURL({origin: OTHER_ORIGIN1, generateBid: ''});
  let biddingLogicURL = createBiddingScriptURL(
      { origin: OTHER_ORIGIN1,
        generateBid:
          `let biddingScriptBaseURL =
            interestGroup.biddingLogicURL.replace(/generateBid=[^&]*/, "generateBid=");
          if (biddingScriptBaseURL !== "${biddingScriptBaseURL}")
            throw "Wrong bidding script URL: " + interestGroup.biddingLogicURL`
      });

  await joinCrossOriginInterestGroup(test, uuid, OTHER_ORIGIN1,
                                     { biddingLogicURL: biddingLogicURL });

  await runBasicFledgeTestExpectingWinner(test, uuid, {interestGroupBuyers: [OTHER_ORIGIN1]});
}, 'InterestGroup.biddingLogicURL.');

// Much like above test, but use a relative URL that points to bidding script.
subsetTest(promise_test,async test => {
  const uuid = generateUuid(test);

  let biddingScriptBaseURL = createBiddingScriptURL({generateBid: ''});
  let biddingLogicURL = createBiddingScriptURL(
      { generateBid:
          `let biddingScriptBaseURL =
            interestGroup.biddingLogicURL.replace(/generateBid=[^&]*/, "generateBid=");
          if (biddingScriptBaseURL !== "${biddingScriptBaseURL}")
            throw "Wrong bidding script URL: " + interestGroup.biddingLogicURL`
      });
  biddingLogicURL = biddingLogicURL.replace(BASE_URL, 'foo/../');

  await joinInterestGroup(test, uuid, { biddingLogicURL: biddingLogicURL });

  await runBasicFledgeTestExpectingWinner(test, uuid);
}, 'InterestGroup.biddingLogicURL with relative URL.');

makeTest({
  name: 'InterestGroup.lifetimeMs should not be passed in.',
  fieldName: 'lifetimeMs',
  fieldValue: undefined,
  interestGroupOverrides: { lifetimeMs: "120000" }
});

makeTest({
  name: 'InterestGroup.priority should not be passed in, since it can be changed by auctions.',
  fieldName: 'priority',
  fieldValue: undefined,
  interestGroupOverrides: { priority: 500 }
});

makeTest({
  name: 'InterestGroup.priorityVector undefined.',
  fieldName: 'priorityVector',
  fieldValue: undefined
});

makeTest({
  name: 'InterestGroup.priorityVector empty.',
  fieldName: 'priorityVector',
  fieldValue: {}
});

makeTest({
  name: 'InterestGroup.priorityVector.',
  fieldName: 'priorityVector',
  fieldValue: { 'a': -1, 'b': 2 }
});

// TODO: This is currently using USVString internally, so doesn't allow unpaired
// surrogates, but the spec says it should.
makeTest({
  name: 'InterestGroup.priorityVector with unpaired surrogate character.',
  fieldName: 'priorityVector',
  fieldValue: { '\uFFFD': -1 },
  interestGroupOverrides: { prioritySignalsOverrides: { '\uD800': -1 } }
});

makeTest({
  name: 'InterestGroup.prioritySignalsOverrides should not be passed in, since it can be changed by auctions.',
  fieldName: 'prioritySignalsOverrides',
  fieldValue: undefined,
  interestGroupOverrides: { prioritySignalsOverrides: { 'a': 1, 'b': 2 } }
});

makeTest({
  name: 'InterestGroup.enableBiddingSignalsPrioritization not set.',
  fieldName: 'enableBiddingSignalsPrioritization',
  fieldValue: false,
  interestGroupOverrides: { enableBiddingSignalsPrioritization: undefined }
});

makeTest({
  name: 'InterestGroup.enableBiddingSignalsPrioritization unrecognized.',
  fieldName: 'enableBiddingSignalsPrioritization',
  // Non-empty strings are treated as true by Javascript. This test is serves
  // to make sure that the 'foo' isn't preserved.
  fieldValue: true,
  interestGroupOverrides: { enableBiddingSignalsPrioritization: 'foo' }
});

makeTest({
  name: 'InterestGroup.enableBiddingSignalsPrioritization false.',
  fieldName: 'enableBiddingSignalsPrioritization',
  fieldValue: false
});

makeTest({
  name: 'InterestGroup.enableBiddingSignalsPrioritization true.',
  fieldName: 'enableBiddingSignalsPrioritization',
  fieldValue: true
});

makeTest({
  name: 'InterestGroup.biddingWasmHelperURL not set.',
  fieldName: 'biddingWasmHelperURL',
  fieldValue: undefined
});

makeTest({
  name: 'InterestGroup.biddingWasmHelperURL.',
  fieldName: 'biddingWasmHelperURL',
  fieldValue: `${OTHER_ORIGIN1}${RESOURCE_PATH}wasm-helper.py`,
  interestGroupOverrides: {owner: OTHER_ORIGIN1}
});

makeTest({
  name: 'InterestGroup.biddingWasmHelperURL with non-normalized value.',
  fieldName: 'biddingWasmHelperURL',
  fieldValue: `${OTHER_ORIGIN1}${RESOURCE_PATH}wasm-helper.py`,
  interestGroupOverrides: {
    owner: OTHER_ORIGIN1,
    biddingWasmHelperURL:
        `${OTHER_ORIGIN1.toUpperCase()}${RESOURCE_PATH}wasm-helper.py`
  }
});

makeTest({
  name: 'InterestGroup.biddingWasmHelperURL with relative URL.',
  fieldName: 'biddingWasmHelperURL',
  fieldValue: `${OTHER_ORIGIN1}${RESOURCE_PATH}wasm-helper.py`,
  interestGroupOverrides: {
    owner: OTHER_ORIGIN1,
    biddingWasmHelperURL: 'foo/../resources/wasm-helper.py'
  }
});

makeTest({
  name: 'InterestGroup.biddingWasmHelperURL with unpaired surrogate characters, which should be replaced with "\\uFFFD".',
  fieldName: 'biddingWasmHelperURL',
  fieldValue: (new URL(`${OTHER_ORIGIN1}${RESOURCE_PATH}wasm-helper.py?\uFFFD.\uFFFD`)).href,
  interestGroupOverrides: {
    owner: OTHER_ORIGIN1,
    biddingWasmHelperURL: `${OTHER_ORIGIN1}${RESOURCE_PATH}wasm-helper.py?\uD800.\uDBF0`
  }
});

makeTest({
  name: 'InterestGroup.updateURL not set.',
  fieldName: 'updateURL',
  fieldValue: undefined
});

makeTest({
  name: 'InterestGroup.updateURL.',
  fieldName: 'updateURL',
  fieldValue: `${OTHER_ORIGIN1}${BASE_PATH}This-File-Does-Not-Exist.json`,
  interestGroupOverrides: {owner: OTHER_ORIGIN1}
});

makeTest({
  name: 'InterestGroup.updateURL with non-normalized value.',
  fieldName: 'updateURL',
  fieldValue: `${OTHER_ORIGIN1}${BASE_PATH}This-File-Does-Not-Exist.json`,
  interestGroupOverrides: {
    owner: OTHER_ORIGIN1,
    updateURL: `${OTHER_ORIGIN1.toUpperCase()}${BASE_PATH}This-File-Does-Not-Exist.json`
  }
});

makeTest({
  name: 'InterestGroup.updateURL with relative URL.',
  fieldName: 'updateURL',
  fieldValue: (new URL(`${OTHER_ORIGIN1}${BASE_PATH}../This-File-Does-Not-Exist.json`)).href,
  interestGroupOverrides: {
    owner: OTHER_ORIGIN1,
    updateURL: '../This-File-Does-Not-Exist.json'
  }
});

makeTest({
  name: 'InterestGroup.updateURL with unpaired surrogate characters, which should be replaced with "\\uFFFD".',
  fieldName: 'updateURL',
  fieldValue: (new URL(`${BASE_URL}\uFFFD.\uFFFD`)).href,
  interestGroupOverrides: {
    updateURL: `${BASE_URL}\uD800.\uDBF0`
  }
});

makeTest({
  name: 'InterestGroup.executionMode not present.',
  fieldName: 'executionMode',
  fieldValue: 'compatibility',
  interestGroupOverrides: { executionMode: undefined }
});

makeTest({
  name: 'InterestGroup.executionMode compatibility.',
  fieldName: 'executionMode',
  fieldValue: 'compatibility'
});

makeTest({
  name: 'InterestGroup.executionMode frozen-context.',
  fieldName: 'executionMode',
  fieldValue: 'frozen-context'
});

makeTest({
  name: 'InterestGroup.executionMode group-by-origin.',
  fieldName: 'executionMode',
  fieldValue: 'group-by-origin'
});

makeTest({
  name: 'InterestGroup.executionMode has non-standard string.',
  fieldName: 'executionMode',
  fieldValue: 'compatibility',
  interestGroupOverrides: { executionMode: 'foo' }
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsURL not set.',
  fieldName: 'trustedBiddingSignalsURL',
  fieldValue: undefined
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsURL.',
  fieldName: 'trustedBiddingSignalsURL',
  fieldValue: `${OTHER_ORIGIN1}${BASE_PATH}This-File-Does-Not-Exist.json`,
  interestGroupOverrides: {owner: OTHER_ORIGIN1}
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsURL with non-normalized value.',
  fieldName: 'trustedBiddingSignalsURL',
  fieldValue: `${OTHER_ORIGIN1}${BASE_PATH}This-File-Does-Not-Exist.json`,
  interestGroupOverrides: {
    owner: OTHER_ORIGIN1,
    trustedBiddingSignalsURL:
        `${OTHER_ORIGIN1.toUpperCase()}${BASE_PATH}This-File-Does-Not-Exist.json`
  }
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsURL with relative URL.',
  fieldName: 'trustedBiddingSignalsURL',
  fieldValue: (new URL(`${OTHER_ORIGIN1}${BASE_PATH}../This-File-Does-Not-Exist.json`)).href,
  interestGroupOverrides: {
    owner: OTHER_ORIGIN1,
    trustedBiddingSignalsURL: '../This-File-Does-Not-Exist.json'
  }
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsURL with unpaired surrogate characters, which should be replaced with "\\uFFFD".',
  fieldName: 'trustedBiddingSignalsURL',
  fieldValue: (new URL(`${BASE_URL}\uFFFD.\uFFFD`)).href,
  interestGroupOverrides: {
    trustedBiddingSignalsURL: `${BASE_URL}\uD800.\uDBF0`
  }
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsKeys not set.',
  fieldName: 'trustedBiddingSignalsKeys',
  fieldValue: undefined
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsKeys.',
  fieldName: 'trustedBiddingSignalsKeys',
  fieldValue: ['a', ' b ', 'c', '1', '%20', '3', '\u2665']
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsKeys with non-normalized values.',
  fieldName: 'trustedBiddingSignalsKeys',
  fieldValue: ['1', '2', '3'],
  interestGroupOverrides: { trustedBiddingSignalsKeys: [1, 0x2, '3'] }
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsKeys unpaired surrogate characters, which should be replaced with "\\uFFFD".',
  fieldName: 'trustedBiddingSignalsKeys',
  fieldValue: ['\uFFFD', '\uFFFD', '\uFFFD.\uFFFD'],
  interestGroupOverrides: { trustedBiddingSignalsKeys: ['\uD800', '\uDBF0', '\uD800.\uDBF0'] }
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsSlotSizeMode empty.',
  fieldName: 'trustedBiddingSignalsSlotSizeMode',
  fieldValue: 'none',
  interestGroupOverrides: { trustedBiddingSignalsSlotSizeMode: undefined }
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsSlotSizeMode none.',
  fieldName: 'trustedBiddingSignalsSlotSizeMode',
  fieldValue: 'none'
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsSlotSizeMode slot-size.',
  fieldName: 'trustedBiddingSignalsSlotSizeMode',
  fieldValue: 'slot-size'
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsSlotSizeMode all-slots-requested-sizes.',
  fieldName: 'trustedBiddingSignalsSlotSizeMode',
  fieldValue: 'all-slots-requested-sizes'
});

makeTest({
  name: 'InterestGroup.trustedBiddingSignalsSlotSizeMode unrecognized value.',
  fieldName: 'trustedBiddingSignalsSlotSizeMode',
  fieldValue: 'none',
  interestGroupOverrides: { trustedBiddingSignalsSlotSizeMode: 'unrecognized value' }
});

makeTest({
  name: 'InterestGroup.userBiddingSignals not set.',
  fieldName: 'userBiddingSignals',
  fieldValue: undefined
});

makeTest({
  name: 'InterestGroup.userBiddingSignals is integer.',
  fieldName: 'userBiddingSignals',
  fieldValue: 15
});

makeTest({
  name: 'InterestGroup.userBiddingSignals is array.',
  fieldName: 'userBiddingSignals',
  fieldValue: [1, {a: 'b'}, 'c']
});

makeTest({
  name: 'InterestGroup.userBiddingSignals is object.',
  fieldName: 'userBiddingSignals',
  fieldValue: {a:1, b:32.5, c:['d', 'e']}
});

makeTest({
  name: 'InterestGroup.userBiddingSignals unpaired surrogate characters, which should be kept as-is.',
  fieldName: 'userBiddingSignals',
  fieldValue: '\uD800.\uDBF0'
});

makeTest({
  name: 'InterestGroup.userBiddingSignals unpaired surrogate characters in an object, which should be kept as-is.',
  fieldName: 'userBiddingSignals',
  fieldValue: {'\uD800': '\uDBF0', '\uDBF0':['\uD800']}
});

makeTest({
  name: 'InterestGroup.nonStandardField.',
  fieldName: 'nonStandardField',
  fieldValue: undefined,
  interestGroupOverrides: {nonStandardField: 'This value should not be passed to worklets'}
});

// Note that all ad tests have a deprecated "renderUrl" field passed to generateBid.

// Ad URLs need the right UUID for seller scripts to accept their bids. Since UUID changes
// for each test, and is not available outside makeTest(), have to use string that will
// be replaced with the real UUID.
const AD1_URL = createRenderURL('REPLACE_WITH_UUID', /*script=*/';');
const AD2_URL = createRenderURL('REPLACE_WITH_UUID', /*script=*/';;');

makeTest({
  name: 'InterestGroup.ads with one ad.',
  fieldName: 'ads',
  fieldValue: [{renderURL: AD1_URL}]
});

makeTest({
  name: 'InterestGroup.ads one ad with metadata object.',
  fieldName: 'ads',
  fieldValue: [{renderURL: AD1_URL, metadata: {foo: 1, bar: [2, 3], baz: '4'}}]
});

makeTest({
  name: 'InterestGroup.ads one ad with metadata string.',
  fieldName: 'ads',
  fieldValue: [{renderURL: AD1_URL, metadata: 'foo'}]
});

makeTest({
  name: 'InterestGroup.ads one ad with null metadata.',
  fieldName: 'ads',
  fieldValue: [{renderURL: AD1_URL, metadata: null}]
});

makeTest({
  name: 'InterestGroup.ads one ad with adRenderId. This field should not be passed to generateBid.',
  fieldName: 'ads',
  fieldValue: [{renderURL: AD1_URL}],
  interestGroupOverrides: {ads: [{renderURL: AD1_URL, adRenderId: 'twelve chars'}]}
});

makeTest({
  name: 'InterestGroup.ads one ad with buyerAndSellerReportingId. This field should not be passed to generateBid.',
  fieldName: 'ads',
  fieldValue: [{renderURL: AD1_URL}],
  interestGroupOverrides: {ads: [{renderURL: AD1_URL,
                                  buyerAndSellerReportingId: 'Arbitrary text'}]}
});

makeTest({
  name: 'InterestGroup.ads one ad with buyerReportingId. This field should not be passed to generateBid.',
  fieldName: 'ads',
  fieldValue: [{renderURL: AD1_URL}],
  interestGroupOverrides: {ads: [{renderURL: AD1_URL,
                                  buyerReportingId: 'Arbitrary text'}]}
});

makeTest({
  name: 'InterestGroup.ads one ad with novel field. This field should not be passed to generateBid.',
  fieldName: 'ads',
  fieldValue: [{renderURL: AD1_URL}],
  interestGroupOverrides: {ads: [{renderURL: AD1_URL, novelField: 'Foo'}]}
});

makeTest({
  name: 'InterestGroup.ads with multiple ads.',
  fieldName: 'ads',
  fieldValue: [{renderURL: AD1_URL, metadata: 1},
               {renderURL: AD2_URL, metadata: [2]}],
  interestGroupOverrides: {ads: [{renderURL: AD1_URL, metadata: 1},
                                 {renderURL: AD2_URL, metadata: [2]}]}
});

// This should probably be an error. This WPT test serves to encourage there to be a
// new join-leave WPT test when that is fixed.
makeTest({
  name: 'InterestGroup.ads duplicate ad.',
  fieldName: 'ads',
  fieldValue: [{renderURL: AD1_URL}, {renderURL: AD1_URL}],
  interestGroupOverrides: {ads: [{renderURL: AD1_URL}, {renderURL: AD1_URL}]}
});

makeTest({
  name: 'InterestGroup.adComponents is undefined.',
  fieldName: 'adComponents',
  fieldValue: undefined
});

// This one is likely a bug.
makeTest({
  name: 'InterestGroup.adComponents is empty array.',
  fieldName: 'adComponents',
  fieldValue: undefined,
  interestGroupOverrides: {adComponents: []}
});

makeTest({
  name: 'InterestGroup.adComponents with one ad.',
  fieldName: 'adComponents',
  fieldValue: [{renderURL: AD1_URL}]
});

makeTest({
  name: 'InterestGroup.adComponents one ad with metadata object.',
  fieldName: 'adComponents',
  fieldValue: [{renderURL: AD1_URL, metadata: {foo: 1, bar: [2, 3], baz: '4'}}]
});

makeTest({
  name: 'InterestGroup.adComponents one ad with metadata string.',
  fieldName: 'adComponents',
  fieldValue: [{renderURL: AD1_URL, metadata: 'foo'}]
});

makeTest({
  name: 'InterestGroup.adComponents one ad with null metadata.',
  fieldName: 'adComponents',
  fieldValue: [{renderURL: AD1_URL, metadata: null}]
});

makeTest({
  name: 'InterestGroup.adComponents one ad with adRenderId. This field should not be passed to generateBid.',
  fieldName: 'adComponents',
  fieldValue: [{renderURL: AD1_URL}],
  interestGroupOverrides: {adComponents: [{renderURL: AD1_URL,
                                           adRenderId: 'twelve chars'}]}
});

makeTest({
  name: 'InterestGroup.adComponents one ad with buyerAndSellerReportingId. This field should not be passed to generateBid.',
  fieldName: 'adComponents',
  fieldValue: [{renderURL: AD1_URL}],
  interestGroupOverrides: {adComponents: [{renderURL: AD1_URL,
                                           buyerAndSellerReportingId: 'Arbitrary text'}]}
});

makeTest({
  name: 'InterestGroup.adComponents one ad with buyerReportingId. This field should not be passed to generateBid.',
  fieldName: 'adComponents',
  fieldValue: [{renderURL: AD1_URL}],
  interestGroupOverrides: {adComponents: [{renderURL: AD1_URL,
                                           buyerReportingId: 'Arbitrary text'}]}
});

makeTest({
  name: 'InterestGroup.adComponents one ad with novel field. This field should not be passed to generateBid.',
  fieldName: 'adComponents',
  fieldValue: [{renderURL: AD1_URL}],
  interestGroupOverrides: {adComponents: [{renderURL: AD1_URL,
                                           novelField: 'Foo'}]}
});

makeTest({
  name: 'InterestGroup.adComponents with multiple ads.',
  fieldName: 'adComponents',
  fieldValue: [{renderURL: AD1_URL, metadata: 1}, {renderURL: AD2_URL, metadata: [2]}]
});

makeTest({
  name: 'InterestGroup.auctionServerRequestFlags is undefined',
  fieldName: 'auctionServerRequestFlags',
  fieldValue: undefined
});

makeTest({
  name: 'InterestGroup.auctionServerRequestFlags is "omit-ads".',
  fieldName: 'auctionServerRequestFlags',
  fieldValue: undefined,
  interestGroupOverrides: {auctionServerRequestFlags: ['omit-ads']}
});

makeTest({
  name: 'InterestGroup.auctionServerRequestFlags is "include-full-ads".',
  fieldName: 'auctionServerRequestFlags',
  fieldValue: undefined,
  interestGroupOverrides: {auctionServerRequestFlags: ['include-full-ads']}
});

makeTest({
  name: 'InterestGroup.auctionServerRequestFlags has multiple values.',
  fieldName: 'auctionServerRequestFlags',
  fieldValue: undefined,
  interestGroupOverrides: {auctionServerRequestFlags: ['omit-ads', 'include-full-ads']}
});

makeTest({
  name: 'InterestGroup.auctionServerRequestFlags.',
  fieldName: 'auctionServerRequestFlags',
  fieldValue: undefined,
  interestGroupOverrides: {auctionServerRequestFlags: ['noval value']}
});

// This should probably be an error. This WPT test serves to encourage there to be a
// new join-leave WPT test when that is fixed.
makeTest({
  name: 'InterestGroup.adComponents duplicate ad.',
  fieldName: 'adComponents',
  fieldValue: [{renderURL: AD1_URL}, {renderURL: AD1_URL}],
  interestGroupOverrides: {adComponents: [{renderURL: AD1_URL}, {renderURL: AD1_URL}]}
});