lighthouse 9.5.0-dev.20230123 → 9.5.0-dev.20230125

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 (167) hide show
  1. package/.codecov.yml +0 -5
  2. package/core/audits/accessibility/accesskeys.js +1 -1
  3. package/core/audits/accessibility/aria-allowed-attr.js +1 -1
  4. package/core/audits/accessibility/aria-command-name.js +1 -1
  5. package/core/audits/accessibility/aria-hidden-body.js +1 -1
  6. package/core/audits/accessibility/aria-hidden-focus.js +1 -1
  7. package/core/audits/accessibility/aria-input-field-name.js +1 -1
  8. package/core/audits/accessibility/aria-meter-name.js +1 -1
  9. package/core/audits/accessibility/aria-progressbar-name.js +1 -1
  10. package/core/audits/accessibility/aria-required-attr.js +1 -1
  11. package/core/audits/accessibility/aria-required-children.js +1 -1
  12. package/core/audits/accessibility/aria-required-parent.js +1 -1
  13. package/core/audits/accessibility/aria-roles.js +1 -1
  14. package/core/audits/accessibility/aria-toggle-field-name.js +1 -1
  15. package/core/audits/accessibility/aria-tooltip-name.js +1 -1
  16. package/core/audits/accessibility/aria-treeitem-name.js +1 -1
  17. package/core/audits/accessibility/aria-valid-attr-value.js +1 -1
  18. package/core/audits/accessibility/aria-valid-attr.js +1 -1
  19. package/core/audits/accessibility/button-name.js +1 -1
  20. package/core/audits/accessibility/bypass.js +1 -1
  21. package/core/audits/accessibility/color-contrast.js +1 -1
  22. package/core/audits/accessibility/definition-list.js +1 -1
  23. package/core/audits/accessibility/dlitem.js +1 -1
  24. package/core/audits/accessibility/document-title.js +1 -1
  25. package/core/audits/accessibility/duplicate-id-active.js +1 -1
  26. package/core/audits/accessibility/duplicate-id-aria.js +1 -1
  27. package/core/audits/accessibility/form-field-multiple-labels.js +1 -1
  28. package/core/audits/accessibility/frame-title.js +1 -1
  29. package/core/audits/accessibility/heading-order.js +1 -1
  30. package/core/audits/accessibility/html-has-lang.js +1 -1
  31. package/core/audits/accessibility/html-lang-valid.js +1 -1
  32. package/core/audits/accessibility/image-alt.js +1 -1
  33. package/core/audits/accessibility/input-image-alt.js +1 -1
  34. package/core/audits/accessibility/label.js +1 -1
  35. package/core/audits/accessibility/link-name.js +1 -1
  36. package/core/audits/accessibility/list.js +1 -1
  37. package/core/audits/accessibility/listitem.js +1 -1
  38. package/core/audits/accessibility/meta-refresh.js +1 -1
  39. package/core/audits/accessibility/meta-viewport.js +1 -1
  40. package/core/audits/accessibility/object-alt.js +1 -1
  41. package/core/audits/accessibility/tabindex.js +1 -1
  42. package/core/audits/accessibility/td-headers-attr.js +1 -1
  43. package/core/audits/accessibility/th-has-data-cells.js +1 -1
  44. package/core/audits/accessibility/valid-lang.js +1 -1
  45. package/core/audits/accessibility/video-caption.js +1 -1
  46. package/core/audits/audit.js +1 -1
  47. package/core/audits/byte-efficiency/legacy-javascript.d.ts +1 -0
  48. package/core/audits/byte-efficiency/legacy-javascript.js +7 -3
  49. package/core/audits/dobetterweb/uses-http2.d.ts +5 -2
  50. package/core/audits/dobetterweb/uses-http2.js +12 -7
  51. package/core/audits/network-requests.js +7 -6
  52. package/core/audits/third-party-facades.d.ts +3 -2
  53. package/core/audits/third-party-facades.js +12 -9
  54. package/core/audits/third-party-summary.d.ts +7 -6
  55. package/core/audits/third-party-summary.js +16 -14
  56. package/core/audits/valid-source-maps.d.ts +5 -3
  57. package/core/audits/valid-source-maps.js +11 -9
  58. package/core/computed/entity-classification.d.ts +29 -0
  59. package/core/computed/entity-classification.js +102 -0
  60. package/core/computed/metrics/responsiveness.js +5 -2
  61. package/core/computed/page-dependency-graph.js +1 -1
  62. package/core/computed/resource-summary.d.ts +4 -2
  63. package/core/computed/resource-summary.js +8 -5
  64. package/core/gather/gatherers/accessibility.js +3 -1
  65. package/core/lib/network-request.d.ts +2 -0
  66. package/core/lib/network-request.js +3 -0
  67. package/core/lib/stack-packs.js +4 -0
  68. package/core/lib/tracehouse/trace-processor.d.ts +14 -5
  69. package/core/lib/tracehouse/trace-processor.js +85 -30
  70. package/core/lib/traces/metric-trace-events.js +1 -1
  71. package/core/lib/url-utils.js +1 -1
  72. package/core/runner.d.ts +10 -0
  73. package/core/runner.js +48 -0
  74. package/dist/report/bundle.esm.js +724 -687
  75. package/dist/report/flow.js +25 -15
  76. package/dist/report/standalone.js +25 -15
  77. package/flow-report/src/common.tsx +1 -1
  78. package/flow-report/src/i18n/i18n.tsx +17 -16
  79. package/flow-report/src/sidebar/sidebar.tsx +2 -2
  80. package/flow-report/src/summary/category.tsx +6 -6
  81. package/flow-report/src/summary/summary.tsx +2 -2
  82. package/package.json +7 -8
  83. package/report/renderer/category-renderer.js +19 -17
  84. package/report/renderer/crc-details-renderer.js +6 -6
  85. package/report/renderer/details-renderer.js +7 -6
  86. package/report/renderer/dom.js +1 -1
  87. package/report/renderer/element-screenshot-renderer.js +3 -3
  88. package/report/renderer/performance-category-renderer.js +17 -15
  89. package/report/renderer/pwa-category-renderer.js +5 -4
  90. package/report/renderer/report-globals.d.ts +21 -0
  91. package/report/renderer/report-globals.js +49 -0
  92. package/report/renderer/report-renderer.js +22 -20
  93. package/report/renderer/report-ui-features.js +9 -8
  94. package/report/renderer/report-utils.d.ts +116 -0
  95. package/report/renderer/{util.js → report-utils.js} +81 -429
  96. package/report/renderer/snippet-renderer.js +3 -2
  97. package/report/test/renderer/category-renderer-test.js +9 -4
  98. package/report/test/renderer/crc-details-renderer-test.js +7 -3
  99. package/report/test/renderer/details-renderer-test.js +7 -3
  100. package/report/test/renderer/dom-test.js +7 -3
  101. package/report/test/renderer/element-screenshot-renderer-test.js +8 -4
  102. package/report/test/renderer/performance-category-renderer-test.js +14 -9
  103. package/report/test/renderer/pwa-category-renderer-test.js +10 -5
  104. package/report/test/renderer/report-renderer-test.js +2 -2
  105. package/report/test/renderer/report-ui-features-test.js +3 -3
  106. package/report/test/renderer/{util-test.js → report-utils-test.js} +36 -234
  107. package/report/test/renderer/snippet-renderer-test.js +7 -3
  108. package/shared/localization/format.js +5 -2
  109. package/shared/localization/locales/ar-XB.json +50 -50
  110. package/shared/localization/locales/ar.json +50 -50
  111. package/shared/localization/locales/bg.json +50 -50
  112. package/shared/localization/locales/ca.json +50 -50
  113. package/shared/localization/locales/cs.json +50 -50
  114. package/shared/localization/locales/da.json +50 -50
  115. package/shared/localization/locales/de.json +50 -50
  116. package/shared/localization/locales/el.json +50 -50
  117. package/shared/localization/locales/en-GB.json +50 -50
  118. package/shared/localization/locales/en-US.json +128 -98
  119. package/shared/localization/locales/en-XA.json +50 -50
  120. package/shared/localization/locales/en-XL.json +128 -98
  121. package/shared/localization/locales/es-419.json +50 -50
  122. package/shared/localization/locales/es.json +50 -50
  123. package/shared/localization/locales/fi.json +50 -50
  124. package/shared/localization/locales/fil.json +50 -50
  125. package/shared/localization/locales/fr.json +50 -50
  126. package/shared/localization/locales/he.json +50 -50
  127. package/shared/localization/locales/hi.json +50 -50
  128. package/shared/localization/locales/hr.json +50 -50
  129. package/shared/localization/locales/hu.json +50 -50
  130. package/shared/localization/locales/id.json +50 -50
  131. package/shared/localization/locales/it.json +50 -50
  132. package/shared/localization/locales/ja.json +50 -50
  133. package/shared/localization/locales/ko.json +50 -50
  134. package/shared/localization/locales/lt.json +50 -50
  135. package/shared/localization/locales/lv.json +50 -50
  136. package/shared/localization/locales/nl.json +50 -50
  137. package/shared/localization/locales/no.json +50 -50
  138. package/shared/localization/locales/pl.json +50 -50
  139. package/shared/localization/locales/pt-PT.json +50 -50
  140. package/shared/localization/locales/pt.json +50 -50
  141. package/shared/localization/locales/ro.json +50 -50
  142. package/shared/localization/locales/ru.json +50 -50
  143. package/shared/localization/locales/sk.json +50 -50
  144. package/shared/localization/locales/sl.json +50 -50
  145. package/shared/localization/locales/sr-Latn.json +50 -50
  146. package/shared/localization/locales/sr.json +50 -50
  147. package/shared/localization/locales/sv.json +50 -50
  148. package/shared/localization/locales/ta.json +50 -50
  149. package/shared/localization/locales/te.json +50 -50
  150. package/shared/localization/locales/th.json +50 -50
  151. package/shared/localization/locales/tr.json +50 -50
  152. package/shared/localization/locales/uk.json +50 -50
  153. package/shared/localization/locales/vi.json +50 -50
  154. package/shared/localization/locales/zh-HK.json +50 -50
  155. package/shared/localization/locales/zh-TW.json +50 -50
  156. package/shared/localization/locales/zh.json +50 -50
  157. package/shared/test/util-test.js +214 -0
  158. package/shared/util.d.ts +122 -0
  159. package/shared/util.js +332 -0
  160. package/tsconfig.json +0 -2
  161. package/types/artifacts.d.ts +21 -2
  162. package/types/lhr/lhr.d.ts +33 -0
  163. package/core/lib/minify-trace.d.ts +0 -6
  164. package/core/lib/minify-trace.js +0 -172
  165. package/core/util.cjs +0 -845
  166. package/core/util.d.cts +0 -342
  167. package/report/renderer/util.d.ts +0 -342
@@ -17,6 +17,7 @@ import type { TaskNode as _TaskNode } from '../core/lib/tracehouse/main-thread-t
17
17
  import AuditDetails from './lhr/audit-details.js'
18
18
  import Config from './config.js';
19
19
  import Gatherer from './gatherer.js';
20
+ import {IEntity} from 'third-party-web';
20
21
  import {IcuMessage} from './lhr/i18n.js';
21
22
  import LHResult from './lhr/lhr.js'
22
23
  import Protocol from './protocol.js';
@@ -720,12 +721,16 @@ declare module Artifacts {
720
721
  frameEvents: Array<TraceEvent>;
721
722
  /** The subset of trace events from the main frame and any child frames, sorted by timestamp. */
722
723
  frameTreeEvents: Array<TraceEvent>;
723
- /** IDs for the trace's main frame, process, and thread. */
724
- mainFrameIds: {pid: number, tid: number, frameId: string};
724
+ /** IDs for the trace's main frame, and process. The startingPid is the initial process id, however cross-origin navigations may incur changes to the pid while the frame ID remains identical. */
725
+ mainFrameInfo: {startingPid: number, frameId: string};
725
726
  /** The list of frames committed in the trace. */
726
727
  frames: Array<{id: string, url: string}>;
727
728
  /** The trace event marking the time at which the run should consider to have begun. Typically the same as the navigationStart but might differ due to SPA navigations, client-side redirects, etc. In the FR timespan case, this event is injected by Lighthouse itself. */
728
729
  timeOriginEvt: TraceEvent;
730
+ /** All received trace events subsetted to important categories. */
731
+ _keyEvents: Array<TraceEvent>;
732
+ /** Map where keys are process IDs and their values are thread IDs */
733
+ _rendererPidToTid: Map<number, number>;
729
734
  }
730
735
 
731
736
  interface ProcessedNavigation {
@@ -925,6 +930,19 @@ declare module Artifacts {
925
930
  /** The MIME type of the underlying image file. */
926
931
  mimeType?: string;
927
932
  }
933
+
934
+ interface Entity extends IEntity {
935
+ isUnrecognized?: boolean;
936
+ }
937
+
938
+ interface EntityClassification {
939
+ urlsByEntity: Map<Entity, Set<string>>;
940
+ entityByUrl: Map<string, Entity>;
941
+ firstParty?: Entity;
942
+
943
+ // Convenience methods.
944
+ isFirstParty: (url: string) => boolean;
945
+ }
928
946
  }
929
947
 
930
948
  export interface Trace {
@@ -959,6 +977,7 @@ export interface TraceEvent {
959
977
  };
960
978
  data?: {
961
979
  frame?: string;
980
+ processId?: number;
962
981
  isLoadingMainFrame?: boolean;
963
982
  documentLoaderURL?: string;
964
983
  frames?: {
@@ -56,6 +56,8 @@ interface Result {
56
56
  };
57
57
  /** An array containing the result of all stack packs. */
58
58
  stackPacks?: Result.StackPack[];
59
+ /** All the origins encountered during this Lighthouse run, and information about what web property (aka "entity") they belong to. Won't be present for snapshot mode. */
60
+ entities?: Result.Entities;
59
61
  /** Screenshot taken of the full page, with node rects referencing audit results. If there was an error with collection, this is null. If disabled via the disableFullPageScreenshot setting, this is undefined. */
60
62
  fullPageScreenshot?: Result.FullPageScreenshot | null;
61
63
  }
@@ -151,6 +153,37 @@ declare module Result {
151
153
  nodes: Record<string, AuditDetails.Rect>;
152
154
  }
153
155
 
156
+ /**
157
+ * Entity classification for the run, for resolving URLs/items to entities in report.
158
+ * The two lookup tables (LUT) below provide space-optimized, O(1) index lookup into entities.list.
159
+ */
160
+ interface Entities {
161
+ /** All entities (1st and 3rd party) discovered during the run */
162
+ list: Array<LhrEntity>;
163
+ /** Name of the first-party entity */
164
+ firstParty?: string;
165
+ /** Entity-name to entity index lookup table */
166
+ entityIndexByName: Record<string, number>;
167
+ /** URL origin to entity index lookup table */
168
+ entityIndexByOrigin: Record<string, number>;
169
+ }
170
+
171
+ /**
172
+ * An entity that's either recognized by third-party-web or made up by Lighthouse.
173
+ */
174
+ interface LhrEntity {
175
+ /** Name of the entity. Maps to third-party-web unique name for recognized entities and a root domain name for the unrecognized. */
176
+ name: string;
177
+ /** Homepage URL for a recognized entity, if available in third-party-web. */
178
+ homepage?: string;
179
+ /** Category name that the entity belongs to, if available. */
180
+ category?: string;
181
+ /** Is this entity the first party? */
182
+ isFirstParty?: boolean;
183
+ /** Is this entity recognized by third-party-web? */
184
+ isUnrecognized?: boolean;
185
+ }
186
+
154
187
  /**
155
188
  * Info about an `LH.IcuMessage` value that was localized to a string when
156
189
  * included in the LHR. Value is either a
@@ -1,6 +0,0 @@
1
- /**
2
- * @param {LH.Trace} inputTrace
3
- * @return {LH.Trace}
4
- */
5
- export function minifyTrace(inputTrace: LH.Trace): LH.Trace;
6
- //# sourceMappingURL=minify-trace.d.ts.map
@@ -1,172 +0,0 @@
1
- /**
2
- * @license Copyright 2019 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
- /* eslint-disable no-console */
8
-
9
- /**
10
- * @fileoverview Minifies a trace by removing unnecessary events, throttling screenshots, etc.
11
- * See the following files for necessary events:
12
- * - core/computed/page-dependency-graph.js
13
- * - core/lib/dependency-graph/cpu-node.js
14
- * - core/lib/tracehouse/trace-processor.js
15
- */
16
-
17
- import {TraceProcessor} from './tracehouse/trace-processor.js';
18
-
19
- const toplevelTaskNames = new Set([
20
- 'RunTask', // m71+
21
- 'ThreadControllerImpl::RunTask', // m69-70
22
- 'ThreadControllerImpl::DoWork', // m66-68
23
- 'TaskQueueManager::ProcessTaskFromWorkQueue', // m65 and below
24
- ]);
25
-
26
- const traceCategoriesToAlwaysKeep = new Set([
27
- // Labels the threads correctly in DevTools Performance panel
28
- '__metadata',
29
- ]);
30
-
31
- const traceEventsToAlwaysKeep = new Set([
32
- 'Screenshot',
33
- 'TracingStartedInBrowser',
34
- 'TracingStartedInPage',
35
- 'navigationStart',
36
- 'ParseAuthorStyleSheet',
37
- 'ParseHTML',
38
- 'PlatformResourceSendRequest',
39
- 'ResourceSendRequest',
40
- 'ResourceReceiveResponse',
41
- 'ResourceFinish',
42
- 'ResourceReceivedData',
43
- 'EventDispatch',
44
- 'LayoutShift',
45
- 'FrameCommittedInBrowser',
46
- 'EventTiming',
47
- 'Responsiveness.Renderer.UserInteraction',
48
- // Not currently used by Lighthouse but might be used in the future for cross-frame LCP
49
- 'NavStartToLargestContentfulPaint::Invalidate::AllFrames::UKM',
50
- 'NavStartToLargestContentfulPaint::Candidate::AllFrames::UKM',
51
- // Needed for CPU profiler task attribution
52
- 'Profile',
53
- 'ProfileChunk',
54
- ]);
55
-
56
- const traceEventsToKeepInToplevelTask = new Set([
57
- // Needed for CPU node timing simulations
58
- 'Layout',
59
- 'RunMicrotasks',
60
- // All of these are needed to create graph relationships
61
- 'TimerInstall',
62
- 'TimerFire',
63
- 'InvalidateLayout',
64
- 'ScheduleStyleRecalculation',
65
- 'EvaluateScript',
66
- 'XHRReadyStateChange',
67
- 'FunctionCall',
68
- 'v8.compile',
69
- 'ParseAuthorStyleSheet',
70
- 'ResourceSendRequest',
71
- ]);
72
-
73
- const traceEventsToKeepInProcess = new Set([
74
- ...toplevelTaskNames,
75
- ...traceEventsToKeepInToplevelTask,
76
-
77
- // See the DevTools marker events
78
- // https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/timeline_model/TimelineModel.js?q=-f:out%20f:TimelineModel%20%22MarkLoad:%20%27%22&ss=chromium
79
- 'firstPaint',
80
- 'firstContentfulPaint',
81
- 'firstMeaningfulPaint',
82
- 'firstMeaningfulPaintCandidate',
83
- 'loadEventEnd',
84
- 'MarkLoad',
85
- 'domContentLoadedEventEnd',
86
- 'MarkDOMContent',
87
- 'largestContentfulPaint::Invalidate',
88
- 'largestContentfulPaint::Candidate',
89
- 'Animation',
90
- ]);
91
-
92
- /**
93
- * @param {LH.TraceEvent[]} events
94
- */
95
- function filterOutUnnecessaryTasksByNameAndDuration(events) {
96
- const {pid} = TraceProcessor.findMainFrameIds(events);
97
-
98
- return events.filter(evt => {
99
- if (toplevelTaskNames.has(evt.name) && evt.dur < 1000) return false;
100
- if (evt.pid === pid && traceEventsToKeepInProcess.has(evt.name)) return true;
101
- if (traceCategoriesToAlwaysKeep.has(evt.cat)) return true;
102
- return traceEventsToAlwaysKeep.has(evt.name);
103
- });
104
- }
105
-
106
- /**
107
- * Filters out tasks that are not within a toplevel task.
108
- * @param {LH.TraceEvent[]} events
109
- */
110
- function filterOutOrphanedTasks(events) {
111
- const toplevelRanges = events
112
- .filter(evt => toplevelTaskNames.has(evt.name))
113
- .map(evt => [evt.ts, evt.ts + evt.dur]);
114
-
115
- /** @param {LH.TraceEvent} e */
116
- const isInToplevelTask = e => toplevelRanges.some(([start, end]) => e.ts >= start && e.ts <= end);
117
-
118
- return events.filter((evt, index) => {
119
- if (!traceEventsToKeepInToplevelTask.has(evt.name)) return true;
120
- if (!isInToplevelTask(evt)) return false;
121
-
122
- if (evt.ph === 'B') {
123
- const endEvent = events.slice(index).find(e => e.name === evt.name && e.ph === 'E');
124
- return endEvent && isInToplevelTask(endEvent);
125
- } else {
126
- return true;
127
- }
128
- });
129
- }
130
-
131
- /**
132
- * Throttles screenshot events in the trace to 2fps.
133
- * @param {LH.TraceEvent[]} events
134
- */
135
- function filterOutExcessiveScreenshots(events) {
136
- const screenshotTimestamps = events.filter(evt => evt.name === 'Screenshot').map(evt => evt.ts);
137
-
138
- let lastScreenshotTs = -Infinity;
139
- return events.filter(evt => {
140
- if (evt.name !== 'Screenshot') return true;
141
- const timeSinceLastScreenshot = evt.ts - lastScreenshotTs;
142
- const nextScreenshotTs = screenshotTimestamps.find(ts => ts > evt.ts);
143
- const timeUntilNextScreenshot = nextScreenshotTs ? nextScreenshotTs - evt.ts : Infinity;
144
- const threshold = 500 * 1000; // Throttle to ~2fps
145
- // Keep the frame if it's been more than 500ms since the last frame we kept or the next frame won't happen for at least 500ms
146
- const shouldKeep = timeUntilNextScreenshot > threshold || timeSinceLastScreenshot > threshold;
147
- if (shouldKeep) lastScreenshotTs = evt.ts;
148
- return shouldKeep;
149
- });
150
- }
151
-
152
- /**
153
- * @param {LH.TraceEvent[]} events
154
- */
155
- function filterTraceEvents(events) {
156
- // Filter out event names we don't care about and tasks <1ms
157
- let filtered = filterOutUnnecessaryTasksByNameAndDuration(events);
158
- // Filter out events not inside a toplevel task
159
- filtered = filterOutOrphanedTasks(filtered);
160
- // Filter down the screenshots to key moments + 2fps animations
161
- return filterOutExcessiveScreenshots(filtered);
162
- }
163
-
164
- /**
165
- * @param {LH.Trace} inputTrace
166
- * @return {LH.Trace}
167
- */
168
- function minifyTrace(inputTrace) {
169
- return {traceEvents: filterTraceEvents(inputTrace.traceEvents)};
170
- }
171
-
172
- export {minifyTrace};