tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_syntaxError.html (936B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Test syntax errors parsing a 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" src="module_badSyntax.mjs" onerror="eventCount++"></script>
     30 <body onload='testError()'></body>