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

Unified Diff: tracing/tracing/extras/importer/gzip_importer_test.html

Issue 1739663003: Use TextDecoder instead of JSZip.utils.transformTo in GzipImporter (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Don't access TextDecoder through 'window' (d8) Created 4 years, 10 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 | « tracing/tracing/extras/importer/gzip_importer.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/extras/importer/gzip_importer_test.html
diff --git a/tracing/tracing/extras/importer/gzip_importer_test.html b/tracing/tracing/extras/importer/gzip_importer_test.html
index 003dfe4a79d3f609971a9e8409d51ad79b91818f..f226aae68131e570af8205286efb0ab54846147a 100644
--- a/tracing/tracing/extras/importer/gzip_importer_test.html
+++ b/tracing/tracing/extras/importer/gzip_importer_test.html
@@ -6,8 +6,8 @@ found in the LICENSE file.
-->
<link rel="import" href="/tracing/base/base64.html">
-<link rel="import" href="/tracing/extras/importer/gzip_importer.html">
<link rel="import" href="/tracing/core/test_utils.html">
+<link rel="import" href="/tracing/extras/importer/gzip_importer.html">
<link rel="import" href="/tracing/extras/importer/trace_event_importer.html">
<script>
@@ -61,6 +61,45 @@ tr.b.unittest.testSuite(function() {
var slice = findSliceNamed(threads[0].sliceGroup, 'a');
assert.equal(slice.category, 'foo');
});
+
+ test('transformToString', function() {
+ function checkTransform(data, expectedString) {
+ assert.strictEqual(tr.e.importer.GzipImporter.transformToString(data),
+ expectedString);
+ }
+
+ function createArrayBuffer(values) {
+ var buffer = new ArrayBuffer(values.length);
+ var view = new Uint8Array(buffer);
+ view.set(values);
+ return buffer;
+ }
+
+ // If the browser supports TextDecoder, this will test our custom
+ // implementation. Otherwise, the jszip fallback will be tested.
+ checkTransform('abc012', 'abc012');
+ checkTransform([100, 101, 102, 51, 52, 53], 'def345');
+ checkTransform(createArrayBuffer([103, 104, 105, 54, 55, 56]), 'ghi678');
+ checkTransform(new Uint8Array([106, 107, 108, 57, 58, 59]), 'jkl9:;');
+
+ if (typeof TextDecoder === 'undefined') {
+ // The browser doesn't support TextDecoder, so we have already checked
+ // the jszip fallback.
+ return;
+ }
+
+ // The browser supports TextDecoder, so we now check the jszip fallback.
+ var oldTextDecoder = TextDecoder;
+ TextDecoder = undefined;
+ try {
+ checkTransform('abc012', 'abc012');
+ checkTransform([100, 101, 102, 51, 52, 53], 'def345');
+ checkTransform(createArrayBuffer([103, 104, 105, 54, 55, 56]), 'ghi678');
+ checkTransform(new Uint8Array([106, 107, 108, 57, 58, 59]), 'jkl9:;');
+ } finally {
+ TextDecoder = oldTextDecoder;
+ }
+ });
});
</script>
« no previous file with comments | « tracing/tracing/extras/importer/gzip_importer.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698