Skip to content

Commit

Permalink
don't emit script tags in devtools report.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Dec 3, 2016
1 parent 94f3290 commit af48478
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 6 additions & 3 deletions lighthouse-core/report/report-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ class ReportGenerator {
* @return {string}
*/
getReportJS() {
return fs.readFileSync(path.join(__dirname, './scripts/lighthouse-report.js'), 'utf8');
const scriptSrc = fs.readFileSync(path.join(__dirname, './scripts/lighthouse-report.js'), 'utf8');
return `<script>${scriptSrc}</script>`;
}

/**
Expand Down Expand Up @@ -261,14 +262,16 @@ class ReportGenerator {
});

const template = Handlebars.compile(this.getReportTemplate());
reportContext = reportContext || 'extension'; // could be: devtools, extension

return template({
url: results.url,
lighthouseVersion: results.lighthouseVersion,
generatedTime: this._formatTime(results.generatedTime),
lhresults: this._escapeScriptTags(JSON.stringify(results, null, 2)),
css: this.getReportCSS(),
reportContext: reportContext || 'extension', // devtools, extension, cli
script: this.getReportJS(),
reportContext: reportContext,
script: reportContext === 'devtools' ? '' : this.getReportJS(),
aggregations: results.aggregations,
auditsByCategory: this._createPWAAuditsByCategory(results.aggregations)
});
Expand Down
10 changes: 6 additions & 4 deletions lighthouse-core/report/templates/report-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
<meta name="viewport" content="width=device-width">
<title>Lighthouse report: {{ url }}</title>
<style>{{{ css }}}</style>
<script>{{{ script }}}</script>
{{{ script }}}
</head>
<body>

<script>
// expose the original results
<!--
<script>
// the original results
self.lhresults = {{{ lhresults }}};
</script>
</script>
-->

<div class="js-report report">
<section class="report-body">
Expand Down

0 comments on commit af48478

Please sign in to comment.