external-script-bare-descendent.html (1497B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 </head> 7 <body> 8 <script type="importmap"> 9 { 10 "imports": { 11 "a": "../resources/log.sub.js?name=A", 12 "foo/bar": "../resources/log.sub.js?name=FOOBAR" 13 } 14 } 15 </script> 16 <script type="module" src="../resources/importer.sub.js?name=a"></script> 17 <script type="module" src="../resources/importer.sub.js?name=foo/bar"></script> 18 <script> 19 const log = []; 20 21 // Try to redefine the descendent with an import map 22 </script> 23 <script type="importmap"> 24 { 25 "imports": { 26 "a": "../resources/log.sub.js?name=B", 27 "foo/bar": "../resources/log.sub.js?name=OtherFoobar", 28 "foo/": "../resources/log.sub.js?name=OtherFoo", 29 "foo": "../resources/log.sub.js?name=foo" 30 } 31 } 32 </script> 33 <script type="module"> 34 // Testing that the resolution is correct using `resolve`, as you can't import 35 // the same module twice. 36 test(() => { 37 assert_true(import.meta.resolve("a").endsWith("/resources/log.sub.js?name=A")); 38 }, "Resolution after import map should not be redefined"); 39 40 test(() => { 41 assert_true(import.meta.resolve("foo/bar").endsWith("/resources/log.sub.js?name=FOOBAR")); 42 }, "Resolution after import map should not be redefined for bare prefixes or exact matches"); 43 44 test(() => { 45 assert_true(import.meta.resolve("foo").endsWith("/resources/log.sub.js?name=foo")); 46 }, "Resolution after import map should be redefined for non-prefixes"); 47 </script> 48 </body> 49 </html>