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

Side by Side Diff: LayoutTests/fast/encoding/api/textdecoder-labels.html

Issue 1071283004: Encoding API: ignore leading/trailing whitespace in labels (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/encoding/api/textencoder-labels.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Encoding API: TextDecoder labels and whitespace</title>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <script src="resources/shared.js"></script>
6 <script>
7 var tests = [], failure_tests = [];
8 setup(function() {
9 var whitespace = [' ', '\t', '\n', '\f', '\r'];
10 var bad_whitespace = ['\u000B', '\u00A0', '\u2028', '\u2029'];
11 encodings_table.forEach(function(section) {
12 section.encodings.filter(function(encoding) {
13 return encoding.name !== 'replacement';
14 }).forEach(function(encoding) {
15 var name = encoding.name;
16 encoding.labels.forEach(function(label) {
17 tests.push([label, encoding.name]);
18 whitespace.forEach(function(ws) {
19 tests.push([ws + label, encoding.name]);
20 tests.push([label + ws, encoding.name]);
21 tests.push([ws + label + ws, encoding.name]);
22 });
23 bad_whitespace.forEach(function(ws) {
24 failure_tests.push([ws + label, encoding.name]);
25 failure_tests.push([label + ws, encoding.name]);
26 failure_tests.push([ws + label + ws, encoding.name]);
27 });
28 });
29 });
30 });
31 });
32
33 tests.forEach(function(t) {
34 var input = t[0], output = t[1];
35 test(function() {
36 assert_equals(new TextDecoder(input).encoding, output,
37 'label for encoding should match');
38 assert_equals(new TextDecoder(input.toUpperCase()).encoding, output,
39 'label matching should be case-insensitive');
40 }, format_value(input) + " => " + format_value(output));
41 });
42
43 failure_tests.forEach(function(t) {
44 var input = t[0], output = t[1];
45 test(function() {
46 assert_throws({name:'RangeError'},
47 function() { new TextDecoder(input); },
48 'non-ASCII whitespace should not be stripped');
49 }, format_value(input) + " => " + format_value(output));
50 });
51 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/encoding/api/textencoder-labels.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698