sync-xhr-reporting.html (1212B)
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/document-policy-report-json.js'></script> 7 </head> 8 <body> 9 <script> 10 var t = async_test("Sync-xhr Report Format"); 11 12 var check_report_format = (reports, observer) => { 13 let report = reports[0]; 14 assert_equals(report.type, "document-policy-violation"); 15 assert_equals(report.url, document.location.href); 16 assert_equals(report.body.featureId, "sync-xhr"); 17 assert_equals(report.body.sourceFile, document.location.href); 18 assert_equals(typeof report.body.lineNumber, "number"); 19 assert_equals(typeof report.body.columnNumber, "number"); 20 assert_equals(report.body.disposition, "enforce"); 21 check_report_json(report); 22 }; 23 24 new ReportingObserver(t.step_func_done(check_report_format), 25 {types: ['document-policy-violation']}).observe(); 26 27 t.step_func(() => { 28 var xhr = new XMLHttpRequest(); 29 xhr.open("GET", document.location.href, false); 30 assert_throws_dom('NetworkError', 31 () => xhr.send(), 32 "Synchronous XHR.send should throw an exception when disabled"); 33 })(); 34 </script> 35 </body> 36 </html>