fence-report-event-cross-origin-content-initiated.https.html (1894B)
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', '?1' 18 ]], 19 register_beacon: true, 20 origin: get_host_info().HTTPS_ORIGIN 21 }); 22 // Perform a cross-origin navigation. Since the navigation is 23 // content-initiated, the fenced frame reporting metadata will persist. 24 await navigateFrameContext(fencedframe, { 25 origin: get_host_info().HTTPS_REMOTE_ORIGIN, 26 }); 27 await fencedframe.execute(() => { 28 // This page will call reportEvent() twice. Once for a destination enum 29 // event (i.e. an event with an eventType/eventData specified), and once for 30 // a destination URL event (i.e. an event with a destinationURL specified). 31 const destination_enum_event = { 32 eventType: "click", 33 eventData: "enum", 34 destination: ["buyer"], 35 crossOriginExposed: true 36 } 37 window.fence.reportEvent(destination_enum_event); 38 39 const destination_url = new URL(BEACON_URL + "?type=url", 40 get_host_info().HTTPS_ORIGIN); 41 const destination_url_event = { 42 destinationURL: destination_url, 43 crossOriginExposed: true 44 } 45 window.fence.reportEvent(destination_url_event); 46 }); 47 await nextBeacon("click", "enum"); 48 await nextBeacon("url", "<No data>"); 49 }, 'window.fence.reportEvent from a content-initiated cross-origin navigation'); 50 </script> 51 </body>