Chromium Code Reviews| Index: LayoutTests/fast/encoding/api/base64.html |
| diff --git a/LayoutTests/fast/encoding/api/base64.html b/LayoutTests/fast/encoding/api/base64.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7464606e3daaa44ba3696974ee5f0057ff7c85d5 |
| --- /dev/null |
| +++ b/LayoutTests/fast/encoding/api/base64.html |
| @@ -0,0 +1,34 @@ |
| +<!DOCTYPE html> |
| +<script src="../../../resources/js-test.js"></script> |
| +<script src="resources/shared.js"></script> |
| +<script> |
| + |
| +description("Verify Base64 encoding/decoding"); |
|
jsbell
2014/01/24 22:15:05
Need a streaming encode and streaming decode test.
|
| + |
| +string = 'AQIzh6L+'; |
| +decoded = null; |
|
jsbell
2014/01/24 22:15:05
No need to initialize vars to null that will be as
|
| +bytes = [0x01, 0x02, 0x33, 0x87, 0xA2, 0xFE]; |
| + |
| +decoder = null; |
| +evalAndLog("decoder = new TextDecoder(" + JSON.stringify('base64') + ")"); |
|
jsbell
2014/01/24 22:15:05
Can you add a comment (or debug("...") line) that
|
| +if (decoder) { |
|
jsbell
2014/01/24 22:15:05
No need for this if() block.
|
| + evalAndLog("decoded = decoder.decode(new Uint8Array(bytes))"); |
| + // encodeURIComponent ensures output is printable |
| + shouldBe("encodeURIComponent(string)", "encodeURIComponent(decoded)"); |
| +} |
| + |
| +encoder = null; |
| +encoded = null; |
| +evalAndLog("encoder = new TextEncoder(" + JSON.stringify('base64') + ")"); |
|
jsbell
2014/01/24 22:15:05
... and can you add a comment about the reverse he
|
| +if (encoder) { |
|
jsbell
2014/01/24 22:15:05
No need for this if() block.
|
| + evalAndLog("encoded = encoder.encode(string)"); |
| + shouldBeTrue("encoded.length === bytes.length"); |
|
jsbell
2014/01/24 22:15:05
This and the rest of the test can just use areArra
|
| + if (encoded.length != bytes.length) { |
| + return; |
| + } |
| + for (var i = 0; i < bytes.length; i++) { |
| + shouldBeTrue("encoded[i] === bytes[i]"); |
| + } |
| +} |
| + |
| +</script> |