Skip to content

Commit

Permalink
reportcontext etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Nov 10, 2016
1 parent e43341e commit 4adf946
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lighthouse-core/report/report-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,10 @@ class ReportGenerator {
/**
* Generates the Lighthouse report HTML.
* @param {!Object} results Lighthouse results.
* @param {!string} reportContext Where the report is going
* @returns {string} HTML of the report page.
*/
generateHTML(results) {
generateHTML(results, reportContext) {
// Ensure the formatter for each extendedInfo is registered.
Object.keys(results.audits).forEach(audit => {
// Use value rather than key for audit.
Expand Down Expand Up @@ -261,7 +262,7 @@ class ReportGenerator {
generatedTime: this._formatTime(results.generatedTime),
lhresults: JSON.stringify(results, null, 2),
css: this.getReportCSS(),
reportContext: 'extension', // devtools, extension, cli
reportContext: reportContext || 'extension', // devtools, extension, cli
script: this.getReportJS(),
aggregations: results.aggregations,
auditsByCategory: this._createPWAAuditsByCategory(results.aggregations)
Expand Down
7 changes: 4 additions & 3 deletions lighthouse-extension/app/src/lighthouse-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ window.runLighthouseInExtension = function(options, requestedAudits) {
return connection.getCurrentTabURL()
.then(url => window.runLighthouseForConnection(connection, url, options, requestedAudits))
.then(results => {
const blobURL = window.createReportPageAsBlob(results);
const blobURL = window.createReportPageAsBlob(results, 'extension');
chrome.tabs.create({url: blobURL});
});
};
Expand All @@ -84,15 +84,16 @@ window.runLighthouseInWorker = function(port, url, options, requestedAudits) {

/**
* @param {!Object} results Lighthouse results object
* @param {!string} reportContext Where the report is going
* @return {!string} Blob URL of the report (or error page) HTML
*/
window.createReportPageAsBlob = function(results) {
window.createReportPageAsBlob = function(results, reportContext) {
performance.mark('report-start');

const reportGenerator = new ReportGenerator();
let html;
try {
html = reportGenerator.generateHTML(results);
html = reportGenerator.generateHTML(results, reportContext);
} catch (err) {
html = reportGenerator.renderException(err, results);
}
Expand Down

0 comments on commit 4adf946

Please sign in to comment.