blob: ff037173a1128983da123043f7afa3b260c27254 [file] [log] [blame]
Andrew Top61a84952019-04-30 15:07:33 -07001<!DOCTYPE html>
2<title>Encoding API: invalid label</title>
3<meta name="timeout" content="long">
4<script src="/resources/testharness.js"></script>
5<script src="/resources/testharnessreport.js"></script>
6<script src="resources/encodings.js"></script>
7<script>
8var tests = ["invalid-invalidLabel"];
9setup(function() {
10 encodings_table.forEach(function(section) {
11 section.encodings.filter(function(encoding) {
12 return encoding.name !== 'replacement';
13 }).forEach(function(encoding) {
14 encoding.labels.forEach(function(label) {
15 ["\u0000", "\u000b", "\u00a0", "\u2028", "\u2029"].forEach(function(ws) {
16 tests.push(ws + label);
17 tests.push(label + ws);
18 tests.push(ws + label + ws);
19 });
20 });
21 });
22 });
23});
24
25tests.forEach(function(input) {
26 test(function() {
27 assert_throws(new RangeError(), function() { new TextEncoder(input); });
28 }, 'Invalid label ' + format_value(input) + ' should be rejected by TextEncoder.');
29
30 test(function() {
31 assert_throws(new RangeError(), function() { new TextDecoder(input); });
32 }, 'Invalid label ' + format_value(input) + ' should be rejected by TextDecoder.');
33});
34</script>