summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/import-maps/acquiring/dynamic-import.html
blob: 49d8a701da2e436ccdded0f7438c3dc11f6c4656 (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
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const t = async_test(
  'After dynamic imports, import maps should fire error events');
const log = [];
// To ensure we are testing that the flag is cleared at the beginning of module
// script loading unconditionally, not at the end of loading or not at the
// first attempt to resolve a module specifier, trickle(d1) is used to ensure
// the following import map is added after module loading is triggered but
// before the first module script is parsed.
promise_test(() => import('../resources/empty.js?pipe=trickle(d1)'),
             "A dynamic import succeeds");
</script>
<script type="importmap" onload="t.assert_unreached('onload')" onerror="t.done()">
{
  "imports": {
    "../resources/log.js?pipe=sub&name=A": "../resources/log.js?pipe=sub&name=B"
  }
}
</script>
<script>
promise_test(() => {
  return import("../resources/log.js?pipe=sub&name=A")
    .then(() => assert_array_equals(log, ["log:A"]))
  },
  'After a dynamic import(), import maps are not effective');
</script>