Skip to content

Commit

Permalink
Merge pull request #1777 from Ms2ger/label
Browse files Browse the repository at this point in the history
Extend the api-invalid-label test to check for non-ASCII whitespace trimming; r=jsbell
  • Loading branch information
Ms2ger committed Apr 29, 2015
2 parents 5ba6f6a + 0bd7738 commit 74fc6fb
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions encoding/api-invalid-label.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@
<title>Encoding API: invalid label</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/encodings.js"></script>
<script>
var tests = ["invalid-invalidLabel"];
setup(function() {
encodings_table.forEach(function(section) {
section.encodings.filter(function(encoding) {
return encoding.name !== 'replacement';
}).forEach(function(encoding) {
encoding.labels.forEach(function(label) {
["\u0000", "\u000b", "\u00a0", "\u2028", "\u2029"].forEach(function(ws) {
tests.push(ws + label);
tests.push(label + ws);
tests.push(ws + label + ws);
});
});
});
});
});

var invalidLabel = "invalid-invalidLabel"

test(function() {
assert_throws(new RangeError(), function() { new TextEncoder(invalidLabel); });
assert_throws(new RangeError(), function() { new TextDecoder(invalidLabel); });
}, 'Invalid label "' + invalidLabel + '" should be rejected by API.');
tests.forEach(function(input) {
test(function() {
assert_throws(new RangeError(), function() { new TextEncoder(input); });
}, 'Invalid label ' + format_value(input) + ' should be rejected by TextEncoder.');

test(function() {
assert_throws(new RangeError(), function() { new TextDecoder(input); });
}, 'Invalid label ' + format_value(input) + ' should be rejected by TextDecoder.');
});
</script>

0 comments on commit 74fc6fb

Please sign in to comment.