tor-browser

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

utf-8-lone-surrogate.html (1336B)


      1 <html>
      2 <head>
      3    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'nonce-abc' 'sha256-YJSaNEZFStZqU2Mp2EttwhcP2aT9lnDvexn+BM2HfKo=';">
      4    <script src='/resources/testharness.js'></script>
      5    <script src='/resources/testharnessreport.js'></script>
      6 </head>
      7 <body>
      8    <script nonce="abc">
      9      var t = async_test("Should convert the script contents to UTF-8 before hashing");
     10      var count = 0;
     11      var script_ran = function() {
     12        // if both blocks run the tests is succsssful
     13        if (++count == 2) t.done();
     14      }
     15      window.addEventListener("securitypolicyviolation", t.unreached_func("Should not have fired a spv"));
     16 
     17      // Insert a script element that contains the U+FFFD replacement character
     18      var scr1 = document.createElement('script');
     19      scr1.text ="//\uFFFD\nscript_ran();";
     20      document.body.appendChild(scr1);
     21 
     22      // Insert a script element that contains a surrogate character but it otherwise
     23      // entirely identical to the previously inserted one, the surrogate should be
     24      // be converted to U+FFFD when converting to UTF-8 so it should have the
     25      // same hash as the one inserted before
     26      var scr2 = document.createElement('script');
     27      scr2.text ="//\uD801\nscript_ran();";
     28      document.body.appendChild(scr2);
     29    </script>
     30 </body>
     31 </html>