File: script-charset-01.html

package info (click to toggle)
firefox-esr 115.14.0esr-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,659,200 kB
  • sloc: cpp: 6,676,648; javascript: 5,690,850; ansic: 3,328,545; python: 1,120,605; asm: 397,163; xml: 180,531; java: 178,838; sh: 68,930; makefile: 20,999; perl: 12,595; objc: 12,561; yacc: 4,583; cs: 3,846; pascal: 2,840; lex: 1,720; ruby: 1,079; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (89 lines) | stat: -rw-r--r-- 3,626 bytes parent folder | download | duplicates (32)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <title>Script @type: unknown parameters</title>
  <link rel="author" title="askalski" href="github.com/askalski">
  <link rel="help" href="https://html.spec.whatwg.org/multipage/#scriptingLanguages">
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <div id="log"></div>

  <!-- "Step1" tests -->
  <!-- charset is set incorrectly via Content Type "text/javascript;charset=utf-8" in response
      which has priority before a correct setting in "charset" attribute of script tag.
   -->
  <script type="text/javascript"
    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript%3Bcharset=utf-8" charset="windows-1250">
  </script>
  <script>
  test(function() {
    //these strings should not match, since the file charset is set incorrectly
    assert_not_equals(window.getSomeString(), "śćążź");
  });
  </script>
  <!-- charset is set correctly via Content Type "text/javascript;charset=utf-8" in response
      which has priority before a incorrect setting in "charset" attribute of script tag.
   -->

  <script type="text/javascript"
    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript%3Bcharset=windows-1250" charset="utf-8">
  </script>
  <script>
  //the charset is set correctly via Content Type "text/javascript;charset=windows-1250" in respones
  test(function() {
    assert_equals(window.getSomeString(), "śćążź");
  });
  </script>

  <!-- end of step1 tests, now step2 tests -->
  <!-- in this case, the response's Content Type does not bring charset information.
  Second step takes block character encoding if available.-->
  <script type="text/javascript"
    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript" charset="utf-8">
  </script>
  <script>
  test(function() {
    //these strings should not match, since the file charset is set incorrectly in "charset" tag of <script> above
    assert_not_equals(window.getSomeString(), "śćążź");
  });
  </script>
  <!-- charset is set correctly via Content Type "text/javascript;charset=utf-8" in response
      which has priority before a incorrect setting in "charset" attribute of script tag.
   -->

  <script type="text/javascript"
    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript" charset="windows-1250">
  </script>
  <script>
  //the charset is set correctly via content attribute in <script> above
  test(function() {
    assert_equals(window.getSomeString(), "śćążź");
  });
  </script>

  <!-- end of step2 tests, now step3 tests -->
  <!-- in this case, neither response's Content Type nor charset attribute bring correct charset information.
  Third step takes this document's character encoding (declared correctly as UTF-8).-->
  <script type="text/javascript"
    src="serve-with-content-type.py?fn=external-script-windows1250.js&ct=text/javascript">
  </script>
  <script>
  test(function() {
    //these strings should not match, since the tested file is in windows-1250, and document is utf-8
    assert_not_equals(window.getSomeString(), "śćążź");
  });
  </script>

  <script type="text/javascript"
    src="serve-with-content-type.py?fn=external-script-utf8.js&ct=text/javascript">
  </script>
  <script>
  //these strings should match, both document and tested file are utf-8
  test(function() {
    assert_equals(window.getSomeString(), "śćążź");
  });
  </script>

  <!-- the last portion of tests (step4) are in file script-charset-02.html

</head>