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

Side by Side Diff: LayoutTests/fast/encoding/api/latin-1.html

Issue 240283013: Convert Encoding API tests to W3C testharness.js (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
OLDNEW
1 B<!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../../resources/js-test.js"></script> 2 <title>Encoding API: Latin-1 decoders</title>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
3 <script src="resources/shared.js"></script> 5 <script src="resources/shared.js"></script>
4 <script> 6 <script>
5 7
6 description("Verify that Latin-1 decoders (windows-1252, iso-8859-1, us-ascii, e tc) decode identically.");
7
8 // Blink uses separate decoder object intances for these encoding aliases, 8 // Blink uses separate decoder object intances for these encoding aliases,
9 // so test that they are behaving identically. 9 // so test that they are behaving identically.
10 10
11 var labels; 11 test(function() {
12 encodings_table.forEach(function(section) { 12
13 section.encodings.forEach(function(encoding) { 13 var labels;
14 if (encoding.name === "windows-1252") 14 encodings_table.forEach(function(section) {
15 labels = encoding.labels; 15 section.encodings.forEach(function(encoding) {
16 if (encoding.name === 'windows-1252')
17 labels = encoding.labels;
18 });
16 }); 19 });
17 }); 20 labels = labels.filter(function(label) { return label !== 'windows-1252'; }) ;
18 labels = labels.filter(function(label) { return label !== 'windows-1252'; });
19 21
20 evalAndLog("array = new Uint8Array(256)"); 22 var array = new Uint8Array(256);
21 debug("initialize array to 0...255"); 23 for (var cp = 0; cp <= 255; ++cp) {
22 for (var cp = 0; cp <= 255; ++cp) { 24 array[cp] = cp;
23 array[cp] = cp; 25 }
24 }
25 26
26 evalAndLog("windows1252 = new TextDecoder('windows-1252')"); 27 var windows1252 = new TextDecoder('windows-1252');
27 28
28 labels.forEach(function(label) { 29 labels.forEach(function(label) {
29 decoder = null; 30 var decoder = new TextDecoder(label);
30 evalAndLog("decoder = new TextDecoder(" + JSON.stringify(label) + ")"); 31 assert_equals(decoder.decode(array), windows1252.decode(array));
31 // Above may throw if encoding unsupported. 32 });
32 if (decoder) { 33
33 shouldBe("decoder.decode(array)", "windows1252.decode(array)"); 34 }, 'Latin-1 decoders (windows-1252, iso-8859-1, us-ascii, etc) decode identicall y.');
34 }
35 });
36 35
37 </script> 36 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698