Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: LayoutTests/fast/encoding/api/end-of-file.html

Issue 23532016: Handle odd data lengths in UTF-16 decoder (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/encoding/api/end-of-file.html
diff --git a/LayoutTests/fast/encoding/api/end-of-file.html b/LayoutTests/fast/encoding/api/end-of-file.html
index 4c2fc59a70cad2929e06c6accda5d2b698d32266..9e375248126ed7453e5e70cf2168bebf6831b869 100644
--- a/LayoutTests/fast/encoding/api/end-of-file.html
+++ b/LayoutTests/fast/encoding/api/end-of-file.html
@@ -7,22 +7,31 @@ description("Edge cases around non-fatal errors at EOF");
shouldThrow("new TextDecoder('utf-8', {fatal: true}).decode(new Uint8Array([0xff]))");
debug("");
-debug("Should not throw or hang:");
-evalAndLog("new TextDecoder('utf-8').decode(new Uint8Array([0xff]))");
+shouldBe("new TextDecoder('utf-8').decode(new Uint8Array([0xff]))", "'\uFFFD'");
debug("");
shouldThrow("new TextDecoder('utf-16le', {fatal: true}).decode(new Uint8Array([0x00]))");
debug("");
-debug("Should not throw or hang:");
-evalAndLog("new TextDecoder('utf-16le').decode(new Uint8Array([0x00]))");
+shouldBe("new TextDecoder('utf-16le').decode(new Uint8Array([0x00]))", "'\uFFFD'");
debug("");
shouldThrow("new TextDecoder('utf-16be', {fatal: true}).decode(new Uint8Array([0x00]))");
debug("");
-debug("Should not throw or hang:");
-evalAndLog("new TextDecoder('utf-16be').decode(new Uint8Array([0x00]));");
+shouldBe("new TextDecoder('utf-16be').decode(new Uint8Array([0x00]))", "'\uFFFD'");
+
+debug("");
+debug("Streaming cases:");
+evalAndLog("decoder = new TextDecoder('utf-16le', {fatal: true})");
+evalAndLog("odd = new Uint8Array([0x00])");
+evalAndLog("even = new Uint8Array([0x00, 0x00])");
+
+debug("");
+shouldNotThrow("decoder.decode(odd, {stream: true}); decoder.decode(odd)");
+shouldThrow("decoder.decode(even, {stream: true}); decoder.decode(odd)");
+shouldThrow("decoder.decode(odd, {stream: true}); decoder.decode(even)");
+shouldNotThrow("decoder.decode(even, {stream: true}); decoder.decode(even)");
</script>
<script src="../../js/resources/js-test-post.js"></script>

Powered by Google App Engine
This is Rietveld 408576698