Mypal/dom/base/test/jsmodules/test_syntaxErrorInlineAsync...

35 lines
1.0 KiB
HTML
Raw Normal View History

2019-03-11 03:26:37 -07:00
<!DOCTYPE html>
<meta charset=utf-8>
<title>Test syntax errors parsing an inline async module are reported</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
var wasRun = false;
2020-07-15 17:48:35 -07:00
var errorCount = 0;
var syntaxErrorCount = 0;
var eventCount = 0;
2019-03-11 03:26:37 -07:00
SimpleTest.waitForExplicitFinish();
window.onerror = handleError;
function handleError(message, url, line, column, error) {
2020-07-15 17:48:35 -07:00
errorCount++;
if (error instanceof SyntaxError) {
syntaxErrorCount++;
}
2019-03-11 03:26:37 -07:00
}
function testError() {
ok(!wasRun, 'Check script was not run');
2020-07-15 17:48:35 -07:00
ok(errorCount == 1, 'Check that an error was reported');
ok(syntaxErrorCount == 1, 'Check that a syntax error was reported');
ok(eventCount == 0, 'Check that no error event was fired');
2019-03-11 03:26:37 -07:00
SimpleTest.finish();
}
</script>
2020-07-15 17:48:35 -07:00
<script type="module" async onerror="eventCount++">
2019-03-11 03:26:37 -07:00
// Module with a syntax error.
some invalid js syntax;
wasRun = true;
</script>
<body onload='testError()'></body>