automatic-beacon-component-ad.https.html (2504B)
1 <!DOCTYPE html> 2 <title>Test automatic beacons in ad components</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="resources/utils.js"></script> 8 <script src="/resources/testdriver.js"></script> 9 <script src="/resources/testdriver-actions.js"></script> 10 <script src="/resources/testdriver-vendor.js"></script> 11 <script src="/common/get-host-info.sub.js"></script> 12 <script src="resources/automatic-beacon-helper.js"></script> 13 14 <body> 15 <script> 16 promise_test(async(t) => { 17 const actions = new test_driver.Actions(); 18 const fencedframe = await attachFencedFrameContext({ 19 generator_api: 'fledge', 20 register_beacon: true, 21 component_origin: get_host_info().HTTPS_REMOTE_ORIGIN, 22 num_components: 1, 23 // These headers will also be given to the component ad. 24 headers: [["Allow-Fenced-Frame-Automatic-Beacons", "true"]] 25 }); 26 const new_url = new URL("resources/close.html", location.href); 27 28 await fencedframe.execute(async (new_url) => { 29 window.fence.setReportEventDataForAutomaticBeacons({ 30 eventType: "reserved.top_navigation_start", 31 eventData: "this is the beacon data from the root fenced frame", 32 destination: ["buyer"], 33 crossOriginExposed: true, 34 }); 35 36 // Add an ad component that will perform the top-level navigation. 37 // The headers are the same as the ones given to `fencedframe`. 38 const ad_component = await attachComponentFencedFrameContext(); 39 await ad_component.execute(async (new_url) => { 40 window.fence.setReportEventDataForAutomaticBeacons({ 41 eventType: "reserved.top_navigation_start", 42 eventData: "this is the beacon data from the ad component", 43 destination: ["buyer"], 44 crossOriginExposed: true, 45 }); 46 addEventListener("click", (event) => { 47 window.open(new_url); 48 }); 49 }, [new_url]); 50 }, [new_url]); 51 52 await actions.pointerMove(0, 0, {origin: fencedframe.element}) 53 .pointerDown() 54 .pointerUp() 55 .send(); 56 57 // The component frame should not use its parent's data. 58 // The component frame's data should not have been set. 59 // The referrer header should be set to the root ad frame's origin. 60 await verifyBeaconData("reserved.top_navigation_start", "<No data>"); 61 }, 'Automatic beacon in an ad component should send without data with a ' + 62 'header opt-in.'); 63 </script> 64 </body>