fence-report-event-cross-origin-no-embedder-opt-in.https.html (1884B)
1 <!DOCTYPE html> 2 <title>Test window.fence.reportEvent from cross-origin subframes.</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/utils.js"></script> 6 <script src="/common/dispatcher/dispatcher.js"></script> 7 <script src="/common/get-host-info.sub.js"></script> 8 <script src="resources/automatic-beacon-helper.js"></script> 9 <script src="resources/utils.js"></script> 10 11 <body> 12 <script> 13 promise_test(async(t) => { 14 const fencedframe = await attachFencedFrameContext({ 15 generator_api: 'fledge', 16 headers: [[ 17 'Allow-Cross-Origin-Event-Reporting', '?0' 18 ]], 19 register_beacon: true 20 }); 21 // Perform a cross-origin navigation. Since the navigation is 22 // content-initiated, the fenced frame reporting metadata will persist. 23 await navigateFrameContext(fencedframe, { 24 origin: get_host_info().HTTPS_REMOTE_ORIGIN, 25 }); 26 await fencedframe.execute(() => { 27 // This page will call reportEvent() twice. Once for a destination enum 28 // event (i.e. an event with an eventType/eventData specified), and once for 29 // a destination URL event (i.e. an event with a destinationURL specified). 30 const destination_enum_event = { 31 eventType: "click", 32 eventData: "enum", 33 destination: ["buyer"], 34 crossOriginExposed: true 35 } 36 window.fence.reportEvent(destination_enum_event); 37 38 const destination_url = new URL(BEACON_URL + "?type=url", 39 get_host_info().HTTPS_ORIGIN); 40 const destination_url_event = { 41 destinationURL: destination_url, 42 crossOriginExposed: true 43 } 44 window.fence.reportEvent(destination_url_event); 45 }); 46 await verifyBeaconData("click", "enum", null, false, t); 47 await verifyBeaconData("url", "<No data>", null, false, t); 48 }, 'Cross-origin window.fence.reportEvent without embedder opt-in'); 49 </script> 50 </body>