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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/encoding/textdecoder-labels.html

Issue 2657583002: Import wpt@cf62b859e6b890abc34f8140d185ba91df95c5b6 (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. Created 3 years, 10 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Encoding API: Encoding labels</title> 2 <title>Encoding API: Encoding labels</title>
3 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script> 4 <script src="/resources/testharnessreport.js"></script>
5 <script src="resources/encodings.js"></script> 5 <script src="resources/encodings.js"></script>
6 <script> 6 <script>
7 var tests = []; 7 var whitespace = [' ', '\t', '\n', '\f', '\r'];
8 setup(function() { 8 encodings_table.forEach(function(section) {
9 var whitespace = [' ', '\t', '\n', '\f', '\r']; 9 section.encodings.filter(function(encoding) {
10 encodings_table.forEach(function(section) { 10 return encoding.name !== 'replacement';
11 section.encodings.filter(function(encoding) { 11 }).forEach(function(encoding) {
12 return encoding.name !== 'replacement'; 12 encoding.labels.forEach(function(label) {
13 }).forEach(function(encoding) { 13 test(function(t) {
14 var name = encoding.name; 14 assert_equals(
15 encoding.labels.forEach(function(label) { 15 new TextDecoder(label).encoding, encoding.name,
16 tests.push([label, encoding.name]); 16 'label for encoding should match');
17 assert_equals(
18 new TextDecoder(label.toUpperCase()).encoding, encoding.name,
19 'label matching should be case-insensitive');
17 whitespace.forEach(function(ws) { 20 whitespace.forEach(function(ws) {
18 tests.push([ws + label, encoding.name]); 21 assert_equals(
19 tests.push([label + ws, encoding.name]); 22 new TextDecoder(ws + label).encoding, encoding.name,
20 tests.push([ws + label + ws, encoding.name]); 23 'label for encoding with leading whitespace should match');
24 assert_equals(
25 new TextDecoder(label + ws).encoding, encoding.name,
26 'label for encoding with trailing whitespace should match');
27 assert_equals(
28 new TextDecoder(ws + label + ws).encoding, encoding.name,
29 'label for encoding with surrounding whitespace should match');
21 }); 30 });
22 }); 31 }, label + ' => ' + encoding.name);
23 }); 32 });
24 }); 33 });
25 }); 34 });
26
27 tests.forEach(function(t) {
28 var input = t[0], output = t[1];
29 test(function() {
30 assert_equals(new TextDecoder(input).encoding, output,
31 'label for encoding should match');
32 assert_equals(new TextDecoder(input.toUpperCase()).encoding, output,
33 'label matching should be case-insensitive');
34 }, format_value(input) + " => " + format_value(output));
35 });
36 </script> 35 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698