| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <meta charset=utf-8> | |
| 3 <title>FileAPI Test: Blob Determining Encoding</title> | |
| 4 <link ref="author" title="march1993" href="mailto:march511@gmail.com"> | |
| 5 <link rel=help href="http://dev.w3.org/2006/webapi/FileAPI/#enctype"> | |
| 6 <link rel=help href="http://encoding.spec.whatwg.org/#decode"> | |
| 7 <script src="../../../../resources/testharness.js"></script> | |
| 8 <script src="../../../../resources/testharnessreport.js"></script> | |
| 9 <div id="log"></div> | |
| 10 <script> | |
| 11 var t = async_test("Blob Determing Encoding with encoding argument"); | |
| 12 t.step(function() { | |
| 13 // string 'hello' | |
| 14 var data = [0xFE,0xFF,0x00,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F]; | |
| 15 var blob = new Blob([new Uint8Array(data)]); | |
| 16 var reader = new FileReader(); | |
| 17 | |
| 18 reader.onloadend = t.step_func_done (function(event) { | |
| 19 assert_equals(this.result, "hello", "The FileReader should read the Arra
yBuffer through UTF-16BE.") | |
| 20 }, reader); | |
| 21 | |
| 22 reader.readAsText(blob, "UTF-16BE"); | |
| 23 }); | |
| 24 | |
| 25 var t = async_test("Blob Determing Encoding with type attribute"); | |
| 26 t.step(function() { | |
| 27 var data = [0xFE,0xFF,0x00,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F]; | |
| 28 var blob = new Blob([new Uint8Array(data)], {type:"text/plain;charset=UTF-16
BE"}); | |
| 29 var reader = new FileReader(); | |
| 30 | |
| 31 reader.onloadend = t.step_func_done (function(event) { | |
| 32 assert_equals(this.result, "hello", "The FileReader should read the Arra
yBuffer through UTF-16BE.") | |
| 33 }, reader); | |
| 34 | |
| 35 reader.readAsText(blob); | |
| 36 }); | |
| 37 | |
| 38 | |
| 39 var t = async_test("Blob Determing Encoding with UTF-8 BOM"); | |
| 40 t.step(function() { | |
| 41 var data = [0xEF,0xBB,0xBF,0x68,0x65,0x6C,0x6C,0xC3,0xB6]; | |
| 42 var blob = new Blob([new Uint8Array(data)]); | |
| 43 var reader = new FileReader(); | |
| 44 | |
| 45 reader.onloadend = t.step_func_done (function(event) { | |
| 46 assert_equals(this.result, "hellö", "The FileReader should read the blob
with UTF-8."); | |
| 47 }, reader); | |
| 48 | |
| 49 reader.readAsText(blob); | |
| 50 }); | |
| 51 | |
| 52 var t = async_test("Blob Determing Encoding without anything implying charset.")
; | |
| 53 t.step(function() { | |
| 54 var data = [0x68,0x65,0x6C,0x6C,0xC3,0xB6]; | |
| 55 var blob = new Blob([new Uint8Array(data)]); | |
| 56 var reader = new FileReader(); | |
| 57 | |
| 58 reader.onloadend = t.step_func_done (function(event) { | |
| 59 assert_equals(this.result, "hellö", "The FileReader should read the blob
by default with UTF-8."); | |
| 60 }, reader); | |
| 61 | |
| 62 reader.readAsText(blob); | |
| 63 }); | |
| 64 | |
| 65 var t = async_test("Blob Determing Encoding with UTF-16BE BOM"); | |
| 66 t.step(function() { | |
| 67 var data = [0xFE,0xFF,0x00,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F]; | |
| 68 var blob = new Blob([new Uint8Array(data)]); | |
| 69 var reader = new FileReader(); | |
| 70 | |
| 71 reader.onloadend = t.step_func_done (function(event) { | |
| 72 assert_equals(this.result, "hello", "The FileReader should read the Arra
yBuffer through UTF-16BE."); | |
| 73 }, reader); | |
| 74 | |
| 75 reader.readAsText(blob); | |
| 76 }); | |
| 77 | |
| 78 var t = async_test("Blob Determing Encoding with UTF-16LE BOM"); | |
| 79 t.step(function() { | |
| 80 var data = [0xFF,0xFE,0x68,0x00,0x65,0x00,0x6C,0x00,0x6C,0x00,0x6F,0x00]; | |
| 81 var blob = new Blob([new Uint8Array(data)]); | |
| 82 var reader = new FileReader(); | |
| 83 | |
| 84 reader.onloadend = t.step_func_done (function(event) { | |
| 85 assert_equals(this.result, "hello", "The FileReader should read the Arra
yBuffer through UTF-16LE."); | |
| 86 }, reader); | |
| 87 | |
| 88 reader.readAsText(blob); | |
| 89 }); | |
| 90 | |
| 91 </script> | |
| OLD | NEW |