diff options
Diffstat (limited to '')
-rw-r--r-- | dom/base/test/jsmodules/importmaps/test_sortedImportMap.html | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/dom/base/test/jsmodules/importmaps/test_sortedImportMap.html b/dom/base/test/jsmodules/importmaps/test_sortedImportMap.html new file mode 100644 index 0000000000..17e4049d1a --- /dev/null +++ b/dom/base/test/jsmodules/importmaps/test_sortedImportMap.html @@ -0,0 +1,62 @@ +<!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: +https://html.spec.whatwg.org/multipage/webappapis.html#sorting-and-normalizing-a-module-specifier-map, Step 3. +https://html.spec.whatwg.org/multipage/webappapis.html#sorting-and-normalizing-scopes, Step 3. +--> + +<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": { + "chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/": { + "simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/scope2/module_simpleExport.js" + }, + "chrome://mochitests/content/chrome/dom/base/test/jsmodules/importmaps/scope1/": { + "simple": "/content/chrome/dom/base/test/jsmodules/importmaps/scope1/module_simpleExport.js" + } + } +} +</script> + +<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></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.js"></script> +<script type="module" src="scope1/scope2/module_simpleImportMap.js"></script> +<body onload='testLoaded()'></body> |