automatic-beacon-unfenced-top.https.html (2245B)
1 <!DOCTYPE html> 2 <title>Test automatic beacons sent from an '_unfencedTop' navigation</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 // The actual test is not in this file. Instead, this file sets up a fenced 17 // frame with automatic beacon data. It then causes the fenced frame to do an 18 // '_unfencedTop' navigation, which will cause the automatic beacon to send. The 19 // page that's navigated through '_unfencedTop' hosts the test, which simply 20 // checks that the automatic beacon was sent when the navigation happened. 21 // 22 // The reason we do this is because an '_unfencedTop' navigation replaces this 23 // page, so any test running here will stop. Other tests get around this by 24 // loading the test in a pop-up, but that doesn't allow the page to receive 25 // click events through test_driver.Actions(). 26 async function init() { 27 const actions = new test_driver.Actions(); 28 const fencedframe = await attachFencedFrameContext( 29 {generator_api: 'fledge', register_beacon: true, 30 origin: get_host_info().HTTPS_REMOTE_ORIGIN}); 31 32 const beacon_event = { 33 eventType: "reserved.top_navigation_commit", 34 eventData: "This is the beacon data!", 35 destination: ["buyer"], 36 randomField: "blah", 37 } 38 await setupAutomaticBeacon(fencedframe, [beacon_event], 39 "resources/automatic-beacon-unfenced-page.html", NavigationTrigger.Click, 40 "_unfencedTop"); 41 42 await actions.setContext(window) 43 .pointerMove(0, 0, {origin: fencedframe.element}) 44 .pointerDown() 45 .pointerUp() 46 .send(); 47 48 // After this point, the top-level frame will be navigated to 49 // 'automatic-beacon-unfenced-page.html', which will verify that the automatic 50 // beacon was sent. 51 } 52 53 init(); 54 </script> 55 </body>