report-only-and-enforce.https.sub.html (1523B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script src='/resources/testharness.js'></script> 5 <script src='/resources/testharnessreport.js'></script> 6 <script src='/resources/testdriver.js'></script> 7 <script src='/resources/testdriver-vendor.js'></script> 8 <script src='../../mediacapture-streams/permission-helper.js'></script> 9 <script src='/reporting/resources/report-helper.js'></script> 10 </head> 11 <body> 12 <script> 13 const base_url = `${location.protocol}//${location.host}`; 14 const endpoint = `${base_url}/reporting/resources/report.py`; 15 const enforcing_id = '69c90b97-8b7c-4439-b5d2-ff03f237b2b2'; 16 const report_only_id = '9d095a14-6b1c-40e1-be19-55a1fec97d11'; 17 18 promise_test(async t => { 19 await setMediaPermission("granted", ["camera","microphone"]); 20 await promise_rejects_dom( 21 t, "NotAllowedError", navigator.mediaDevices.getUserMedia({video: true}), 22 "UserMedia camera access should not be allowed in this document."); 23 while(true) { 24 await wait(100); 25 const reports = await pollReports(endpoint, enforcing_id); 26 if (reports.length) { 27 checkReportExists(reports, 'permissions-policy-violation', location.href); 28 break; 29 } 30 } 31 const report_only_reports = await pollReports(endpoint, report_only_id); 32 assert_equals(report_only_reports.length, 0, "Report-only endpoint should not receive report."); 33 }, "Enforcing policy receives reports when both enforcing and report-only policies are set."); 34 </script> 35 </body> 36 </html>