Skip to content

Commit

Permalink
Bug 1846805 [wpt PR 41294] - Add web platform test for recency in gen…
Browse files Browse the repository at this point in the history
…erateBid(), a=testonly

Automatic update from web-platform-tests
Add web platform test for recency in generateBid()

Add a web platform test to test recency of browserSignals in
generateBid() is below a certain 5 minutes threshold and is rounded
to multiple of 100 milliseconds.

Re-introduces code from crrev.com/c/4727328 that was reverted due to an mac11-arm64-rel failure. The failure was fixed in this CL by removing the non-virtual expected file.

Bug: 1425952
Change-Id: I9922ce0ec79b9d73ede1d3d9ffd1d1dc498c3798
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4742524
Reviewed-by: Caleb Raitto <caraitto@chromium.org>
Commit-Queue: Tianyang Xu <xtlsheep@google.com>
Cr-Commit-Position: refs/heads/main@{#1179687}

--

wpt-commits: 9946d998fd588bed9f97dc7fa465896c54b910b0
wpt-pr: 41294
  • Loading branch information
Tianyang Xu authored and moz-wptsync-bot committed Aug 17, 2023
1 parent c56d7f5 commit 1645ecf
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 182 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// META: script=/resources/testdriver.js
// META: script=/common/utils.js
// META: script=resources/fledge-util.js
// META: timeout=long

"use strict;"

promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
{ generateBid:
`if (browserSignals.recency === undefined)
throw new Error("Missing recency in browserSignals.")
if (browserSignals.recency < 0)
throw new Error("Recency is a negative value.")
if (browserSignals.recency > 30000)
throw new Error("Recency is over 30 seconds threshold.")
if (browserSignals.recency % 100 !== 0)
throw new Error("Recency is not rounded to multiple of 100 milliseconds.")
return {'bid': 9,
'render': interestGroup.ads[0].renderUrl};`,
reportWin:
`sendReportTo('${createBidderReportUrl(uuid)}');` },
// expectedReportUrls
[createBidderReportUrl(uuid)]
);
}, 'Check recency in generateBid() is below a certain threshold and rounded ' +
'to multiple of 100 milliseconds.');
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
// reportWin:
null,
'',
{ reportResult:
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
reportWin:
'' },
// expectedReportUrls:
[`${createSellerBeaconUrl(uuid)}, body: `],
// renderUrlOverride:
Expand All @@ -32,12 +30,10 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
'',
// reportWin:
null,
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`,
{ reportResult:
'',
reportWin:
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});` },
// expectedReportUrls:
[`${createBidderBeaconUrl(uuid)}, body: `],
// renderUrlOverride:
Expand All @@ -55,12 +51,10 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
// reportWin:
null,
'',
{ reportResult:
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
reportWin:
'' },
// expectedReportUrls:
[`${createSellerBeaconUrl(uuid)}, body: body`],
// renderUrlOverride:
Expand All @@ -78,12 +72,10 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
'',
// reportWin:
null,
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`,
{ reportResult:
'',
reportWin:
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});` },
// expectedReportUrls:
[`${createBidderBeaconUrl(uuid)}, body: body`],
// renderUrlOverride:
Expand All @@ -101,12 +93,10 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
// reportWin:
null,
'',
{ reportResult:
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
reportWin:
'' },
// expectedReportUrls:
[`${createSellerBeaconUrl(uuid)}, body: body1`,
`${createSellerBeaconUrl(uuid)}, body: body2`],
Expand All @@ -130,12 +120,10 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
'',
// reportWin:
null,
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`,
{ reportResult:
'',
reportWin:
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});` },
// expectedReportUrls:
[`${createBidderBeaconUrl(uuid)}, body: body1`,
`${createBidderBeaconUrl(uuid)}, body: body2`],
Expand All @@ -159,13 +147,11 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`registerAdBeacon({beacon1: '${createSellerBeaconUrl(uuid, '1')}',
beacon2: '${createSellerBeaconUrl(uuid, '2')}'});`,
// reportWin:
null,
'',
{ reportResult:
`registerAdBeacon({beacon1: '${createSellerBeaconUrl(uuid, '1')}',
beacon2: '${createSellerBeaconUrl(uuid, '2')}'});`,
reportWin:
'' },
// expectedReportUrls:
[`${createSellerBeaconUrl(uuid, '1')}, body: body1`,
`${createSellerBeaconUrl(uuid, '2')}, body: body2`],
Expand All @@ -189,13 +175,12 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
'',
// reportWin:
null,
`registerAdBeacon({beacon1: '${createBidderBeaconUrl(uuid, '1')}',
beacon2: '${createBidderBeaconUrl(uuid, '2')}'});`,
{ reportResult:
'',
reportWin:
`registerAdBeacon({beacon1: '${createBidderBeaconUrl(uuid, '1')}',
beacon2: '${createBidderBeaconUrl(uuid, '2')}'});`
},
// expectedReportUrls:
[`${createBidderBeaconUrl(uuid, '1')}, body: body1`,
`${createBidderBeaconUrl(uuid, '2')}, body: body2`],
Expand All @@ -219,12 +204,10 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
// reportWin:
null,
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`,
{ reportResult:
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
reportWin:
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});` },
// expectedReportUrls:
[`${createSellerBeaconUrl(uuid)}, body: body`,
`${createBidderBeaconUrl(uuid)}, body: body`],
Expand All @@ -243,12 +226,10 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
// reportWin:
null,
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`,
{ reportResult:
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
reportWin:
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});` },
// expectedReportUrls:
[`${createSellerBeaconUrl(uuid)}, body: body1`,
`${createBidderBeaconUrl(uuid)}, body: body2`],
Expand All @@ -272,16 +253,16 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
// Multiple registerAdBeacon() call should result in an exception,
// throwing away all beacons and other types of reports.
`sendReportTo('${createSellerReportUrl(uuid)}');
registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});
registerAdBeacon({beacon1: '${createSellerBeaconUrl(uuid)}'});`,
// reportWin:
'sellerSignals === null',
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`,
{ reportResult:
// Multiple registerAdBeacon() call should result in an exception,
// throwing away all beacons and other types of reports.
`sendReportTo('${createSellerReportUrl(uuid)}');
registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});
registerAdBeacon({beacon1: '${createSellerBeaconUrl(uuid)}'});`,
reportWinSuccessCondition:
'sellerSignals === null',
reportWin:
`registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});` },
// expectedReportUrls:
[`${createBidderBeaconUrl(uuid)}, body: body`],
// renderUrlOverride:
Expand All @@ -299,16 +280,14 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
// reportWin:
null,
// Multiple registerAdBeacon() call should result in an exception,
// throwing away all beacons and other types of reports.
`sendReportTo('${createBidderReportUrl(uuid)}');
registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});
registerAdBeacon({beacon1: '${createBidderBeaconUrl(uuid)}'});`,
{ reportResult:
`registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`,
reportWin:
// Multiple registerAdBeacon() call should result in an exception,
// throwing away all beacons and other types of reports.
`sendReportTo('${createBidderReportUrl(uuid)}');
registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});
registerAdBeacon({beacon1: '${createBidderBeaconUrl(uuid)}'});` },
// expectedReportUrls:
[`${createSellerBeaconUrl(uuid)}, body: body`],
// renderUrlOverride:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ async function runReportArgumentValidationTest(
uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
reportResultSuccessCondition,
`sendReportTo('${createSellerReportUrl(uuid)}');`,
// reportWin:
reportWinSuccessCondition,
`sendReportTo('${createBidderReportUrl(uuid)}');`,
{ reportResultSuccessCondition:
reportResultSuccessCondition,
reportResult:
`sendReportTo('${createSellerReportUrl(uuid)}');`,
reportWinSuccessCondition:
reportWinSuccessCondition,
reportWin:
`sendReportTo('${createBidderReportUrl(uuid)}');` },
[createSellerReportUrl(uuid), createBidderReportUrl(uuid)]
);
}
Expand All @@ -32,13 +34,13 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`sendReportTo('${createSellerReportUrl(uuid)}');
return 45;`,
// reportWin:
'sellerSignals === 45',
`sendReportTo('${createBidderReportUrl(uuid)}');`,
{ reportResult:
`sendReportTo('${createSellerReportUrl(uuid)}');
return 45;`,
reportWinSuccessCondition:
'sellerSignals === 45',
reportWin:
`sendReportTo('${createBidderReportUrl(uuid)}');` },
// expectedReportUrls:
[createSellerReportUrl(uuid), createBidderReportUrl(uuid)]
);
Expand All @@ -48,13 +50,13 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`sendReportTo('${createSellerReportUrl(uuid)}');
return 'foo';`,
// reportWin:
'sellerSignals === "foo"',
`sendReportTo('${createBidderReportUrl(uuid)}');`,
{ reportResult:
`sendReportTo('${createSellerReportUrl(uuid)}');
return 'foo';`,
reportWinSuccessCondition:
'sellerSignals === "foo"',
reportWin:
`sendReportTo('${createBidderReportUrl(uuid)}');` },
// expectedReportUrls:
[createSellerReportUrl(uuid), createBidderReportUrl(uuid)]
);
Expand All @@ -64,13 +66,13 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`sendReportTo('${createSellerReportUrl(uuid)}');
return [3, 1, 2];`,
// reportWin:
'JSON.stringify(sellerSignals) === "[3,1,2]"',
`sendReportTo('${createBidderReportUrl(uuid)}');`,
{ reportResult:
`sendReportTo('${createSellerReportUrl(uuid)}');
return [3, 1, 2];`,
reportWinSuccessCondition:
'JSON.stringify(sellerSignals) === "[3,1,2]"',
reportWin:
`sendReportTo('${createBidderReportUrl(uuid)}');` },
// expectedReportUrls:
[createSellerReportUrl(uuid), createBidderReportUrl(uuid)]
);
Expand All @@ -80,13 +82,13 @@ promise_test(async test => {
const uuid = generateUuid(test);
await runReportTest(
test, uuid,
// reportResult:
null,
`sendReportTo('${createSellerReportUrl(uuid)}');
return {a: 4, b:['c', null, {}]};`,
// reportWin:
`JSON.stringify(sellerSignals) === '{"a":4,"b":["c",null,{}]}'`,
`sendReportTo('${createBidderReportUrl(uuid)}');`,
{ reportResult:
`sendReportTo('${createSellerReportUrl(uuid)}');
return {a: 4, b:['c', null, {}]};`,
reportWinSuccessCondition:
`JSON.stringify(sellerSignals) === '{"a":4,"b":["c",null,{}]}'`,
reportWin:
`sendReportTo('${createBidderReportUrl(uuid)}');` },
// expectedReportUrls:
[createSellerReportUrl(uuid), createBidderReportUrl(uuid)]
);
Expand Down
Loading

0 comments on commit 1645ecf

Please sign in to comment.