modulepreload-sri-importmap.html (848B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script type="importmap"> 6 { 7 "imports": { 8 "test": "https://example.com/test.js" 9 } 10 } 11 </script> 12 <link rel="modulepreload" href="resources/module1.js" integrity="sha384-invalid"> 13 <script type="module" src="resources/module1.js" id="myscript"></script> 14 <body> 15 <script> 16 // compared to modulepreload.html, this tests behavior when elements are 17 // initially on an HTML page instead of being added by JS 18 promise_test(() => { 19 return new Promise((resolve, reject) => { 20 let myscript = document.querySelector('#myscript'); 21 myscript.onerror = resolve; 22 myscript.onload = reject; 23 }); 24 }, "Script should not be loaded if modulepreload's integrity is invalid"); 25 </script>