prefix.html (1093B)
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> 9 const log = []; 10 11 // First, use a module specifier 12 promise_test(() => { 13 return import("../resources/log.js?pipe=sub&name=A") 14 .then(() => { 15 assert_array_equals(log, ["log:A"], "First import should use original module"); 16 }); 17 }, "Initial import before import map"); 18 19 // Now try to redefine it with an import map 20 </script> 21 <script type="importmap"> 22 { 23 "imports": { 24 "../resources/": "/foobar/" 25 } 26 } 27 </script> 28 <script type="module"> 29 // Testing that the resolution is correct using `resolve`, as you can't import 30 // the same module twice. 31 test(() => { 32 assert_false(import.meta.resolve("../resources/log.js?pipe=sub&name=A") 33 .endsWith("/foobar/log.js?pipe=sub&name=A")); 34 assert_true(import.meta.resolve("../resources/log.js?pipe=sub&name=A") 35 .endsWith("/resources/log.js?pipe=sub&name=A")); 36 }, "Prefix resolution after import map should not be redefined"); 37 </script> 38 </body> 39 </html>