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/textdecoder-eof.any.js | |
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/textdecoder-eof.any.js')
-rw-r--r-- | testing/web-platform/tests/encoding/textdecoder-eof.any.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/testing/web-platform/tests/encoding/textdecoder-eof.any.js b/testing/web-platform/tests/encoding/textdecoder-eof.any.js new file mode 100644 index 0000000000..e41e326aac --- /dev/null +++ b/testing/web-platform/tests/encoding/textdecoder-eof.any.js @@ -0,0 +1,40 @@ +test(() => { + // Truncated sequences + assert_equals(new TextDecoder().decode(new Uint8Array([0xF0])), "\uFFFD"); + assert_equals(new TextDecoder().decode(new Uint8Array([0xF0, 0x9F])), "\uFFFD"); + assert_equals(new TextDecoder().decode(new Uint8Array([0xF0, 0x9F, 0x92])), "\uFFFD"); + + // Errors near end-of-queue + assert_equals(new TextDecoder().decode(new Uint8Array([0xF0, 0x9F, 0x41])), "\uFFFDA"); + assert_equals(new TextDecoder().decode(new Uint8Array([0xF0, 0x41, 0x42])), "\uFFFDAB"); + assert_equals(new TextDecoder().decode(new Uint8Array([0xF0, 0x41, 0xF0])), "\uFFFDA\uFFFD"); + assert_equals(new TextDecoder().decode(new Uint8Array([0xF0, 0x8F, 0x92])), "\uFFFD\uFFFD\uFFFD"); +}, "TextDecoder end-of-queue handling"); + +test(() => { + const decoder = new TextDecoder(); + decoder.decode(new Uint8Array([0xF0]), { stream: true }); + assert_equals(decoder.decode(), "\uFFFD"); + + decoder.decode(new Uint8Array([0xF0]), { stream: true }); + decoder.decode(new Uint8Array([0x9F]), { stream: true }); + assert_equals(decoder.decode(), "\uFFFD"); + + decoder.decode(new Uint8Array([0xF0, 0x9F]), { stream: true }); + assert_equals(decoder.decode(new Uint8Array([0x92])), "\uFFFD"); + + assert_equals(decoder.decode(new Uint8Array([0xF0, 0x9F]), { stream: true }), ""); + assert_equals(decoder.decode(new Uint8Array([0x41]), { stream: true }), "\uFFFDA"); + assert_equals(decoder.decode(), ""); + + assert_equals(decoder.decode(new Uint8Array([0xF0, 0x41, 0x42]), { stream: true }), "\uFFFDAB"); + assert_equals(decoder.decode(), ""); + + assert_equals(decoder.decode(new Uint8Array([0xF0, 0x41, 0xF0]), { stream: true }), "\uFFFDA"); + assert_equals(decoder.decode(), "\uFFFD"); + + assert_equals(decoder.decode(new Uint8Array([0xF0]), { stream: true }), ""); + assert_equals(decoder.decode(new Uint8Array([0x8F]), { stream: true }), "\uFFFD\uFFFD"); + assert_equals(decoder.decode(new Uint8Array([0x92]), { stream: true }), "\uFFFD"); + assert_equals(decoder.decode(), ""); +}, "TextDecoder end-of-queue handling using stream: true"); |