• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<html lang="en-GB">
3<head>
4<meta charset="utf-8"/>
5<title>ISO 2022-JP decoding errors</title>
6<meta name="timeout" content="long">
7<script src="/resources/testharness.js"></script>
8<script src="/resources/testharnessreport.js"></script>
9<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org">
10<link rel="help" href="https://encoding.spec.whatwg.org/#euc-jp">
11<meta name="assert" content="When decoding iso-2022-jp text, the browser uses replacement characters as described by the algorithm in the Encoding spec.">
12<style>
13 iframe { display:none }
14 form { display:none }
15</style>
16</head>
17
18<body onload="showNodes();">
19
20<iframe src="iso2022jp_errors.html" name="scriptWindow" id="scrwin"></iframe>
21
22<div id="log"></div>
23
24<script>
25var tests = [];
26
27function iframeRef(frameRef) {
28    return frameRef.contentWindow
29        ? frameRef.contentWindow.document
30        : frameRef.contentDocument;
31}
32
33function showNodes() {
34    var iframe = iframeRef(document.getElementById("scrwin"));
35    var nodes = iframe.querySelectorAll("span");
36
37    var t = -1;
38    t++;
39    tests[t] = async_test("ascii: 0E 24 42 79 56 1B 28 42");
40    t++;
41    tests[t] = async_test("roman: 1B 28 4A 0F 1B 28 42");
42    t++;
43    tests[t] = async_test("katakana: 1B 28 49 65 1B 28 42");
44
45    t++;
46    tests[t] = async_test(
47        "lead byte and trail byte 1B: 1B 24 42 7F 56 1B 28 42"
48    );
49    t++;
50    tests[t] = async_test("trail byte null index code point: 1B 24 42 24 74");
51    //t++; tests[t] = async_test("trail byte end of stream: 1B 24 42 79")   not sure how to test this, since it corrupts the html following
52    t++;
53    tests[t] = async_test("trail byte out of range: 1B 24 42 79 7F 1B 28 42");
54
55    t++;
56    tests[t] = async_test("escape start: 1B 65 79 56 1B 28 42");
57    t++;
58    tests[t] = async_test("escape: 1B 24 65 79 56 1B 28 42");
59
60    t = -1;
61    t++;
62    tests[t].step(function() {
63        assert_equals(nodes[t].textContent, "�$ByV");
64    });
65    tests[t].done();
66    t++;
67    tests[t].step(function() {
68        assert_equals(nodes[t].textContent, "�");
69    });
70    tests[t].done();
71    t++;
72    tests[t].step(function() {
73        assert_equals(nodes[t].textContent, "�");
74    });
75    tests[t].done();
76    t++;
77    tests[t].step(function() {
78        assert_equals(nodes[t].textContent, "��");
79    });
80    tests[t].done();
81    t++;
82    tests[t].step(function() {
83        assert_equals(nodes[t].textContent, "�");
84    });
85    tests[t].done();
86    //t++; tests[t].step(function() {assert_equals(nodes[t].textContent, '�') } )
87    //tests[t].done()
88    t++;
89    tests[t].step(function() {
90        assert_equals(nodes[t].textContent, "�");
91    });
92    tests[t].done();
93    t++;
94    tests[t].step(function() {
95        assert_equals(nodes[t].textContent, "�eyV");
96    });
97    tests[t].done();
98    t++;
99    tests[t].step(function() {
100        assert_equals(nodes[t].textContent, "�$eyV");
101    });
102    tests[t].done();
103}
104</script>
105</body>
106</html>
107