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

Unified Diff: LayoutTests/fast/encoding/api/base64.html

Issue 143943017: Added Base64 support in TextEncoder and TextDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/encoding/api/base64-expected.txt » ('j') | Source/wtf/text/TextCodecBase64.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | LayoutTests/fast/encoding/api/base64-expected.txt » ('j') | Source/wtf/text/TextCodecBase64.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698