Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / importer / trace2html_importer_test.html
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
6 -->
7
8 <link rel="import" href="/tracing/importer/trace2html_importer.html">
9
10 <script>
11 'use strict';
12
13 tv.unittest.testSuite(function() { // @suppress longLineCheck
14   test('simple', function() {
15     var html_lines = [
16       '<!DOCTYPE HTML>',
17       '<script id="viewer-data" type="application/json">',
18       btoa('hello'),
19       '<\/script>',
20       '<script id="viewer-data" type="application/json">',
21       btoa('world'),
22       '<\/script>',
23       '</html>'
24     ];
25     var html_text = html_lines.join('\n');
26     assertTrue(tracing.importer.Trace2HTMLImporter.canImport(html_text));
27
28     var m = new tracing.TraceModel();
29     var imp = new tracing.importer.Trace2HTMLImporter(m, html_text);
30     var subTracesAsBuffers = imp.extractSubtraces();
31     var subTracesAsStrings = subTracesAsBuffers.map(function(buffer) {
32       var str = '';
33       var ary = new Uint8Array(buffer);
34       for (var i = 0; i < ary.length; i++)
35         str += String.fromCharCode(ary[i]);
36       return str;
37     });
38     assertArrayEquals(['hello', 'world'], subTracesAsStrings);
39   });
40 });
41 </script>