gecko-dev/testing/web-platform/tests/encoding/textencoder-utf16-surrogates.html
James Graham f3629d1236 Bug 1180500 - Update web-platform-tests to revision 87398b8448f699e3e324148795891658f2fa16dd, a=testonly
--HG--
rename : testing/web-platform/tests/conformance-checkers/html/media-queries/023-isvalid.html => testing/web-platform/tests/conformance-checkers/html/media-queries/device-aspect-ratio-novalid.html
rename : testing/web-platform/tests/conformance-checkers/html/media-queries/004-isvalid.html => testing/web-platform/tests/conformance-checkers/html/media-queries/projection-novalid.html
rename : testing/web-platform/tests/conformance-checkers/html/media-queries/021-isvalid.html => testing/web-platform/tests/conformance-checkers/html/media-queries/tv-novalid.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/001-1.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001-1.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/001a.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001a.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/001b.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/001b.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/002-1.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002-1.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/002a.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002a.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/002b.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/002b.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/003-1.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003-1.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/003a.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003a.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/003b.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/003b.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/004-1.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004-1.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/004a.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004a.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/004b.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/004b.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/005-1.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005-1.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/005a.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005a.html
rename : testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/005b.html => testing/web-platform/tests/html/browsers/browsing-the-web/unloading-documents/support/005b.html
rename : testing/web-platform/tests/subresource-integrity/crossorigin-anon.js.headers => testing/web-platform/tests/subresource-integrity/crossorigin-anon-script.js.headers
rename : testing/web-platform/tests/subresource-integrity/crossorigin-anon.js.headers => testing/web-platform/tests/subresource-integrity/crossorigin-anon-style.css.headers
2015-07-07 10:05:28 +01:00

55 lines
1.3 KiB
HTML

<!DOCTYPE html>
<title>Encoding API: USVString surrogate handling when encoding</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var bad = [
{
input: '\uD800',
expected: '\uFFFD',
name: 'lone surrogate lead'
},
{
input: '\uDC00',
expected: '\uFFFD',
name: 'lone surrogate trail'
},
{
input: '\uD800\u0000',
expected: '\uFFFD\u0000',
name: 'unmatched surrogate lead'
},
{
input: '\uDC00\u0000',
expected: '\uFFFD\u0000',
name: 'unmatched surrogate trail'
},
{
input: '\uDC00\uD800',
expected: '\uFFFD\uFFFD',
name: 'swapped surrogate pair'
},
{
input: '\uD834\uDD1E',
expected: '\uD834\uDD1E',
name: 'properly encoded MUSICAL SYMBOL G CLEF (U+1D11E)'
}
];
var encoding = 'utf-8';
bad.forEach(function(t) {
test(function() {
var encoded = new TextEncoder(encoding).encode(t.input);
var decoded = new TextDecoder(encoding).decode(encoded);
assert_equals(decoded, t.expected);
}, 'USVString handling: ' + t.name);
});
test(function() {
assert_equals(new TextEncoder(encoding).encode().length, 0, 'Should default to empty string');
}, 'USVString default');
</script>