geolocation-report-only.https.html (1166B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script src='/resources/testharness.js'></script> 5 <script src='/resources/testharnessreport.js'></script> 6 </head> 7 <body> 8 <script> 9 var check_report_format = ([reports, observer]) => { 10 let report = reports[0]; 11 assert_equals(report.type, "permissions-policy-violation"); 12 assert_equals(report.body.featureId, "geolocation"); 13 assert_equals(report.body.disposition, "report"); 14 }; 15 16 promise_test(async t => { 17 const report = new Promise(resolve => { 18 new ReportingObserver((reports, observer) => resolve([reports, observer]), 19 {types: ['permissions-policy-violation']}).observe(); 20 }); 21 try { 22 await new Promise((resolve, reject) => { 23 navigator.geolocation.getCurrentPosition(resolve, reject); 24 }); 25 check_report_format(await report); 26 } catch (err) { 27 // In case the getCurrentPosition call was rejected due to user permissions, 28 // the report should be generated anyway. Wait for it and check the format 29 // before failing this test. 30 check_report_format(await report); 31 throw err; 32 } 33 }, "Geolocation report only mode"); 34 </script> 35 </body> 36 </html>