applied-to-target-dynamic.sub.html (1160B)
1 <!DOCTYPE html> 2 <html> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="../resources/test-helper.js"></script> 6 <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';"> 7 <script type="importmap"> 8 { 9 "imports": { 10 "../resources/log.js?pipe=sub&name=A": "https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=B", 11 "https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=C": "../resources/log.js?pipe=sub&name=D" 12 } 13 } 14 </script> 15 <script> 16 promise_test(t => { 17 return promise_rejects_js(t, TypeError, 18 import('../resources/log.js?pipe=sub&name=A'), 19 'Dynamic import should fail'); 20 }, 'The URL after mapping violates CSP (but not the URL before mapping)'); 21 22 promise_test(t => { 23 return import('https://{{domains[www1]}}:{{ports[https][0]}}/import-maps/resources/log.js?pipe=sub&name=C') 24 .then(() => assert_array_equals(log, ["log:D"])); 25 }, 'The URL before mapping violates CSP (but not the URL after mapping)'); 26 </script>