chromium/third_party/blink/web_tests/external/wpt/encoding/legacy-mb-tchinese/big5/big5-decode-errors.html

<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8"/>
<title>Big5 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:[email protected]">
<link rel="help" href="https://encoding.spec.whatwg.org/#big5">
<meta name="assert" content="The browser decodes characters that are not recognised from the big5 encoding as replacement characters.">
<style>
 iframe { display:none }
</style>
</head>

<body onload="showNodes();">

<iframe src="big5_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"));
	nodes = iframe.querySelectorAll("span");

	t = -1;
	t++;
	tests[t] = async_test("lead not 0x00 and no more bytes: AB");
	t++;
	tests[t] = async_test("lead not 0x00 and no more bytes: AB B5 AB");
	t++;
	tests[t] = async_test("lead not 0x00 and no more bytes: AB AB AB");

	t++;
	tests[t] = async_test("lead byte outside 0x81-0xFE: FF");
	t++;
	tests[t] = async_test("lead byte outside 0x81-0xFE: AB AB FF");

	t++;
	tests[t] = async_test("trail byte outside 0x41-0xFE: AB 31");
	t++;
	tests[t] = async_test("trail byte outside 0x41-0xFE: AB FF");

	t++;
	tests[t] = async_test("pointer is null: C8 F2");

	t = -1;
	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, "�1");
	});
	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();
}
</script>

</body>
</html>