Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
<!DOCTYPE html>
<meta charset=utf-8>
<title>Test a sorted import map</title>
<!--
According to Import maps spec, the entries in "imports" and "scopes" need to be
sorted. Key with longest prefix should be chosen. So "a/b/" should take
precendence over "a/".
This test is verifying that requirement.
In "imports" below, "scope1/scope2/" and "scope1/scope2/scope3/scope4/" should
be chosen over "scope1" and "scope1/scope2/scop3/" respectively.
Also "scope1/scope2/" is listed _after_ "scope1/ and
"scope1/scope2/scope3/scope4" is listed _before_ "scope1/scope2/scope3/" to make
sure the map is sorted.
For "scopes" below, the "scope1/" is listed before "scope1/scope2/" in
test_simpleImportMap.html, here we reverse the order, for example, we list
"scope1/" after "scope1/scope2/" in this test.
See:
-->
<script type="importmap">
{
"imports": {
"scope1/": "/content/chrome/dom/base/test/jsmodules/importmaps/",
"scope1/scope2/": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/",
"scope1/scope2/scope3/scope4/": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/",
"scope1/scope2/scope3/": "/content/chrome/dom/base/test/jsmodules/importmaps/"
},
"scopes": {
"simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/module_simpleExport.mjs"
},
"simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/module_simpleExport.mjs"
}
}
}
</script>
<script>
var sorted_result, sorted_result2;
var result_scope2;
SimpleTest.waitForExplicitFinish();
function testLoaded() {
ok(sorted_result == 126, 'Check imported value sorted_result: ' + sorted_result);
ok(sorted_result2 == 126, 'Check imported value sorted_result: ' + sorted_result2);
ok(result_scope2 == 126, 'Check imported value result_scope2: ' + result_scope2);
SimpleTest.finish();
}
</script>
<script type="module" src="module_sortedImportMap.mjs"></script>
<script type="module" src="scope1/scope2/module_simpleImportMap.mjs"></script>
<body onload='testLoaded()'></body>