diff --git a/testing/web-platform/tests/fledge/tentative/register-ad-beacon.https.sub.window.js b/testing/web-platform/tests/fledge/tentative/register-ad-beacon.https.sub.window.js new file mode 100644 index 000000000000..3df6b408a570 --- /dev/null +++ b/testing/web-platform/tests/fledge/tentative/register-ad-beacon.https.sub.window.js @@ -0,0 +1,321 @@ +// META: script=/resources/testdriver.js +// META: script=/common/utils.js +// META: script=resources/fledge-util.js +// META: timeout=long + +promise_test(async test => { + const uuid = generateUuid(test); + await runReportTest( + test, uuid, + // reportResult: + null, + `registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`, + // reportWin: + null, + '', + // expectedReportUrls: + [`${createSellerBeaconUrl(uuid)}, body: `], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon", + eventData: "", + destination: ["seller"] + });`) + ); +}, 'Seller calls registerAdBeacon().'); + +promise_test(async test => { + const uuid = generateUuid(test); + await runReportTest( + test, uuid, + // reportResult: + null, + '', + // reportWin: + null, + `registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`, + // expectedReportUrls: + [`${createBidderBeaconUrl(uuid)}, body: `], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon", + eventData: "", + destination: ["buyer"] + });`) + ); +}, 'Buyer calls registerAdBeacon().'); + +promise_test(async test => { + const uuid = generateUuid(test); + await runReportTest( + test, uuid, + // reportResult: + null, + `registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`, + // reportWin: + null, + '', + // expectedReportUrls: + [`${createSellerBeaconUrl(uuid)}, body: body`], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon", + eventData: "body", + destination: ["seller"] + });`) + ); +}, 'Seller calls registerAdBeacon(), beacon sent with body.'); + +promise_test(async test => { + const uuid = generateUuid(test); + await runReportTest( + test, uuid, + // reportResult: + null, + '', + // reportWin: + null, + `registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`, + // expectedReportUrls: + [`${createBidderBeaconUrl(uuid)}, body: body`], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon", + eventData: "body", + destination: ["buyer"] + });`) + ); +}, 'Buyer calls registerAdBeacon(), beacon sent with body.'); + +promise_test(async test => { + const uuid = generateUuid(test); + await runReportTest( + test, uuid, + // reportResult: + null, + `registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`, + // reportWin: + null, + '', + // expectedReportUrls: + [`${createSellerBeaconUrl(uuid)}, body: body1`, + `${createSellerBeaconUrl(uuid)}, body: body2`], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon", + eventData: "body1", + destination: ["seller"] + }); + window.fence.reportEvent({ + eventType: "beacon", + eventData: "body2", + destination: ["seller"] + });`) + ); +}, 'Seller calls registerAdBeacon(). reportEvent() called twice.'); + +promise_test(async test => { + const uuid = generateUuid(test); + await runReportTest( + test, uuid, + // reportResult: + null, + '', + // reportWin: + null, + `registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`, + // expectedReportUrls: + [`${createBidderBeaconUrl(uuid)}, body: body1`, + `${createBidderBeaconUrl(uuid)}, body: body2`], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon", + eventData: "body1", + destination: ["buyer"] + }); + window.fence.reportEvent({ + eventType: "beacon", + eventData: "body2", + destination: ["buyer"] + });`) + ); +}, 'Buyer calls registerAdBeacon(). reportEvent() called twice.'); + +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, + '', + // expectedReportUrls: + [`${createSellerBeaconUrl(uuid, '1')}, body: body1`, + `${createSellerBeaconUrl(uuid, '2')}, body: body2`], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon1", + eventData: "body1", + destination: ["seller"] + }); + window.fence.reportEvent({ + eventType: "beacon2", + eventData: "body2", + destination: ["seller"] + });`) + ); +}, 'Seller calls registerAdBeacon() with multiple beacons.'); + +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')}'});`, + // expectedReportUrls: + [`${createBidderBeaconUrl(uuid, '1')}, body: body1`, + `${createBidderBeaconUrl(uuid, '2')}, body: body2`], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon1", + eventData: "body1", + destination: ["buyer"] + }); + window.fence.reportEvent({ + eventType: "beacon2", + eventData: "body2", + destination: ["buyer"] + });`) + ); +}, 'Buyer calls registerAdBeacon() with multiple beacons.'); + +promise_test(async test => { + const uuid = generateUuid(test); + await runReportTest( + test, uuid, + // reportResult: + null, + `registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`, + // reportWin: + null, + `registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`, + // expectedReportUrls: + [`${createSellerBeaconUrl(uuid)}, body: body`, + `${createBidderBeaconUrl(uuid)}, body: body`], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon", + eventData: "body", + destination: ["seller","buyer"] + });`) + ); +}, 'Seller and buyer call registerAdBeacon() with shared reportEvent() call.'); + +promise_test(async test => { + const uuid = generateUuid(test); + await runReportTest( + test, uuid, + // reportResult: + null, + `registerAdBeacon({beacon: '${createSellerBeaconUrl(uuid)}'});`, + // reportWin: + null, + `registerAdBeacon({beacon: '${createBidderBeaconUrl(uuid)}'});`, + // expectedReportUrls: + [`${createSellerBeaconUrl(uuid)}, body: body1`, + `${createBidderBeaconUrl(uuid)}, body: body2`], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon", + eventData: "body1", + destination: ["seller"] + }); + window.fence.reportEvent({ + eventType: "beacon", + eventData: "body2", + destination: ["buyer"] + });`) + ); +}, 'Seller and buyer call registerAdBeacon() with separate reportEvent() calls.'); + +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)}'});`, + // expectedReportUrls: + [`${createBidderBeaconUrl(uuid)}, body: body`], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon", + eventData: "body", + destination: ["seller","buyer"] + });`) + ); +}, 'Seller calls registerAdBeacon() multiple times.'); + +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)}'});`, + // expectedReportUrls: + [`${createSellerBeaconUrl(uuid)}, body: body`], + // renderUrlOverride: + createRenderUrl( + uuid, + `window.fence.reportEvent({ + eventType: "beacon", + eventData: "body", + destination: ["seller","buyer"] + });`) + ); +}, 'Buyer calls registerAdBeacon() multiple times.'); diff --git a/testing/web-platform/tests/fledge/tentative/resources/fenced-frame.sub.py b/testing/web-platform/tests/fledge/tentative/resources/fenced-frame.sub.py new file mode 100644 index 000000000000..c29bb6fecccf --- /dev/null +++ b/testing/web-platform/tests/fledge/tentative/resources/fenced-frame.sub.py @@ -0,0 +1,19 @@ +# Fenced frame HTML body. Generated by a Python file to avoid having quotes in +# the injected script escaped, which the test server does to *.html files. +def main(request, response): + response.status = (200, b"OK") + response.headers.set(b"Content-Type", b"text/html") + response.headers.set(b"Supports-Loading-Mode", b"fenced-frame") + + return """ + + +
+ + + + """ + + diff --git a/testing/web-platform/tests/fledge/tentative/resources/fenced_frame.sub.html b/testing/web-platform/tests/fledge/tentative/resources/fenced_frame.sub.html deleted file mode 100644 index eaca3f49fd15..000000000000 --- a/testing/web-platform/tests/fledge/tentative/resources/fenced_frame.sub.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/testing/web-platform/tests/fledge/tentative/resources/fenced_frame.sub.html.headers b/testing/web-platform/tests/fledge/tentative/resources/fenced_frame.sub.html.headers deleted file mode 100644 index bc74b5851b6c..000000000000 --- a/testing/web-platform/tests/fledge/tentative/resources/fenced_frame.sub.html.headers +++ /dev/null @@ -1,2 +0,0 @@ -Content-Type: text/html -Supports-Loading-Mode: fenced-frame diff --git a/testing/web-platform/tests/fledge/tentative/resources/fledge-util.js b/testing/web-platform/tests/fledge/tentative/resources/fledge-util.js index 9f95a59e43a3..6432752e075c 100644 --- a/testing/web-platform/tests/fledge/tentative/resources/fledge-util.js +++ b/testing/web-platform/tests/fledge/tentative/resources/fledge-util.js @@ -30,6 +30,17 @@ function createSellerReportUrl(uuid, id = '1') { `seller_report_${id}`); } +// Much like above ReportUrl methods, except designed for beacons, which +// are expected to be POSTs. +function createBidderBeaconUrl(uuid, id = '1') { + return createTrackerUrl(window.location.origin, uuid, `track_post`, + `bidder_beacon_${id}`); +} +function createSellerBeaconUrl(uuid, id = '1') { + return createTrackerUrl(window.location.origin, uuid, `track_post`, + `seller_beacon_${id}`); +} + // Generates a UUID and registers a cleanup method with the test fixture to // request a URL from the request tracking script that clears all data // associated with the generated uuid when requested. @@ -44,10 +55,13 @@ function generateUuid(test) { return uuid; } -// Repeatedly requests "request_list" URL until exactly the URLs listed -// in "expectedRequests" have been observed by the request tracker script (in +// Repeatedly requests "request_list" URL until exactly the entries in +// "expectedRequests" have been observed by the request tracker script (in // any order, since report URLs are not guaranteed to be sent in any order). // +// Elements of `expectedRequests` should either be URLs, in the case of GET +// requests, or "