- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / third_party / spaceport / js / fullReport.js
1 define([ 'tables', 'util/report' ], function (tables, report) {
2     function val(id) {
3         var el = document.getElementById(id);
4         var customEl = document.getElementById(id + '-custom');
5
6         return el.value || (customEl && customEl.value);
7     }
8
9     function getAgentMetadata() {
10         if (typeof window !== 'undefined' && window) {
11             return {
12                 userAgent: window.navigator.userAgent,
13                 language: window.navigator.language,
14                 browser: val('ua-browser'),
15                 name: val('ua-device-name'),
16                 os: val('ua-os'),
17                 type: val('ua-type'),
18                 misc: val('ua-misc')
19             };
20         } else {
21             return null;
22         }
23     }
24
25     function csvReport(results, agentMetadata) {
26         agentMetadata = agentMetadata || getAgentMetadata();
27
28         var reports = [ ];
29         if (agentMetadata) {
30             reports.push(report.csvByObject(agentMetadata));
31         }
32
33         Object.keys(tables.performance).forEach(function (testName) {
34             var layout = report.makeTableLayout(tables.performance[testName]);
35             reports.push(report.csvByLayout(results[testName], layout, [ testName ]));
36         });
37
38         return reports.join('\n\n') + '\n';
39     }
40
41     return {
42         csvReport: csvReport,
43         getAgentMetadata: getAgentMetadata
44     };
45 });