module-import-referrer.html (1450B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Referrer for module imports</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script>setup({ explicit_done: true })</script> 8 </head> 9 <body> 10 <script type="module"> 11 12 import { referrerExternalStatic, referrerExternalDynamic } from "./module-import-referrer.js"; 13 14 // "name" parameter is necessary for bypassing the module map. 15 import { referrer as referrerInlineStatic } from "./resources/referrer-checker.py?name=internal-static" 16 const { referrer: referrerInlineDynamic } = await import("./resources/referrer-checker.py?name=internal-dynamic"); 17 18 const scriptURL = new URL("module-import-referrer.js", location.href) 19 20 test(t => { 21 assert_equals( 22 referrerInlineStatic, location.href, 23 "Referrer should be the document URL"); 24 }, "Static imports from inline modules in the HTML document"); 25 26 test(t => { 27 assert_equals( 28 referrerInlineDynamic, location.href, 29 "Referrer should be the document URL"); 30 }, "Dynamic imports from inline modules in the HTML document"); 31 32 test(t => { 33 assert_equals( 34 referrerExternalStatic, scriptURL.href, 35 "Referrer should be the importer module URL"); 36 }, "Static imports from external modules"); 37 38 test(t => { 39 assert_equals( 40 referrerExternalDynamic, scriptURL.href, 41 "Referrer should be the document URL"); 42 }, "Dynamic imports from external modules"); 43 44 done(); 45 46 </script> 47 </body> 48 </html>