tor-browser

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

script-charset-02.html (1767B)


      1 <!DOCTYPE html>
      2 <head>
      3  <title>Script encoding for document encoding windows-1250</title>
      4  <link rel="author" title="askalski" href="github.com/askalski">
      5  <link rel="author" title="Aaqa Ishtyaq" href="github.com/aaqaishtyaq">
      6  <link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-script">
      7  <script src="/resources/testharness.js"></script>
      8  <script src="/resources/testharnessreport.js"></script>
      9  <div id="log"></div>
     10  <!-- to avoid conflating tests for script encoding declaring the encoding at the top of file. i.e, windows-1250-->
     11  <meta charset="windows-1250">
     12  <script>
     13  test(function() {
     14    assert_equals(document.characterSet, "windows-1250")
     15  }, "assumption: document encoding is windows-1250");
     16  </script>
     17 
     18  <!-- in this case, neither response's Content Type nor charset attribute bring correct charset information.
     19  -->
     20  <script type="text/javascript"
     21    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript">
     22  </script>
     23 
     24  <script>
     25  test(function() {
     26    //these string should match since, windows-1250 is the fallback encoding.
     27    assert_equals(window.getSomeString(), "\u015b\u0107\u0105\u017c\u017a");
     28  }, "windows-1250 script decoded using document encoding (also windows-1250)");
     29  </script>
     30 
     31  <script type="text/javascript"
     32    src="serve-with-content-type.py?fn=external-script-utf8.js&ct=text/javascript">
     33  </script>
     34  <script>
     35  //these strings should match, since this string is the result of decoding the utf-8 text as windows-1250.
     36  test(function() {
     37    assert_equals(window.getSomeString(), "\u0139\u203a\xc4\u2021\xc4\u2026\u0139\u013d\u0139\u015f");
     38  }, "UTF-8 script decoded using document encoding (windows-1250)");
     39  </script>
     40 
     41 </head>