summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fledge/tentative/trusted-bidding-signals.https.window.js
blob: 905abf8381eaeaee800be38c25d44e5704be0247 (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
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
// META: script=/resources/testdriver.js
// META: script=/common/utils.js
// META: script=/common/subset-tests.js
// META: script=resources/fledge-util.sub.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-last

"use strict";

// These tests focus on trustedBiddingSignals: Requesting them, handling network
// errors, handling the keys portion of the response, and passing keys to
// worklet scripts, and handling the Data-Version header
//
// Because of request batching, left over interest groups from
// other tests may result in tests that request TRUSTED_BIDDING_SIGNALS_URL
// with certain special keys failing, if interest groups with names other than
// the default one are not successfully left after previously run tests.

// Helper for trusted bidding signals test. Runs an auction, and fails the
// test if there's no winner. "generateBidCheck" is an expression that should
// be true when evaluated in generateBid(). "interestGroupOverrides" is a
// set of overridden fields added to the default interestGroup when joining it,
// allowing trusted bidding signals keys and URL to be set, in addition to other
// fields.
async function runTrustedBiddingSignalsTest(
    test, generateBidCheck, interestGroupOverrides = {}, auctionConfigOverrides = {}, uuidOverride = null) {
  interestGroupOverrides.biddingLogicURL =
      createBiddingScriptURL({
          allowComponentAuction: true,
          generateBid: `if (!(${generateBidCheck})) return false;` });
  let testConfig = {
    interestGroupOverrides: interestGroupOverrides,
    auctionConfigOverrides: auctionConfigOverrides
  };
  if (uuidOverride)
    testConfig.uuid = uuidOverride;
  await joinGroupAndRunBasicFledgeTestExpectingWinner(test, testConfig);
}

// Much like runTrustedBiddingSignalsTest, but runs auctions through reporting
// as well, and evaluates `check` both in generateBid() and reportWin(). Also
// makes sure browserSignals.dataVersion is undefined in scoreAd() and
// reportResult().
async function runTrustedBiddingSignalsDataVersionTest(
    test, check, interestGroupOverrides = {}) {
  const uuid = generateUuid(test);
  interestGroupOverrides.biddingLogicURL =
    createBiddingScriptURL({
          generateBid:
              `if (!(${check})) return false;`,
          reportWin:
              `if (!(${check}))
                sendReportTo('${createBidderReportURL(uuid, 'error')}');
              else
                sendReportTo('${createBidderReportURL(uuid)}');` });
  await joinInterestGroup(test, uuid, interestGroupOverrides);

  const auctionConfigOverrides = {
    decisionLogicURL: createDecisionScriptURL(
        uuid,
        { scoreAd:
              `if (browserSignals.dataVersion !== undefined)
                return false;`,
          reportResult:
              `if (browserSignals.dataVersion !== undefined)
                 sendReportTo('${createSellerReportURL(uuid, 'error')}')
               sendReportTo('${createSellerReportURL(uuid)}')`, })
  }
  await runBasicFledgeAuctionAndNavigate(test, uuid, auctionConfigOverrides);
  await waitForObservedRequests(
      uuid, [createBidderReportURL(uuid), createSellerReportURL(uuid)]);
}

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(test, 'trustedBiddingSignals === null');
}, 'No trustedBiddingSignalsKeys or trustedBiddingSignalsURL.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['numValue'] });
}, 'trustedBiddingSignalsKeys but no trustedBiddingSignalsURL.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'trustedBiddingSignalsURL without trustedBiddingSignalsKeys.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['close-connection'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'trustedBiddingSignalsURL closes the connection without sending anything.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['http-error'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response is HTTP 404 error.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['no-content-type'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has no content-type.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['wrong-content-type'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has wrong content-type.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['ad-auction-not-allowed'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response does not allow fledge.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['bad-ad-auction-allowed'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has wrong Ad-Auction-Allowed header.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['no-ad-auction-allow'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has no Ad-Auction-Allowed header.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['replace-body:'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has no body.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['replace-body:Not JSON'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response is not JSON.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['replace-body:[]'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response is a JSON array.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals === null',
      { trustedBiddingSignalsKeys: ['replace-body:{JSON_keys_need_quotes: 1}'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response in invalid JSON object.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals["replace-body:{}"] === null',
      { trustedBiddingSignalsKeys: ['replace-body:{}'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has no keys object.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, `trustedBiddingSignals['replace-body:{"keys":{}}'] === null`,
      { trustedBiddingSignalsKeys: ['replace-body:{"keys":{}}'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has no keys.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      `trustedBiddingSignals["0"] === null &&
       trustedBiddingSignals["1"] === null &&
       trustedBiddingSignals["2"] === null &&
       trustedBiddingSignals["length"] === null`,
      { trustedBiddingSignalsKeys:
            ['replace-body:{"keys":[1,2,3]}', "0", "1", "2", "length"],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response keys is incorrectly an array.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      `trustedBiddingSignals["wrong-value"] === null &&
      trustedBiddingSignals["another-value"] === undefined`,
      { trustedBiddingSignalsKeys: ['wrong-value'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has key not in trustedBiddingSignalsKeys.');

subsetTest(promise_test, async test => {
    await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals["null-value"] === null',
      { trustedBiddingSignalsKeys: ['null-value'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has null value for key.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals["num-value"] === 1',
      { trustedBiddingSignalsKeys: ['num-value'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has a number value for key.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test, 'trustedBiddingSignals["string-value"] === "1"',
      { trustedBiddingSignalsKeys: ['string-value'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has string value for key.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      `JSON.stringify(trustedBiddingSignals["array-value"]) === '[1,"foo",null]'`,
      { trustedBiddingSignalsKeys: ['array-value'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has array value for key.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      `Object.keys(trustedBiddingSignals["object-value"]).length  === 2 &&
       trustedBiddingSignals["object-value"]["a"] === "b" &&
       JSON.stringify(trustedBiddingSignals["object-value"]["c"]) === '["d"]'`,
      { trustedBiddingSignalsKeys: ['object-value'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has object value for key.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      'trustedBiddingSignals[""] === "default value"',
      { trustedBiddingSignalsKeys: [''],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals receives empty string key.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      `Object.keys(trustedBiddingSignals).length === 6 &&
       trustedBiddingSignals["wrong-value"] === null &&
       trustedBiddingSignals["null-value"] === null &&
       trustedBiddingSignals["num-value"] === 1 &&
       trustedBiddingSignals["string-value"] === "1" &&
       JSON.stringify(trustedBiddingSignals["array-value"]) === '[1,"foo",null]' &&
       trustedBiddingSignals[""] === "default value"`,
      { trustedBiddingSignalsKeys: ['wrong-value', 'null-value', 'num-value',
                                    'string-value', 'array-value', ''],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has multiple keys.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      'trustedBiddingSignals["+%20 \x00?,3#&"] === "default value"',
      { trustedBiddingSignalsKeys: ['+%20 \x00?,3#&'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals receives escaped key.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      'trustedBiddingSignals["\x00"] === "default value"',
      { trustedBiddingSignalsKeys: ['\x00'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals receives null key.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      `trustedBiddingSignals["interest-group-names"] === '["${DEFAULT_INTEREST_GROUP_NAME}"]'`,
      { trustedBiddingSignalsKeys: ['interest-group-names'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals receives interest group name.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      // Interest group names is a JSONified list of JSONified names, so the
      // null ends up being escaped twice.
      `trustedBiddingSignals["interest-group-names"] === '["+%20 \\\\u0000?,3#&"]'`,
      { name: '+%20 \x00?,3#&',
        trustedBiddingSignalsKeys: ['interest-group-names'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals receives escaped interest group name.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      `trustedBiddingSignals["interest-group-names"] === '[""]'`,
      { name: '',
        trustedBiddingSignalsKeys: ['interest-group-names'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals receives empty interest group name.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      `trustedBiddingSignals["hostname"] === "${window.location.hostname}"`,
      { trustedBiddingSignalsKeys: ['hostname'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals receives hostname field.');

/////////////////////////////////////////////////////////////////////////////
// Data-Version tests
/////////////////////////////////////////////////////////////////////////////

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === undefined',
      { trustedBiddingSignalsKeys: ['num-value'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has no Data-Version.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === 3',
      { trustedBiddingSignalsKeys: ['data-version:3'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has numeric Data-Version.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === 0',
      { trustedBiddingSignalsKeys: ['data-version:0'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has min Data-Version.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === 4294967295',
      { trustedBiddingSignalsKeys: ['data-version:4294967295'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has max Data-Version.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === undefined',
      { trustedBiddingSignalsKeys: ['data-version:4294967296'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has too large Data-Version.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === undefined',
      { trustedBiddingSignalsKeys: ['data-version:03'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has Data-Version with leading 0.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === undefined',
      { trustedBiddingSignalsKeys: ['data-version:-1'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has negative Data-Version.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === undefined',
      { trustedBiddingSignalsKeys: ['data-version:1.3'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has decimal in Data-Version.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === undefined',
      { trustedBiddingSignalsKeys: ['data-version:2 2'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has space in Data-Version.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === undefined',
      { trustedBiddingSignalsKeys: ['data-version:0x4'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has hex Data-Version.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === 4',
      { name: 'data-version',
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has Data-Version and no trustedBiddingSignalsKeys.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === undefined',
      { trustedBiddingSignalsKeys: ['data-version:3', 'replace-body:'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response with Data-Version and empty body.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === undefined',
      { trustedBiddingSignalsKeys: ['data-version:3', 'replace-body:[]'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response with Data-Version and JSON array body.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === undefined',
      { trustedBiddingSignalsKeys: ['data-version:3', 'replace-body:{} {}'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response with Data-Version and double JSON object body.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsDataVersionTest(
      test,
      'browserSignals.dataVersion === 3',
      { trustedBiddingSignalsKeys: ['data-version:3', 'replace-body:{"keys":5}'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response with Data-Version and invalid keys entry');

/////////////////////////////////////////////////////////////////////////////
// trustedBiddingSignalsSlotSizeMode tests
/////////////////////////////////////////////////////////////////////////////

async function runTrustedBiddingSignalsSlotSizeTest(
    test,
    expectedSlotSize,
    expectedAllSlotsRequestedSizes,
    trustedBiddingSignalsSlotSizeMode = null,
    auctionConfigOverrides = {},
    uuidOverride = null) {
  await runTrustedBiddingSignalsTest(
      test,
      `trustedBiddingSignals["slotSize"] ===
           ${JSON.stringify(expectedSlotSize)} &&
       trustedBiddingSignals["allSlotsRequestedSizes"] ===
           ${JSON.stringify(expectedAllSlotsRequestedSizes)}`,
      { trustedBiddingSignalsKeys: ['slotSize', 'allSlotsRequestedSizes'],
        trustedBiddingSignalsSlotSizeMode: trustedBiddingSignalsSlotSizeMode,
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL},
      auctionConfigOverrides,
      uuidOverride);
}

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found');
}, 'Null trustedBiddingSignalsSlotSizeMode, no sizes in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'not-a-real-mode');
}, 'Unknown trustedBiddingSignalsSlotSizeMode, no sizes in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'none');
}, 'none trustedBiddingSignalsSlotSizeMode, no sizes in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'slot-size');
}, 'slot-size trustedBiddingSignalsSlotSizeMode, no sizes in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'slot-size');
}, 'all-slots-requested-sizes trustedBiddingSignalsSlotSizeMode, no sizes in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'none',
      {requestedSize: {width:'10', height:'20'}});
}, 'none trustedBiddingSignalsSlotSizeMode, requestedSize in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/null,
      {requestedSize: {width:'10', height:'20'}});
}, 'Null trustedBiddingSignalsSlotSizeMode, requestedSize in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'not-a-real-mode',
      {requestedSize: {width:'10', height:'20'}});
}, 'Unknown trustedBiddingSignalsSlotSizeMode, requestedSize in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'10px,20px',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'slot-size',
      {requestedSize: {width:'10', height:'20'}});
}, 'slot-size trustedBiddingSignalsSlotSizeMode, requestedSize in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'all-slots-requested-sizes',
      {requestedSize: {width:'10', height:'20'}});
}, 'all-slots-requested-sizes trustedBiddingSignalsSlotSizeMode, requestedSize in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'none',
      {allSlotsRequestedSizes: [{width:10, height:20}]});
}, 'none trustedBiddingSignalsSlotSizeMode, allSlotsRequestedSizes in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/null,
      {allSlotsRequestedSizes: [{width:'10', height:'20'}]});
}, 'Null trustedBiddingSignalsSlotSizeMode, allSlotsRequestedSizes in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'not-a-real-mode',
      {allSlotsRequestedSizes: [{width:'10', height:'20'}]});
}, 'Unknown trustedBiddingSignalsSlotSizeMode, allSlotsRequestedSizes in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'slot-size',
      {allSlotsRequestedSizes: [{width:'10', height:'20'}]});
}, 'slot-size trustedBiddingSignalsSlotSizeMode, allSlotsRequestedSizes in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'10px,20px',
      /*trustedBiddingSignalsSlotSizeMode=*/'all-slots-requested-sizes',
      {allSlotsRequestedSizes: [{width:'10', height:'20'}]});
}, 'all-slots-requested-sizes trustedBiddingSignalsSlotSizeMode, allSlotsRequestedSizes in AuctionConfig');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'10px,20px',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'slot-size',
      {requestedSize: {width:'10px', height:'20px'}});
}, 'slot-size trustedBiddingSignalsSlotSizeMode, explicit pixel units');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'80sw,12.5sh',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'slot-size',
      {requestedSize: {width:'80sw', height:'12.50sh'}});
}, 'slot-size trustedBiddingSignalsSlotSizeMode, screen size units');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'80sh,12.5sw',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'slot-size',
      {requestedSize: {width:'80sh', height:'12.5sw'}});
}, 'slot-size trustedBiddingSignalsSlotSizeMode, flipped screen size units');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'10px,25sh',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'slot-size',
      {requestedSize: {width:'10', height:'25sh'}});
}, 'slot-size trustedBiddingSignalsSlotSizeMode, mixed pixel and screen width units');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'10px,20px,25sw,20px,22px,80sh',
      /*trustedBiddingSignalsSlotSizeMode=*/'all-slots-requested-sizes',
      { allSlotsRequestedSizes: [ {width:'10', height:'20'},
                                  {width:'25sw', height:'20px'},
                                  {width:'22', height:'80sh'}]});
}, 'all-slots-requested-sizes trustedBiddingSignalsSlotSizeMode, multiple unit types');

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

  let group1ReportURL = createBidderReportURL(uuid, /*id=*/'none')
  let group2ReportURL = createBidderReportURL(uuid, /*id=*/'slot-size')
  let group3ReportURL = createBidderReportURL(uuid, /*id=*/'all-slots-requested-sizes')

  // The simplest way to make sure interest groups with different modes all receive
  // the right sizes is to have interest groups that modify their bids based on ad
  // size sent to the trusted server.
  await Promise.all(
      [ joinInterestGroup(
          test, uuid,
          { name: 'group 1',
            trustedBiddingSignalsKeys: ['slotSize', 'allSlotsRequestedSizes'],
            trustedBiddingSignalsSlotSizeMode: 'none',
            trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL,
            biddingLogicURL: createBiddingScriptURL(
                { generateBid:
                    `if (trustedBiddingSignals["slotSize"] !== "not-found" ||
                         trustedBiddingSignals["allSlotsRequestedSizes"] !== "not-found") {
                       throw "unexpected trustedBiddingSignals";
                     }
                     return {bid: 5, render: interestGroup.ads[0].renderURL};`,
                  reportWin: `sendReportTo("${group1ReportURL}");`})}),
        joinInterestGroup(
          test, uuid,
          { name: 'group 2',
            trustedBiddingSignalsKeys: ['slotSize', 'allSlotsRequestedSizes'],
            trustedBiddingSignalsSlotSizeMode: 'slot-size',
            trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL,
            biddingLogicURL: createBiddingScriptURL(
                { generateBid:
                    `if (trustedBiddingSignals["slotSize"] === "not-found" ||
                         trustedBiddingSignals["allSlotsRequestedSizes"] !== "not-found") {
                       throw "unexpected trustedBiddingSignals";
                     }
                     // Group 3 bids using the first digit of the first dimension.
                     return { bid: trustedBiddingSignals["slotSize"].substr(0, 1),
                              render: interestGroup.ads[0].renderURL};`,
                  reportWin: `sendReportTo("${group2ReportURL}");`})}),
        joinInterestGroup(
          test, uuid,
          { name: 'group 3',
            trustedBiddingSignalsKeys: ['slotSize', 'allSlotsRequestedSizes'],
            trustedBiddingSignalsSlotSizeMode: 'all-slots-requested-sizes',
            trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL,
            biddingLogicURL: createBiddingScriptURL(
                { generateBid:
                    `if (trustedBiddingSignals["slotSize"] !== "not-found" ||
                         trustedBiddingSignals["allSlotsRequestedSizes"] === "not-found") {
                       throw "unexpected trustedBiddingSignals";
                     }
                     // Group 3 bids using the second digit of the first dimension.
                     return { bid: trustedBiddingSignals["allSlotsRequestedSizes"].substr(1, 1),
                              render: interestGroup.ads[0].renderURL};`,
                  reportWin: `sendReportTo("${group3ReportURL}");`})}),
      ]
  );

  let auctionConfigOverrides = {
    // Disable the default seller reporting, for simplicity.
    decisionLogicURL: createDecisionScriptURL(uuid, { reportResult: '' }),
    // Default sizes start with a "11", so groups 2 and 3 will start with a bid
    // of 1 and lose.
    requestedSize: {width:'11', height:'20'},
    allSlotsRequestedSizes: [{width:'11', height:'20'}]
  };

  // Group 1 wins the first auction.
  await runBasicFledgeAuctionAndNavigate(test, uuid, auctionConfigOverrides);
  await waitForObservedRequests(uuid, [group1ReportURL]);

  // Group2 should bid "6" in the second auction, and win it.
  auctionConfigOverrides.requestedSize = {width:'61', height:'20'};
  auctionConfigOverrides.allSlotsRequestedSizes = [{width:'61', height:'20'}];
  await runBasicFledgeAuctionAndNavigate(test, uuid, auctionConfigOverrides);
  await waitForObservedRequests(uuid, [group1ReportURL, group2ReportURL]);

  // Group3 should bid "7" in the third auction, and win it.
  auctionConfigOverrides.requestedSize = {width:'67', height:'20'};
  auctionConfigOverrides.allSlotsRequestedSizes = [{width:'67', height:'20'}];
  await runBasicFledgeAuctionAndNavigate(test, uuid, auctionConfigOverrides);
  await waitForObservedRequests(uuid, [group1ReportURL, group2ReportURL, group3ReportURL]);
}, 'Mixed trustedBiddingSignalsSlotSizeModes in a single auction');

subsetTest(promise_test, async test => {
  const uuid = generateUuid(test);
  let componentAuctionConfig = {
    seller: window.location.origin,
    decisionLogicURL: createDecisionScriptURL(uuid),
    interestGroupBuyers: [window.location.origin],
    requestedSize: {width:'10', height:'20'}
  };

  let auctionConfigOverrides = {
    interestGroupBuyers: [],
    componentAuctions: [componentAuctionConfig],
    requestedSize: {width:'22', height:'33'}
  }

  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      // Dimensions from the component auction should be used.
      /*expectedSlotSize=*/'10px,20px',
      /*expectedAllSlotsRequestedSizes=*/'not-found',
      /*trustedBiddingSignalsSlotSizeMode=*/'slot-size',
      auctionConfigOverrides,
      uuid);
}, 'slot-size trustedBiddingSignalsSlotSizeMode in a component auction');

subsetTest(promise_test, async test => {
  const uuid = generateUuid(test);
  let componentAuctionConfig = {
    seller: window.location.origin,
    decisionLogicURL: createDecisionScriptURL(uuid),
    interestGroupBuyers: [window.location.origin],
    allSlotsRequestedSizes: [{width:'11', height:'22'}, {width:'12', height:'23'}]
  };

  let auctionConfigOverrides = {
    interestGroupBuyers: [],
    componentAuctions: [componentAuctionConfig],
    allSlotsRequestedSizes: [{width:'10', height:'20'}]
  }

  await runTrustedBiddingSignalsSlotSizeTest(
      test,
      // Dimensions from the component auction should be used.
      /*expectedSlotSize=*/'not-found',
      /*expectedAllSlotsRequestedSizes=*/'11px,22px,12px,23px',
      /*trustedBiddingSignalsSlotSizeMode=*/'all-slots-requested-sizes',
      auctionConfigOverrides,
      uuid);
}, 'all-slots-requested-sizes trustedBiddingSignalsSlotSizeMode in a component auction');

/////////////////////////////////////////////////////////////////////////////
// maxTrustedBiddingSignalsURLLength tests
/////////////////////////////////////////////////////////////////////////////

// Trusted bidding signals can be retrieved when `maxTrustedBiddingSignalsURLLength` is set to 0,
// which means infinite length limit.
// In the following three tests, the generated request URL contains approximately 166 characters.
// The target of the tests is primarily to make sure all the signals are fetched with the full URL.
subsetTest(promise_test, async test => {
  const name = 'group';
  await runTrustedBiddingSignalsTest(
      test,
      // Check the URL length is within an approximate range to ensure the URL is not truncated.
      ` trustedBiddingSignals["interest-group-names"] === '["${name}"]' &&
        trustedBiddingSignals["url"].length > 150 &&
        trustedBiddingSignals["url"].length < 180 `,
      {
        name: name,
        trustedBiddingSignalsKeys: ['interest-group-names', 'url'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL,
        maxTrustedBiddingSignalsURLLength: 0
      });
}, 'Trusted bidding signals request works with a URL length limit set to 0.');

// Trusted bidding signals can be retrieved when `maxTrustedBiddingSignalsURLLength` is set to
// a non-zero value smaller than the length of the request URL. It also tests that multiple
// bidding keys from the same interest group will not be separated even the full URL length is
// larger than the limit.
subsetTest(promise_test, async test => {
  const name = 'group';
  await runTrustedBiddingSignalsTest(
      test,
      ` trustedBiddingSignals["interest-group-names"] === '["${name}"]' &&
        trustedBiddingSignals["url"].length > 150 &&
        trustedBiddingSignals["url"].length < 180 `,
      {
        name: name,
        trustedBiddingSignalsKeys: ['interest-group-names', 'url'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL,
        maxTrustedBiddingSignalsURLLength: 1
      });
}, 'Trusted bidding signals request works with a URL length limit smaller than the URL length.');

// Trusted bidding signals can be retrieved when `maxTrustedBiddingSignalsURLLength` is set to
// a value larger than the length of the request URL.
subsetTest(promise_test, async test => {
  const name = 'group';
  await runTrustedBiddingSignalsTest(
      test,
      ` trustedBiddingSignals["interest-group-names"] === '["${name}"]' &&
        trustedBiddingSignals["url"].length < 180 `,
      {
        name: name,
        trustedBiddingSignalsKeys: ['interest-group-names', 'url'],
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL,
        maxTrustedBiddingSignalsURLLength: 1000
      });
}, 'Trusted bidding signals request works with a URL length limit larger than the URL length.');

// Test whether an oversized trusted bidding signals request URL, generated from two interest
// groups, will be split into two parts when `maxTrustedBiddingSignalsURLLength` is set to a
// value larger than a single URL length and smaller than the combined URL length. A request
// URL from a single interest group contains about 188 characters, while a request URL from
// two interest groups contains about 216 characters. Note that this test can only verifies
// the fetch status of the winner's trusted bidding signal, which is the second interest
// group. We consider the request to be split if the URL length check passes for the second
// interest group.
subsetTest(promise_test, async test => {
  const uuid = generateUuid(test);
  const name1 = 'extraordinarilyLongNameGroup1';
  const name2 = 'extraordinarilyLongNameGroup2';

  await Promise.all(
      [ joinInterestGroup(
          test, uuid,
          {
            name: name1,
            trustedBiddingSignalsKeys: ['interest-group-names', 'url'],
            trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL,
            maxTrustedBiddingSignalsURLLength: 200,
            biddingLogicURL: createBiddingScriptURL(
                {
                  // Return 0 as bid to force the second interest group to win. This interest group
                  // is considered as fetching trusted bidding signals by itself if the winner's
                  // URL length passes the limit check.
                  generateBid:
                    `return { bid: 0, render: interestGroup.ads[0].renderURL };`
                })
          }),
        joinInterestGroup(
          test, uuid,
          {
            name: name2,
            trustedBiddingSignalsKeys: ['interest-group-names', 'url'],
            trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL,
            maxTrustedBiddingSignalsURLLength: 200,
            biddingLogicURL: createBiddingScriptURL(
                {
                  generateBid:
                    `if (trustedBiddingSignals["interest-group-names"] !== '["${name2}"]' ||
                        trustedBiddingSignals["url"].length > 200) {
                      throw "unexpected trustedBiddingSignals";
                    }
                    return { bid: 10, render: interestGroup.ads[0].renderURL };`})
          })
      ]
  );
  runBasicFledgeTestExpectingWinner(test, uuid);
}, 'Trusted bidding signals splits the request if the combined URL length exceeds the limit of regular value.');

// Test whether an oversized trusted bidding signals request URL, generated from two interest
// groups, will be split into two parts when `maxTrustedBiddingSignalsURLLength` is set to a
// value smaller than a single URL length.
subsetTest(promise_test, async test => {
  const uuid = generateUuid(test);
  const name1 = 'extraordinaryLongNameGroup1';
  const name2 = 'extraordinaryLongNameGroup2';

  await Promise.all(
      [ joinInterestGroup(
          test, uuid,
          {
            name: name1,
            trustedBiddingSignalsKeys: ['interest-group-names', 'url'],
            trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL,
            maxTrustedBiddingSignalsURLLength: 1,
            biddingLogicURL: createBiddingScriptURL(
                {
                  generateBid:
                    `return { bid: 0, render: interestGroup.ads[0].renderURL };`
                })
          }),
        joinInterestGroup(
          test, uuid,
          {
            name: name2,
            trustedBiddingSignalsKeys: ['interest-group-names', 'url'],
            trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL,
            maxTrustedBiddingSignalsURLLength: 1,
            biddingLogicURL: createBiddingScriptURL(
                {
                  generateBid:
                    `if (trustedBiddingSignals["interest-group-names"] !== '["${name2}"]' ||
                        trustedBiddingSignals["url"].length > 200) {
                      throw "unexpected trustedBiddingSignals";
                    }
                    return { bid: 10, render: interestGroup.ads[0].renderURL };`})
          })
      ]
  );
  runBasicFledgeTestExpectingWinner(test, uuid);
}, 'Trusted bidding signals splits the request if the combined URL length exceeds the limit of small value.');

/////////////////////////////////////////////////////////////////////////////
// updateIfOlderThanMs tests
//
// NOTE: Due to the lack of mock time in wpt, these test just exercise the code
// paths and ensure that no crash occurs -- they don't otherwise verify
// behavior.
/////////////////////////////////////////////////////////////////////////////

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      'true',
      { name: 'use-update-if-older-than-ms',
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has updateIfOlderThanMs > 10 min.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      'true',
      { name: 'use-update-if-older-than-ms-small',
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has updateIfOlderThanMs == 1 ms.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      'true',
      { name: 'use-update-if-older-than-ms-zero',
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has updateIfOlderThanMs == 0 ms.');

subsetTest(promise_test, async test => {
  await runTrustedBiddingSignalsTest(
      test,
      'true',
      { name: 'use-update-if-older-than-ms-negative',
        trustedBiddingSignalsURL: TRUSTED_BIDDING_SIGNALS_URL });
}, 'Trusted bidding signals response has updateIfOlderThanMs == -1 ms.');