Skip to content

Commit

Permalink
[ProtectedAudience] Add more generateBid() browserSignals tests.
Browse files Browse the repository at this point in the history
In particular, make sure that bidCount and prevWins are updated only
once when an ad from a single auction is used twice.

Bug: 40261114
Change-Id: I1a5fcc9be04397acd6b91437b5767fa67a22f12e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5344201
Reviewed-by: Maks Orlovich <[email protected]>
Commit-Queue: mmenke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1269755}
  • Loading branch information
Matt Menke authored and chromium-wpt-export-bot committed Mar 7, 2024
1 parent fbdb9fc commit 04aeef2
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
73 changes: 71 additions & 2 deletions fledge/tentative/generate-bid-browser-signals.https.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ subsetTest(promise_test, async test => {

// Run two auctions at once, without any navigations.
// "bidCount" should be 0 for both auctions.
fencedFrameConfigs =
let fencedFrameConfigs =
await Promise.all([runBasicFledgeTestExpectingWinner(test, uuid),
runBasicFledgeTestExpectingWinner(test, uuid)]);

Expand All @@ -281,6 +281,40 @@ subsetTest(promise_test, async test => {
await runBasicFledgeTestExpectingWinner(test, uuid);
}, 'browserSignals.bidCount two auctions at once.');

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

// Use a tracker URL for the ad. It won't be successfully loaded, due to missing
// the fenced frame header, but it should be fetched twice.
let trackedRenderURL =
createTrackerURL(window.location.origin, uuid, 'track_get', /*id=*/'ad');
await joinInterestGroup(
test, uuid,
{ name: uuid,
biddingLogicURL: createBidCountBiddingScriptURL(0),
ads: [{ renderURL: trackedRenderURL }]
});

let fencedFrameConfig = await runBasicFledgeTestExpectingWinner(test, uuid);

// Start navigating two frames to the winning ad.
createAndNavigateFencedFrame(test, fencedFrameConfig);
createAndNavigateFencedFrame(test, fencedFrameConfig);

// Wait for both navigations to have requested ads (and thus to have updated
// bid counts).
await waitForObservedRequests(uuid, [createSellerReportURL(uuid),
trackedRenderURL,
trackedRenderURL]);

// Check that "bidCount" has increased by only 1.
await joinInterestGroup(
test, uuid,
{ name: uuid,
biddingLogicURL: createBidCountBiddingScriptURL(1) });
await runBasicFledgeTestExpectingWinner(test, uuid);
}, 'browserSignals.bidCount incremented once when winning ad used twice.');

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

Expand Down Expand Up @@ -684,7 +718,7 @@ subsetTest(promise_test, async test => {

// Run two auctions at once, without any navigations.
// "prevWinsMs" should be empty for both auctions.
fencedFrameConfigs =
let fencedFrameConfigs =
await Promise.all([runBasicFledgeTestExpectingWinner(test, uuid),
runBasicFledgeTestExpectingWinner(test, uuid)]);

Expand All @@ -708,6 +742,41 @@ subsetTest(promise_test, async test => {
await runBasicFledgeTestExpectingWinner(test, uuid);
}, 'browserSignals.prevWinsMs two auctions at once.');

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

// Use a tracker URL for the ad. It won't be successfully loaded, due to missing
// the fenced frame header, but it should be fetched twice.
let trackedRenderURL =
createTrackerURL(window.location.origin, uuid, 'track_get', /*id=*/'ad');
await joinInterestGroup(
test, uuid,
{ name: uuid,
biddingLogicURL: createPrevWinsMsBiddingScriptURL([]),
ads: [{ renderURL: trackedRenderURL }]
});

let fencedFrameConfig = await runBasicFledgeTestExpectingWinner(test, uuid);

// Start navigating two frames to the winning ad.
createAndNavigateFencedFrame(test, fencedFrameConfig);
createAndNavigateFencedFrame(test, fencedFrameConfig);

// Wait for both navigations to have requested ads (and thus to have updated
// "prevWinsMs").
await waitForObservedRequests(uuid, [createSellerReportURL(uuid),
trackedRenderURL,
trackedRenderURL]);

// Check that "prevWins" has only a single win.
await joinInterestGroup(
test, uuid,
{ name: uuid,
biddingLogicURL: createPrevWinsMsBiddingScriptURL(
[[0, {renderURL: trackedRenderURL}]]) });
await runBasicFledgeTestExpectingWinner(test, uuid);
}, 'browserSignals.prevWinsMs has only one win when winning ad used twice.');

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

Expand Down
2 changes: 2 additions & 0 deletions fledge/tentative/resources/request-tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ def simple_response(request, response, status_code, status_message, body,
content_type=b"text/plain"):
response.status = (status_code, status_message)
response.headers.set(b"Content-Type", content_type)
# Force refetch on reuse, so multiple requests to tracked URLs are all visible.
response.headers.set(b"Cache-control", b"no-store")
return body

0 comments on commit 04aeef2

Please sign in to comment.