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.
Files changed (210) hide show
  1. package/changelog.md +121 -0
  2. package/dist/report/bundle.esm.js +6009 -0
  3. package/dist/report/flow.js +98 -25
  4. package/dist/report/standalone.js +41 -35
  5. package/flow-report/.eslintrc.cjs +2 -0
  6. package/flow-report/assets/standalone-flow-template.html +3 -4
  7. package/flow-report/assets/styles.css +108 -31
  8. package/flow-report/src/app.tsx +25 -28
  9. package/flow-report/src/common.tsx +28 -15
  10. package/flow-report/src/header.tsx +12 -13
  11. package/flow-report/src/help-dialog.tsx +3 -4
  12. package/flow-report/src/i18n/i18n.tsx +57 -16
  13. package/flow-report/src/i18n/ui-strings.js +50 -0
  14. package/flow-report/src/icons.tsx +36 -8
  15. package/flow-report/src/sidebar/flow.tsx +3 -3
  16. package/flow-report/src/sidebar/sidebar.tsx +35 -14
  17. package/flow-report/src/summary/category.tsx +97 -24
  18. package/flow-report/src/summary/summary.tsx +21 -14
  19. package/flow-report/src/topbar.tsx +13 -12
  20. package/flow-report/src/util.ts +61 -27
  21. package/flow-report/src/wrappers/category-score.tsx +9 -27
  22. package/flow-report/src/wrappers/markdown.tsx +18 -0
  23. package/flow-report/src/wrappers/report.tsx +26 -37
  24. package/flow-report/standalone-flow.tsx +5 -4
  25. package/flow-report/test/common-test.tsx +32 -17
  26. package/flow-report/test/flow-report-pptr-test.ts +46 -0
  27. package/flow-report/test/header-test.tsx +6 -6
  28. package/flow-report/test/setup/env-setup.ts +11 -5
  29. package/flow-report/test/sidebar/sidebar-test.tsx +43 -1
  30. package/flow-report/test/summary/category-test.tsx +114 -21
  31. package/flow-report/test/summary/summary-test.tsx +4 -7
  32. package/flow-report/test/topbar-test.tsx +15 -14
  33. package/flow-report/test/util-test.tsx +69 -11
  34. package/flow-report/test/wrappers/category-score-test.tsx +84 -0
  35. package/flow-report/test/wrappers/markdown-test.tsx +17 -0
  36. package/flow-report/tsconfig.json +1 -0
  37. package/jest.config.js +4 -2
  38. package/lighthouse-cli/.eslintrc.cjs +2 -0
  39. package/lighthouse-cli/cli-flags.js +1 -1
  40. package/lighthouse-cli/run.js +1 -1
  41. package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +4 -2
  42. package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +1 -1
  43. package/lighthouse-cli/test/smokehouse/smokehouse.js +1 -1
  44. package/lighthouse-core/audits/accessibility/axe-audit.js +7 -1
  45. package/lighthouse-core/audits/audit.js +1 -1
  46. package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +2 -0
  47. package/lighthouse-core/audits/byte-efficiency/modern-image-formats.js +4 -2
  48. package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +11 -10
  49. package/lighthouse-core/audits/byte-efficiency/uses-optimized-images.js +5 -3
  50. package/lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js +2 -1
  51. package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +2 -1
  52. package/lighthouse-core/audits/deprecations.js +33 -11
  53. package/lighthouse-core/audits/dobetterweb/uses-http2.js +27 -11
  54. package/lighthouse-core/audits/errors-in-console.js +0 -2
  55. package/lighthouse-core/audits/image-aspect-ratio.js +5 -5
  56. package/lighthouse-core/audits/image-size-responsive.js +6 -6
  57. package/lighthouse-core/audits/installable-manifest.js +16 -7
  58. package/lighthouse-core/audits/preload-lcp-image.js +7 -5
  59. package/lighthouse-core/audits/script-treemap-data.js +1 -1
  60. package/lighthouse-core/audits/unsized-images.js +2 -3
  61. package/lighthouse-core/computed/image-records.js +4 -3
  62. package/lighthouse-core/computed/metrics/lantern-total-blocking-time.js +3 -4
  63. package/lighthouse-core/computed/metrics/tbt-utils.js +57 -0
  64. package/lighthouse-core/computed/metrics/total-blocking-time.js +3 -53
  65. package/lighthouse-core/computed/resource-summary.js +1 -1
  66. package/lighthouse-core/config/config-helpers.js +21 -10
  67. package/lighthouse-core/config/constants.js +3 -4
  68. package/lighthouse-core/config/default-config.js +61 -71
  69. package/lighthouse-core/fraggle-rock/config/config.js +1 -1
  70. package/lighthouse-core/fraggle-rock/config/default-config.js +4 -5
  71. package/lighthouse-core/fraggle-rock/gather/base-gatherer.js +6 -1
  72. package/lighthouse-core/fraggle-rock/gather/session.js +3 -4
  73. package/lighthouse-core/gather/connections/cri.js +1 -1
  74. package/lighthouse-core/gather/driver/storage.js +0 -1
  75. package/lighthouse-core/gather/driver.js +3 -7
  76. package/lighthouse-core/gather/fetcher.js +4 -7
  77. package/lighthouse-core/gather/gather-runner.js +29 -6
  78. package/lighthouse-core/gather/gatherers/accessibility.js +27 -0
  79. package/lighthouse-core/gather/gatherers/dobetterweb/response-compression.js +1 -0
  80. package/lighthouse-core/gather/gatherers/image-elements.js +0 -3
  81. package/lighthouse-core/gather/gatherers/inspector-issues.js +5 -0
  82. package/lighthouse-core/lib/asset-saver.js +7 -4
  83. package/lighthouse-core/lib/emulation.js +45 -1
  84. package/lighthouse-core/lib/i18n/i18n.js +19 -8
  85. package/lighthouse-core/lib/lh-env.js +2 -0
  86. package/lighthouse-core/lib/page-functions.js +2 -1
  87. package/lighthouse-core/lib/proto-preprocessor.js +14 -2
  88. package/lighthouse-core/lib/statistics.js +26 -39
  89. package/lighthouse-core/lib/tappable-rects.js +8 -15
  90. package/lighthouse-core/lib/url-shim.js +1 -1
  91. package/lighthouse-core/runner.js +1 -1
  92. package/lighthouse-core/util-commonjs.js +65 -46
  93. package/package.json +27 -17
  94. package/readme.md +3 -3
  95. package/report/.eslintrc.cjs +2 -0
  96. package/report/README.md +1 -1
  97. package/report/assets/standalone-template.html +2 -3
  98. package/report/assets/styles.css +362 -256
  99. package/report/assets/templates.html +21 -76
  100. package/report/clients/bundle.js +1 -0
  101. package/report/clients/standalone.js +6 -15
  102. package/report/generator/README.md +1 -1
  103. package/report/renderer/api.js +66 -0
  104. package/report/renderer/category-renderer.js +76 -22
  105. package/report/renderer/components.js +59 -110
  106. package/report/renderer/crc-details-renderer.js +15 -12
  107. package/report/renderer/dom.js +16 -1
  108. package/report/renderer/drop-down-menu.js +2 -2
  109. package/report/renderer/element-screenshot-renderer.js +8 -8
  110. package/report/renderer/features-util.js +1 -1
  111. package/report/renderer/open-tab.js +9 -3
  112. package/report/renderer/performance-category-renderer.js +55 -34
  113. package/report/renderer/pwa-category-renderer.js +0 -10
  114. package/report/renderer/report-renderer.js +92 -44
  115. package/report/renderer/report-ui-features.js +36 -33
  116. package/report/renderer/swap-locale-feature.js +3 -3
  117. package/report/renderer/topbar-features.js +53 -48
  118. package/report/renderer/util.js +66 -46
  119. package/report/test/clients/bundle-test.js +70 -0
  120. package/report/test/renderer/category-renderer-test.js +76 -3
  121. package/report/test/renderer/i18n-test.js +0 -7
  122. package/report/test/renderer/performance-category-renderer-test.js +51 -14
  123. package/report/test/renderer/pwa-category-renderer-test.js +6 -6
  124. package/report/test/renderer/report-renderer-axe-test.js +11 -13
  125. package/report/test/renderer/report-renderer-test.js +52 -22
  126. package/report/test/renderer/report-ui-features-test.js +20 -10
  127. package/report/test/renderer/text-encoding-test.js +1 -1
  128. package/report/test/renderer/util-test.js +35 -31
  129. package/report/test-assets/faux-psi-template.html +3 -11
  130. package/report/test-assets/faux-psi.js +26 -22
  131. package/report/types/html-renderer.d.ts +2 -0
  132. package/report/types/report-renderer.d.ts +28 -0
  133. package/shared/localization/format.js +64 -30
  134. package/shared/localization/locales/ar-XB.json +72 -75
  135. package/shared/localization/locales/ar.json +72 -75
  136. package/shared/localization/locales/bg.json +72 -75
  137. package/shared/localization/locales/ca.json +72 -75
  138. package/shared/localization/locales/cs.json +89 -92
  139. package/shared/localization/locales/da.json +72 -75
  140. package/shared/localization/locales/de.json +89 -92
  141. package/shared/localization/locales/el.json +72 -75
  142. package/shared/localization/locales/en-GB.json +72 -75
  143. package/shared/localization/locales/en-US.json +78 -75
  144. package/shared/localization/locales/en-XA.json +72 -75
  145. package/shared/localization/locales/en-XL.json +78 -75
  146. package/shared/localization/locales/es-419.json +90 -93
  147. package/shared/localization/locales/es.json +90 -93
  148. package/shared/localization/locales/fi.json +72 -75
  149. package/shared/localization/locales/fil.json +72 -75
  150. package/shared/localization/locales/fr.json +89 -92
  151. package/shared/localization/locales/he.json +73 -76
  152. package/shared/localization/locales/hi.json +72 -75
  153. package/shared/localization/locales/hr.json +72 -75
  154. package/shared/localization/locales/hu.json +89 -92
  155. package/shared/localization/locales/id.json +89 -92
  156. package/shared/localization/locales/it.json +89 -92
  157. package/shared/localization/locales/ja.json +89 -92
  158. package/shared/localization/locales/ko.json +89 -92
  159. package/shared/localization/locales/lt.json +89 -92
  160. package/shared/localization/locales/lv.json +95 -98
  161. package/shared/localization/locales/nl.json +89 -92
  162. package/shared/localization/locales/no.json +72 -75
  163. package/shared/localization/locales/pl.json +72 -75
  164. package/shared/localization/locales/pt-PT.json +72 -75
  165. package/shared/localization/locales/pt.json +89 -92
  166. package/shared/localization/locales/ro.json +90 -93
  167. package/shared/localization/locales/ru.json +89 -92
  168. package/shared/localization/locales/sk.json +89 -92
  169. package/shared/localization/locales/sl.json +89 -92
  170. package/shared/localization/locales/sr-Latn.json +89 -92
  171. package/shared/localization/locales/sr.json +89 -92
  172. package/shared/localization/locales/sv.json +72 -75
  173. package/shared/localization/locales/ta.json +89 -92
  174. package/shared/localization/locales/te.json +89 -92
  175. package/shared/localization/locales/th.json +89 -92
  176. package/shared/localization/locales/tr.json +89 -92
  177. package/shared/localization/locales/uk.json +92 -95
  178. package/shared/localization/locales/vi.json +89 -92
  179. package/shared/localization/locales/zh-HK.json +89 -92
  180. package/shared/localization/locales/zh-TW.json +89 -92
  181. package/shared/localization/locales/zh.json +89 -92
  182. package/shared/localization/locales.js +6 -0
  183. package/shared/test/localization/format-test.js +45 -9
  184. package/shared/test/localization/swap-locale-test.js +0 -12
  185. package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +19 -11
  186. package/third-party/chromium-synchronization/installability-errors-test.js +3 -2
  187. package/third-party/download-content-shell/download-content-shell.js +2 -2
  188. package/third-party/download-content-shell/utils.js +0 -24
  189. package/third-party/snyk/snapshot.json +4 -1
  190. package/tsconfig-all.json +2 -2
  191. package/tsconfig.json +0 -1
  192. package/types/artifacts.d.ts +7 -7
  193. package/types/enquirer.d.ts +3 -1
  194. package/types/lhr/audit-details.d.ts +6 -5
  195. package/types/lhr/flow.d.ts +3 -2
  196. package/types/lhr/lhr.d.ts +1 -1
  197. package/types/node.d.ts +5 -5
  198. package/types/rollup-plugin-postprocess.d.ts +10 -0
  199. package/flow-report/src/wrappers/report-renderer.tsx +0 -46
  200. package/lighthouse-core/audits/dobetterweb/appcache-manifest.js +0 -67
  201. package/lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js +0 -96
  202. package/lighthouse-core/audits/redirects-http.js +0 -59
  203. package/lighthouse-core/gather/gatherers/dobetterweb/appcache.js +0 -34
  204. package/lighthouse-core/gather/gatherers/http-redirect.js +0 -46
  205. package/lighthouse-core/lib/i18n/locales/en-US.ctc.json +0 -6699
  206. package/lighthouse-core/lib/i18n/locales/en-XL.ctc.json +0 -6672
  207. package/report/clients/psi.js +0 -158
  208. package/report/test/clients/psi-test.js +0 -143
  209. package/shared/localization/locales/en-US.ctc.json +0 -6877
  210. package/shared/localization/locales/en-XL.ctc.json +0 -6852
@@ -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 {
@@ -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 NodeJS.EventEmitter {
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
- * 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
- */
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?: {
@@ -12,9 +12,10 @@ declare module FlowResult {
12
12
  name: string;
13
13
  }
14
14
 
15
- interface LhrRef {
16
- value: Result;
15
+ interface HashState {
16
+ currentLhr: Result;
17
17
  index: number;
18
+ anchor: string|null;
18
19
  }
19
20
  }
20
21
 
@@ -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: Record<string, string>,
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 module NodeJS {
8
- interface Global {
9
- isDevtools?: boolean;
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;