blob: 75db3c28480f6ea482c0cc576c9bf1a09939337c [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/mre/mre_result.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: auto;',
' margin: 0px;',
' padding: 0;',
' width: 100%;',
' height: 100%;',
' font-family: sans-serif;',
'}',
'body > .pib-result-view {',
' width: 100%;',
' height: 100%;',
'}'
];
styleEl.textContent = lines.join('\n');
document.head.appendChild(styleEl);
})();
tr.exportTo('pib', function() {
function initPiReportNamed(reportElementName) {
g_viewEl = document.createElement(reportElementName);
g_viewEl.classList.add('pib-result-view');
document.body.appendChild(g_viewEl);
var results = [];
var wrDataScripts = document.querySelectorAll('#pi-report-data');
if (wrDataScripts.length !== 1) {
tr.base.showPanic('Init error', new Error('Expected 1 #pi-report-data'));
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 = data.map(function(rd) {
return pi.mre.MreResult.fromDict(rd);
});
} catch (ex) {
var overlay = new tr.ui.b.Overlay();
overlay.title = 'Results.fromDict error';
overlay.textContent = tr.b.normalizeException(ex).stack;
overlay.visible = true;
return;
}
g_viewEl.mapResults = results;
}
return {
initPiReportNamed: initPiReportNamed
};
});
</script>