<!DOCTYPE HTML><!-- webkit-test-runner [ jscOptions=--validateExceptionChecks=true ] -->
<html>
  <head>
    <script src="../../../resources/js-test-pre.js"></script>
  </head>
  <body>
    <script>
      description('Test module import with validateExceptionChecks.');
      window.jsTestIsAsync = true;
      var error;
    </script>
    <script src="../../../resources/js-test-post.js"></script>
    <script>
      (async function () {

          debug(`Import should fail because path is not a file.`)
          error = null;
          try {
              await import(`./`);
          } catch (e) {
              error = e;
          }

          // Depending on the port, the import may fail due to different rejections.
          // Hence, we'll discount the rest of the error message in this comparison.
          shouldBeEqualToString(`String(error).substr(0, 11)`, `TypeError: `);

          debug(`\nImporting a module script should fail if the file is not found.`)
          error = null;
          try {
              await import(`./resources/import-not-found.js`);
          } catch (e) {
              error = e;
          }
          shouldBeEqualToString(`String(error)`, `TypeError: Importing a module script failed.`);

          debug(`\nImporting a module script should fail if it does not not a valid JavaScript MIME type.`);
          error = null;
          try {
              await import(`data:text/html,Hello World`);
          } catch (e) {
              error = e;
          }
          shouldBeEqualToString(`String(error)`, `TypeError: 'text/html' is not a valid JavaScript MIME type.`);

          debug(`\nImporting a simple module script should succeed.`);
          error = null;
          try {
              await import(`./resources/module-inline-simple.js`);
          } catch (e) {
              error = e;
          }
          shouldBeNull(`error`);

          finishJSTest();
      }());
    </script>
  </body>
</html>
