set-automatic-beacon.https.html (1775B)
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 9 <body> 10 <script> 11 promise_test(async(t) => { 12 const fencedframe = await attachFencedFrameContext( 13 {generator_api: 'fledge'}); 14 await fencedframe.execute(() => { 15 let event = { 16 eventType: "reserved.top_navigation_commit", 17 eventData: "a".repeat(64000), 18 destination: ["buyer"], 19 } 20 window.fence.setReportEventDataForAutomaticBeacons(event); 21 }); 22 }, 'setReportEventDataForAutomaticBeacons works at the size limit'); 23 24 promise_test(async(t) => { 25 const fencedframe = await attachFencedFrameContext( 26 {generator_api: 'fledge'}); 27 await fencedframe.execute(() => { 28 let event = { 29 eventType: "reserved.top_navigation_commit", 30 eventData: "a".repeat(64001), 31 destination: ["buyer"], 32 } 33 assert_throws_dom("SecurityError", () => { 34 window.fence.setReportEventDataForAutomaticBeacons(event); 35 }); 36 }); 37 }, 'setReportEventDataForAutomaticBeacons fails over the size limit'); 38 39 promise_test(async(t) => { 40 const fencedframe = await attachFencedFrameContext( 41 {generator_api: 'fledge'}); 42 await fencedframe.execute(() => { 43 let event = { 44 eventType: "reserved.top_navigation_commit", 45 eventData: "a".repeat(32), 46 destination: ["invalid"], 47 } 48 assert_throws_js(TypeError, () => { 49 window.fence.setReportEventDataForAutomaticBeacons(event); 50 }); 51 }); 52 }, 'setReportEventDataForAutomaticBeacons fails for invalid destination'); 53 </script> 54 </body>