Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / encoding / api / legacy-encode.html
index f01b93b..c545323 100644 (file)
@@ -1,20 +1,24 @@
 <!DOCTYPE html>
-<script src="../../../resources/js-test.js"></script>
+<title>Encoding API: Legacy encodings</title>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
 <script src="resources/shared.js"></script>
 <script>
 
-description("Non-UTF encodings supported only for decode, not encode");
-
 encodings_table.forEach(function(section) {
-    section.encodings.forEach(function(encoding) {
-        if (encoding.name === "replacement")
-            return;
+    section.encodings.filter(function(encoding) {
+        return encoding.name !== 'replacement';
+    }).forEach(function(encoding) {
         if (utf_encodings.indexOf(encoding.name) !== -1) {
-            shouldBeEqualToString("new TextDecoder(" + JSON.stringify(encoding.name) + ").encoding", encoding.name);
-            shouldBeEqualToString("new TextEncoder(" + JSON.stringify(encoding.name) + ").encoding", encoding.name);
+            test(function() {
+                assert_equals(new TextDecoder(encoding.name).encoding, encoding.name);
+                assert_equals(new TextEncoder(encoding.name).encoding, encoding.name);
+            }, 'UTF encodings are supported for encode and decode: ' + encoding.name);
         } else {
-            shouldBeEqualToString("new TextDecoder(" + JSON.stringify(encoding.name) + ").encoding", encoding.name);
-            shouldThrow("new TextEncoder(" + JSON.stringify(encoding.name) + ").encoding");
+            test(function() {
+                assert_equals(new TextDecoder(encoding.name).encoding, encoding.name);
+                assert_throws({name:'TypeError'}, function() { new TextEncoder(encoding.name); });
+            }, 'Non-UTF encodings supported only for decode, not encode: ' + encoding.name);
         }
     });
 });