-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISO 2022-jp encoding and decoding tests
Closes #3199, which this is an updated version of.
- Loading branch information
Showing
31 changed files
with
16,695 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
encoding/legacy-mb-japanese/iso-2022-jp/iso2022jp-decode-csiso2022jp.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-GB"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>csiso2022jp decoding</title> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org"> | ||
<link rel="help" href="https://encoding.spec.whatwg.org/#iso-2022-jp"> | ||
<meta name="assert" content="The browser produces the same decoding behavior for a document labeled 'csiso2022jp' as for a document labeled 'iso-2022-jp'."> | ||
<style> | ||
iframe { display:none } | ||
</style> | ||
<script src="jis0208_index.js"></script> | ||
<script src="iso2022jp-decoder.js"></script> | ||
</head> | ||
|
||
<body onload="showNodes();"> | ||
|
||
<iframe src="iso2022jp_chars-csiso2022jp.html" name="scriptWindow" id="scrwin"></iframe> | ||
|
||
<div id="log"></div> | ||
|
||
<script> | ||
var tests = []; | ||
|
||
function iframeRef(frameRef) { | ||
return frameRef.contentWindow | ||
? frameRef.contentWindow.document | ||
: frameRef.contentDocument; | ||
} | ||
|
||
function showNodes() { | ||
var iframe = iframeRef(document.getElementById("scrwin")); | ||
nodes = iframe.querySelectorAll("span"); | ||
|
||
for (var i = 0; i < nodes.length; i++) { | ||
tests[i] = async_test( | ||
"U+" + | ||
nodes[i].dataset.cp + | ||
" " + | ||
String.fromCodePoint(parseInt(nodes[i].dataset.cp, 16)) + | ||
" " + | ||
iso2022jpDecoder(nodes[i].dataset.bytes) + | ||
" " + | ||
nodes[i].dataset.bytes | ||
); | ||
} | ||
|
||
for (var i = 0; i < nodes.length; i++) { | ||
tests[i].step(function() { | ||
assert_equals( | ||
nodes[i].textContent, | ||
iso2022jpDecoder(nodes[i].dataset.bytes) | ||
); | ||
}); | ||
tests[i].done(); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |
107 changes: 107 additions & 0 deletions
107
encoding/legacy-mb-japanese/iso-2022-jp/iso2022jp-decode-errors.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-GB"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>ISO 2022-JP decoding errors</title> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org"> | ||
<link rel="help" href="https://encoding.spec.whatwg.org/#euc-jp"> | ||
<meta name="assert" content="When decoding iso-2022-jp text, the browser uses replacement characters as described by the algorithm in the Encoding spec."> | ||
<style> | ||
iframe { display:none } | ||
form { display:none } | ||
</style> | ||
</head> | ||
|
||
<body onload="showNodes();"> | ||
|
||
<iframe src="iso2022jp_errors.html" name="scriptWindow" id="scrwin"></iframe> | ||
|
||
<div id="log"></div> | ||
|
||
<script> | ||
var tests = []; | ||
|
||
function iframeRef(frameRef) { | ||
return frameRef.contentWindow | ||
? frameRef.contentWindow.document | ||
: frameRef.contentDocument; | ||
} | ||
|
||
function showNodes() { | ||
var iframe = iframeRef(document.getElementById("scrwin")); | ||
var nodes = iframe.querySelectorAll("span"); | ||
|
||
var t = -1; | ||
t++; | ||
tests[t] = async_test("ascii: 0E 24 42 79 56 1B 28 42"); | ||
t++; | ||
tests[t] = async_test("roman: 1B 28 4A 0F 1B 28 42"); | ||
t++; | ||
tests[t] = async_test("katakana: 1B 28 49 65 1B 28 42"); | ||
|
||
t++; | ||
tests[t] = async_test( | ||
"lead byte and trail byte 1B: 1B 24 42 7F 56 1B 28 42" | ||
); | ||
t++; | ||
tests[t] = async_test("trail byte null index code point: 1B 24 42 24 74"); | ||
//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 | ||
t++; | ||
tests[t] = async_test("trail byte out of range: 1B 24 42 79 7F 1B 28 42"); | ||
|
||
t++; | ||
tests[t] = async_test("escape start: 1B 65 79 56 1B 28 42"); | ||
t++; | ||
tests[t] = async_test("escape: 1B 24 65 79 56 1B 28 42"); | ||
|
||
t = -1; | ||
t++; | ||
tests[t].step(function() { | ||
assert_equals(nodes[t].textContent, "�$ByV"); | ||
}); | ||
tests[t].done(); | ||
t++; | ||
tests[t].step(function() { | ||
assert_equals(nodes[t].textContent, "�"); | ||
}); | ||
tests[t].done(); | ||
t++; | ||
tests[t].step(function() { | ||
assert_equals(nodes[t].textContent, "�"); | ||
}); | ||
tests[t].done(); | ||
t++; | ||
tests[t].step(function() { | ||
assert_equals(nodes[t].textContent, "��"); | ||
}); | ||
tests[t].done(); | ||
t++; | ||
tests[t].step(function() { | ||
assert_equals(nodes[t].textContent, "�"); | ||
}); | ||
tests[t].done(); | ||
//t++; tests[t].step(function() {assert_equals(nodes[t].textContent, '�') } ) | ||
//tests[t].done() | ||
t++; | ||
tests[t].step(function() { | ||
assert_equals(nodes[t].textContent, "�"); | ||
}); | ||
tests[t].done(); | ||
t++; | ||
tests[t].step(function() { | ||
assert_equals(nodes[t].textContent, "�eyV"); | ||
}); | ||
tests[t].done(); | ||
t++; | ||
tests[t].step(function() { | ||
assert_equals(nodes[t].textContent, "�$eyV"); | ||
}); | ||
tests[t].done(); | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
|
63 changes: 63 additions & 0 deletions
63
encoding/legacy-mb-japanese/iso-2022-jp/iso2022jp-decode.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-GB"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>ISO 2022-JP decoding</title> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<link rel="author" title="Richard Ishida" href="mailto:ishida@w3.org"> | ||
<link rel="help" href="https://encoding.spec.whatwg.org/#iso-2022-jp"> | ||
<meta name="assert" content="The browser decodes all characters as expected from a file generated by encoding all pointers in the iso-2022-jp encoding per the encoder steps in the specification."> | ||
<style> | ||
iframe { display:none } | ||
</style> | ||
<script src="jis0208_index.js"></script> | ||
<script src="iso2022jp-decoder.js"></script> | ||
</head> | ||
|
||
<body onload="showNodes();"> | ||
|
||
<iframe src="iso2022jp_chars.html" name="scriptWindow" id="scrwin"></iframe> | ||
|
||
<div id="log"></div> | ||
|
||
<script> | ||
var tests = []; | ||
|
||
function iframeRef(frameRef) { | ||
return frameRef.contentWindow | ||
? frameRef.contentWindow.document | ||
: frameRef.contentDocument; | ||
} | ||
|
||
function showNodes() { | ||
var iframe = iframeRef(document.getElementById("scrwin")); | ||
nodes = iframe.querySelectorAll("span"); | ||
|
||
for (var i = 0; i < nodes.length; i++) { | ||
tests[i] = async_test( | ||
"U+" + | ||
nodes[i].dataset.cp + | ||
" " + | ||
String.fromCodePoint(parseInt(nodes[i].dataset.cp, 16)) + | ||
" " + | ||
iso2022jpDecoder(nodes[i].dataset.bytes) + | ||
" " + | ||
nodes[i].dataset.bytes | ||
); | ||
} | ||
|
||
for (var i = 0; i < nodes.length; i++) { | ||
tests[i].step(function() { | ||
assert_equals( | ||
nodes[i].textContent, | ||
iso2022jpDecoder(nodes[i].dataset.bytes) | ||
); | ||
}); | ||
tests[i].done(); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.