integrity.html (1582B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title><script> integrity=""</title> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#prepare-a-script"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <script> 9 window.matchesLog = []; 10 window.matchesEvents = []; 11 12 window.mismatchesLog = []; 13 window.mismatchesEvents = []; 14 </script> 15 <script type="module" src="integrity-matches.js" integrity="sha384-kc1K2KFKQhnYE1AdnpmUUpFVnxz1GCgGbQ19e3zmXrZw23rgpwa9il4/pHp7NYWA" onload="window.matchesEvents.push('load');" onerror="window.matchesEvents.push('error')"></script> 16 <script type="module" src="integrity-mismatches.js" integrity="sha384-doesnotmatch" onload="window.mismatchesEvents.push('load');" onerror="window.mismatchesEvents.push('error')"></script> 17 18 <script type="module"> 19 test(() => { 20 assert_array_equals(window.matchesLog, ["integrity-matches,json:42"], "The module and its dependency must have executed"); 21 assert_array_equals(window.matchesEvents, ["load"], "The load event must have fired"); 22 }, "The integrity attribute must be verified on the top-level of a module loading a JSON module and allow it to execute when it matches"); 23 24 test(() => { 25 assert_array_equals(window.mismatchesLog, [], "The module and its dependency must not have executed"); 26 assert_array_equals(window.mismatchesEvents, ["error"], "The error event must have fired"); 27 }, "The integrity attribute must be verified on the top-level of a module loading a JSON module and not allow it to execute when there's a mismatch"); 28 </script>