Skip to content

Commit

Permalink
Add WPT for multi-seller getInterestGroupAdAuctionData
Browse files Browse the repository at this point in the history
Change-Id: Ic65307069147f6325303fc35dfda29f733df6346
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6180162
Commit-Queue: Russ Hamilton <[email protected]>
Reviewed-by: Qingxin Wu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1409702}
  • Loading branch information
brusshamilton authored and chromium-wpt-export-bot committed Jan 22, 2025
1 parent d7ef1ba commit ecd260d
Showing 1 changed file with 167 additions and 0 deletions.
167 changes: 167 additions & 0 deletions fledge/tentative/get-interest-group-auction-data.https.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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');

0 comments on commit ecd260d

Please sign in to comment.