lighthouse 9.2.0-dev.20220110 → 9.2.0-dev.20220111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lighthouse-cli/test/smokehouse/smokehouse.js +0 -1
- package/lighthouse-core/audits/audit.js +17 -2
- package/lighthouse-core/audits/deprecations.js +2 -2
- package/lighthouse-core/audits/dobetterweb/inspector-issues.js +8 -8
- package/lighthouse-core/audits/is-on-https.js +1 -1
- package/lighthouse-core/audits/seo/is-crawlable.js +2 -1
- package/lighthouse-core/gather/gatherers/inspector-issues.js +36 -46
- package/package.json +6 -5
- package/report/test/generator/report-generator-test.js +1 -1
- package/types/artifacts.d.ts +16 -6
- package/types/robots-parser/index.d.ts +0 -20
|
@@ -73,13 +73,28 @@ class Audit {
|
|
|
73
73
|
* considering a log-normal distribution governed by two control points (the 10th
|
|
74
74
|
* percentile value and the median value) and represents the percentage of sites that are
|
|
75
75
|
* greater than `value`.
|
|
76
|
+
*
|
|
77
|
+
* Score characteristics:
|
|
78
|
+
* - within [0, 1]
|
|
79
|
+
* - rounded to two digits
|
|
80
|
+
* - value must meet or beat a controlPoint value to meet or exceed its percentile score:
|
|
81
|
+
* - value > median will give a score < 0.5; value ≤ median will give a score ≥ 0.5.
|
|
82
|
+
* - value > p10 will give a score < 0.9; value ≤ p10 will give a score ≥ 0.9.
|
|
83
|
+
* - values < p10 will get a slight boost so a score of 1 is achievable by a
|
|
84
|
+
* `value` other than those close to 0. Scores of > ~0.99524 end up rounded to 1.
|
|
76
85
|
* @param {{median: number, p10: number}} controlPoints
|
|
77
86
|
* @param {number} value
|
|
78
87
|
* @return {number}
|
|
79
88
|
*/
|
|
80
89
|
static computeLogNormalScore(controlPoints, value) {
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
let percentile = statistics.getLogNormalScore(controlPoints, value);
|
|
91
|
+
// Add a boost to scores of 90+, linearly ramping from 0 at 0.9 to half a
|
|
92
|
+
// point (0.005) at 1. Expands scores in (0.9, 1] to (0.9, 1.005], so more top
|
|
93
|
+
// scores will be a perfect 1 after the two-digit `Math.floor()` rounding below.
|
|
94
|
+
if (percentile > 0.9) { // getLogNormalScore ensures `percentile` can't exceed 1.
|
|
95
|
+
percentile += 0.05 * (percentile - 0.9);
|
|
96
|
+
}
|
|
97
|
+
return Math.floor(percentile * 100) / 100;
|
|
83
98
|
}
|
|
84
99
|
|
|
85
100
|
/**
|
|
@@ -62,8 +62,8 @@ class Deprecations extends Audit {
|
|
|
62
62
|
const bundles = await JsBundles.request(artifacts, context);
|
|
63
63
|
|
|
64
64
|
let deprecations;
|
|
65
|
-
if (artifacts.InspectorIssues.
|
|
66
|
-
deprecations = artifacts.InspectorIssues.
|
|
65
|
+
if (artifacts.InspectorIssues.deprecationIssue.length) {
|
|
66
|
+
deprecations = artifacts.InspectorIssues.deprecationIssue
|
|
67
67
|
.map(deprecation => {
|
|
68
68
|
const {url, lineNumber, columnNumber} = deprecation.sourceCodeLocation;
|
|
69
69
|
const bundle = bundles.find(bundle => bundle.script.src === url);
|
|
@@ -161,19 +161,19 @@ class IssuesPanelEntries extends Audit {
|
|
|
161
161
|
/** @type LH.Audit.Details.TableItem[] */
|
|
162
162
|
const items = [];
|
|
163
163
|
|
|
164
|
-
if (issues.
|
|
165
|
-
items.push(this.getMixedContentRow(issues.
|
|
164
|
+
if (issues.mixedContentIssue.length) {
|
|
165
|
+
items.push(this.getMixedContentRow(issues.mixedContentIssue));
|
|
166
166
|
}
|
|
167
|
-
if (issues.
|
|
168
|
-
items.push(this.getSameSiteCookieRow(issues.
|
|
167
|
+
if (issues.sameSiteCookieIssue.length) {
|
|
168
|
+
items.push(this.getSameSiteCookieRow(issues.sameSiteCookieIssue));
|
|
169
169
|
}
|
|
170
|
-
if (issues.
|
|
171
|
-
items.push(this.getBlockedByResponseRow(issues.
|
|
170
|
+
if (issues.blockedByResponseIssue.length) {
|
|
171
|
+
items.push(this.getBlockedByResponseRow(issues.blockedByResponseIssue));
|
|
172
172
|
}
|
|
173
|
-
if (issues.
|
|
173
|
+
if (issues.heavyAdIssue.length) {
|
|
174
174
|
items.push({issueType: str_(UIStrings.issueTypeHeavyAds)});
|
|
175
175
|
}
|
|
176
|
-
const cspIssues = issues.
|
|
176
|
+
const cspIssues = issues.contentSecurityPolicyIssue.filter(issue => {
|
|
177
177
|
// kTrustedTypesSinkViolation and kTrustedTypesPolicyViolation aren't currently supported by the Issues panel
|
|
178
178
|
return issue.contentSecurityPolicyViolationType !== 'kTrustedTypesSinkViolation' &&
|
|
179
179
|
issue.contentSecurityPolicyViolationType !== 'kTrustedTypesPolicyViolation';
|
|
@@ -87,7 +87,7 @@ class HTTPS extends Audit {
|
|
|
87
87
|
{key: 'resolution', itemType: 'text', text: str_(UIStrings.columnResolution)},
|
|
88
88
|
];
|
|
89
89
|
|
|
90
|
-
for (const details of artifacts.InspectorIssues.
|
|
90
|
+
for (const details of artifacts.InspectorIssues.mixedContentIssue) {
|
|
91
91
|
let item = items.find(item => item.url === details.insecureURL);
|
|
92
92
|
if (!item) {
|
|
93
93
|
item = {url: details.insecureURL};
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const Audit = require('../audit.js');
|
|
9
|
-
|
|
9
|
+
// TODO(esmodules): cast can be removed when this switches to import.
|
|
10
|
+
const robotsParser = /** @type {typeof import('robots-parser').default} */ (/** @type {unknown} */(require('robots-parser'))); // eslint-disable-line max-len
|
|
10
11
|
const URL = require('../../lib/url-shim.js');
|
|
11
12
|
const MainResource = require('../../computed/main-resource.js');
|
|
12
13
|
const BLOCKLIST = new Set([
|
|
@@ -58,58 +58,48 @@ class InspectorIssues extends FRGatherer {
|
|
|
58
58
|
* @return {Promise<LH.Artifacts['InspectorIssues']>}
|
|
59
59
|
*/
|
|
60
60
|
async _getArtifact(networkRecords) {
|
|
61
|
+
/** @type {LH.Artifacts.InspectorIssues} */
|
|
61
62
|
const artifact = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
attributionReportingIssue: [],
|
|
64
|
+
blockedByResponseIssue: [],
|
|
65
|
+
clientHintIssue: [],
|
|
66
|
+
contentSecurityPolicyIssue: [],
|
|
67
|
+
corsIssue: [],
|
|
68
|
+
deprecationIssue: [],
|
|
69
|
+
genericIssue: [],
|
|
70
|
+
heavyAdIssue: [],
|
|
71
|
+
lowTextContrastIssue: [],
|
|
72
|
+
mixedContentIssue: [],
|
|
73
|
+
navigatorUserAgentIssue: [],
|
|
74
|
+
quirksModeIssue: [],
|
|
75
|
+
sameSiteCookieIssue: [],
|
|
76
|
+
sharedArrayBufferIssue: [],
|
|
77
|
+
twaQualityEnforcement: [],
|
|
78
|
+
wasmCrossOriginModuleSharingIssue: [],
|
|
74
79
|
};
|
|
75
|
-
|
|
76
|
-
for (const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
const keys = /** @type {Array<keyof LH.Artifacts['InspectorIssues']>} */(Object.keys(artifact));
|
|
81
|
+
for (const key of keys) {
|
|
82
|
+
// The wasmCrossOriginModuleSharingIssue key doesn't follow the pattern of the rest. See
|
|
83
|
+
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/public/devtools_protocol/browser_protocol.pdl;l=811;drc=9c10bf258928b5d169ba6a449f8f33958f7947ea
|
|
84
|
+
/** @type {`${key}Details` | `wasmCrossOriginModuleSharingIssue`} */
|
|
85
|
+
const detailsKey = (key === 'wasmCrossOriginModuleSharingIssue' ? `${key}` : `${key}Details`);
|
|
86
|
+
const allDetails = this._issues.map(issue => issue.details[detailsKey]);
|
|
87
|
+
for (const detail of allDetails) {
|
|
88
|
+
if (!detail) {
|
|
89
|
+
continue;
|
|
84
90
|
}
|
|
85
|
-
}
|
|
86
|
-
if (issue.details.sameSiteCookieIssueDetails) {
|
|
87
|
-
const issueDetails = issue.details.sameSiteCookieIssueDetails;
|
|
88
|
-
const issueReqId = issueDetails.request?.requestId;
|
|
89
91
|
// Duplicate issues can occur for the same request; only use the one with a matching networkRequest.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
const requestId = 'request' in detail && detail.request && detail.request.requestId;
|
|
93
|
+
if (requestId) {
|
|
94
|
+
if (networkRecords.find(req => req.requestId === requestId)) {
|
|
95
|
+
// @ts-expect-error - detail types are not all compatible
|
|
96
|
+
artifact[key].push(detail);
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
// @ts-expect-error - detail types are not all compatible
|
|
100
|
+
artifact[key].push(detail);
|
|
93
101
|
}
|
|
94
102
|
}
|
|
95
|
-
if (issue.details.blockedByResponseIssueDetails) {
|
|
96
|
-
const issueDetails = issue.details.blockedByResponseIssueDetails;
|
|
97
|
-
const issueReqId = issueDetails.request?.requestId;
|
|
98
|
-
// Duplicate issues can occur for the same request; only use the one with a matching networkRequest.
|
|
99
|
-
if (issueReqId &&
|
|
100
|
-
networkRecords.find(req => req.requestId === issueReqId)) {
|
|
101
|
-
artifact.blockedByResponse.push(issueDetails);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (issue.details.heavyAdIssueDetails) {
|
|
105
|
-
artifact.heavyAds.push(issue.details.heavyAdIssueDetails);
|
|
106
|
-
}
|
|
107
|
-
if (issue.details.contentSecurityPolicyIssueDetails) {
|
|
108
|
-
artifact.contentSecurityPolicy.push(issue.details.contentSecurityPolicyIssueDetails);
|
|
109
|
-
}
|
|
110
|
-
if (issue.details.deprecationIssueDetails) {
|
|
111
|
-
artifact.deprecations.push(issue.details.deprecationIssueDetails);
|
|
112
|
-
}
|
|
113
103
|
}
|
|
114
104
|
|
|
115
105
|
return artifact;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse",
|
|
3
|
-
"version": "9.2.0-dev.
|
|
3
|
+
"version": "9.2.0-dev.20220111",
|
|
4
4
|
"description": "Automated auditing, performance metrics, and best practices for the web.",
|
|
5
5
|
"main": "./lighthouse-core/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"prepack": "yarn build-report --standalone --flow --esm",
|
|
16
16
|
"build-all": "npm-run-posix-or-windows build-all:task",
|
|
17
|
-
"build-all:task": "yarn build-report && yarn build-cdt-lib && yarn build-devtools &&
|
|
17
|
+
"build-all:task": "yarn build-report && yarn build-cdt-lib && yarn build-devtools && concurrently 'yarn build-extension' 'yarn build-lr' 'yarn build-viewer' 'yarn build-treemap' 'yarn build-smokehouse-bundle' && yarn build-pack",
|
|
18
18
|
"build-all:task:windows": "yarn build-report && yarn build-cdt-lib && yarn build-extension && yarn build-devtools && yarn build-lr && yarn build-viewer && yarn build-treemap && yarn build-smokehouse-bundle",
|
|
19
19
|
"build-cdt-lib": "node ./build/build-cdt-lib.js",
|
|
20
20
|
"build-extension": "yarn build-extension-chrome && yarn build-extension-firefox",
|
|
@@ -137,11 +137,12 @@
|
|
|
137
137
|
"c8": "^7.4.0",
|
|
138
138
|
"chalk": "^2.4.1",
|
|
139
139
|
"chrome-devtools-frontend": "1.0.922924",
|
|
140
|
+
"concurrently": "^6.4.0",
|
|
140
141
|
"conventional-changelog-cli": "^2.1.1",
|
|
141
142
|
"cpy": "^8.1.2",
|
|
142
143
|
"cross-env": "^7.0.2",
|
|
143
144
|
"csv-validator": "^0.0.3",
|
|
144
|
-
"devtools-protocol": "0.0.
|
|
145
|
+
"devtools-protocol": "0.0.957544",
|
|
145
146
|
"es-main": "^1.0.2",
|
|
146
147
|
"eslint": "^8.4.1",
|
|
147
148
|
"eslint-config-google": "^0.14.0",
|
|
@@ -205,7 +206,7 @@
|
|
|
205
206
|
"parse-cache-control": "1.0.1",
|
|
206
207
|
"ps-list": "^8.0.0",
|
|
207
208
|
"raven": "^2.2.1",
|
|
208
|
-
"robots-parser": "^
|
|
209
|
+
"robots-parser": "^3.0.0",
|
|
209
210
|
"semver": "^5.3.0",
|
|
210
211
|
"speedline-core": "^1.4.3",
|
|
211
212
|
"third-party-web": "^0.12.7",
|
|
@@ -215,7 +216,7 @@
|
|
|
215
216
|
"yargs-parser": "^20.2.4"
|
|
216
217
|
},
|
|
217
218
|
"resolutions": {
|
|
218
|
-
"puppeteer/**/devtools-protocol": "0.0.
|
|
219
|
+
"puppeteer/**/devtools-protocol": "0.0.957544"
|
|
219
220
|
},
|
|
220
221
|
"repository": "GoogleChrome/lighthouse",
|
|
221
222
|
"keywords": [
|
|
@@ -97,7 +97,7 @@ describe('ReportGenerator', () => {
|
|
|
97
97
|
expect(lines.slice(0, 3).join('\n')).toMatchInlineSnapshot(`
|
|
98
98
|
"requestedUrl,finalUrl,category,name,title,type,score
|
|
99
99
|
\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"performance-score\\",\\"Overall Performance Category Score\\",\\"numeric\\",\\"0.26\\"
|
|
100
|
-
\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"first-contentful-paint\\",\\"First Contentful Paint\\",\\"numeric\\",\\"0.
|
|
100
|
+
\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"Performance\\",\\"first-contentful-paint\\",\\"First Contentful Paint\\",\\"numeric\\",\\"0.01\\"
|
|
101
101
|
"
|
|
102
102
|
`);
|
|
103
103
|
|
package/types/artifacts.d.ts
CHANGED
|
@@ -553,12 +553,22 @@ declare module Artifacts {
|
|
|
553
553
|
}
|
|
554
554
|
|
|
555
555
|
interface InspectorIssues {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
556
|
+
attributionReportingIssue: LH.Crdp.Audits.AttributionReportingIssueDetails[];
|
|
557
|
+
blockedByResponseIssue: LH.Crdp.Audits.BlockedByResponseIssueDetails[];
|
|
558
|
+
clientHintIssue: LH.Crdp.Audits.ClientHintIssueDetails[];
|
|
559
|
+
contentSecurityPolicyIssue: LH.Crdp.Audits.ContentSecurityPolicyIssueDetails[];
|
|
560
|
+
corsIssue: LH.Crdp.Audits.CorsIssueDetails[];
|
|
561
|
+
deprecationIssue: LH.Crdp.Audits.DeprecationIssueDetails[];
|
|
562
|
+
genericIssue: LH.Crdp.Audits.GenericIssueDetails[];
|
|
563
|
+
heavyAdIssue: LH.Crdp.Audits.HeavyAdIssueDetails[];
|
|
564
|
+
lowTextContrastIssue: LH.Crdp.Audits.LowTextContrastIssueDetails[];
|
|
565
|
+
mixedContentIssue: LH.Crdp.Audits.MixedContentIssueDetails[];
|
|
566
|
+
navigatorUserAgentIssue: LH.Crdp.Audits.NavigatorUserAgentIssueDetails[];
|
|
567
|
+
quirksModeIssue: LH.Crdp.Audits.QuirksModeIssueDetails[];
|
|
568
|
+
sameSiteCookieIssue: LH.Crdp.Audits.SameSiteCookieIssueDetails[];
|
|
569
|
+
sharedArrayBufferIssue: LH.Crdp.Audits.SharedArrayBufferIssueDetails[];
|
|
570
|
+
twaQualityEnforcement: LH.Crdp.Audits.TrustedWebActivityIssueDetails[];
|
|
571
|
+
wasmCrossOriginModuleSharingIssue: LH.Crdp.Audits.WasmCrossOriginModuleSharingIssueDetails[];
|
|
562
572
|
}
|
|
563
573
|
|
|
564
574
|
// Computed artifact types below.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2018 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
-
* 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
|
|
4
|
-
* 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.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
declare module 'robots-parser' {
|
|
8
|
-
interface Robots {
|
|
9
|
-
isAllowed(url: string, ua?: string): boolean | undefined;
|
|
10
|
-
isDisallowed(url: string, ua?: string): boolean | undefined;
|
|
11
|
-
getMatchingLineNumber(url: string, ua?: string): number | undefined;
|
|
12
|
-
getCrawlDelay(ua?: string): number | undefined;
|
|
13
|
-
getSitemaps(): Array<string>;
|
|
14
|
-
getPreferredHost(): string | null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function RobotsParser(url: string, robotsTxt: string): Robots;
|
|
18
|
-
|
|
19
|
-
export = RobotsParser;
|
|
20
|
-
}
|