test_syntaxErrorInline.html (988B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Test syntax errors parsing an inline module are reported</title> 4 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 5 <script> 6 var wasRun = false; 7 var errorCount = 0; 8 var syntaxErrorCount = 0; 9 var eventCount = 0; 10 11 SimpleTest.waitForExplicitFinish(); 12 window.onerror = handleError; 13 14 function handleError(message, url, line, column, error) { 15 errorCount++; 16 if (error instanceof SyntaxError) { 17 syntaxErrorCount++; 18 } 19 } 20 21 function testError() { 22 ok(!wasRun, 'Check script was not run'); 23 ok(errorCount == 1, 'Check that an error was reported'); 24 ok(syntaxErrorCount == 1, 'Check that a syntax error was reported'); 25 ok(eventCount == 0, 'Check that no error event was fired'); 26 SimpleTest.finish(); 27 } 28 </script> 29 <script type="module" onerror="eventCount++"> 30 // Module with a syntax error. 31 some invalid js syntax; 32 wasRun = true; 33 </script> 34 <body onload='testError()'></body>