diff --git a/lighthouse-core/report/v2/report-generator.js b/lighthouse-core/report/v2/report-generator.js index 942724fb31b3..66430fbbfed9 100644 --- a/lighthouse-core/report/v2/report-generator.js +++ b/lighthouse-core/report/v2/report-generator.js @@ -96,11 +96,17 @@ class ReportGeneratorV2 { /** * Returns the report JSON object with computed scores. - * @param {{categories: !Object<{audits: !Array}>}} config - * @param {!Object<{score: ?number|boolean|undefined}>} resultsByAuditId + * @param {{categories: !Object<{audits: !Array}>, config: ?Object, audits: ?Object}} config + * @param {!Object<{score: ?number|boolean|undefined}>=} resultsByAuditId * @return {{categories: !Array<{audits: !Array<{score: number, result: !Object}>}>}} */ - generateReportJson(config, resultsByAuditId) { + generateReportJson(configOrLhr, resultsByAuditId) { + let config = configOrLhr; + if (configOrLhr.config && configOrLhr.audits) { + config = configOrLhr.config; + resultsByAuditId = configOrLhr.audits; + } + const categories = Object.keys(config.categories).map(categoryId => { const category = config.categories[categoryId]; category.id = categoryId; @@ -131,8 +137,14 @@ class ReportGeneratorV2 { * @param {!Object} reportAsJson * @return {string} */ - generateReportHtml(reportAsJson) { - const sanitizedJson = JSON.stringify(reportAsJson).replace(/