static-integrity.html (2222B)
1 <!DOCTYPE html> 2 <html> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script> 6 let log = []; 7 </script> 8 <script type="importmap"> 9 { 10 "imports": { 11 "./resources/log.js?pipe=sub&name=A": "./resources/log.js?pipe=sub&name=B", 12 "./resources/log.js?pipe=sub&name=C": "./resources/log.js?pipe=sub&name=D" 13 }, 14 "integrity": { 15 "./resources/log.js?pipe=sub&name=B": "sha384-Li9vy3DqF8tnTXuiaAJuML3ky+er10rcgNR/VqsVpcw+ThHmYcwiB1pbOxEbzJr7", 16 "./resources/log.js?pipe=sub&name=D": "sha384-rxZqznFuOnvObm6JJKVmwzBXrsRG25IepqKDFHGhtitRu9YPjxPpRPMIu2hzvtxF", 17 "./resources/log.js?pipe=sub&name=X": "sha384-mCon9M46vUfNK2Wb3yjvBmpBw/3hwB+wMYS8IzDBng+7//R5Qao35E1azo4gFVzx", 18 "./resources/log.js?pipe=sub&name=Y": "sha384-u0yaFlBF39Au++qcn+MGL/Ml7UmuVfLymNJAz6Yyi4RqyUfWelcuAzVyE8Shs9xn", 19 "./resources/log.js?pipe=sub&name=Z": "sha384-u0yaFlBF39Au++qcn+MGL/Ml7UmuVfLymNJAz6Yyi4RqyUfWelcuAzVyE8Shs9xn" 20 } 21 } 22 </script> 23 <script type="module"> 24 import './resources/log.js?pipe=sub&name=A'; 25 </script> 26 <script type="module"> 27 test(t => { 28 assert_array_equals(log, []); 29 }, 'Static script did not load as it failed its integrity check'); 30 log = []; 31 </script> 32 <script type="module"> 33 import './resources/log.js?pipe=sub&name=C'; 34 </script> 35 <script type="module"> 36 test(t => { 37 assert_array_equals(log, ["log:D"]); 38 }, 'Static script loaded as its integrity check passed'); 39 log = []; 40 </script> 41 <script type="module"> 42 import './resources/log.js?pipe=sub&name=X'; 43 </script> 44 <script type="module"> 45 test(t => { 46 assert_array_equals(log, []); 47 }, 'Static script did not load as it failed its integrity check, even' + 48 ' without an import defined'); 49 log = []; 50 </script> 51 <script type="module"> 52 import './resources/log.js?pipe=sub&name=Y'; 53 </script> 54 <script type="module"> 55 test(t => { 56 assert_array_equals(log, ["log:Y"]); 57 }, 'Static script loaded as its integrity check passed without an import' + 58 ' defined'); 59 log = []; 60 </script> 61 <script type="module" src="./resources/log.js?pipe=sub&name=Z">; 62 </script> 63 <script type="module"> 64 test(t => { 65 assert_array_equals(log, []); 66 }, 'HTML-based module script did not load as its integrity check failed.'); 67 log = []; 68 </script>