tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

integrity.html (1865B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>&lt;script> integrity=""</title>
      4 <link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
      5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#prepare-a-script">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 
      9 <script>
     10 window.inlineRan = false;
     11 
     12 window.matchesLog = [];
     13 window.matchesEvents = [];
     14 
     15 window.mismatchesLog = [];
     16 window.mismatchesEvents = [];
     17 </script>
     18 
     19 <script type="module" integrity="sha384-garbage">
     20 window.inlineRan = true;
     21 </script>
     22 
     23 <script type="module" src="integrity-matches.js" integrity="sha384-1/XwTy38IAlmvk1O674Efus1/REqfuX6x0V/B2/GX5R3lNbRjhrIwlWyEDPyOwpN" onload="window.matchesEvents.push('load');" onerror="window.matchesEvents.push('error')"></script>
     24 <script type="module" src="integrity-mismatches.js" integrity="sha384-doesnotmatch" onload="window.mismatchesEvents.push('load');" onerror="window.mismatchesEvents.push('error')"></script>
     25 
     26 <script type="module">
     27 test(() => {
     28  assert_true(window.inlineRan);
     29 }, "The integrity attribute must have no affect on inline module scripts");
     30 
     31 test(() => {
     32  assert_array_equals(window.matchesLog, ["integrity-matches-inner", "integrity-matches"], "The module and its dependency must have executed");
     33  assert_array_equals(window.matchesEvents, ["load"], "The load event must have fired");
     34 }, "The integrity attribute must be verified on the top-level of a module and allow it to execute when it matches");
     35 
     36 test(() => {
     37  assert_array_equals(window.mismatchesLog, [], "The module and its dependency must not have executed");
     38  assert_array_equals(window.mismatchesEvents, ["error"], "The error event must have fired");
     39 }, "The integrity attribute must be verified on the top-level of a module and not allow it to execute when there's a mismatch");
     40 </script>