Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../../../resources/js-test.js"></script> | |
| 3 <script src="resources/shared.js"></script> | |
| 4 <script> | |
| 5 | |
| 6 description("Verify Base64 encoding/decoding"); | |
|
jsbell
2014/01/24 22:15:05
Need a streaming encode and streaming decode test.
| |
| 7 | |
| 8 string = 'AQIzh6L+'; | |
| 9 decoded = null; | |
|
jsbell
2014/01/24 22:15:05
No need to initialize vars to null that will be as
| |
| 10 bytes = [0x01, 0x02, 0x33, 0x87, 0xA2, 0xFE]; | |
| 11 | |
| 12 decoder = null; | |
| 13 evalAndLog("decoder = new TextDecoder(" + JSON.stringify('base64') + ")"); | |
|
jsbell
2014/01/24 22:15:05
Can you add a comment (or debug("...") line) that
| |
| 14 if (decoder) { | |
|
jsbell
2014/01/24 22:15:05
No need for this if() block.
| |
| 15 evalAndLog("decoded = decoder.decode(new Uint8Array(bytes))"); | |
| 16 // encodeURIComponent ensures output is printable | |
| 17 shouldBe("encodeURIComponent(string)", "encodeURIComponent(decoded)"); | |
| 18 } | |
| 19 | |
| 20 encoder = null; | |
| 21 encoded = null; | |
| 22 evalAndLog("encoder = new TextEncoder(" + JSON.stringify('base64') + ")"); | |
|
jsbell
2014/01/24 22:15:05
... and can you add a comment about the reverse he
| |
| 23 if (encoder) { | |
|
jsbell
2014/01/24 22:15:05
No need for this if() block.
| |
| 24 evalAndLog("encoded = encoder.encode(string)"); | |
| 25 shouldBeTrue("encoded.length === bytes.length"); | |
|
jsbell
2014/01/24 22:15:05
This and the rest of the test can just use areArra
| |
| 26 if (encoded.length != bytes.length) { | |
| 27 return; | |
| 28 } | |
| 29 for (var i = 0; i < bytes.length; i++) { | |
| 30 shouldBeTrue("encoded[i] === bytes[i]"); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 </script> | |
| OLD | NEW |