diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/encoding/legacy-mb-tchinese/big5/big5-enc-ascii.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/encoding/legacy-mb-tchinese/big5/big5-enc-ascii.html')
-rw-r--r-- | testing/web-platform/tests/encoding/legacy-mb-tchinese/big5/big5-enc-ascii.html | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encoding/legacy-mb-tchinese/big5/big5-enc-ascii.html b/testing/web-platform/tests/encoding/legacy-mb-tchinese/big5/big5-enc-ascii.html new file mode 100644 index 0000000000..91959206b3 --- /dev/null +++ b/testing/web-platform/tests/encoding/legacy-mb-tchinese/big5/big5-enc-ascii.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset=big5> <!-- test breaks if the server overrides this --> +<title>Big5 encoding ASCII</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/#big5'> +<meta name="assert" content="The browser produces the characters when encoding ASCII in a Big5-encoded document."> +</head> +<body> +<div id=log></div> +<script> +// index is Big5 index pointer, value is Unicode codepoint (dec) + +function encode(input, output, desc) { + // tests whether a Unicode character is converted to an equivalent Big5 %-encoded byte sequence by href + // input: a escaped Unicode code point from the list of characters in the Big5 index + // output: expected percent-encoded byte sequence for the code point's equivalent in Big5 encoding + // desc: what's being tested + test(function() { + var a = document.createElement("a"); // <a> uses document encoding for URL's query + // Append and prepend x to test for off-by-one errors + a.href = "https://example.com/?x" + input + "x"; + assert_true( + a.search.substr(1) == "x" + output + "x" || + a.search.substr(1) == "x" + input + "x" + ); // remove leading "?" + }, "big5 encoder: " + desc); +} + +// test ASCII - test separately for chars that aren't escaped +for (var a = 0; a < 0x7f; a++) { + // The first 3 are stripped from URLs and the last is # which introduces a new URL segment + if (a === 0x09 || a === 0x0a || a === 0x0d || a === 0x23) { + continue; + } + hex = a.toString(16).toUpperCase(); + while (hex.length < 2) { + hex = "0" + hex; + } + encode( + String.fromCharCode(a), + "%" + hex, + "test for ASCII codepoint 0x" + + a.toString(16) + + " " + + String.fromCharCode(a) + ); +} +</script> +</body> +</html> |