Bug 1778112 - Move dom/base/test/jsmodules/ to use mjs files, rather than defining sourceType for ESLint. r=allstarschh

Differential Revision: https://phabricator.services.mozilla.com/D183372
This commit is contained in:
Mark Banner 2023-07-13 13:56:12 +00:00
parent 602952a200
commit 5eeac4e3f9
124 changed files with 269 additions and 231 deletions

View file

@ -136,9 +136,10 @@ dom/serviceworkers/test/file_js_cache.js
# Intentional broken files # Intentional broken files
dom/base/test/file_js_cache_syntax_error.js dom/base/test/file_js_cache_syntax_error.js
dom/base/test/jsmodules/test_scriptNotParsedAsModule.html
dom/base/test/jsmodules/test_syntaxError.html dom/base/test/jsmodules/test_syntaxError.html
dom/base/test/jsmodules/test_syntaxErrorAsync.html dom/base/test/jsmodules/test_syntaxErrorAsync.html
dom/base/test/jsmodules/module_badSyntax.js dom/base/test/jsmodules/module_badSyntax.mjs
dom/base/test/jsmodules/test_syntaxErrorInline.html dom/base/test/jsmodules/test_syntaxErrorInline.html
dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html
dom/base/test/test_bug687859.html dom/base/test/test_bug687859.html

View file

@ -1111,9 +1111,10 @@ dom/serviceworkers/test/file_js_cache.js
# Intentional broken files # Intentional broken files
dom/base/test/file_js_cache_syntax_error.js dom/base/test/file_js_cache_syntax_error.js
dom/base/test/jsmodules/test_scriptNotParsedAsModule.html
dom/base/test/jsmodules/test_syntaxError.html dom/base/test/jsmodules/test_syntaxError.html
dom/base/test/jsmodules/test_syntaxErrorAsync.html dom/base/test/jsmodules/test_syntaxErrorAsync.html
dom/base/test/jsmodules/module_badSyntax.js dom/base/test/jsmodules/module_badSyntax.mjs
dom/base/test/jsmodules/test_syntaxErrorInline.html dom/base/test/jsmodules/test_syntaxErrorInline.html
dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html dom/base/test/jsmodules/test_syntaxErrorInlineAsync.html
dom/base/test/test_bug687859.html dom/base/test/test_bug687859.html

View file

@ -1,7 +1,15 @@
"use strict"; "use strict";
module.exports = { module.exports = {
parserOptions: { overrides: [
sourceType: "module", {
}, // eslint-plugin-html doesn't automatically detect module sections in
// html files. Enable these as a module here. JavaScript files can use
// the mjs extension.
files: ["*.html"],
parserOptions: {
sourceType: "module",
},
},
],
}; };

View file

@ -1,26 +1,26 @@
[DEFAULT] [DEFAULT]
support-files = support-files =
module_setRan.js module_setRan.mjs
module_testSyntax.js module_testSyntax.mjs
module_badSyntax.js module_badSyntax.mjs
module_simpleImport.js module_simpleImport.mjs
module_simpleExport.js module_simpleExport.mjs
module_badImport.js module_badImport.mjs
module_simple1.js module_simple1.mjs
module_simple2.js module_simple2.mjs
module_simple3.js module_simple3.mjs
module_cyclic1.js module_cyclic1.mjs
module_cyclic2.js module_cyclic2.mjs
module_cyclic3.js module_cyclic3.mjs
module_multiImports.js module_multiImports.mjs
module_multiLargeImports.js module_multiLargeImports.mjs
script_simple2.js script_simple2.js
module_large1.js module_large1.mjs
module_large2.js module_large2.mjs
module_large3.js module_large3.mjs
module_extractIntroType.js module_extractIntroType.mjs
iframe_extractIntroType.html iframe_extractIntroType.html
module_missingImport.js module_missingImport.mjs
[test_moduleScriptsRun.html] [test_moduleScriptsRun.html]
[test_moduleParsedAsModule.html] [test_moduleParsedAsModule.html]

View file

@ -1 +0,0 @@
throw "Shouldn't load file bad/module_2.js";

View file

@ -0,0 +1 @@
throw "Shouldn't load file bad/module_2.mjs";

View file

@ -1,7 +0,0 @@
import {} from "../circular_depdendency.js";
export function exportedFunction() {
throw "Wrong version of function called";
}
throw "Shouldn't laod file bad/module_3.js";

View file

@ -0,0 +1,8 @@
// eslint-disable-next-line import/no-unassigned-import, import/no-unresolved
import {} from "../circular_depdendency.mjs";
export function exportedFunction() {
throw "Wrong version of function called";
}
throw "Shouldn't laod file bad/module_3.mjs";

View file

@ -1 +0,0 @@
throw "Shouldn't load file bad/module_4.js";

View file

@ -0,0 +1 @@
throw "Shouldn't load file bad/module_4.mjs";

View file

@ -1 +0,0 @@
throw "Shouldn't load file bad/module_7.js";

View file

@ -0,0 +1 @@
throw "Shouldn't load file bad/module_7.mjs";

View file

@ -2,16 +2,16 @@
support-files = support-files =
external_importMap.js external_importMap.js
insert_a_base_element.js insert_a_base_element.js
module_simpleImportMap.js module_simpleImportMap.mjs
module_simpleImportMap_dir.js module_simpleImportMap_dir.mjs
module_simpleImportMap_remap.js module_simpleImportMap_remap.mjs
module_simpleImportMap_remap_https.js module_simpleImportMap_remap_https.mjs
module_simpleExport.js module_simpleExport.mjs
module_sortedImportMap.js module_sortedImportMap.mjs
scope1/module_simpleExport.js scope1/module_simpleExport.mjs
scope1/module_simpleImportMap.js scope1/module_simpleImportMap.mjs
scope1/scope2/module_simpleExport.js scope1/scope2/module_simpleExport.mjs
scope1/scope2/module_simpleImportMap.js scope1/scope2/module_simpleImportMap.mjs
prefs = prefs =
dom.importMaps.enabled=true dom.importMaps.enabled=true

View file

@ -1,6 +0,0 @@
// Should be remapped to good/module_3.js.
import { exportedFunction } from "./bad/module_3.js";
if (exportedFunction()) {
success("circular_dependency.js");
}

View file

@ -0,0 +1,6 @@
// Should be remapped to good/module_3.mjs.
import { exportedFunction } from "./bad/module_3.mjs";
if (exportedFunction()) {
success("circular_dependency.mjs");
}

View file

@ -1 +0,0 @@
success("good/module_0.js");

View file

@ -0,0 +1 @@
success("good/module_0.mjs");

View file

@ -1 +0,0 @@
success("good/module_1.js");

View file

@ -0,0 +1 @@
success("good/module_1.mjs");

View file

@ -1 +0,0 @@
success("good/module_2.js");

View file

@ -0,0 +1 @@
success("good/module_2.mjs");

View file

@ -1,5 +0,0 @@
import {} from "../circular_dependency.js";
export function exportedFunction() {
return true;
}

View file

@ -0,0 +1,6 @@
// eslint-disable-next-line import/no-unassigned-import
import {} from "../circular_dependency.mjs";
export function exportedFunction() {
return true;
}

View file

@ -1 +0,0 @@
success("good/module_4.js");

View file

@ -0,0 +1 @@
success("good/module_4.mjs");

View file

@ -1 +0,0 @@
success("good/module_7.js");

View file

@ -0,0 +1 @@
success("good/module_7.mjs");

View file

@ -1,26 +1,26 @@
[DEFAULT] [DEFAULT]
support-files = support-files =
module_importMap_with_external_script_0.js module_importMap_with_external_script_0.mjs
module_importMap_with_external_script_1.js module_importMap_with_external_script_1.mjs
module_importMap_with_external_script_2.js module_importMap_with_external_script_2.mjs
module_importMap_with_external_script_3.js module_importMap_with_external_script_3.mjs
module_importMap_with_external_script_4.js module_importMap_with_external_script_4.mjs
module_importMap_with_external_script_5.js module_importMap_with_external_script_5.mjs
module_importMap_with_external_script_5.js^headers^ module_importMap_with_external_script_5.mjs^headers^
module_importMap_with_external_script_6.js module_importMap_with_external_script_6.mjs
module_importMap_with_external_script_6.js^headers^ module_importMap_with_external_script_6.mjs^headers^
module_importMap_with_external_script_7.js module_importMap_with_external_script_7.mjs
bad/module_2.js bad/module_2.mjs
bad/module_3.js bad/module_3.mjs
bad/module_4.js bad/module_4.mjs
bad/module_7.js bad/module_7.mjs
good/module_0.js good/module_0.mjs
good/module_1.js good/module_1.mjs
good/module_2.js good/module_2.mjs
good/module_3.js good/module_3.mjs
good/module_4.js good/module_4.mjs
good/module_7.js good/module_7.mjs
circular_dependency.js circular_dependency.mjs
prefs = prefs =
dom.importMaps.enabled=true dom.importMaps.enabled=true

View file

@ -1,2 +0,0 @@
// Bareword specifier should be mapped to ./good/module_0.js.
import {} from "bare";

View file

@ -0,0 +1,3 @@
// Bareword specifier should be mapped to ./good/module_0.mjs.
// eslint-disable-next-line import/no-unassigned-import, import/no-unresolved
import {} from "bare";

View file

@ -1,2 +0,0 @@
// Missing file ./bad/module_1.js should be mapped to ./good/module_1.js.
import {} from "./bad/module_1.js";

View file

@ -0,0 +1,3 @@
// Missing file ./bad/module_1.mjs should be mapped to ./good/module_1.mjs.
// eslint-disable-next-line import/no-unassigned-import, import/no-unresolved
import {} from "./bad/module_1.mjs";

View file

@ -1,2 +0,0 @@
// Existing file ./bad/module_2.js should be mapped to ./good/module_2.js.
import {} from "./bad/module_2.js";

View file

@ -0,0 +1,3 @@
// Existing file ./bad/module_2.mjs should be mapped to ./good/module_2.mjs.
// eslint-disable-next-line import/no-unassigned-import
import {} from "./bad/module_2.mjs";

View file

@ -1,2 +0,0 @@
// Existing file ./bad/module_3.js should be mapped to ./good/module_3.js.
import {} from "./bad/module_3.js";

View file

@ -0,0 +1,3 @@
// Existing file ./bad/module_3.mjs should be mapped to ./good/module_3.mjs.
// eslint-disable-next-line import/no-unassigned-import
import {} from "./bad/module_3.mjs";

View file

@ -1,2 +0,0 @@
// Existing file ./bad/module_4.js should be mapped to ./good/module_4.js.
import {} from "./bad/module_4.js";

View file

@ -0,0 +1,3 @@
// Existing file ./bad/module_4.mjs should be mapped to ./good/module_4.mjs.
// eslint-disable-next-line import/no-unassigned-import
import {} from "./bad/module_4.mjs";

View file

@ -1,3 +0,0 @@
// Existing file ./bad/module_3.js should be mapped to ./good/module_3.js.
//import {} from "./bad/module_3.js";
throw "Error: script_5.js";

View file

@ -1,2 +0,0 @@
HTTP 301 Moved Permanently
Location: module_importMap_with_external_script_4.js

View file

@ -0,0 +1,3 @@
// Existing file ./bad/module_3.mjs should be mapped to ./good/module_3.mjs.
//import {} from "./bad/module_3.mjs";
throw "Error: script_5.mjs";

View file

@ -0,0 +1,2 @@
HTTP 301 Moved Permanently
Location: module_importMap_with_external_script_4.mjs

View file

@ -1,3 +0,0 @@
// Existing file ./bad/module_3.js should be mapped to ./good/module_3.js.
//import {} from "./bad/module_3.js";
throw "Error: script_6.js";

View file

@ -1,2 +0,0 @@
HTTP 301 Moved Permanently
Location: module_importMap_with_external_script_5.js

View file

@ -0,0 +1,3 @@
// Existing file ./bad/module_3.mjs should be mapped to ./good/module_3.mjs.
//import {} from "./bad/module_3.mjs";
throw "Error: script_6.mjs";

View file

@ -0,0 +1,2 @@
HTTP 301 Moved Permanently
Location: module_importMap_with_external_script_5.mjs

View file

@ -1,2 +0,0 @@
// Existing file ./bad/module_7.js should be mapped to ./good/module_4.js.
import {} from "./bad/module_7.js";

View file

@ -0,0 +1,3 @@
// Existing file ./bad/module_7.mjs should be mapped to ./good/module_4.mjs.
// eslint-disable-next-line import/no-unassigned-import
import {} from "./bad/module_7.mjs";

View file

@ -1,2 +0,0 @@
import { x } from "simple";
result = x;

View file

@ -0,0 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import { x } from "simple";
result = x;

View file

@ -1,2 +0,0 @@
import { x } from "dir/module_simpleExport.js";
result_dir = x + 1;

View file

@ -0,0 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import { x } from "dir/module_simpleExport.mjs";
result_dir = x + 1;

View file

@ -1,2 +0,0 @@
import { x } from "./module.js";
result_remap = x + 2;

View file

@ -0,0 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import { x } from "./module.mjs";
result_remap = x + 2;

View file

@ -1,2 +0,0 @@
import { x } from "https://example.com/module.js";
result_remap_https = x + 3;

View file

@ -0,0 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import { x } from "https://example.com/module.mjs";
result_remap_https = x + 3;

View file

@ -1,4 +0,0 @@
import { x } from "scope1/scope2/module_simpleExport.js";
import { x as y } from "scope1/scope2/scope3/scope4/module_simpleExport.js";
sorted_result = x;
sorted_result2 = y;

View file

@ -0,0 +1,6 @@
/* eslint-disable import/no-unresolved */
import { x } from "scope1/scope2/module_simpleExport.mjs";
import { x as y } from "scope1/scope2/scope3/scope4/module_simpleExport.mjs";
sorted_result = x;
sorted_result2 = y;

View file

@ -1,2 +0,0 @@
import { x } from "simple";
result_scope1 = x;

View file

@ -0,0 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import { x } from "simple";
result_scope1 = x;

View file

@ -1,2 +0,0 @@
import { x } from "simple";
result_scope2 = x;

View file

@ -0,0 +1,4 @@
// eslint-disable-next-line import/no-unresolved
import { x } from "simple";
result_scope2 = x;

View file

@ -9,17 +9,17 @@
<!--There is a dynamic import before the import map tag, so the import map--> <!--There is a dynamic import before the import map tag, so the import map-->
<!--cannot be accepted according to the spec.--> <!--cannot be accepted according to the spec.-->
<!--And because the import map is rejected, so the module specifier--> <!--And because the import map is rejected, so the module specifier-->
<!--"./module_simpleExport.js" won't be remapped to--> <!--"./module_simpleExport.mjs" won't be remapped to-->
<!--"./scope1/module_simpleExport.js".--> <!--"./scope1/module_simpleExport.mjs".-->
<script> <script>
import("./module_simpleExport.js"); import("./module_simpleExport.mjs");
</script> </script>
<script type="importmap" onerror='importMapError()'> <script type="importmap" onerror='importMapError()'>
{ {
"imports": { "imports": {
"./module_simpleExport.js": "./scope1/module_simpleExport.js" "./module_simpleExport.mjs": "./scope1/module_simpleExport.mjs"
} }
} }
</script> </script>
@ -33,7 +33,7 @@
} }
function testLoaded() { function testLoaded() {
import("./module_simpleExport.js").then((ns) => { import("./module_simpleExport.mjs").then((ns) => {
ok(ns.x == 42, 'Check simple imported value result: ' + ns.x); ok(ns.x == 42, 'Check simple imported value result: ' + ns.x);
ok(hasError, "onerror of the import map should be called."); ok(hasError, "onerror of the import map should be called.");
}).catch((e) => { }).catch((e) => {

View file

@ -14,12 +14,12 @@
<script type="importmap"> <script type="importmap">
{ {
"imports": { "imports": {
"bare": "./good/module_0.js", "bare": "./good/module_0.mjs",
"./bad/module_1.js": "./good/module_1.js", "./bad/module_1.mjs": "./good/module_1.mjs",
"./bad/module_2.js": "./good/module_2.js", "./bad/module_2.mjs": "./good/module_2.mjs",
"./bad/module_3.js": "./good/module_3.js", "./bad/module_3.mjs": "./good/module_3.mjs",
"./bad/module_4.js": "./good/module_4.js", "./bad/module_4.mjs": "./good/module_4.mjs",
"./bad/module_7.js": "./good/module_7.js" "./bad/module_7.mjs": "./good/module_7.mjs"
} }
} }
</script> </script>
@ -27,36 +27,36 @@
<!-- <!--
Test bareword import (not supported before import map installed). Test bareword import (not supported before import map installed).
--> -->
<script type="module" src="module_importMap_with_external_script_0.js"></script> <script type="module" src="module_importMap_with_external_script_0.mjs"></script>
<!-- <!--
Test mapping from missing resource to existing resource (not found before Test mapping from missing resource to existing resource (not found before
import map installed). import map installed).
--> -->
<script type="module" src="module_importMap_with_external_script_1.js"></script> <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 Test mapping from one existing resource to another (would load wrong resource before
import map installed). import map installed).
--> -->
<script type="module" src="module_importMap_with_external_script_2.js"></script> <script type="module" src="module_importMap_with_external_script_2.mjs"></script>
<!-- <!--
Test mapping from one existing resource to another with circular dependency. Test mapping from one existing resource to another with circular dependency.
--> -->
<script type="module" src="module_importMap_with_external_script_3.js"></script> <script type="module" src="module_importMap_with_external_script_3.mjs"></script>
<!-- <!--
Test with redirect, script_6.js -> script_5.js -> script_4.js. 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 We redirect twice here, as sometimes one redirect can't reproduce the crash
from bug 1835468. from bug 1835468.
--> -->
<script type="module" src="module_importMap_with_external_script_6.js"></script> <script type="module" src="module_importMap_with_external_script_6.mjs"></script>
<!-- <!--
Test with async attribute Test with async attribute
--> -->
<script type="module" async src="module_importMap_with_external_script_7.js"></script> <script type="module" async src="module_importMap_with_external_script_7.mjs"></script>
<script> <script>
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();

View file

@ -8,7 +8,7 @@
<script type="importmap"> <script type="importmap">
{ {
"imports": { "imports": {
"simple": "./module_simpleExport.js" "simple": "./module_simpleExport.mjs"
} }
} }
</script> </script>
@ -27,7 +27,7 @@
<script type="module"> <script type="module">
ok(import.meta.resolve("simple") == ok(import.meta.resolve("simple") ==
"chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/module_simpleExport.js", "chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/module_simpleExport.mjs",
"calling import.meta.resolve with a specifier from import map."); "calling import.meta.resolve with a specifier from import map.");
wasRun = true; wasRun = true;
</script> </script>

View file

@ -24,8 +24,8 @@ console.registerListener(listener);
<!--There is an inline module before the import map tag, so the import map--> <!--There is an inline module before the import map tag, so the import map-->
<!--cannot be accepted according to the spec.--> <!--cannot be accepted according to the spec.-->
<!--And because the import map is rejected, so the module specifier--> <!--And because the import map is rejected, so the module specifier-->
<!--"./module_simpleExport.js" won't be remapped to--> <!--"./module_simpleExport.mjs" won't be remapped to-->
<!--"./scope1/module_simpleExport.js".--> <!--"./scope1/module_simpleExport.mjs".-->
<script type="module"> <script type="module">
</script> </script>
@ -33,7 +33,7 @@ console.registerListener(listener);
<script type="importmap" onerror='importMapError()'> <script type="importmap" onerror='importMapError()'>
{ {
"imports": { "imports": {
"./module_simpleExport.js": "./scope1/module_simpleExport.js" "./module_simpleExport.mjs": "./scope1/module_simpleExport.mjs"
} }
} }
</script> </script>
@ -47,7 +47,7 @@ console.registerListener(listener);
} }
function testLoaded() { function testLoaded() {
import("./module_simpleExport.js").then((ns) => { import("./module_simpleExport.mjs").then((ns) => {
ok(ns.x == 42, 'Check simple imported value result: ' + ns.x); ok(ns.x == 42, 'Check simple imported value result: ' + ns.x);
ok(hasError, "onerror of the import map should be called."); ok(hasError, "onerror of the import map should be called.");
ok(gotMsg, "Should have got the console warning."); ok(gotMsg, "Should have got the console warning.");

View file

@ -9,14 +9,14 @@
<base href="chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/"> <base href="chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/">
<!-- <!--
With the <base> element, the correct "module_simpleExport.js" should be mapped With the <base> element, the correct "module_simpleExport.mjs" should be mapped
to "scope1/module_simpleExport.js", instead of "./module_simpleExport.js". to "scope1/module_simpleExport.mjs", instead of "./module_simpleExport.mjs".
--> -->
<script type="importmap"> <script type="importmap">
{ {
"imports": { "imports": {
"simple": "./module_simpleExport.js" "simple": "./module_simpleExport.mjs"
} }
} }
</script> </script>
@ -28,7 +28,7 @@ to "scope1/module_simpleExport.js", instead of "./module_simpleExport.js".
result2 = x; result2 = x;
</script> </script>
<script type="module" src="module_simpleImportMap.js"></script> <script type="module" src="module_simpleImportMap.mjs"></script>
<script> <script>
var result_scope1, result2; var result_scope1, result2;

View file

@ -9,14 +9,14 @@
<script src="insert_a_base_element.js"></script> <script src="insert_a_base_element.js"></script>
<!-- <!--
With the <base> element, the correct "module_simpleExport.js" should be mapped With the <base> element, the correct "module_simpleExport.mjs" should be mapped
to "scope1/module_simpleExport.js", instead of "./module_simpleExport.js". to "scope1/module_simpleExport.mjs", instead of "./module_simpleExport.mjs".
--> -->
<script type="importmap"> <script type="importmap">
{ {
"imports": { "imports": {
"simple": "./module_simpleExport.js" "simple": "./module_simpleExport.mjs"
} }
} }
</script> </script>
@ -28,7 +28,7 @@ to "scope1/module_simpleExport.js", instead of "./module_simpleExport.js".
result2 = x; result2 = x;
</script> </script>
<script type="module" src="module_simpleImportMap.js"></script> <script type="module" src="module_simpleImportMap.mjs"></script>
<script> <script>
var result_scope1, result2; var result_scope1, result2;

View file

@ -9,16 +9,16 @@
<!--There is a module load before the import map tag, so the import map cannot--> <!--There is a module load before the import map tag, so the import map cannot-->
<!--be accepted according to the spec.--> <!--be accepted according to the spec.-->
<!--And because the import map is rejected, so the module specifier--> <!--And because the import map is rejected, so the module specifier-->
<!--"./module_simpleExport.js" won't be remapped to--> <!--"./module_simpleExport.mjs" won't be remapped to-->
<!--"./scope1/module_simpleExport.js".--> <!--"./scope1/module_simpleExport.mjs".-->
<script src="./module_simpleExport.js" type="module"> <script src="./module_simpleExport.mjs" type="module">
</script> </script>
<script type="importmap" onerror='importMapError()'> <script type="importmap" onerror='importMapError()'>
{ {
"imports": { "imports": {
"./module_simpleExport.js": "./scope1/module_simpleExport.js" "./module_simpleExport.mjs": "./scope1/module_simpleExport.mjs"
} }
} }
</script> </script>
@ -32,7 +32,7 @@
} }
function testLoaded() { function testLoaded() {
import("./module_simpleExport.js").then((ns) => { import("./module_simpleExport.mjs").then((ns) => {
ok(ns.x == 42, 'Check simple imported value result: ' + ns.x); ok(ns.x == 42, 'Check simple imported value result: ' + ns.x);
ok(hasError, "onerror of the import map should be called."); ok(hasError, "onerror of the import map should be called.");
}).catch((e) => { }).catch((e) => {

View file

@ -24,7 +24,7 @@ console.registerListener(listener);
<script type="importmap" onerror='importMapError1()'> <script type="importmap" onerror='importMapError1()'>
{ {
"imports": { "imports": {
"./module_simpleExport.js": "./scope1/module_simpleExport.js" "./module_simpleExport.mjs": "./scope1/module_simpleExport.mjs"
} }
} }
</script> </script>
@ -33,7 +33,7 @@ console.registerListener(listener);
<script type="importmap" onerror='importMapError2()'> <script type="importmap" onerror='importMapError2()'>
{ {
"imports": { "imports": {
"./module_simpleExport.js": "./scope1/module_simpleExport.js" "./module_simpleExport.mjs": "./scope1/module_simpleExport.mjs"
} }
} }
</script> </script>
@ -50,7 +50,7 @@ console.registerListener(listener);
} }
function testLoaded() { function testLoaded() {
import("./module_simpleExport.js").then((ns) => { import("./module_simpleExport.mjs").then((ns) => {
ok(ns.x == 84, 'Check simple imported value result: ' + ns.x); ok(ns.x == 84, 'Check simple imported value result: ' + ns.x);
ok(hasError, "onerror of the import map should be called."); ok(hasError, "onerror of the import map should be called.");
ok(gotMsg, "Should have got the console warning."); ok(gotMsg, "Should have got the console warning.");

View file

@ -4,17 +4,17 @@
<script type="importmap"> <script type="importmap">
{ {
"imports": { "imports": {
"simple": "./module_simpleExport.js", "simple": "./module_simpleExport.mjs",
"dir/": "/content/chrome/dom/base/test/jsmodules/importmaps/", "dir/": "/content/chrome/dom/base/test/jsmodules/importmaps/",
"./module.js": "/content/chrome/dom/base/test/jsmodules/importmaps/module_simpleExport.js", "./module.mjs": "/content/chrome/dom/base/test/jsmodules/importmaps/module_simpleExport.mjs",
"https://example.com/module.js": "./module_simpleExport.js" "https://example.com/module.mjs": "./module_simpleExport.mjs"
}, },
"scopes": { "scopes": {
"chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/": { "chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/": {
"simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/module_simpleExport.js" "simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/module_simpleExport.mjs"
}, },
"chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/": { "chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/": {
"simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/module_simpleExport.js" "simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/module_simpleExport.mjs"
} }
} }
} }
@ -39,24 +39,24 @@
import("simple").then((ns) => { import("simple").then((ns) => {
ok(ns.x == 42, 'Check simple imported value result: ' + ns.x); ok(ns.x == 42, 'Check simple imported value result: ' + ns.x);
return import("dir/module_simpleExport.js"); return import("dir/module_simpleExport.mjs");
}).then((ns) => { }).then((ns) => {
ok(ns.x == 42, 'Check dir imported value result: ' + ns.x); ok(ns.x == 42, 'Check dir imported value result: ' + ns.x);
return import("./module.js"); return import("./module.mjs");
}).then((ns) => { }).then((ns) => {
ok(ns.x == 42, 'Check remap imported value result: ' + ns.x); ok(ns.x == 42, 'Check remap imported value result: ' + ns.x);
return import("https://example.com/module.js"); return import("https://example.com/module.mjs");
}).then((ns) => { }).then((ns) => {
ok(ns.x == 42, 'Check remap https imported value result: ' + ns.x); ok(ns.x == 42, 'Check remap https imported value result: ' + ns.x);
SimpleTest.finish(); SimpleTest.finish();
}); });
} }
</script> </script>
<script type="module" src="module_simpleImportMap.js"></script> <script type="module" src="module_simpleImportMap.mjs"></script>
<script type="module" src="module_simpleImportMap_dir.js"></script> <script type="module" src="module_simpleImportMap_dir.mjs"></script>
<script type="module" src="module_simpleImportMap_remap.js"></script> <script type="module" src="module_simpleImportMap_remap.mjs"></script>
<script type="module" src="module_simpleImportMap_remap_https.js"></script> <script type="module" src="module_simpleImportMap_remap_https.mjs"></script>
<script type="module" src="module_simpleImportMap_remap_https.js"></script> <script type="module" src="module_simpleImportMap_remap_https.mjs"></script>
<script type="module" src="scope1/module_simpleImportMap.js"></script> <script type="module" src="scope1/module_simpleImportMap.mjs"></script>
<script type="module" src="scope1/scope2/module_simpleImportMap.js"></script> <script type="module" src="scope1/scope2/module_simpleImportMap.mjs"></script>
<body onload='testLoaded()'></body> <body onload='testLoaded()'></body>

View file

@ -33,10 +33,10 @@ https://html.spec.whatwg.org/multipage/webappapis.html#sorting-and-normalizing-s
}, },
"scopes": { "scopes": {
"chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/": { "chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/": {
"simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/module_simpleExport.js" "simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/module_simpleExport.mjs"
}, },
"chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/": { "chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/": {
"simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/module_simpleExport.js" "simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/module_simpleExport.mjs"
} }
} }
} }
@ -57,6 +57,6 @@ https://html.spec.whatwg.org/multipage/webappapis.html#sorting-and-normalizing-s
SimpleTest.finish(); SimpleTest.finish();
} }
</script> </script>
<script type="module" src="module_sortedImportMap.js"></script> <script type="module" src="module_sortedImportMap.mjs"></script>
<script type="module" src="scope1/scope2/module_simpleImportMap.js"></script> <script type="module" src="scope1/scope2/module_simpleImportMap.mjs"></script>
<body onload='testLoaded()'></body> <body onload='testLoaded()'></body>

View file

@ -1 +0,0 @@
import "invalid specifier";

View file

@ -0,0 +1,2 @@
/* eslint-disable import/no-unassigned-import, import/no-unresolved */
import "invalid specifier";

View file

@ -1,4 +1,4 @@
import { func2 } from "./module_cyclic2.js"; import { func2 } from "./module_cyclic2.mjs";
export function func1(x, y) { export function func1(x, y) {
if (x <= 0) { if (x <= 0) {

View file

@ -1,4 +1,4 @@
import { func3 } from "./module_cyclic3.js"; import { func3 } from "./module_cyclic3.mjs";
export function func2(x, y) { export function func2(x, y) {
if (x <= 0) { if (x <= 0) {

View file

@ -1,4 +1,4 @@
import { func1 } from "./module_cyclic1.js"; import { func1 } from "./module_cyclic1.mjs";
export function func3(x, y) { export function func3(x, y) {
if (x <= 0) { if (x <= 0) {

View file

@ -1 +0,0 @@
import { missing } from "./module_simple1.js";

View file

@ -0,0 +1 @@
import { missing } from "./module_simple1.mjs";

View file

@ -1,4 +0,0 @@
import "./module_simple1.js";
import "./module_simple2.js";
import "./module_simple3.js";
results.push(4);

View file

@ -0,0 +1,6 @@
/* eslint-disable import/no-unassigned-import */
import "./module_simple1.mjs";
import "./module_simple2.mjs";
import "./module_simple3.mjs";
results.push(4);

View file

@ -1,4 +0,0 @@
import "./module_large1.js";
import "./module_large2.js";
import "./module_large3.js";
results.push(4);

View file

@ -0,0 +1,6 @@
/* eslint-disable import/no-unassigned-import */
import "./module_large1.mjs";
import "./module_large2.mjs";
import "./module_large3.mjs";
results.push(4);

View file

@ -1,2 +0,0 @@
import { x } from "./module_simpleExport.js";
result = x;

View file

@ -0,0 +1,3 @@
import { x } from "./module_simpleExport.mjs";
result = x;

View file

@ -28,7 +28,7 @@
results.push(1); results.push(1);
</script> </script>
<script type="module" async> <script type="module" async>
import "./module_simple2.js"; import "./module_simple2.mjs";
</script> </script>
<script type="module" async> <script type="module" async>
results.push(3); results.push(3);

Some files were not shown because too many files have changed in this diff Show more