From ecd260d7f8c67ee76941bf31bffb96c224f3761b Mon Sep 17 00:00:00 2001 From: Russ Hamilton Date: Wed, 22 Jan 2025 09:08:35 -0800 Subject: [PATCH] Add WPT for multi-seller getInterestGroupAdAuctionData Change-Id: Ic65307069147f6325303fc35dfda29f733df6346 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6180162 Commit-Queue: Russ Hamilton Reviewed-by: Qingxin Wu Cr-Commit-Position: refs/heads/main@{#1409702} --- ...nterest-group-auction-data.https.window.js | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/fledge/tentative/get-interest-group-auction-data.https.window.js b/fledge/tentative/get-interest-group-auction-data.https.window.js index 205391d21ffdc3..da48a843dc5a5a 100644 --- a/fledge/tentative/get-interest-group-auction-data.https.window.js +++ b/fledge/tentative/get-interest-group-auction-data.https.window.js @@ -10,6 +10,7 @@ // META: variant=?5-8 // META: variant=?9-12 // META: variant=?13-16 +// META: variant=?17-last // These tests focus on the navigator.getInterestGroupAdAuctionData() method. @@ -618,3 +619,169 @@ subsetTest(promise_test, async test => { assert_own_property(decoded.message, 'enforceKAnon'); assert_equals(decoded.message.enforceKAnon, true); }, 'getInterestGroupAdAuctionData() requests k-anon.'); + + +/************************************************************************* + * Tests for the multi-seller variant of the API + *************************************************************************/ + + async function validateForSeller(adAuctionData, seller) { + assert_equals(adAuctionData.seller, seller); + assert_not_own_property(adAuctionData, 'error'); + assert_own_property(adAuctionData, 'request'); + assert_true(adAuctionData.request.length > 0); + + let decoded = await BA.decodeInterestGroupData(adAuctionData.request); + let ig = validateWithOneIg(decoded); + + assert_equals(ig.name, DEFAULT_INTEREST_GROUP_NAME); + assert_array_equals(ig.ads, ['a', 'b']); + + assert_true(ig.components instanceof Array); + assert_array_equals(ig.components, ['ca', 'cb', 'cc']); + + assert_array_equals(ig.biddingSignalsKeys, ['alpha', 'beta']); + assert_equals(ig.userBiddingSignals, '14'); +} + + subsetTest(promise_test, async test => { + const uuid = generateUuid(test); + const igConfig = makeTemplateIgConfig(uuid); + await joinInterestGroup(test, uuid, igConfig); + + const result = await navigator.getInterestGroupAdAuctionData({ + sellers: [{ + coordinatorOrigin: await BA.configureCoordinator(), + seller: window.location.origin, + }] + }); + + assert_true(result.requestId !== null); + assert_own_property(result, 'requests'); + assert_equals(result.requests.length, 1); + validateForSeller(result.requests[0], window.location.origin); +}, 'getInterestGroupAdAuctionData() multi-seller with single seller'); + +subsetTest(promise_test, async test => { + const uuid = generateUuid(test); + const igConfig = makeTemplateIgConfig(uuid); + await joinInterestGroup(test, uuid, igConfig); + + const result = await navigator.getInterestGroupAdAuctionData({ + sellers: [{ + coordinatorOrigin: await BA.configureCoordinator(), + seller: window.location.origin, + }, { + coordinatorOrigin: await BA.configureCoordinator(), + seller: OTHER_ORIGIN1, + }] + }); + + assert_true(result.requestId !== null); + assert_own_property(result, 'requests'); + assert_equals(result.requests.length, 2, JSON.stringify(result)); + result.requests.sort((a,b)=> (a.seller < b.seller ? -1 : +(a.seller > b.seller))); + + await validateForSeller(result.requests[0], OTHER_ORIGIN1); + await validateForSeller(result.requests[1], window.location.origin); + + assert_not_equals(result.requests[0].request.toString(), result.requests[1].request.toString()); +}, 'getInterestGroupAdAuctionData() multi-seller with multiple sellers - valid'); + +subsetTest(promise_test, async test => { + const uuid = generateUuid(test); + const igConfig = makeTemplateIgConfig(uuid); + await joinInterestGroup(test, uuid, igConfig); + + const result = await navigator.getInterestGroupAdAuctionData({ + sellers: [{ + coordinatorOrigin: await BA.configureCoordinator(), + seller: window.location.origin, + }, { + coordinatorOrigin: "https://invalid.coordinator.test/", + seller: OTHER_ORIGIN1, + }] + }); + + assert_true(result.requestId !== null); + assert_own_property(result, 'requests'); + assert_equals(result.requests.length, 2, JSON.stringify(result)); + result.requests.sort((a,b)=> (a.seller < b.seller ? -1 : +(a.seller > b.seller))); + + assert_equals(result.requests[0].seller, OTHER_ORIGIN1); + assert_own_property(result.requests[0], 'error'); + assert_not_own_property(result.requests[0], 'request'); + + await validateForSeller(result.requests[1], window.location.origin); +}, 'getInterestGroupAdAuctionData() multi-seller with multiple sellers - one invalid coordinator'); + +subsetTest(promise_test, async test => { + const uuid = generateUuid(test); + const igConfig = makeTemplateIgConfig(uuid); + await joinInterestGroup(test, uuid, igConfig); + + await promise_rejects_js(test, TypeError, navigator.getInterestGroupAdAuctionData({ + sellers: [{ + coordinatorOrigin: await BA.configureCoordinator(), + seller: window.location.origin, + }, { + coordinatorOrigin: await BA.configureCoordinator(), + seller: "http://not.secure.test/", + }] + })); +}, 'getInterestGroupAdAuctionData() multi-seller with multiple sellers - one invalid seller'); + +subsetTest(promise_test, async test => { + const uuid = generateUuid(test); + const igConfig = makeTemplateIgConfig(uuid); + await joinInterestGroup(test, uuid, igConfig); + + await promise_rejects_js(test, TypeError, navigator.getInterestGroupAdAuctionData({ + })); +}, 'getInterestGroupAdAuctionData() one of "seller" and "sellers" is required'); + +subsetTest(promise_test, async test => { + const uuid = generateUuid(test); + const igConfig = makeTemplateIgConfig(uuid); + await joinInterestGroup(test, uuid, igConfig); + + await promise_rejects_js(test, TypeError, navigator.getInterestGroupAdAuctionData({ + seller: window.location.origin, + sellers: [{ + coordinatorOrigin: await BA.configureCoordinator(), + seller: window.location.origin, + }] + })); +}, 'getInterestGroupAdAuctionData() doesn\'t allow "seller" and "sellers" fields'); + +subsetTest(promise_test, async test => { + const uuid = generateUuid(test); + const igConfig = makeTemplateIgConfig(uuid); + await joinInterestGroup(test, uuid, igConfig); + + await promise_rejects_js(test, TypeError, navigator.getInterestGroupAdAuctionData({ + coordinatorOrigin: window.location.origin, + sellers: [{ + coordinatorOrigin: await BA.configureCoordinator(), + seller: window.location.origin, + }] + })); +}, 'getInterestGroupAdAuctionData() doesn\'t allow "coordinatorOrigin" and "sellers" fields'); + +subsetTest(promise_test, async test => { + const uuid = generateUuid(test); + const igConfig = makeTemplateIgConfig(uuid); + await joinInterestGroup(test, uuid, igConfig); + + await promise_rejects_js(test, TypeError, navigator.getInterestGroupAdAuctionData({ + coordinatorOrigin: window.location.origin, + sellers: [{ + coordinatorOrigin: await BA.configureCoordinator(), + seller: window.location.origin, + }, { + coordinatorOrigin: await BA.configureCoordinator(), + seller: window.location.origin, + } + ] + })); +}, 'getInterestGroupAdAuctionData() doesn\'t allow duplicate sellers in "sellers" field');