blob: 267bdc4a8277f789aef66c2fece26a8c4ebc36a9 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/perf_insights/ui/wr/wr_result_view.html">
<link rel="import" href="/perf_insights/results/results.html">
<link rel="import" href="/tracing/ui/base/overlay.html">
<script>
'use strict';
var g_viewEl;
(function() {
var styleEl = document.createElement('style');
var lines = [
'html, body {',
' box-sizing: border-box;',
' overflow: hidden;',
' margin: 0px;',
' padding: 0;',
' width: 100%;',
' height: 100%;',
'}',
'pi-ui-wr-wr-result-view {',
' width: 100%;',
' height: 100%;',
'}',
'pi-ui-wr-wr-result-view:focus {',
' outline: none;',
'}'
];
styleEl.textContent = lines.join('\n');
document.head.appendChild(styleEl);
})();
document.addEventListener('DOMContentLoaded', function() {
g_viewEl = document.createElement('pi-ui-wr-wr-result-view');
document.body.appendChild(g_viewEl);
var results = [];
var wrDataScripts = document.querySelectorAll('#wr-data');
if (wrDataScripts.length !== 1) {
tr.base.showPanic('Init error', new Error('Only 1 #wr-data supported'));
return;
}
var text = wrDataScripts[0].textContent;
// Trim leading newlines off the text. They happen during writing.
while (text[0] == '\n')
text = text.substring(1);
var data = JSON.parse(text);
var results;
try {
results = pi.r.Results.fromDict(data);
} catch (ex) {
var overlay = new tr.ui.b.Overlay();
overlay.textContent = tr.b.normalizeException(ex).stack;
overlay.title = 'Import error';
overlay.visible = true;
return;
}
g_viewEl.mapResults = results;
});
</script>