fence-report-event-destination-url.https.html (1513B)
1 <!DOCTYPE html> 2 <title>Test window.fence.reportEvent destination URL.</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({generator_api: 'fledge'}); 13 await fencedframe.execute(() => { 14 // The destinationURL must be a valid URL. 15 let event = {destinationURL: "foobarbaz"}; 16 assert_throws_js(TypeError, () => {window.fence.reportEvent(event);}); 17 18 // The destinationURL must be an https URL. 19 event.destinationURL = "http://3pat.com"; 20 assert_throws_js(TypeError, () => {window.fence.reportEvent(event);}); 21 22 event.destinationURL = "https://3pat.com"; 23 window.fence.reportEvent(event); 24 25 // `eventType` isn't allowed. 26 event.eventType = 'click'; 27 assert_throws_js(TypeError, () => {window.fence.reportEvent(event);}); 28 event.eventType = undefined; 29 30 // `eventData` isn't allowed. 31 event.eventData = 'payload'; 32 assert_throws_js(TypeError, () => {window.fence.reportEvent(event);}); 33 event.eventData = undefined; 34 35 // `destination` isn't allowed. 36 event.destination = ['buyer']; 37 assert_throws_js(TypeError, () => {window.fence.reportEvent(event);}); 38 event.destination = undefined; 39 }); 40 }, 'window.fence.reportEvent destinationURL'); 41 </script> 42 </body>