fence-report-event-cross-origin-urn-iframe.https.html (1516B)
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 outer_iframe = await attachIFrameContext({ 15 generator_api: 'fledge', 16 headers: [[ 17 'Allow-Cross-Origin-Event-Reporting', '?1' 18 ]], 19 register_beacon: true 20 }); 21 await outer_iframe.execute(async () => { 22 const inner_iframe = await attachIFrameContext({ 23 origin: get_host_info().HTTPS_REMOTE_ORIGIN, 24 }); 25 await inner_iframe.execute(() => { 26 const destination_url = new URL(BEACON_URL + "?type=url", 27 get_host_info().HTTPS_ORIGIN); 28 window.fence.reportEvent({ 29 eventType: "click", 30 eventData: "enum", 31 destination: ["buyer"], 32 crossOriginExposed: true 33 }); 34 window.fence.reportEvent({ 35 destinationURL: destination_url, 36 crossOriginExposed: true 37 }); 38 }); 39 }); 40 // Check that both the destination enum and destination URL events were 41 // reported. 42 await nextBeacon("click", "enum"); 43 await nextBeacon("url", "<No data>"); 44 }, 'window.fence.reportEvent from a cross-origin iframe'); 45 </script> 46 </body>