automatic-beacon-click-handler.https.html (2374B)
1 <!DOCTYPE html> 2 <title>Test window.fence.setReportEventDataForAutomaticBeacons</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', register_beacon: true, 20 origin: get_host_info().HTTPS_REMOTE_ORIGIN}); 21 22 await fencedframe.execute(() => { 23 // This tests that old automatic beacon data is overwritten in subsequent 24 // calls to setReportEventDataForAutomaticBeacons(). 25 let start_beacon_event_old = { 26 eventType: "reserved.top_navigation_start", 27 eventData: "this should not be the data", 28 destination: ["buyer"], 29 } 30 window.fence.setReportEventDataForAutomaticBeacons(start_beacon_event_old); 31 }); 32 const start_event = { 33 eventType: "reserved.top_navigation_start", 34 eventData: "This is the start data", 35 destination: ["buyer"], 36 } 37 const commit_event = { 38 eventType: "reserved.top_navigation_commit", 39 eventData: "This is the commit data", 40 destination: ["buyer"], 41 } 42 // This will only set the automatic beacon data when the fenced frame is 43 // clicked. 44 await setupAutomaticBeacon(fencedframe, [start_event, commit_event], 45 NavigationTrigger.Click); 46 47 await actions.pointerMove(0, 0, {origin: fencedframe.element}) 48 .pointerDown() 49 .pointerUp() 50 .send(); 51 52 await verifyBeaconData(start_event.eventType, start_event.eventData, 53 get_host_info().HTTPS_REMOTE_ORIGIN); 54 await verifyBeaconData(commit_event.eventType, commit_event.eventData, 55 get_host_info().HTTPS_REMOTE_ORIGIN); 56 57 // Leaving this fenced frame around for subsequent tests can lead to 58 // flakiness. 59 document.body.removeChild(fencedframe.element); 60 }, 'Set and trigger an automatic beacon in a click handler'); 61 62 </script> 63 </body>