blob: 2a3498094cc1ccbfe047b6c10393d4163e6f88f0 (
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
|
<!DOCTYPE html>
<head>
<meta charset=utf-8>
<title>Test the 2nd import map should be rejected.</title>
</head>
<body onload='testLoaded()'>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script>
let gotMsg = false;
let console = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
let listener = {
QueryInterface: ChromeUtils.generateQI(["nsIConsoleListener"]),
observe(msg) {
info("console message:" + msg);
ok(msg.logLevel == Ci.nsIConsoleMessage.warn, "log level should be 'warn'.");
console.unregisterListener(this);
gotMsg = true;
}
};
console.registerListener(listener);
</script>
<script type="importmap" onerror='importMapError1()'>
{
"imports": {
"./module_simpleExport.mjs": "./scope1/module_simpleExport.mjs"
}
}
</script>
<!--The 2nd import map should be rejected.-->
<script type="importmap" onerror='importMapError2()'>
{
"imports": {
"./module_simpleExport.mjs": "./scope1/module_simpleExport.mjs"
}
}
</script>
<script>
SimpleTest.waitForExplicitFinish();
let hasError = false;
function importMapError1() {
ok(false, "The first import map should be accepted.");
}
function importMapError2() {
hasError = true;
}
function testLoaded() {
import("./module_simpleExport.mjs").then((ns) => {
ok(ns.x == 84, 'Check simple imported value result: ' + ns.x);
ok(hasError, "onerror of the import map should be called.");
ok(gotMsg, "Should have got the console warning.");
}).catch((e) => {
ok(false, "throws " + e);
}).then(() => {
SimpleTest.finish();
});
}
</script>
</body>
|