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

Unified Diff: LayoutTests/fast/encoding/api/surrogate-pairs.html

Issue 15901002: Implement Encoding API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaseline webexposed global constructor tests Created 7 years, 5 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/surrogate-pairs.html
diff --git a/LayoutTests/fast/encoding/api/surrogate-pairs.html b/LayoutTests/fast/encoding/api/surrogate-pairs.html
new file mode 100644
index 0000000000000000000000000000000000000000..8be62c4076cc67cbdb6b9308f5a080a8bc27fcf0
--- /dev/null
+++ b/LayoutTests/fast/encoding/api/surrogate-pairs.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script>
+
+description("Test invalid UTF-16 surrogate pairs with UTF-8 encoding");
+
+var badStrings = [
+ { input: 'abc123', expected: 'abc123' }, // Sanity check.
+ { input: '\ud800', expected: '\ufffd' }, // Surrogate half.
+ { input: '\udc00', expected: '\ufffd' }, // Surrogate half.
+ { input: 'abc\ud800def', expected: 'abc\ufffddef' }, // Surrogate half.
+ { input: 'abc\udc00def', expected: 'abc\ufffddef' }, // Surrogate half.
+ { input: '\udc00\ud800', expected: '\ufffd\ufffd' } // Wrong order.
+];
+
+badStrings.forEach(
+ function(t) {
+ evalAndLog("encoded = new TextEncoder('utf-8').encode(" + JSON.stringify(t.input) + ")");
+ evalAndLog("decoded = new TextDecoder('utf-8').decode(encoded)");
+ shouldBeEqualToString("decoded", t.expected);
+ debug("");
+ });
+
+</script>
+<script src="../../js/resources/js-test-post.js"></script>

Powered by Google App Engine
This is Rietveld 408576698