window-onerror-parse-error.html (1315B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>window.onerror: parse errors</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <!-- 8 9 In https://html.spec.whatwg.org/multipage/#creating-scripts , 10 step 3 describes parsing the script, and step 5 says: 11 # Otherwise, report the error using the onerror event handler of 12 # the script's global object. If the error is still not handled 13 # after this, then the error may be reported to the user. 14 which links to 15 https://html.spec.whatwg.org/multipage/#report-the-error , 16 which describes what to do when onerror is a Function. 17 18 --> 19 </head> 20 <body> 21 22 <div id="log"></div> 23 <script> 24 setup({allow_uncaught_exception:true}); 25 var error_count = 0; 26 window.onerror = function(msg, url, lineno) { 27 ++error_count; 28 test(function() {assert_equals(url, window.location.href)}, 29 "correct url passed to window.onerror"); 30 test(function() {assert_equals(lineno, 34)}, 31 "correct line number passed to window.onerror"); 32 }; 33 </script> 34 <script>This script does not parse correctly.</script> 35 <script> 36 test(function() {assert_equals(error_count, 1)}, 37 "correct number of calls to window.onerror"); 38 </script> 39 </body> 40 </html>