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

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

Issue 240283013: Convert Encoding API tests to W3C testharness.js (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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
index 7c6104d1ff4c2b0df67978ecd1409f7706d01d7d..cae583cbaac44faeb5ea82b6727841952ffdd600 100644
--- a/LayoutTests/fast/encoding/api/surrogate-pairs.html
+++ b/LayoutTests/fast/encoding/api/surrogate-pairs.html
@@ -1,23 +1,54 @@
<!DOCTYPE html>
-<script src="../../../resources/js-test.js"></script>
+<title>Encoding API: Invalid UTF-16 surrogate pairs with UTF-8 encoding</title>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
<script>
-description("Test invalid UTF-16 surrogate pairs with UTF-8 encoding");
-
var badStrings = [
- { input: "'abc123'", expected: [97, 98, 99, 49, 50, 51] }, // Sanity check.
- { input: "'\\ud800'", expected: [0xef, 0xbf, 0xbd] }, // Surrogate half.
- { input: "'\\udc00'", expected: [0xef, 0xbf, 0xbd] }, // Surrogate half.
- { input: "'abc\\ud800123'", expected: [0x61, 0x62, 0x63, 0xef, 0xbf, 0xbd, 0x31, 0x32, 0x33] }, // Surrogate half.
- { input: "'abc\\udc00123'", expected: [0x61, 0x62, 0x63, 0xef, 0xbf, 0xbd, 0x31, 0x32, 0x33] }, // Surrogate half.
- { input: "'\\udc00\\ud800'", expected: [239, 191, 189, 239, 191, 189] } // Wrong order.
+ {
+ input: 'abc123',
+ expected: [97, 98, 99, 49, 50, 51],
jungshik at Google 2014/04/29 16:51:04 nit: Would you use hexadecimal here, too?
jsbell 2014/04/29 21:41:18 Done.
+ decoded: 'abc123',
+ name: 'Sanity check'
+ },
+ {
+ input: '\uD800',
+ expected: [0xef, 0xbf, 0xbd],
+ decoded: '\uFFFD',
+ name: 'Surrogate half (low)'
+ },
+ {
+ input: '\uDC00',
+ expected: [0xef, 0xbf, 0xbd],
+ decoded: '\uFFFD',
+ name: 'Surrogate half (high)'
+ },
+ {
+ input: 'abc\uD800123',
+ expected: [0x61, 0x62, 0x63, 0xef, 0xbf, 0xbd, 0x31, 0x32, 0x33],
+ decoded: 'abc\uFFFD123',
+ name: 'Surrogate half (low), in a string'
+ },
+ {
+ input: 'abc\uDC00123',
+ expected: [0x61, 0x62, 0x63, 0xef, 0xbf, 0xbd, 0x31, 0x32, 0x33],
+ decoded: 'abc\uFFFD123',
+ name: 'Surrogate half (high), in a string'
+ },
+ {
+ input: '\uDC00\uD800',
+ expected: [239, 191, 189, 239, 191, 189],
jsbell 2014/04/29 21:41:18 Here too.
+ decoded: '\uFFFD\uFFFD',
+ name: 'Wrong order'
+ }
];
-badStrings.forEach(
- function(t) {
- evalAndLog("encoded = new TextEncoder('utf-8').encode(" + t.input + ")");
- shouldBeEqualToString("JSON.stringify([].slice.call(encoded))", JSON.stringify(t.expected));
- debug("");
- });
+badStrings.forEach(function(t) {
+ test(function() {
+ var encoded = new TextEncoder('utf-8').encode(t.input);
+ assert_array_equals([].slice.call(encoded), t.expected);
+ assert_equals(new TextDecoder('utf-8').decode(encoded), t.decoded);
+ }, 'Invalid surrogate pairs encoded into UTF-8: ' + t.name);
+});
</script>

Powered by Google App Engine
This is Rietveld 408576698