lighthouse 9.3.1 → 9.4.0-dev.20220219

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 (57) hide show
  1. package/changelog.md +45 -0
  2. package/dist/report/bundle.esm.js +38 -24
  3. package/dist/report/flow.js +5 -5
  4. package/dist/report/standalone.js +9 -9
  5. package/flow-report/src/topbar.tsx +1 -1
  6. package/flow-report/src/wrappers/report.tsx +2 -1
  7. package/flow-report/test/topbar-test.tsx +1 -1
  8. package/lighthouse-cli/bin.js +1 -4
  9. package/lighthouse-cli/run.js +1 -1
  10. package/lighthouse-cli/test/smokehouse/core-tests.js +4 -5
  11. package/lighthouse-cli/test/smokehouse/readme.md +4 -0
  12. package/lighthouse-cli/test/smokehouse/report-assert.js +36 -0
  13. package/lighthouse-core/audits/autocomplete.js +34 -37
  14. package/lighthouse-core/audits/byte-efficiency/uses-long-cache-ttl.js +1 -0
  15. package/lighthouse-core/audits/seo/hreflang.js +2 -17
  16. package/lighthouse-core/config/default-config.js +2 -2
  17. package/lighthouse-core/fraggle-rock/config/default-config.js +3 -3
  18. package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +50 -31
  19. package/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +4 -5
  20. package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +4 -5
  21. package/lighthouse-core/fraggle-rock/user-flow.js +8 -6
  22. package/lighthouse-core/gather/driver/navigation.js +29 -10
  23. package/lighthouse-core/gather/driver/network-monitor.js +8 -6
  24. package/lighthouse-core/gather/driver/prepare.js +13 -7
  25. package/lighthouse-core/gather/driver/wait-for-condition.js +11 -4
  26. package/lighthouse-core/gather/gather-runner.js +1 -1
  27. package/lighthouse-core/gather/gatherers/full-page-screenshot.js +35 -9
  28. package/lighthouse-core/gather/gatherers/inputs.js +113 -0
  29. package/lighthouse-core/index.js +3 -3
  30. package/lighthouse-core/lib/page-functions.js +11 -1
  31. package/lighthouse-core/lib/sentry.js +39 -24
  32. package/lighthouse-core/runner.js +79 -52
  33. package/lighthouse-core/util-commonjs.js +4 -0
  34. package/package.json +2 -3
  35. package/readme.md +1 -1
  36. package/report/assets/templates.html +2 -5
  37. package/report/renderer/components.js +3 -3
  38. package/report/renderer/dom.js +1 -3
  39. package/report/renderer/report-ui-features.js +25 -17
  40. package/report/renderer/topbar-features.js +5 -1
  41. package/report/renderer/util.js +4 -0
  42. package/report/test/renderer/__snapshots__/report-renderer-axe-test.js.snap +107 -0
  43. package/report/test/renderer/report-renderer-axe-test.js +38 -17
  44. package/report/test-assets/faux-psi.js +2 -1
  45. package/report/types/report-renderer.d.ts +21 -2
  46. package/shared/localization/locales/en-US.json +7 -1
  47. package/shared/localization/locales/en-XL.json +7 -1
  48. package/third-party/axe/LICENSE +362 -0
  49. package/third-party/axe/README.md +6 -0
  50. package/third-party/axe/valid-langs.js +110 -0
  51. package/third-party/snyk/snapshot.json +1 -0
  52. package/tsconfig.json +1 -0
  53. package/types/artifacts.d.ts +14 -14
  54. package/types/global-lh.d.ts +1 -0
  55. package/types/parse-cache-control/index.d.ts +1 -0
  56. package/types/smokehouse.d.ts +3 -0
  57. package/lighthouse-core/gather/gatherers/form-elements.js +0 -113
@@ -139,8 +139,8 @@ export interface GathererArtifacts extends PublicGathererArtifacts,LegacyBaseArt
139
139
  Fonts: Artifacts.Font[];
140
140
  /** Information on poorly sized font usage and the text affected by it. */
141
141
  FontSize: Artifacts.FontSize;
142
- /** All the form elements in the page and formless inputs. */
143
- FormElements: Artifacts.Form[];
142
+ /** All the input elements, including associated form and label elements. */
143
+ Inputs: {inputs: Artifacts.InputElement[]; forms: Artifacts.FormElement[]; labels: Artifacts.LabelElement[]};
144
144
  /** Screenshot of the entire page (rather than just the above the fold content). */
145
145
  FullPageScreenshot: Artifacts.FullPageScreenshot | null;
146
146
  /** Information about event listeners registered on the global object. */
@@ -787,22 +787,22 @@ declare module Artifacts {
787
787
  observedSpeedIndexTs: number;
788
788
  }
789
789
 
790
- interface Form {
791
- /** If attributes is missing that means this is a formless set of elements. */
792
- attributes?: {
793
- id: string;
794
- name: string;
795
- autocomplete: string;
796
- };
797
- node: NodeDetails | null;
798
- inputs: Array<FormInput>;
799
- labels: Array<FormLabel>;
790
+ interface FormElement {
791
+ id: string;
792
+ name: string;
793
+ autocomplete: string;
794
+ node: NodeDetails;
800
795
  }
801
796
 
802
797
  /** Attributes collected for every input element in the inputs array from the forms interface. */
803
- interface FormInput {
798
+ interface InputElement {
799
+ /** If set, the parent form is the index into the associated FormElement array. Otherwise, the input element has no parent form. */
800
+ parentFormIndex?: number;
801
+ /** Array of indices into associated LabelElement array. */
802
+ labelIndices: number[];
804
803
  id: string;
805
804
  name: string;
805
+ type: string;
806
806
  placeholder?: string;
807
807
  autocomplete: {
808
808
  property: string;
@@ -813,7 +813,7 @@ declare module Artifacts {
813
813
  }
814
814
 
815
815
  /** Attributes collected for every label element in the labels array from the forms interface */
816
- interface FormLabel {
816
+ interface LabelElement {
817
817
  for: string;
818
818
  node: NodeDetails;
819
819
  }
@@ -26,6 +26,7 @@ import Treemap_ from './lhr/treemap';
26
26
  declare global {
27
27
  module LH {
28
28
  export type ArbitraryEqualityMap = ArbitraryEqualityMap_;
29
+ export type NavigationRequestor = string | (() => Promise<void> | void);
29
30
 
30
31
  // artifacts.d.ts
31
32
  export import Artifacts = Artifacts_.Artifacts;
@@ -12,6 +12,7 @@ declare module 'parse-cache-control' {
12
12
  'no-cache'?: boolean;
13
13
  'no-store'?: boolean;
14
14
  'private'?: boolean;
15
+ 'stale-while-revalidate'?: boolean;
15
16
  }
16
17
 
17
18
  function ParseCacheControl(headers?: string): CacheHeaders | null;
@@ -20,6 +20,9 @@ declare global {
20
20
  code?: any;
21
21
  message?: any;
22
22
  };
23
+ timing?: {
24
+ entries?: any
25
+ }
23
26
  }
24
27
 
25
28
  export type ExpectedRunnerResult = {
@@ -1,113 +0,0 @@
1
- /**
2
- * @license Copyright 2020 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
- /* global getNodeDetails */
9
-
10
- const FRGatherer = require('../../fraggle-rock/gather/base-gatherer.js');
11
- const pageFunctions = require('../../lib/page-functions.js');
12
-
13
- /* eslint-env browser, node */
14
-
15
- /**
16
- * @return {LH.Artifacts['FormElements']}
17
- */
18
- /* c8 ignore start */
19
- function collectFormElements() {
20
- // @ts-expect-error - put into scope via stringification
21
- const formChildren = getElementsInDocument('textarea, input, label, select'); // eslint-disable-line no-undef
22
- /** @type {Map<HTMLFormElement|string, LH.Artifacts.Form>} */
23
- const forms = new Map();
24
- /** @type {LH.Artifacts.Form} */
25
- const formlessObj = {
26
- node: null,
27
- inputs: [],
28
- labels: [],
29
- };
30
- for (const child of formChildren) {
31
- const isButton = child instanceof HTMLInputElement &&
32
- (child.type === 'submit' || child.type === 'button');
33
- if (isButton) continue;
34
-
35
- const parentFormElement = child.form;
36
- const hasForm = !!parentFormElement;
37
- if (hasForm && !forms.has(parentFormElement)) {
38
- const newFormObj = {
39
- attributes: {
40
- id: parentFormElement.id,
41
- name: parentFormElement.name,
42
- autocomplete: parentFormElement.autocomplete,
43
- },
44
- // @ts-expect-error - getNodeDetails put into scope via stringification
45
- node: getNodeDetails(parentFormElement),
46
- inputs: [],
47
- labels: [],
48
- };
49
- forms.set(parentFormElement, newFormObj);
50
- }
51
- const formObj = forms.get(parentFormElement) || formlessObj;
52
- if (child instanceof HTMLInputElement || child instanceof HTMLTextAreaElement ||
53
- child instanceof HTMLSelectElement) {
54
- formObj.inputs.push({
55
- id: child.id,
56
- name: child.name,
57
- placeholder: child instanceof HTMLSelectElement ? undefined : child.placeholder,
58
- autocomplete: {
59
- property: child.autocomplete,
60
- // Requires `--enable-features=AutofillShowTypePredictions`.
61
- attribute: child.getAttribute('autocomplete'),
62
- prediction: child.getAttribute('autofill-prediction'),
63
- },
64
- // @ts-expect-error - getNodeDetails put into scope via stringification
65
- node: getNodeDetails(child),
66
- });
67
- }
68
- if (child instanceof HTMLLabelElement) {
69
- formObj.labels.push({
70
- for: child.htmlFor,
71
- // @ts-expect-error - getNodeDetails put into scope via stringification
72
- node: getNodeDetails(child),
73
- });
74
- }
75
- }
76
-
77
- if (formlessObj.inputs.length > 0 || formlessObj.labels.length > 0) {
78
- forms.set('formless', {
79
- node: formlessObj.node,
80
- inputs: formlessObj.inputs,
81
- labels: formlessObj.labels,
82
- });
83
- }
84
- return [...forms.values()];
85
- }
86
- /* c8 ignore stop */
87
-
88
- class FormElements extends FRGatherer {
89
- /** @type {LH.Gatherer.GathererMeta} */
90
- meta = {
91
- supportedModes: ['snapshot', 'navigation'],
92
- };
93
-
94
- /**
95
- * @param {LH.Gatherer.FRTransitionalContext} passContext
96
- * @return {Promise<LH.Artifacts['FormElements']>}
97
- */
98
- async getArtifact(passContext) {
99
- const driver = passContext.driver;
100
-
101
- const formElements = await driver.executionContext.evaluate(collectFormElements, {
102
- args: [],
103
- useIsolation: true,
104
- deps: [
105
- pageFunctions.getElementsInDocumentString,
106
- pageFunctions.getNodeDetailsString,
107
- ],
108
- });
109
- return formElements;
110
- }
111
- }
112
-
113
- module.exports = FormElements;