summaryrefslogtreecommitdiffstats
path: root/dom/base/test/jsmodules/importmaps/test_importMap_with_external_script.html
blob: 3b21003feb9970bcc68b1524af3b2fa7026a6298 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<meta charset=utf-8>
<head>
<title>Test speculative preload of external script doesn't conflict with import map</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>

<!--
    These tests check that speculative preloading, which could happen before
    the import map is installed, doesn't load the wrong modules.
-->

<script type="importmap">
  {
    "imports": {
      "bare": "./good/module_0.mjs",
      "./bad/module_1.mjs": "./good/module_1.mjs",
      "./bad/module_2.mjs": "./good/module_2.mjs",
      "./bad/module_3.mjs": "./good/module_3.mjs",
      "./bad/module_4.mjs": "./good/module_4.mjs",
      "./bad/module_7.mjs": "./good/module_7.mjs"
    }
  }
</script>

<!--
Test bareword import (not supported before import map installed).
-->
<script type="module" src="module_importMap_with_external_script_0.mjs"></script>

<!--
Test mapping from missing resource to existing resource (not found before
import map installed).
-->
<script type="module" src="module_importMap_with_external_script_1.mjs"></script>

<!--
Test mapping from one existing resource to another (would load wrong resource before
import map installed).
-->
<script type="module" src="module_importMap_with_external_script_2.mjs"></script>

<!--
Test mapping from one existing resource to another with circular dependency.
-->
<script type="module" src="module_importMap_with_external_script_3.mjs"></script>

<!--
Test with redirect, script_6.mjs -> script_5.mjs -> script_4.mjs.
We redirect twice here, as sometimes one redirect can't reproduce the crash
from bug 1835468.
-->
<script type="module" src="module_importMap_with_external_script_6.mjs"></script>

<!--
Test with async attribute
-->
<script type="module" async src="module_importMap_with_external_script_7.mjs"></script>

<script>
  SimpleTest.waitForExplicitFinish();

  let passCount = 0;
  const expectedCount = 6;

  function success(name) {
    ok(true, "Test passed, loaded " + name);
    passCount++;
    if (passCount == expectedCount) {
      SimpleTest.finish();
    }
  }
</script>
<body></body>