summaryrefslogtreecommitdiffstats
path: root/dom/base/test/jsmodules/importmaps/test_module_script_reject_importMap.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/test/jsmodules/importmaps/test_module_script_reject_importMap.html')
-rw-r--r--dom/base/test/jsmodules/importmaps/test_module_script_reject_importMap.html45
1 files changed, 45 insertions, 0 deletions
diff --git a/dom/base/test/jsmodules/importmaps/test_module_script_reject_importMap.html b/dom/base/test/jsmodules/importmaps/test_module_script_reject_importMap.html
new file mode 100644
index 0000000000..88db016e3d
--- /dev/null
+++ b/dom/base/test/jsmodules/importmaps/test_module_script_reject_importMap.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<head>
+ <meta charset=utf-8>
+ <title>Test import map should be rejected.</title>
+</head>
+<body onload='testLoaded()'>
+<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<!--There is a module load before the import map tag, so the import map cannot-->
+<!--be accepted according to the spec.-->
+<!--And because the import map is rejected, so the module specifier-->
+<!--"./module_simpleExport.mjs" won't be remapped to-->
+<!--"./scope1/module_simpleExport.mjs".-->
+
+<script src="./module_simpleExport.mjs" type="module">
+</script>
+
+<script type="importmap" onerror='importMapError()'>
+{
+ "imports": {
+ "./module_simpleExport.mjs": "./scope1/module_simpleExport.mjs"
+ }
+}
+</script>
+
+<script>
+ SimpleTest.waitForExplicitFinish();
+
+ let hasError = false;
+ function importMapError() {
+ hasError = true;
+ }
+
+ function testLoaded() {
+ import("./module_simpleExport.mjs").then((ns) => {
+ ok(ns.x == 42, 'Check simple imported value result: ' + ns.x);
+ ok(hasError, "onerror of the import map should be called.");
+ }).catch((e) => {
+ ok(false, "throws " + e);
+ }).then(() => {
+ SimpleTest.finish();
+ });
+ }
+</script>
+</body>