summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/encoding/legacy-mb-schinese/gbk
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/encoding/legacy-mb-schinese/gbk
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/encoding/legacy-mb-schinese/gbk')
-rw-r--r--testing/web-platform/tests/encoding/legacy-mb-schinese/gbk/gbk-decoder.any.js28
-rw-r--r--testing/web-platform/tests/encoding/legacy-mb-schinese/gbk/gbk-encoder.html26
2 files changed, 54 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encoding/legacy-mb-schinese/gbk/gbk-decoder.any.js b/testing/web-platform/tests/encoding/legacy-mb-schinese/gbk/gbk-decoder.any.js
new file mode 100644
index 0000000000..c0221480da
--- /dev/null
+++ b/testing/web-platform/tests/encoding/legacy-mb-schinese/gbk/gbk-decoder.any.js
@@ -0,0 +1,28 @@
+const gbkPointers = [
+ 6432, 7533, 7536, 7672, 7673, 7674, 7675, 7676, 7677, 7678, 7679, 7680, 7681, 7682, 7683, 7684,
+ 23766, 23770, 23771, 23772, 23773, 23774, 23776, 23777, 23778, 23779, 23780, 23781, 23782, 23784, 23785, 23786,
+ 23787, 23790, 23791, 23792, 23793, 23796, 23797, 23798, 23799, 23800, 23801, 23802, 23803, 23805, 23806, 23807,
+ 23808, 23809, 23810, 23811, 23813, 23814, 23815, 23816, 23817, 23818, 23819, 23820, 23821, 23822, 23823, 23824,
+ 23825, 23826, 23827, 23828, 23831, 23832, 23833, 23834, 23835, 23836, 23837, 23838, 23839, 23840, 23841, 23842,
+ 23843, 23844
+];
+const codePoints = [
+ 0x20ac, 0x1e3f, 0x01f9, 0x303e, 0x2ff0, 0x2ff1, 0x2ff2, 0x2ff3, 0x2ff4, 0x2ff5, 0x2ff6, 0x2ff7, 0x2ff8, 0x2ff9, 0x2ffa, 0x2ffb,
+ 0x2e81, 0x2e84, 0x3473, 0x3447, 0x2e88, 0x2e8b, 0x359e, 0x361a, 0x360e, 0x2e8c, 0x2e97, 0x396e, 0x3918, 0x39cf, 0x39df, 0x3a73,
+ 0x39d0, 0x3b4e, 0x3c6e, 0x3ce0, 0x2ea7, 0x2eaa, 0x4056, 0x415f, 0x2eae, 0x4337, 0x2eb3, 0x2eb6, 0x2eb7, 0x43b1, 0x43ac, 0x2ebb,
+ 0x43dd, 0x44d6, 0x4661, 0x464c, 0x4723, 0x4729, 0x477c, 0x478d, 0x2eca, 0x4947, 0x497a, 0x497d, 0x4982, 0x4983, 0x4985, 0x4986,
+ 0x499f, 0x499b, 0x49b7, 0x49b6, 0x4ca3, 0x4c9f, 0x4ca0, 0x4ca1, 0x4c77, 0x4ca2, 0x4d13, 0x4d14, 0x4d15, 0x4d16, 0x4d17, 0x4d18,
+ 0x4d19, 0x4dae
+];
+
+for (let i = 0; i < gbkPointers.length; i++) {
+ const pointer = gbkPointers[i];
+ test(function() {
+ const lead = pointer / 190 + 0x81;
+ const trail = pointer % 190;
+ const offset = trail < 0x3F ? 0x40 : 0x41;
+ const encoded = [lead, trail + offset];
+ const decoded = new TextDecoder("GBK").decode(new Uint8Array(encoded)).charCodeAt(0);
+ assert_equals(decoded, codePoints[i]);
+ }, "gbk pointer: " + pointer)
+}
diff --git a/testing/web-platform/tests/encoding/legacy-mb-schinese/gbk/gbk-encoder.html b/testing/web-platform/tests/encoding/legacy-mb-schinese/gbk/gbk-encoder.html
new file mode 100644
index 0000000000..e43cb73fea
--- /dev/null
+++ b/testing/web-platform/tests/encoding/legacy-mb-schinese/gbk/gbk-encoder.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<meta charset=gbk> <!-- if the server overrides this, it is stupid, as this is a testsuite -->
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script>
+ function encode(input, output, desc) {
+ test(function() {
+ const a = document.createElement("a") // <a> uses document encoding for URL's query
+ a.href = "https://example.com/?" + input;
+ assert_equals(a.search.substr(1), output); // remove leading "?"
+ }, "gbk encoder: " + desc);
+ }
+
+ encode("s", "s", "very basic");
+ encode("\u20AC", "%80", "Euro");
+ encode("\u4E02", "%81@", "character");
+ encode("\uE4C6", "%A1@", "PUA");
+ encode("\uE4C5", "%FE%FE", "PUA #2");
+ encode("\ud83d\udca9", "%26%23128169%3B", "poo");
+ encode("\uE7C8", "%26%2359336%3B", "legacy ICU special case 1");
+ encode("\u2026", "%A1%AD", "legacy ICU special case 2");
+ encode("\uFF5E", "%A1%AB", "legacy ICU special case 3");
+ encode("\u00A5", "%26%23165%3B", "legacy WebKit case 1");
+ encode("\u22EF", "%26%238943%3B", "legacy WebKit case 2");
+ encode("\u301C", "%26%2312316%3B", "legacy WebKit case 3");
+</script>