serial-reporting.https.html (1935B)
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 </head> 9 <body> 10 <script> 11 var check_report_format = ([reports, observer]) => { 12 let report = reports[0]; 13 assert_equals(report.type, "permissions-policy-violation"); 14 assert_equals(report.url, document.location.href); 15 assert_equals(report.body.featureId, "serial"); 16 assert_equals(report.body.sourceFile, document.location.href); 17 assert_equals(typeof report.body.lineNumber, "number"); 18 assert_equals(typeof report.body.columnNumber, "number"); 19 assert_equals(report.body.disposition, "enforce"); 20 }; 21 22 promise_test(async t => { 23 const report = new Promise(resolve => { 24 new ReportingObserver((reports, observer) => resolve([reports, observer]), 25 {types: ['permissions-policy-violation']}).observe(); 26 }); 27 28 await test_driver.bless('Activate document for serial.requestPort'); 29 try { 30 await navigator.serial.requestPort({ filters: [] }); 31 assert_unreached("Serial port access should not be allowed in this document."); 32 } catch (e) { 33 assert_equals(e.code, DOMException.SECURITY_ERR); 34 } 35 check_report_format(await report); 36 }, "requestPort in serial reporting mode"); 37 38 promise_test(async t => { 39 const report = new Promise(resolve => { 40 new ReportingObserver((reports, observer) => resolve([reports, observer]), 41 {types: ['permissions-policy-violation']}).observe(); 42 }); 43 44 try { 45 await navigator.serial.getPorts(); 46 assert_unreached("Serial port access should not be allowed in this document."); 47 } catch (e) { 48 assert_equals(e.code, DOMException.SECURITY_ERR); 49 } 50 check_report_format(await report); 51 }, "getPorts in serial reporting mode"); 52 </script> 53 </body> 54 </html>