Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
<!DOCTYPE html>
<head>
  <meta charset=utf-8>
  <title>Test a simple import map with a base element</title>
</head>
<body onload='testLoaded()'>
<!--  This will change the baseURL of the document.-->
<!--
With the <base> element, the correct "module_simpleExport.mjs" should be mapped
to "scope1/module_simpleExport.mjs", instead of "./module_simpleExport.mjs".
-->
<script type="importmap">
{
  "imports": {
    "simple": "./module_simpleExport.mjs"
  }
}
</script>
<script type="module">
  import { x } from "simple";
  /* global result2 */
  result2 = x;
</script>
<script type="module" src="module_simpleImportMap.mjs"></script>
<script>
  var result_scope1, result2;
  SimpleTest.waitForExplicitFinish();
  // eslint-disable-next-line no-unused-vars
  function testLoaded() {
    ok(result_scope1 == 84, 'Check imported value result_scope1: ' + result_scope1);
    ok(result2 == 84, 'Check imported value result2: ' + result2);
    import("simple").then((ns) => {
      ok(ns.x == 84, 'Check simple imported value result: ' + ns.x);
    }).catch((e) => {
      ok(false, "throws " + e);
    }).then(() => {
      SimpleTest.finish();
    });
  }
</script>
</body>