tor-browser

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

script-charset-01.html (3626B)


      1 <!DOCTYPE html>
      2 <head>
      3  <meta charset="utf-8">
      4  <title>Script @type: unknown parameters</title>
      5  <link rel="author" title="askalski" href="github.com/askalski">
      6  <link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages">
      7  <script src="/resources/testharness.js"></script>
      8  <script src="/resources/testharnessreport.js"></script>
      9  <div id="log"></div>
     10 
     11  <!-- "Step1" tests -->
     12  <!-- charset is set incorrectly via Content Type "text/javascript;charset=utf-8" in response
     13      which has priority before a correct setting in "charset" attribute of script tag.
     14   -->
     15  <script type="text/javascript"
     16    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript%3Bcharset=utf-8" charset="windows-1250">
     17  </script>
     18  <script>
     19  test(function() {
     20    //these strings should not match, since the file charset is set incorrectly
     21    assert_not_equals(window.getSomeString(), "śćążź");
     22  });
     23  </script>
     24  <!-- charset is set correctly via Content Type "text/javascript;charset=utf-8" in response
     25      which has priority before a incorrect setting in "charset" attribute of script tag.
     26   -->
     27 
     28  <script type="text/javascript"
     29    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript%3Bcharset=windows-1250" charset="utf-8">
     30  </script>
     31  <script>
     32  //the charset is set correctly via Content Type "text/javascript;charset=windows-1250" in respones
     33  test(function() {
     34    assert_equals(window.getSomeString(), "śćążź");
     35  });
     36  </script>
     37 
     38  <!-- end of step1 tests, now step2 tests -->
     39  <!-- in this case, the response's Content Type does not bring charset information.
     40  Second step takes block character encoding if available.-->
     41  <script type="text/javascript"
     42    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript" charset="utf-8">
     43  </script>
     44  <script>
     45  test(function() {
     46    //these strings should not match, since the file charset is set incorrectly in "charset" tag of <script> above
     47    assert_not_equals(window.getSomeString(), "śćążź");
     48  });
     49  </script>
     50  <!-- charset is set correctly via Content Type "text/javascript;charset=utf-8" in response
     51      which has priority before a incorrect setting in "charset" attribute of script tag.
     52   -->
     53 
     54  <script type="text/javascript"
     55    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript" charset="windows-1250">
     56  </script>
     57  <script>
     58  //the charset is set correctly via content attribute in <script> above
     59  test(function() {
     60    assert_equals(window.getSomeString(), "śćążź");
     61  });
     62  </script>
     63 
     64  <!-- end of step2 tests, now step3 tests -->
     65  <!-- in this case, neither response's Content Type nor charset attribute bring correct charset information.
     66  Third step takes this document's character encoding (declared correctly as UTF-8).-->
     67  <script type="text/javascript"
     68    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript">
     69  </script>
     70  <script>
     71  test(function() {
     72    //these strings should not match, since the tested file is in windows-1250, and document is utf-8
     73    assert_not_equals(window.getSomeString(), "śćążź");
     74  });
     75  </script>
     76 
     77  <script type="text/javascript"
     78    src="serve-with-content-type.py?fn=external-script-utf8.js&ct=text/javascript">
     79  </script>
     80  <script>
     81  //these strings should match, both document and tested file are utf-8
     82  test(function() {
     83    assert_equals(window.getSomeString(), "śćążź");
     84  });
     85  </script>
     86 
     87  <!-- the last portion of tests (step4) are in file script-charset-02.html
     88 
     89 </head>