report-event-reserved-event.https.html (1301B)
1 <!DOCTYPE html> 2 <title>Test window.fence.reportEvent</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 9 <body> 10 <script> 11 promise_test(async(t) => { 12 const fencedframe = await attachFencedFrameContext({ 13 generator_api: "fledge", 14 register_beacon: true, 15 }); 16 const new_url = new URL("resources/dummy.html", location.href); 17 const beacon_data = "This is the beacon data!"; 18 const beacon_type = "reserved.top_navigation_commit"; 19 20 await fencedframe.execute( 21 (new_url, beacon_data, beacon_type) => { 22 let beacon_event = { 23 eventType: beacon_type, 24 eventData: beacon_data, 25 destination: ["buyer", "seller"], 26 }; 27 window.fence.reportEvent(beacon_event); 28 }, 29 [new_url, beacon_data, beacon_type] 30 ); 31 32 const timeout = new Promise(resolve => t.step_timeout(resolve, 1000)); 33 const result = await Promise.race( 34 [nextBeacon(beacon_type, beacon_data), timeout]); 35 assert_true(typeof result === "undefined", 36 "A beacon should not have been sent."); 37 38 }, 'Reserved events should not be callable through reportEvent()'); 39 </script> 40 </body>