summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/import-maps/multiple-import-maps/basic.html
blob: 9ab03ddc302af11ad7fc12d4dc8c1ed6b90084a6 (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
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const log = [];
</script>
<script type="importmap" onerror="log.push('onerror 1')">
{
  "imports": {
    "../resources/log.js?pipe=sub&name=A1": "../resources/log.js?pipe=sub&name=B1",
    "../resources/log.js?pipe=sub&name=A2": "../resources/log.js?pipe=sub&name=B2"
  }
}
</script>
<script type="importmap" onerror="log.push('onerror 2')">
{
  "imports": {
    "../resources/log.js?pipe=sub&name=A1": "../resources/log.js?pipe=sub&name=C1",
    "../resources/log.js?pipe=sub&name=A3": "../resources/log.js?pipe=sub&name=C3"
  }
}
</script>
<script>
// Currently the spec doesn't allow multiple import maps, by setting acquiring
// import maps to false on preparing the first import map.
promise_test(() => {
  return import("../resources/log.js?pipe=sub&name=A1")
    .then(() => import("../resources/log.js?pipe=sub&name=A2"))
    .then(() => import("../resources/log.js?pipe=sub&name=A3"))
    .then(() => assert_array_equals(
                    log,
                    ["onerror 2", "log:B1", "log:B2", "log:A3"]))
  },
  "Second import map should be rejected");
</script>