lighthouse 8.6.0 → 9.0.0-dev.20211118
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/changelog.md +121 -0
- package/dist/report/bundle.esm.js +6009 -0
- package/dist/report/flow.js +98 -25
- package/dist/report/standalone.js +41 -35
- package/flow-report/.eslintrc.cjs +2 -0
- package/flow-report/assets/standalone-flow-template.html +3 -4
- package/flow-report/assets/styles.css +108 -31
- package/flow-report/src/app.tsx +25 -28
- package/flow-report/src/common.tsx +28 -15
- package/flow-report/src/header.tsx +12 -13
- package/flow-report/src/help-dialog.tsx +3 -4
- package/flow-report/src/i18n/i18n.tsx +57 -16
- package/flow-report/src/i18n/ui-strings.js +50 -0
- package/flow-report/src/icons.tsx +36 -8
- package/flow-report/src/sidebar/flow.tsx +3 -3
- package/flow-report/src/sidebar/sidebar.tsx +35 -14
- package/flow-report/src/summary/category.tsx +97 -24
- package/flow-report/src/summary/summary.tsx +21 -14
- package/flow-report/src/topbar.tsx +13 -12
- package/flow-report/src/util.ts +61 -27
- package/flow-report/src/wrappers/category-score.tsx +9 -27
- package/flow-report/src/wrappers/markdown.tsx +18 -0
- package/flow-report/src/wrappers/report.tsx +26 -37
- package/flow-report/standalone-flow.tsx +5 -4
- package/flow-report/test/common-test.tsx +32 -17
- package/flow-report/test/flow-report-pptr-test.ts +46 -0
- package/flow-report/test/header-test.tsx +6 -6
- package/flow-report/test/setup/env-setup.ts +11 -5
- package/flow-report/test/sidebar/sidebar-test.tsx +43 -1
- package/flow-report/test/summary/category-test.tsx +114 -21
- package/flow-report/test/summary/summary-test.tsx +4 -7
- package/flow-report/test/topbar-test.tsx +15 -14
- package/flow-report/test/util-test.tsx +69 -11
- package/flow-report/test/wrappers/category-score-test.tsx +84 -0
- package/flow-report/test/wrappers/markdown-test.tsx +17 -0
- package/flow-report/tsconfig.json +1 -0
- package/jest.config.js +4 -2
- package/lighthouse-cli/.eslintrc.cjs +2 -0
- package/lighthouse-cli/cli-flags.js +1 -1
- package/lighthouse-cli/run.js +1 -1
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +4 -2
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +1 -1
- package/lighthouse-cli/test/smokehouse/smokehouse.js +1 -1
- package/lighthouse-core/audits/accessibility/axe-audit.js +7 -1
- package/lighthouse-core/audits/audit.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +2 -0
- package/lighthouse-core/audits/byte-efficiency/modern-image-formats.js +4 -2
- package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +11 -10
- package/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js +5 -3
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js +2 -1
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +2 -1
- package/lighthouse-core/audits/deprecations.js +33 -11
- package/lighthouse-core/audits/dobetterweb/uses-http2.js +27 -11
- package/lighthouse-core/audits/errors-in-console.js +0 -2
- package/lighthouse-core/audits/image-aspect-ratio.js +5 -5
- package/lighthouse-core/audits/image-size-responsive.js +6 -6
- package/lighthouse-core/audits/installable-manifest.js +16 -7
- package/lighthouse-core/audits/preload-lcp-image.js +7 -5
- package/lighthouse-core/audits/script-treemap-data.js +1 -1
- package/lighthouse-core/audits/unsized-images.js +2 -3
- package/lighthouse-core/computed/image-records.js +4 -3
- package/lighthouse-core/computed/metrics/lantern-total-blocking-time.js +3 -4
- package/lighthouse-core/computed/metrics/tbt-utils.js +57 -0
- package/lighthouse-core/computed/metrics/total-blocking-time.js +3 -53
- package/lighthouse-core/computed/resource-summary.js +1 -1
- package/lighthouse-core/config/config-helpers.js +21 -10
- package/lighthouse-core/config/constants.js +3 -4
- package/lighthouse-core/config/default-config.js +61 -71
- package/lighthouse-core/fraggle-rock/config/config.js +1 -1
- package/lighthouse-core/fraggle-rock/config/default-config.js +4 -5
- package/lighthouse-core/fraggle-rock/gather/base-gatherer.js +6 -1
- package/lighthouse-core/fraggle-rock/gather/session.js +3 -4
- package/lighthouse-core/gather/connections/cri.js +1 -1
- package/lighthouse-core/gather/driver/storage.js +0 -1
- package/lighthouse-core/gather/driver.js +3 -7
- package/lighthouse-core/gather/fetcher.js +4 -7
- package/lighthouse-core/gather/gather-runner.js +29 -6
- package/lighthouse-core/gather/gatherers/accessibility.js +27 -0
- package/lighthouse-core/gather/gatherers/dobetterweb/response-compression.js +1 -0
- package/lighthouse-core/gather/gatherers/image-elements.js +0 -3
- package/lighthouse-core/gather/gatherers/inspector-issues.js +5 -0
- package/lighthouse-core/lib/asset-saver.js +7 -4
- package/lighthouse-core/lib/emulation.js +45 -1
- package/lighthouse-core/lib/i18n/i18n.js +19 -8
- package/lighthouse-core/lib/lh-env.js +2 -0
- package/lighthouse-core/lib/page-functions.js +2 -1
- package/lighthouse-core/lib/proto-preprocessor.js +14 -2
- package/lighthouse-core/lib/statistics.js +26 -39
- package/lighthouse-core/lib/tappable-rects.js +8 -15
- package/lighthouse-core/lib/url-shim.js +1 -1
- package/lighthouse-core/runner.js +1 -1
- package/lighthouse-core/util-commonjs.js +65 -46
- package/package.json +27 -17
- package/readme.md +3 -3
- package/report/.eslintrc.cjs +2 -0
- package/report/README.md +1 -1
- package/report/assets/standalone-template.html +2 -3
- package/report/assets/styles.css +362 -256
- package/report/assets/templates.html +21 -76
- package/report/clients/bundle.js +1 -0
- package/report/clients/standalone.js +6 -15
- package/report/generator/README.md +1 -1
- package/report/renderer/api.js +66 -0
- package/report/renderer/category-renderer.js +76 -22
- package/report/renderer/components.js +59 -110
- package/report/renderer/crc-details-renderer.js +15 -12
- package/report/renderer/dom.js +16 -1
- package/report/renderer/drop-down-menu.js +2 -2
- package/report/renderer/element-screenshot-renderer.js +8 -8
- package/report/renderer/features-util.js +1 -1
- package/report/renderer/open-tab.js +9 -3
- package/report/renderer/performance-category-renderer.js +55 -34
- package/report/renderer/pwa-category-renderer.js +0 -10
- package/report/renderer/report-renderer.js +92 -44
- package/report/renderer/report-ui-features.js +36 -33
- package/report/renderer/swap-locale-feature.js +3 -3
- package/report/renderer/topbar-features.js +53 -48
- package/report/renderer/util.js +66 -46
- package/report/test/clients/bundle-test.js +70 -0
- package/report/test/renderer/category-renderer-test.js +76 -3
- package/report/test/renderer/i18n-test.js +0 -7
- package/report/test/renderer/performance-category-renderer-test.js +51 -14
- package/report/test/renderer/pwa-category-renderer-test.js +6 -6
- package/report/test/renderer/report-renderer-axe-test.js +11 -13
- package/report/test/renderer/report-renderer-test.js +52 -22
- package/report/test/renderer/report-ui-features-test.js +20 -10
- package/report/test/renderer/text-encoding-test.js +1 -1
- package/report/test/renderer/util-test.js +35 -31
- package/report/test-assets/faux-psi-template.html +3 -11
- package/report/test-assets/faux-psi.js +26 -22
- package/report/types/html-renderer.d.ts +2 -0
- package/report/types/report-renderer.d.ts +28 -0
- package/shared/localization/format.js +64 -30
- package/shared/localization/locales/ar-XB.json +72 -75
- package/shared/localization/locales/ar.json +72 -75
- package/shared/localization/locales/bg.json +72 -75
- package/shared/localization/locales/ca.json +72 -75
- package/shared/localization/locales/cs.json +89 -92
- package/shared/localization/locales/da.json +72 -75
- package/shared/localization/locales/de.json +89 -92
- package/shared/localization/locales/el.json +72 -75
- package/shared/localization/locales/en-GB.json +72 -75
- package/shared/localization/locales/en-US.json +78 -75
- package/shared/localization/locales/en-XA.json +72 -75
- package/shared/localization/locales/en-XL.json +78 -75
- package/shared/localization/locales/es-419.json +90 -93
- package/shared/localization/locales/es.json +90 -93
- package/shared/localization/locales/fi.json +72 -75
- package/shared/localization/locales/fil.json +72 -75
- package/shared/localization/locales/fr.json +89 -92
- package/shared/localization/locales/he.json +73 -76
- package/shared/localization/locales/hi.json +72 -75
- package/shared/localization/locales/hr.json +72 -75
- package/shared/localization/locales/hu.json +89 -92
- package/shared/localization/locales/id.json +89 -92
- package/shared/localization/locales/it.json +89 -92
- package/shared/localization/locales/ja.json +89 -92
- package/shared/localization/locales/ko.json +89 -92
- package/shared/localization/locales/lt.json +89 -92
- package/shared/localization/locales/lv.json +95 -98
- package/shared/localization/locales/nl.json +89 -92
- package/shared/localization/locales/no.json +72 -75
- package/shared/localization/locales/pl.json +72 -75
- package/shared/localization/locales/pt-PT.json +72 -75
- package/shared/localization/locales/pt.json +89 -92
- package/shared/localization/locales/ro.json +90 -93
- package/shared/localization/locales/ru.json +89 -92
- package/shared/localization/locales/sk.json +89 -92
- package/shared/localization/locales/sl.json +89 -92
- package/shared/localization/locales/sr-Latn.json +89 -92
- package/shared/localization/locales/sr.json +89 -92
- package/shared/localization/locales/sv.json +72 -75
- package/shared/localization/locales/ta.json +89 -92
- package/shared/localization/locales/te.json +89 -92
- package/shared/localization/locales/th.json +89 -92
- package/shared/localization/locales/tr.json +89 -92
- package/shared/localization/locales/uk.json +92 -95
- package/shared/localization/locales/vi.json +89 -92
- package/shared/localization/locales/zh-HK.json +89 -92
- package/shared/localization/locales/zh-TW.json +89 -92
- package/shared/localization/locales/zh.json +89 -92
- package/shared/localization/locales.js +6 -0
- package/shared/test/localization/format-test.js +45 -9
- package/shared/test/localization/swap-locale-test.js +0 -12
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +19 -11
- package/third-party/chromium-synchronization/installability-errors-test.js +3 -2
- package/third-party/download-content-shell/download-content-shell.js +2 -2
- package/third-party/download-content-shell/utils.js +0 -24
- package/third-party/snyk/snapshot.json +4 -1
- package/tsconfig-all.json +2 -2
- package/tsconfig.json +0 -1
- package/types/artifacts.d.ts +7 -7
- package/types/enquirer.d.ts +3 -1
- package/types/lhr/audit-details.d.ts +6 -5
- package/types/lhr/flow.d.ts +3 -2
- package/types/lhr/lhr.d.ts +1 -1
- package/types/node.d.ts +5 -5
- package/types/rollup-plugin-postprocess.d.ts +10 -0
- package/flow-report/src/wrappers/report-renderer.tsx +0 -46
- package/lighthouse-core/audits/dobetterweb/appcache-manifest.js +0 -67
- package/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js +0 -96
- package/lighthouse-core/audits/redirects-http.js +0 -59
- package/lighthouse-core/gather/gatherers/dobetterweb/appcache.js +0 -34
- package/lighthouse-core/gather/gatherers/http-redirect.js +0 -46
- package/lighthouse-core/lib/i18n/locales/en-US.ctc.json +0 -6699
- package/lighthouse-core/lib/i18n/locales/en-XL.ctc.json +0 -6672
- package/report/clients/psi.js +0 -158
- package/report/test/clients/psi-test.js +0 -143
- package/shared/localization/locales/en-US.ctc.json +0 -6877
- package/shared/localization/locales/en-XL.ctc.json +0 -6852
package/types/artifacts.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ export interface Artifacts extends BaseArtifacts, GathererArtifacts {}
|
|
|
25
25
|
|
|
26
26
|
export type FRArtifacts = StrictOmit<Artifacts,
|
|
27
27
|
| 'Fonts'
|
|
28
|
-
| 'HTTPRedirect'
|
|
29
28
|
| 'Manifest'
|
|
30
29
|
| 'MixedContent'
|
|
31
30
|
| keyof FRBaseArtifacts
|
|
@@ -123,8 +122,6 @@ export interface GathererArtifacts extends PublicGathererArtifacts,LegacyBaseArt
|
|
|
123
122
|
Accessibility: Artifacts.Accessibility;
|
|
124
123
|
/** Array of all anchors on the page. */
|
|
125
124
|
AnchorElements: Artifacts.AnchorElement[];
|
|
126
|
-
/** The value of the page's <html> manifest attribute, or null if not defined */
|
|
127
|
-
AppCacheManifest: string | null;
|
|
128
125
|
/** Array of all URLs cached in CacheStorage. */
|
|
129
126
|
CacheContents: string[];
|
|
130
127
|
/** CSS coverage information for styles used by page's final state. */
|
|
@@ -148,8 +145,6 @@ export interface GathererArtifacts extends PublicGathererArtifacts,LegacyBaseArt
|
|
|
148
145
|
FullPageScreenshot: Artifacts.FullPageScreenshot | null;
|
|
149
146
|
/** Information about event listeners registered on the global object. */
|
|
150
147
|
GlobalListeners: Array<Artifacts.GlobalListener>;
|
|
151
|
-
/** Whether the page ended up on an HTTPS page after attempting to load the HTTP version. */
|
|
152
|
-
HTTPRedirect: {value: boolean};
|
|
153
148
|
/** The issues surfaced in the devtools Issues panel */
|
|
154
149
|
InspectorIssues: Artifacts.InspectorIssues;
|
|
155
150
|
/** JS coverage information for code used during page load. Keyed by network URL. */
|
|
@@ -211,6 +206,7 @@ declare module Artifacts {
|
|
|
211
206
|
target: Array<string>;
|
|
212
207
|
failureSummary?: string;
|
|
213
208
|
node: NodeDetails;
|
|
209
|
+
relatedNodes: NodeDetails[];
|
|
214
210
|
}>;
|
|
215
211
|
error?: RuleExecutionError;
|
|
216
212
|
}
|
|
@@ -491,8 +487,6 @@ declare module Artifacts {
|
|
|
491
487
|
isPicture: boolean;
|
|
492
488
|
/** Flags whether this element was contained within a ShadowRoot */
|
|
493
489
|
isInShadowDOM: boolean;
|
|
494
|
-
/** The MIME type of the underlying image file. */
|
|
495
|
-
mimeType?: string;
|
|
496
490
|
/** Details for node in DOM for the image element */
|
|
497
491
|
node: NodeDetails;
|
|
498
492
|
/** The loading attribute of the image. */
|
|
@@ -564,6 +558,7 @@ declare module Artifacts {
|
|
|
564
558
|
blockedByResponse: LH.Crdp.Audits.BlockedByResponseIssueDetails[];
|
|
565
559
|
heavyAds: LH.Crdp.Audits.HeavyAdIssueDetails[];
|
|
566
560
|
contentSecurityPolicy: LH.Crdp.Audits.ContentSecurityPolicyIssueDetails[];
|
|
561
|
+
deprecations: LH.Crdp.Audits.DeprecationIssueDetails[];
|
|
567
562
|
}
|
|
568
563
|
|
|
569
564
|
// Computed artifact types below.
|
|
@@ -875,6 +870,11 @@ declare module Artifacts {
|
|
|
875
870
|
}
|
|
876
871
|
|
|
877
872
|
type ConsoleMessage = ConsoleAPICall | ConsoleException | ConsoleProtocolLog;
|
|
873
|
+
|
|
874
|
+
interface ImageElementRecord extends ImageElement {
|
|
875
|
+
/** The MIME type of the underlying image file. */
|
|
876
|
+
mimeType?: string;
|
|
877
|
+
}
|
|
878
878
|
}
|
|
879
879
|
|
|
880
880
|
export interface Trace {
|
package/types/enquirer.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
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
5
|
*/
|
|
6
6
|
|
|
7
|
+
import {EventEmitter} from 'events';
|
|
8
|
+
|
|
7
9
|
declare module 'enquirer' {
|
|
8
10
|
interface ConfirmOption {
|
|
9
11
|
name: string | (() => string);
|
|
@@ -12,7 +14,7 @@ declare module 'enquirer' {
|
|
|
12
14
|
actions?: {'ctrl': {[key: string]: string}}
|
|
13
15
|
}
|
|
14
16
|
|
|
15
|
-
class Confirm extends
|
|
17
|
+
class Confirm extends EventEmitter {
|
|
16
18
|
constructor(option: ConfirmOption);
|
|
17
19
|
run: () => Promise<boolean>;
|
|
18
20
|
close: () => Promise<void>
|
|
@@ -176,11 +176,11 @@ declare module Details {
|
|
|
176
176
|
|
|
177
177
|
interface OpportunityColumnHeading {
|
|
178
178
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
* The name of the property within items being described.
|
|
180
|
+
* If null, subItemsHeading must be defined, and the first table row in this column for
|
|
181
|
+
* every item will be empty.
|
|
182
|
+
* See legacy-javascript for an example.
|
|
183
|
+
*/
|
|
184
184
|
key: string|null;
|
|
185
185
|
/** Readable text label of the field. */
|
|
186
186
|
label: IcuMessage | string;
|
|
@@ -263,6 +263,7 @@ declare module Details {
|
|
|
263
263
|
urlProvider: 'network' | 'comment';
|
|
264
264
|
/** Zero-indexed. */
|
|
265
265
|
line: number;
|
|
266
|
+
/** Zero-indexed. */
|
|
266
267
|
column: number;
|
|
267
268
|
/** The original file location from the source map. */
|
|
268
269
|
original?: {
|
package/types/lhr/flow.d.ts
CHANGED
package/types/lhr/lhr.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ declare module Result {
|
|
|
60
60
|
/** The benchmark index number that indicates rough device class. */
|
|
61
61
|
benchmarkIndex: number;
|
|
62
62
|
/** The version of libraries with which these results were generated. Ex: axe-core. */
|
|
63
|
-
credits
|
|
63
|
+
credits?: Record<string, string|undefined>,
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
interface Timing {
|
package/types/node.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
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
5
|
*/
|
|
6
6
|
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
isLightrider?: boolean;
|
|
11
|
-
}
|
|
7
|
+
declare global {
|
|
8
|
+
var isDevtools: boolean | undefined;
|
|
9
|
+
var isLightrider: boolean | undefined;
|
|
12
10
|
}
|
|
11
|
+
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2021 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 '@stadtlandnetz/rollup-plugin-postprocess' {
|
|
8
|
+
function postprocess(args: Array<[RegExp, string]>): void;
|
|
9
|
+
export = postprocess;
|
|
10
|
+
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2021 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
|
-
import {createContext, FunctionComponent} from 'preact';
|
|
8
|
-
import {useContext, useMemo} from 'preact/hooks';
|
|
9
|
-
|
|
10
|
-
import {CategoryRenderer} from '../../../report/renderer/category-renderer';
|
|
11
|
-
import {DetailsRenderer} from '../../../report/renderer/details-renderer';
|
|
12
|
-
import {DOM} from '../../../report/renderer/dom';
|
|
13
|
-
import {ReportRenderer} from '../../../report/renderer/report-renderer';
|
|
14
|
-
|
|
15
|
-
interface ReportRendererGlobals {
|
|
16
|
-
dom: DOM,
|
|
17
|
-
detailsRenderer: DetailsRenderer,
|
|
18
|
-
categoryRenderer: CategoryRenderer,
|
|
19
|
-
reportRenderer: ReportRenderer,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const ReportRendererContext = createContext<ReportRendererGlobals|undefined>(undefined);
|
|
23
|
-
|
|
24
|
-
export function useReportRenderer() {
|
|
25
|
-
const globals = useContext(ReportRendererContext);
|
|
26
|
-
if (!globals) throw Error('Globals not defined');
|
|
27
|
-
return globals;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const ReportRendererProvider: FunctionComponent = ({children}) => {
|
|
31
|
-
const globals = useMemo(() => {
|
|
32
|
-
const dom = new DOM(document);
|
|
33
|
-
const detailsRenderer = new DetailsRenderer(dom);
|
|
34
|
-
const categoryRenderer = new CategoryRenderer(dom, detailsRenderer);
|
|
35
|
-
const reportRenderer = new ReportRenderer(dom);
|
|
36
|
-
return {
|
|
37
|
-
dom,
|
|
38
|
-
detailsRenderer,
|
|
39
|
-
categoryRenderer,
|
|
40
|
-
reportRenderer,
|
|
41
|
-
};
|
|
42
|
-
}, []);
|
|
43
|
-
return (
|
|
44
|
-
<ReportRendererContext.Provider value={globals}>{children}</ReportRendererContext.Provider>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2016 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
|
-
/**
|
|
8
|
-
* @fileoverview Audit a page to ensure it is not using the Application Cache API.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
const Audit = require('../audit.js');
|
|
14
|
-
const i18n = require('../../lib/i18n/i18n.js');
|
|
15
|
-
|
|
16
|
-
const UIStrings = {
|
|
17
|
-
/** Title of a Lighthouse audit that provides detail on the use of the Application Cache API. This descriptive title is shown to users when they do not use the Application Cache API. */
|
|
18
|
-
title: 'Avoids Application Cache',
|
|
19
|
-
/** Title of a Lighthouse audit that provides detail on the use of the Application Cache API. This descriptive title is shown to users when they do use the Application Cache API, which is considered bad practice. */
|
|
20
|
-
failureTitle: 'Uses Application Cache',
|
|
21
|
-
/** Description of a Lighthouse audit that tells the user why they should not use the Application Cache API. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
|
|
22
|
-
description: 'Application Cache is deprecated. ' +
|
|
23
|
-
'[Learn more](https://web.dev/appcache-manifest/).',
|
|
24
|
-
/**
|
|
25
|
-
* @description Label for the audit identifying uses of the Application Cache.
|
|
26
|
-
* @example {clock.appcache} AppCacheManifest
|
|
27
|
-
*/
|
|
28
|
-
displayValue: 'Found "{AppCacheManifest}"',
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
32
|
-
|
|
33
|
-
class AppCacheManifestAttr extends Audit {
|
|
34
|
-
/**
|
|
35
|
-
* @return {LH.Audit.Meta}
|
|
36
|
-
*/
|
|
37
|
-
static get meta() {
|
|
38
|
-
return {
|
|
39
|
-
id: 'appcache-manifest',
|
|
40
|
-
title: str_(UIStrings.title),
|
|
41
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
42
|
-
description: str_(UIStrings.description),
|
|
43
|
-
requiredArtifacts: ['AppCacheManifest'],
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @param {LH.Artifacts} artifacts
|
|
49
|
-
* @return {LH.Audit.Product}
|
|
50
|
-
*/
|
|
51
|
-
static audit(artifacts) {
|
|
52
|
-
// Fails if an AppCacheManifest was found.
|
|
53
|
-
if (artifacts.AppCacheManifest !== null) {
|
|
54
|
-
return {
|
|
55
|
-
score: 0,
|
|
56
|
-
displayValue: str_(UIStrings.displayValue, {AppCacheManifest: artifacts.AppCacheManifest}),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
score: 1,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
module.exports = AppCacheManifestAttr;
|
|
67
|
-
module.exports.UIStrings = UIStrings;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2016 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
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
const URL = require('../../lib/url-shim.js');
|
|
9
|
-
const Audit = require('../audit.js');
|
|
10
|
-
const i18n = require('../../lib/i18n/i18n.js');
|
|
11
|
-
|
|
12
|
-
const UIStrings = {
|
|
13
|
-
/** Title of a Lighthouse audit that provides detail on the cross-origin links that the web page contains, and whether the links can be considered safe. This descriptive title is shown to users when all links are safe. */
|
|
14
|
-
title: 'Links to cross-origin destinations are safe',
|
|
15
|
-
/** Title of a Lighthouse audit that provides detail on the cross-origin links that the web page contains, and whether the links can be considered safe. This descriptive title is shown to users when not all links can be considered safe. */
|
|
16
|
-
failureTitle: 'Links to cross-origin destinations are unsafe',
|
|
17
|
-
/** Description of a Lighthouse audit that tells the user why and how they should secure cross-origin links. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
|
|
18
|
-
description: 'Add `rel="noopener"` or `rel="noreferrer"` to any external links to improve ' +
|
|
19
|
-
'performance and prevent security vulnerabilities. ' +
|
|
20
|
-
'[Learn more](https://web.dev/external-anchors-use-rel-noopener/).',
|
|
21
|
-
/**
|
|
22
|
-
* @description Warning that some links' destinations cannot be determined and therefore the audit cannot evaluate the link's safety.
|
|
23
|
-
* @example {<a target="_blank">} anchorHTML
|
|
24
|
-
*/
|
|
25
|
-
warning: 'Unable to determine the destination for anchor ({anchorHTML}). ' +
|
|
26
|
-
'If not used as a hyperlink, consider removing target=_blank.',
|
|
27
|
-
/** Label for a column in a data table; entries will be the HTML elements that failed the audit. Anchors are DOM elements that are links. */
|
|
28
|
-
columnFailingAnchors: 'Failing Anchors',
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
32
|
-
|
|
33
|
-
class ExternalAnchorsUseRelNoopenerAudit extends Audit {
|
|
34
|
-
/**
|
|
35
|
-
* @return {LH.Audit.Meta}
|
|
36
|
-
*/
|
|
37
|
-
static get meta() {
|
|
38
|
-
return {
|
|
39
|
-
id: 'external-anchors-use-rel-noopener',
|
|
40
|
-
title: str_(UIStrings.title),
|
|
41
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
42
|
-
description: str_(UIStrings.description),
|
|
43
|
-
requiredArtifacts: ['URL', 'AnchorElements'],
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @param {LH.Artifacts} artifacts
|
|
49
|
-
* @return {LH.Audit.Product}
|
|
50
|
-
*/
|
|
51
|
-
static audit(artifacts) {
|
|
52
|
-
/** @type {LH.IcuMessage[]} */
|
|
53
|
-
const warnings = [];
|
|
54
|
-
const pageHost = new URL(artifacts.URL.finalUrl).host;
|
|
55
|
-
const failingAnchors = artifacts.AnchorElements
|
|
56
|
-
.filter(anchor => anchor.target === '_blank' && !anchor.rel.includes('noopener') &&
|
|
57
|
-
!anchor.rel.includes('noreferrer'))
|
|
58
|
-
// Filter usages to exclude anchors that are same origin
|
|
59
|
-
.filter(anchor => {
|
|
60
|
-
try {
|
|
61
|
-
return new URL(anchor.href).host !== pageHost;
|
|
62
|
-
} catch (err) {
|
|
63
|
-
warnings.push(str_(UIStrings.warning, {anchorHTML: anchor.node.snippet}));
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
.filter(anchor => {
|
|
68
|
-
return !anchor.href || anchor.href.toLowerCase().startsWith('http');
|
|
69
|
-
})
|
|
70
|
-
.map(anchor => {
|
|
71
|
-
return {
|
|
72
|
-
node: Audit.makeNodeItem(anchor.node),
|
|
73
|
-
href: anchor.href || 'Unknown',
|
|
74
|
-
target: anchor.target || '',
|
|
75
|
-
rel: anchor.rel || '',
|
|
76
|
-
outerHTML: anchor.node.snippet || '',
|
|
77
|
-
};
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
/** @type {LH.Audit.Details.Table['headings']} */
|
|
81
|
-
const headings = [
|
|
82
|
-
{key: 'node', itemType: 'node', text: str_(UIStrings.columnFailingAnchors)},
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
const details = Audit.makeTableDetails(headings, failingAnchors);
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
score: Number(failingAnchors.length === 0),
|
|
89
|
-
details,
|
|
90
|
-
warnings,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
module.exports = ExternalAnchorsUseRelNoopenerAudit;
|
|
96
|
-
module.exports.UIStrings = UIStrings;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2016 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
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
const Audit = require('./audit.js');
|
|
9
|
-
const i18n = require('../lib/i18n/i18n.js');
|
|
10
|
-
const URL = require('../lib/url-shim.js');
|
|
11
|
-
|
|
12
|
-
const UIStrings = {
|
|
13
|
-
/** Title of a Lighthouse audit that provides detail on HTTP to HTTPS redirects. This descriptive title is shown to users when HTTP traffic is redirected to HTTPS. */
|
|
14
|
-
title: 'Redirects HTTP traffic to HTTPS',
|
|
15
|
-
/** Title of a Lighthouse audit that provides detail on HTTP to HTTPS redirects. This descriptive title is shown to users when HTTP traffic is not redirected to HTTPS. */
|
|
16
|
-
failureTitle: 'Does not redirect HTTP traffic to HTTPS',
|
|
17
|
-
/** Description of a Lighthouse audit that tells the user why they should direct HTTP traffic to HTTPS. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
|
|
18
|
-
description: 'If you\'ve already set up HTTPS, make sure that you redirect all HTTP ' +
|
|
19
|
-
'traffic to HTTPS in order to enable secure web features for all your users. [Learn more](https://web.dev/redirects-http/).',
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
|
|
23
|
-
|
|
24
|
-
class RedirectsHTTP extends Audit {
|
|
25
|
-
/**
|
|
26
|
-
* @return {LH.Audit.Meta}
|
|
27
|
-
*/
|
|
28
|
-
static get meta() {
|
|
29
|
-
return {
|
|
30
|
-
id: 'redirects-http',
|
|
31
|
-
title: str_(UIStrings.title),
|
|
32
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
33
|
-
description: str_(UIStrings.description),
|
|
34
|
-
requiredArtifacts: ['HTTPRedirect', 'URL'],
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @param {LH.Artifacts} artifacts
|
|
40
|
-
* @return {LH.Audit.Product}
|
|
41
|
-
*/
|
|
42
|
-
static audit(artifacts) {
|
|
43
|
-
// Redirecting HTTP to HTTPS makes no sense on localhost
|
|
44
|
-
const url = new URL(artifacts.URL.finalUrl);
|
|
45
|
-
if (URL.isLikeLocalhost(url.hostname)) {
|
|
46
|
-
return {
|
|
47
|
-
score: 1,
|
|
48
|
-
notApplicable: true,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
score: Number(artifacts.HTTPRedirect.value),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
module.exports = RedirectsHTTP;
|
|
59
|
-
module.exports.UIStrings = UIStrings;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2016 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
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
const FRGatherer = require('../../../fraggle-rock/gather/base-gatherer.js');
|
|
9
|
-
|
|
10
|
-
/* global document */
|
|
11
|
-
|
|
12
|
-
class AppCacheManifest extends FRGatherer {
|
|
13
|
-
/** @type {LH.Gatherer.GathererMeta} */
|
|
14
|
-
meta = {
|
|
15
|
-
supportedModes: ['snapshot', 'navigation'],
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @param {LH.Gatherer.FRTransitionalContext} passContext
|
|
20
|
-
* @return {Promise<LH.Artifacts['AppCacheManifest']>}
|
|
21
|
-
*/
|
|
22
|
-
getArtifact(passContext) {
|
|
23
|
-
const driver = passContext.driver;
|
|
24
|
-
|
|
25
|
-
return driver.executionContext.evaluate(() => {
|
|
26
|
-
return document.documentElement && document.documentElement.getAttribute('manifest');
|
|
27
|
-
}, {
|
|
28
|
-
args: [],
|
|
29
|
-
useIsolation: true,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
module.exports = AppCacheManifest;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2016 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
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
const Gatherer = require('./gatherer.js');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* This gatherer changes the options.url so that its pass loads the http page.
|
|
12
|
-
* After load it detects if its on a crypographic scheme.
|
|
13
|
-
* TODO: Instead of abusing a loadPage pass for this test, it could likely just do an XHR instead
|
|
14
|
-
*/
|
|
15
|
-
class HTTPRedirect extends Gatherer {
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
this._preRedirectURL = '';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @param {LH.Gatherer.PassContext} passContext
|
|
23
|
-
*/
|
|
24
|
-
beforePass(passContext) {
|
|
25
|
-
this._preRedirectURL = passContext.url;
|
|
26
|
-
passContext.url = this._preRedirectURL.replace(/^https/, 'http');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @param {LH.Gatherer.PassContext} passContext
|
|
31
|
-
* @return {Promise<LH.Artifacts['HTTPRedirect']>}
|
|
32
|
-
*/
|
|
33
|
-
async afterPass(passContext) {
|
|
34
|
-
// Reset the options.
|
|
35
|
-
passContext.url = this._preRedirectURL;
|
|
36
|
-
|
|
37
|
-
const executionContext = passContext.driver.executionContext;
|
|
38
|
-
const expression = `new URL(window.location).protocol === 'https:'`;
|
|
39
|
-
const isHttps = await executionContext.evaluateAsync(expression, {useIsolation: true});
|
|
40
|
-
return {
|
|
41
|
-
value: isHttps,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = HTTPRedirect;
|