1 // META: script=/resources/testdriver.js
2 // META: script=/common/utils.js
3 // META: script=resources/fledge-util.js
7 // The tests in this file focus on calls to runAdAuction with various
13 // Expectation function (EXPECT_NULL, etc.)
15 // Overrides to the auction config.
16 auctionConfigOverrides = {},
18 promise_test(async test => {
19 const uuid = generateUuid(test);
20 // Join an interest group so the auction actually runs.
21 await joinInterestGroup(test, uuid);
24 auctionResult = await runBasicFledgeAuction(test, uuid, auctionConfigOverrides);
28 expect(auctionResult);
32 // Expect an unsuccessful auction (yielding null).
33 const EXPECT_NO_WINNER = auctionResult => {
34 assert_equals(auctionResult, null, 'Auction unexpected had a winner');
37 // Expect an exception of the given type.
38 const EXPECT_EXCEPTION = exceptionType => auctionResult => {
39 assert_not_equals(auctionResult, null, "got null instead of expected error");
40 assert_true(auctionResult instanceof Error, "did not get expected error: " + auctionResult);
41 assert_throws_js(exceptionType, () => { throw auctionResult; });
45 name: 'no buyers => no winners',
46 expect: EXPECT_NO_WINNER,
47 auctionConfigOverrides: {interestGroupBuyers: []},
51 name: 'seller is not an https URL',
52 expect: EXPECT_EXCEPTION(TypeError),
53 auctionConfigOverrides: {seller: "ftp://not-https"},
57 name: 'decisionLogicUrl is invalid',
58 expect: EXPECT_EXCEPTION(TypeError),
59 auctionConfigOverrides: { decisionLogicUrl: "https://foo:99999999999" },
63 name: 'decisionLogicUrl is cross-origin with seller',
64 expect: EXPECT_EXCEPTION(TypeError),
65 auctionConfigOverrides: { decisionLogicUrl: "https://example.com" },
69 name: 'trustedScoringSignalsUrl is invalid',
70 expect: EXPECT_EXCEPTION(TypeError),
71 auctionConfigOverrides: { trustedScoringSignalsUrl: "https://foo:99999999999" },
75 name: 'trustedScoringSignalsUrl is cross-origin with seller',
76 expect: EXPECT_EXCEPTION(TypeError),
77 auctionConfigOverrides: { trustedScoringSignalsUrl: "https://example.com" },
81 name: 'interestGroupBuyer is invalid',
82 expect: EXPECT_EXCEPTION(TypeError),
83 auctionConfigOverrides: { interestGroupBuyers: ["https://foo:99999999999"] },
87 name: 'interestGroupBuyer is not https',
88 expect: EXPECT_EXCEPTION(TypeError),
89 auctionConfigOverrides: { interestGroupBuyers: ["http://example.com"] },
93 name: 'only one interestGroupBuyer is invalid',
94 expect: EXPECT_EXCEPTION(TypeError),
95 auctionConfigOverrides: {
96 interestGroupBuyers: ["https://example.com", "https://foo:99999999999"],
101 name: 'only one interestGroupBuyer is not https',
102 expect: EXPECT_EXCEPTION(TypeError),
103 auctionConfigOverrides: {
104 interestGroupBuyers: ["https://example.com", "http://example.com"],
109 name: 'auctionSignals is invalid as JSON',
110 expect: EXPECT_EXCEPTION(TypeError),
111 auctionConfigOverrides: { auctionSignals: { sig: BigInt(13) } },
115 name: 'sellerSignals is invalid as JSON',
116 expect: EXPECT_EXCEPTION(TypeError),
117 auctionConfigOverrides: { sellerSignals: { sig: BigInt(13) } },
121 name: 'directFromSellerSignals is invalid',
122 expect: EXPECT_EXCEPTION(TypeError),
123 auctionConfigOverrides: { directFromSellerSignals: "https://foo:99999999999" },
127 name: 'directFromSellerSignals is cross-origin with seller',
128 expect: EXPECT_EXCEPTION(TypeError),
129 auctionConfigOverrides: { directFromSellerSignals: "https://example.com" },
133 name: 'directFromSellerSignals has nonempty query',
134 expect: EXPECT_EXCEPTION(TypeError),
135 auctionConfigOverrides: { directFromSellerSignals: window.location.origin + "?foo=bar" },
139 name: 'perBuyerSignals has invalid URL in a key',
140 expect: EXPECT_EXCEPTION(TypeError),
141 auctionConfigOverrides: { perBuyerSignals: { "https://foo:99999999999" : {} }},
145 name: 'perBuyerSignals value is invalid as JSON',
146 expect: EXPECT_EXCEPTION(TypeError),
147 auctionConfigOverrides: {
148 perBuyerSignals: { "https://example.com" : { sig: BigInt(1) },
153 name: 'perBuyerGroupLimits has invalid URL in a key',
154 expect: EXPECT_EXCEPTION(TypeError),
155 auctionConfigOverrides: { perBuyerGroupLimits: { "https://foo:99999999999" : 5 }},
159 name: 'perBuyerExperimentGroupIds has invalid URL in a key',
160 expect: EXPECT_EXCEPTION(TypeError),
161 auctionConfigOverrides: { perBuyerExperimentGroupIds: { "https://foo:99999999999" : 11 }},
165 name: 'perBuyerPrioritySignals has invalid URL in a key',
166 expect: EXPECT_EXCEPTION(TypeError),
167 auctionConfigOverrides: {
168 perBuyerPrioritySignals: { "https://foo:99999999999" : { sig: 2.5} },
173 name: 'perBuyerPrioritySignals has a value with a key with prefix "browserSignals"',
174 expect: EXPECT_EXCEPTION(TypeError),
175 auctionConfigOverrides: {
176 perBuyerPrioritySignals: { "https://example.com" : { "browserSignals.foo" : true } },
181 name: 'component auctions are not allowed within component auctions',
182 expect: EXPECT_EXCEPTION(TypeError),
183 auctionConfigOverrides: {
184 interestGroupBuyers: undefined,
187 seller: window.location.origin,
188 decisionLogicUrl: window.location.origin,
189 interestGroupBuyers: undefined,
192 seller: window.location.origin,
193 decisionLogicUrl: window.location.origin,
202 name: 'component auctions are not allowed with interestGroupBuyers',
203 expect: EXPECT_EXCEPTION(TypeError),
204 auctionConfigOverrides: {
205 interestGroupBuyers: ["https://example.com"],
208 seller: window.location.origin,
209 decisionLogicUrl: window.location.origin,
210 interestGroupBuyers: [],