Skip to content

Commit 62b1656

Browse files
Connor ClarkDevtools-frontend LUCI CQ
Connor Clark
authored and
Devtools-frontend LUCI CQ
committed
[Lighthouse] Roll Lighthouse 8.0.0
Bug: 772558 Change-Id: Ib1182e2e3dddf8b0859cee85ca4dd5c7e5812cb3 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2930996 Reviewed-by: Paul Irish <[email protected]> Commit-Queue: Paul Irish <[email protected]>
1 parent 287be69 commit 62b1656

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4832
-3334
lines changed

front_end/panels/lighthouse/LighthouseReportRenderer.ts

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export class LighthouseReportRenderer extends self.ReportRenderer {
7171
if (simulated) {
7272
UI.Tooltip.Tooltip.install(timelineButton, i18nString(UIStrings.thePerformanceMetricsAboveAre));
7373
}
74-
container.insertBefore(timelineButton, disclaimerEl.nextSibling);
7574

7675
async function onViewTraceClick(): Promise<void> {
7776
Host.userMetrics.actionTaken(Host.UserMetrics.Action.LighthouseViewTrace);

front_end/third_party/lighthouse/lighthouse-dt-bundle.js

+821-824
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front_end/third_party/lighthouse/locales/ar-XB.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/ar.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/bg.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/ca.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/cs.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/da.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/de.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/el.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/en-GB.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/en-US.json

+45-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/en-XA.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/en-XL.json

+45-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/es-419.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/es.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/fi.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/fil.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/fr.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/he.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/hi.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/hr.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/hu.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/id.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/it.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/ja.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/ko.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/lt.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/lv.json

+82-52
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/nl.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/no.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/pl.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/pt-PT.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/pt.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/ro.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/ru.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/sk.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/sl.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/sr-Latn.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/sr.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/sv.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/ta.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/te.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/th.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/tr.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/uk.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/vi.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/zh-HK.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/zh-TW.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/locales/zh.json

+81-51
Large diffs are not rendered by default.

front_end/third_party/lighthouse/report-assets/report.css

+16-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front_end/third_party/lighthouse/report-assets/report.js

+147-29
Original file line numberDiff line numberDiff line change
@@ -2542,7 +2542,7 @@ if (typeof module !== 'undefined' && module.exports) {
25422542
* the report.
25432543
*/
25442544

2545-
/* globals getFilenamePrefix Util ElementScreenshotRenderer */
2545+
/* globals getFilenamePrefix Util TextEncoding ElementScreenshotRenderer */
25462546

25472547
/** @typedef {import('./dom')} DOM */
25482548

@@ -2672,8 +2672,7 @@ class ReportUIFeatures {
26722672

26732673
const showTreemapApp =
26742674
this.json.audits['script-treemap-data'] && this.json.audits['script-treemap-data'].details;
2675-
// TODO: need window.opener to work in DevTools.
2676-
if (showTreemapApp && !this._dom.isDevTools()) {
2675+
if (showTreemapApp) {
26772676
this.addButton({
26782677
text: Util.i18n.strings.viewTreemapLabel,
26792678
icon: 'treemap',
@@ -2700,12 +2699,18 @@ class ReportUIFeatures {
27002699
}
27012700

27022701
/**
2703-
* @param {{text: string, icon?: string, onClick: () => void}} opts
2702+
* @param {{container?: Element, text: string, icon?: string, onClick: () => void}} opts
27042703
*/
27052704
addButton(opts) {
2705+
// report-ui-features doesn't have a reference to the root report el, and PSI has
2706+
// 2 reports on the page (and not even attached to DOM when installFeatures is called..)
2707+
// so we need a container option to specify where the element should go.
27062708
const metricsEl = this._document.querySelector('.lh-audit-group--metrics');
2707-
// Not supported without metrics group.
2708-
if (!metricsEl) return;
2709+
const containerEl = opts.container || metricsEl;
2710+
if (!containerEl) return;
2711+
2712+
let buttonsEl = containerEl.querySelector('.lh-buttons');
2713+
if (!buttonsEl) buttonsEl = this._dom.createChildOf(containerEl, 'div', 'lh-buttons');
27092714

27102715
const classes = [
27112716
'lh-button',
@@ -2714,10 +2719,9 @@ class ReportUIFeatures {
27142719
classes.push('report-icon');
27152720
classes.push(`report-icon--${opts.icon}`);
27162721
}
2717-
const buttonEl = this._dom.createChildOf(metricsEl, 'button', classes.join(' '));
2718-
buttonEl.addEventListener('click', opts.onClick);
2722+
const buttonEl = this._dom.createChildOf(buttonsEl, 'button', classes.join(' '));
27192723
buttonEl.textContent = opts.text;
2720-
metricsEl.append(buttonEl);
2724+
buttonEl.addEventListener('click', opts.onClick);
27212725
return buttonEl;
27222726
}
27232727

@@ -3049,23 +3053,31 @@ class ReportUIFeatures {
30493053
}
30503054

30513055
/**
3052-
* Opens a new tab to the online viewer and sends the local page's JSON results
3053-
* to the online viewer using postMessage.
3056+
* The popup's window.name is keyed by version+url+fetchTime, so we reuse/select tabs correctly.
30543057
* @param {LH.Result} json
30553058
* @protected
30563059
*/
3057-
static openTabAndSendJsonReportToViewer(json) {
3058-
// The popup's window.name is keyed by version+url+fetchTime, so we reuse/select tabs correctly
3060+
static computeWindowNameSuffix(json) {
30593061
// @ts-ignore - If this is a v2 LHR, use old `generatedTime`.
30603062
const fallbackFetchTime = /** @type {string} */ (json.generatedTime);
30613063
const fetchTime = json.fetchTime || fallbackFetchTime;
3062-
const windowName = `${json.lighthouseVersion}-${json.requestedUrl}-${fetchTime}`;
3064+
return `${json.lighthouseVersion}-${json.requestedUrl}-${fetchTime}`;
3065+
}
3066+
3067+
/**
3068+
* Opens a new tab to the online viewer and sends the local page's JSON results
3069+
* to the online viewer using postMessage.
3070+
* @param {LH.Result} json
3071+
* @protected
3072+
*/
3073+
static openTabAndSendJsonReportToViewer(json) {
3074+
const windowName = 'viewer-' + this.computeWindowNameSuffix(json);
30633075
const url = getAppsOrigin() + '/viewer/';
30643076
ReportUIFeatures.openTabAndSendData({lhr: json}, url, windowName);
30653077
}
30663078

30673079
/**
3068-
* Opens a new tab to the treemap app and sends the JSON results using postMessage.
3080+
* Opens a new tab to the treemap app and sends the JSON results using URL.fragment
30693081
* @param {LH.Result} json
30703082
*/
30713083
static openTreemap(json) {
@@ -3074,13 +3086,23 @@ class ReportUIFeatures {
30743086
throw new Error('no script treemap data found');
30753087
}
30763088

3077-
const windowName = `treemap-${json.requestedUrl}`;
30783089
/** @type {LH.Treemap.Options} */
30793090
const treemapOptions = {
3080-
lhr: json,
3091+
lhr: {
3092+
requestedUrl: json.requestedUrl,
3093+
finalUrl: json.finalUrl,
3094+
audits: {
3095+
'script-treemap-data': json.audits['script-treemap-data'],
3096+
},
3097+
configSettings: {
3098+
locale: json.configSettings.locale,
3099+
},
3100+
},
30813101
};
30823102
const url = getAppsOrigin() + '/treemap/';
3083-
ReportUIFeatures.openTabAndSendData(treemapOptions, url, windowName);
3103+
const windowName = 'treemap-' + this.computeWindowNameSuffix(json);
3104+
3105+
ReportUIFeatures.openTabWithUrlData(treemapOptions, url, windowName);
30843106
}
30853107

30863108
/**
@@ -3106,10 +3128,26 @@ class ReportUIFeatures {
31063128
}
31073129
});
31083130

3109-
// The popup's window.name is keyed by version+url+fetchTime, so we reuse/select tabs correctly
31103131
const popup = window.open(url, windowName);
31113132
}
31123133

3134+
/**
3135+
* Opens a new tab to an external page and sends data via base64 encoded url params.
3136+
* @param {{lhr: LH.Result} | LH.Treemap.Options} data
3137+
* @param {string} url_
3138+
* @param {string} windowName
3139+
* @protected
3140+
*/
3141+
static async openTabWithUrlData(data, url_, windowName) {
3142+
const url = new URL(url_);
3143+
const gzip = Boolean(window.CompressionStream);
3144+
url.hash = await TextEncoding.toBase64(JSON.stringify(data), {
3145+
gzip,
3146+
});
3147+
if (gzip) url.searchParams.set('gzip', '1');
3148+
window.open(url.toString(), windowName);
3149+
}
3150+
31133151
/**
31143152
* Expands all audit `<details>`.
31153153
* Ideally, a print stylesheet could take care of this, but CSS has no way to
@@ -4071,11 +4109,12 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
40714109
* @return {string}
40724110
*/
40734111
_getScoringCalculatorHref(auditRefs) {
4074-
const v5andv6metrics = auditRefs.filter(audit => audit.group === 'metrics');
4112+
// TODO: filter by !!acronym when dropping renderer support of v7 LHRs.
4113+
const metrics = auditRefs.filter(audit => audit.group === 'metrics');
40754114
const fci = auditRefs.find(audit => audit.id === 'first-cpu-idle');
40764115
const fmp = auditRefs.find(audit => audit.id === 'first-meaningful-paint');
4077-
if (fci) v5andv6metrics.push(fci);
4078-
if (fmp) v5andv6metrics.push(fmp);
4116+
if (fci) metrics.push(fci);
4117+
if (fmp) metrics.push(fmp);
40794118

40804119
/**
40814120
* Clamp figure to 2 decimal places
@@ -4084,7 +4123,7 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
40844123
*/
40854124
const clampTo2Decimals = val => Math.round(val * 100) / 100;
40864125

4087-
const metricPairs = v5andv6metrics.map(audit => {
4126+
const metricPairs = metrics.map(audit => {
40884127
let value;
40894128
if (typeof audit.result.numericValue === 'number') {
40904129
value = audit.id === 'cumulative-layout-shift' ?
@@ -4270,17 +4309,17 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
42704309
]);
42714310
for (const metric of filterChoices) {
42724311
const elemId = `metric-${metric.acronym}`;
4312+
const radioEl = this.dom.createChildOf(metricFilterEl, 'input', 'lh-metricfilter__radio', {
4313+
type: 'radio',
4314+
name: 'metricsfilter',
4315+
id: elemId,
4316+
});
4317+
42734318
const labelEl = this.dom.createChildOf(metricFilterEl, 'label', 'lh-metricfilter__label', {
42744319
for: elemId,
42754320
title: metric.result && metric.result.title,
42764321
});
42774322
labelEl.textContent = metric.acronym || metric.id;
4278-
const radioEl = this.dom.createChildOf(labelEl, 'input', 'lh-metricfilter__radio', {
4279-
type: 'radio',
4280-
name: 'metricsfilter',
4281-
id: elemId,
4282-
hidden: 'true',
4283-
});
42844323

42854324
if (metric.acronym === 'All') {
42864325
radioEl.checked = true;
@@ -5010,3 +5049,82 @@ if (typeof module !== 'undefined' && module.exports) {
50105049
} else {
50115050
self.I18n = I18n;
50125051
}
5052+
;
5053+
/**
5054+
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
5055+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
5056+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5057+
*/
5058+
'use strict';
5059+
5060+
/* global self btoa atob window CompressionStream Response */
5061+
5062+
const btoa_ = typeof btoa !== 'undefined' ?
5063+
btoa :
5064+
/** @param {string} str */
5065+
(str) => Buffer.from(str).toString('base64');
5066+
const atob_ = typeof atob !== 'undefined' ?
5067+
atob :
5068+
/** @param {string} str */
5069+
(str) => Buffer.from(str, 'base64').toString();
5070+
5071+
/**
5072+
* Takes an UTF-8 string and returns a base64 encoded string.
5073+
* If gzip is true, the UTF-8 bytes are gzipped before base64'd, using
5074+
* CompressionStream (currently only in Chrome), falling back to pako
5075+
* (which is only used to encode in our Node tests).
5076+
* @param {string} string
5077+
* @param {{gzip: boolean}} options
5078+
* @return {Promise<string>}
5079+
*/
5080+
async function toBase64(string, options) {
5081+
let bytes = new TextEncoder().encode(string);
5082+
5083+
if (options.gzip) {
5084+
if (typeof CompressionStream !== 'undefined') {
5085+
const cs = new CompressionStream('gzip');
5086+
const writer = cs.writable.getWriter();
5087+
writer.write(bytes);
5088+
writer.close();
5089+
const compAb = await new Response(cs.readable).arrayBuffer();
5090+
bytes = new Uint8Array(compAb);
5091+
} else {
5092+
/** @type {import('pako')=} */
5093+
const pako = window.pako;
5094+
bytes = pako.gzip(string);
5095+
}
5096+
}
5097+
5098+
let binaryString = '';
5099+
// This is ~25% faster than building the string one character at a time.
5100+
// https://jsbench.me/2gkoxazvjl
5101+
const chunkSize = 5000;
5102+
for (let i = 0; i < bytes.length; i += chunkSize) {
5103+
binaryString += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
5104+
}
5105+
return btoa_(binaryString);
5106+
}
5107+
5108+
/**
5109+
* @param {string} encoded
5110+
* @param {{gzip: boolean}} options
5111+
* @return {string}
5112+
*/
5113+
function fromBase64(encoded, options) {
5114+
const binaryString = atob_(encoded);
5115+
const bytes = Uint8Array.from(binaryString, c => c.charCodeAt(0));
5116+
5117+
if (options.gzip) {
5118+
/** @type {import('pako')=} */
5119+
const pako = window.pako;
5120+
return pako.ungzip(bytes, {to: 'string'});
5121+
} else {
5122+
return new TextDecoder().decode(bytes);
5123+
}
5124+
}
5125+
5126+
if (typeof module !== 'undefined' && module.exports) {
5127+
module.exports = {toBase64, fromBase64};
5128+
} else {
5129+
self.TextEncoding = {toBase64, fromBase64};
5130+
}

front_end/third_party/lighthouse/report-assets/templates.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@
323323
background-color: var(--color-gray-200);
324324
outline: none;
325325
}
326-
/* save-as-gist option hidden in report */
327-
.lh-tools__dropdown .lh-tools--gist {
326+
/* save-gist option hidden in report. */
327+
.lh-tools__dropdown a[data-action='save-gist'] {
328328
display: none;
329329
}
330330

@@ -393,8 +393,8 @@
393393
<a role="menuitem" tabindex="-1" href="#" class="report-icon report-icon--copy" data-i18n="dropdownCopyJSON" data-action="copy"></a>
394394
<a role="menuitem" tabindex="-1" href="#" class="report-icon report-icon--download" data-i18n="dropdownSaveHTML" data-action="save-html"></a>
395395
<a role="menuitem" tabindex="-1" href="#" class="report-icon report-icon--download" data-i18n="dropdownSaveJSON" data-action="save-json"></a>
396-
<a role="menuitem" tabindex="-1" href="#" class="report-icon report-icon--open lh-tools--viewer" data-i18n="dropdownViewer" data-action="open-viewer"></a>
397-
<a role="menuitem" tabindex="-1" href="#" class="report-icon report-icon--open lh-tools--gist" data-i18n="dropdownSaveGist" data-action="save-gist"></a>
396+
<a role="menuitem" tabindex="-1" href="#" class="report-icon report-icon--open" data-i18n="dropdownViewer" data-action="open-viewer"></a>
397+
<a role="menuitem" tabindex="-1" href="#" class="report-icon report-icon--open" data-i18n="dropdownSaveGist" data-action="save-gist"></a>
398398
<a role="menuitem" tabindex="-1" href="#" class="report-icon report-icon--dark" data-i18n="dropdownDarkTheme" data-action="toggle-dark"></a>
399399
</div>
400400
</div>

test/webtests/http/tests/devtools/lighthouse/lighthouse-clear-data-warning-expected.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ Tests that Lighthouse panel displays a warning when important data may affect pe
1111
[x] Clear storage
1212
[x] Simulated throttling
1313
Generate report: enabled visible
14-
Warning Text: There may be stored data affecting loading performance in this location: IndexedDB. Audit this page in an incognito window to prevent those resources from affecting your scores.
14+
Warning Text: There may be stored data affecting loading performance in these locations: Web SQL, IndexedDB. Audit this page in an incognito window to prevent those resources from affecting your scores.
1515

test/webtests/http/tests/devtools/lighthouse/lighthouse-emulate-run-expected.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Generate report: enabled visible
1414

1515
=============== Lighthouse Results ===============
1616
URL: http://127.0.0.1:8000/devtools/lighthouse/resources/lighthouse-emulate-pass.html
17-
Version: 7.5.0
17+
Version: 8.0.0
1818
formFactor: mobile
1919
screenEmulation: {
2020
"mobile": true,

test/webtests/http/tests/devtools/lighthouse/lighthouse-export-run-expected.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ Tests that exporting works.
22

33
++++++++ testExportHtml
44

5-
# of .lh-audit divs (original): 136
5+
# of .lh-audit divs (original): 137
66

7-
# of .lh-audit divs (exported html): 136
7+
# of .lh-audit divs (exported html): 137
88

99
++++++++ testExportJson
1010

11-
# of audits (json): 155
11+
# of audits (json): 154
1212

0 commit comments

Comments
 (0)