summaryrefslogtreecommitdiffstats
path: root/dom/base/test/jsmodules/importmaps/test_import_meta_resolve_importMap.html
blob: 5c81dd548e78f689865b07ba7f4bdbfcd583b6da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<head>
  <meta charset=utf-8>
  <title>Test import.meta.resolve with import maps</title>
</head>
<body onload='testLoaded()'>

<script type="importmap">
{
  "imports": {
    "simple": "./module_simpleExport.mjs"
  }
}
</script>

<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
  var wasRun = false;
  var hasThrown = false;
  window.onerror = handleError;

  function handleError(msg, url, line, col, error) {
    ok(error instanceof TypeError, "Thrown error should be TypeError.");
    hasThrown = true;
  }
</script>

<script type="module">
  ok(import.meta.resolve("simple") ==
     "chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/module_simpleExport.mjs",
     "calling import.meta.resolve with a specifier from import map.");
  wasRun = true;
</script>

<script type="module">
  // should throw a TypeError
  import.meta.resolve("fail");
</script>

<script>
  SimpleTest.waitForExplicitFinish();

  function testLoaded() {
    ok(wasRun, "Check inline module has run.");
    ok(hasThrown, "Check inline module has thrown.");
    SimpleTest.finish();
  }
</script>
</body>