diff --git a/docs/plugins.md b/docs/plugins.md index a335efdae554..f15867d955c0 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -60,10 +60,10 @@ A Lighthouse plugin is just a node module with a name that starts with `lighthou "name": "lighthouse-plugin-cats", "main": "plugin.js", "peerDependencies": { - "lighthouse": "^8.6.0" + "lighthouse": "^9.0.0-alpha.0" }, "devDependencies": { - "lighthouse": "^8.6.0" + "lighthouse": "^9.0.0-alpha.0" } } ``` diff --git a/docs/recipes/custom-audit/package.json b/docs/recipes/custom-audit/package.json index da99fcedb401..b2badd8bcd93 100644 --- a/docs/recipes/custom-audit/package.json +++ b/docs/recipes/custom-audit/package.json @@ -3,6 +3,6 @@ "private": true, "scripts": {}, "devDependencies": { - "lighthouse": "^8.6.0" + "lighthouse": "^9.0.0-alpha.0" } } diff --git a/docs/recipes/gulp/package.json b/docs/recipes/gulp/package.json index 9b2b3becb2e8..f32e7ac077c6 100644 --- a/docs/recipes/gulp/package.json +++ b/docs/recipes/gulp/package.json @@ -7,6 +7,6 @@ "devDependencies": { "gulp": "^3.9.1", "gulp-connect": "^5.0.0", - "lighthouse": "^8.6.0" + "lighthouse": "^9.0.0-alpha.0" } } diff --git a/docs/recipes/lighthouse-plugin-example/package.json b/docs/recipes/lighthouse-plugin-example/package.json index 7ed617bd10fb..d12d016b408b 100644 --- a/docs/recipes/lighthouse-plugin-example/package.json +++ b/docs/recipes/lighthouse-plugin-example/package.json @@ -3,7 +3,7 @@ "private": true, "main": "./plugin.js", "peerDependencies": { - "lighthouse": "^8.6.0" + "lighthouse": "^9.0.0-alpha.0" }, "devDependencies": { "lighthouse": "^8.6.0" diff --git a/lighthouse-core/test/results/sample_v2.json b/lighthouse-core/test/results/sample_v2.json index 1dc55a34b43a..84252485470b 100644 --- a/lighthouse-core/test/results/sample_v2.json +++ b/lighthouse-core/test/results/sample_v2.json @@ -9,7 +9,7 @@ "axe-core": "4.2.3" } }, - "lighthouseVersion": "8.6.0", + "lighthouseVersion": "9.0.0-alpha.0", "fetchTime": "2021-09-07T20:11:11.853Z", "requestedUrl": "http://localhost:10200/dobetterweb/dbw_tester.html", "finalUrl": "http://localhost:10200/dobetterweb/dbw_tester.html", diff --git a/lighthouse-core/util-commonjs.js b/lighthouse-core/util-commonjs.js index 9fa4056accd2..576bee47c6db 100644 --- a/lighthouse-core/util-commonjs.js +++ b/lighthouse-core/util-commonjs.js @@ -111,6 +111,23 @@ class Util { /** @type {Map>} */ const relevantAuditToMetricsMap = new Map(); + // This backcompat converts old LHRs (<9.0.0) to use the new "hidden" group. + // Old LHRs used "no group" to identify audits that should be hidden in performance instead of the "hidden" group. + // Newer LHRs use "no group" to identify opportunities and diagnostics whose groups are assigned by details type. + const [majorVersion] = clone.lighthouseVersion.split('.').map(Number); + const perfCategory = clone.categories['performance']; + if (majorVersion < 9 && perfCategory) { + if (!clone.categoryGroups) clone.categoryGroups = {}; + clone.categoryGroups['hidden'] = {title: ''}; + for (const auditRef of perfCategory.auditRefs) { + if (!auditRef.group) { + auditRef.group = 'hidden'; + } else if (['load-opportunities', 'diagnostics'].includes(auditRef.group)) { + delete auditRef.group; + } + } + } + for (const category of Object.values(clone.categories)) { // Make basic lookup table for relevantAudits category.auditRefs.forEach(metricRef => { diff --git a/package.json b/package.json index 3ac40f3007ef..83696a437a44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lighthouse", - "version": "8.6.0", + "version": "9.0.0-alpha.0", "description": "Automated auditing, performance metrics, and best practices for the web.", "main": "./lighthouse-core/index.js", "bin": { diff --git a/report/renderer/util.js b/report/renderer/util.js index bd167821cf98..369233b69e7c 100644 --- a/report/renderer/util.js +++ b/report/renderer/util.js @@ -108,6 +108,23 @@ class Util { /** @type {Map>} */ const relevantAuditToMetricsMap = new Map(); + // This backcompat converts old LHRs (<9.0.0) to use the new "hidden" group. + // Old LHRs used "no group" to identify audits that should be hidden in performance instead of the "hidden" group. + // Newer LHRs use "no group" to identify opportunities and diagnostics whose groups are assigned by details type. + const [majorVersion] = clone.lighthouseVersion.split('.').map(Number); + const perfCategory = clone.categories['performance']; + if (majorVersion < 9 && perfCategory) { + if (!clone.categoryGroups) clone.categoryGroups = {}; + clone.categoryGroups['hidden'] = {title: ''}; + for (const auditRef of perfCategory.auditRefs) { + if (!auditRef.group) { + auditRef.group = 'hidden'; + } else if (['load-opportunities', 'diagnostics'].includes(auditRef.group)) { + delete auditRef.group; + } + } + } + for (const category of Object.values(clone.categories)) { // Make basic lookup table for relevantAudits category.auditRefs.forEach(metricRef => { diff --git a/report/test/renderer/util-test.js b/report/test/renderer/util-test.js index bf222a8e3e0a..058bf33cde58 100644 --- a/report/test/renderer/util-test.js +++ b/report/test/renderer/util-test.js @@ -155,6 +155,28 @@ describe('util helpers', () => { const preparedResult = Util.prepareReportResult(clonedSampleResult); assert.deepStrictEqual(preparedResult.audits, sampleResult.audits); }); + + it('corrects performance category without hidden group', () => { + const clonedSampleResult = JSON.parse(JSON.stringify(sampleResult)); + + clonedSampleResult.lighthouseVersion = '8.6.0'; + delete clonedSampleResult.categoryGroups['hidden']; + for (const auditRef of clonedSampleResult.categories['performance'].auditRefs) { + if (auditRef.group === 'hidden') { + delete auditRef.group; + } else if (!auditRef.group) { + auditRef.group = 'diagnostics'; + } + } + assert.notDeepStrictEqual(clonedSampleResult.categories, sampleResult.categories); + assert.notDeepStrictEqual(clonedSampleResult.categoryGroups, sampleResult.categoryGroups); + + // Original audit results should be restored. + const clonedPreparedResult = Util.prepareReportResult(clonedSampleResult); + const preparedResult = Util.prepareReportResult(sampleResult); + assert.deepStrictEqual(clonedPreparedResult.categories, preparedResult.categories); + assert.deepStrictEqual(clonedPreparedResult.categoryGroups, preparedResult.categoryGroups); + }); }); it('appends stack pack descriptions to auditRefs', () => { diff --git a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt index fc8e1810cd89..228a17a01753 100644 --- a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt +++ b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt @@ -14,7 +14,7 @@ Generate report: enabled visible =============== Lighthouse Results =============== URL: http://127.0.0.1:8000/devtools/lighthouse/resources/lighthouse-emulate-pass.html -Version: 8.6.0 +Version: 9.0.0-alpha.0 formFactor: mobile screenEmulation: { "mobile": true, diff --git a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt index 9cd79a13d080..e68cc06e7e6c 100644 --- a/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt +++ b/third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/lighthouse-successful-run-expected.txt @@ -374,7 +374,7 @@ Generating results... =============== Lighthouse Results =============== URL: http://127.0.0.1:8000/devtools/lighthouse/resources/lighthouse-basic.html -Version: 8.6.0 +Version: 9.0.0-alpha.0 ViewportDimensions: { "innerWidth": 980, "innerHeight": 1743,