devtools-tracing 1.0.0

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 (397) hide show
  1. package/generate.ts +643 -0
  2. package/index.ts +16 -0
  3. package/lib/front_end/core/common/App.ts +7 -0
  4. package/lib/front_end/core/common/AppProvider.ts +32 -0
  5. package/lib/front_end/core/common/Base64.ts +47 -0
  6. package/lib/front_end/core/common/CharacterIdMap.ts +30 -0
  7. package/lib/front_end/core/common/Color.ts +2506 -0
  8. package/lib/front_end/core/common/ColorConverter.ts +402 -0
  9. package/lib/front_end/core/common/ColorUtils.ts +252 -0
  10. package/lib/front_end/core/common/Console.ts +114 -0
  11. package/lib/front_end/core/common/Debouncer.ts +15 -0
  12. package/lib/front_end/core/common/EventTarget.ts +52 -0
  13. package/lib/front_end/core/common/Gzip.ts +74 -0
  14. package/lib/front_end/core/common/JavaScriptMetaData.ts +29 -0
  15. package/lib/front_end/core/common/Lazy.ts +31 -0
  16. package/lib/front_end/core/common/Linkifier.ts +55 -0
  17. package/lib/front_end/core/common/MapWithDefault.ts +26 -0
  18. package/lib/front_end/core/common/Mutex.ts +55 -0
  19. package/lib/front_end/core/common/Object.ts +145 -0
  20. package/lib/front_end/core/common/ParsedURL.ts +554 -0
  21. package/lib/front_end/core/common/Progress.ts +180 -0
  22. package/lib/front_end/core/common/QueryParamHandler.ts +7 -0
  23. package/lib/front_end/core/common/ResolverBase.ts +85 -0
  24. package/lib/front_end/core/common/ResourceType.ts +588 -0
  25. package/lib/front_end/core/common/ReturnToPanel.ts +17 -0
  26. package/lib/front_end/core/common/Revealer.ts +192 -0
  27. package/lib/front_end/core/common/Runnable.ts +41 -0
  28. package/lib/front_end/core/common/SegmentedRange.ts +87 -0
  29. package/lib/front_end/core/common/SettingRegistration.ts +339 -0
  30. package/lib/front_end/core/common/Settings.ts +1497 -0
  31. package/lib/front_end/core/common/SimpleHistoryManager.ts +124 -0
  32. package/lib/front_end/core/common/StringOutputStream.ts +26 -0
  33. package/lib/front_end/core/common/TextDictionary.ts +48 -0
  34. package/lib/front_end/core/common/Throttler.ts +99 -0
  35. package/lib/front_end/core/common/Trie.ts +152 -0
  36. package/lib/front_end/core/common/Worker.ts +60 -0
  37. package/lib/front_end/core/common/common.ts +81 -0
  38. package/lib/front_end/core/host/AidaClient.ts +733 -0
  39. package/lib/front_end/core/host/GdpClient.ts +316 -0
  40. package/lib/front_end/core/host/InspectorFrontendHost.ts +648 -0
  41. package/lib/front_end/core/host/InspectorFrontendHostAPI.ts +551 -0
  42. package/lib/front_end/core/host/Platform.ts +76 -0
  43. package/lib/front_end/core/host/ResourceLoader.ts +282 -0
  44. package/lib/front_end/core/host/UserMetrics.ts +1230 -0
  45. package/lib/front_end/core/host/host.ts +23 -0
  46. package/lib/front_end/core/i18n/ByteUtilities.ts +82 -0
  47. package/lib/front_end/core/i18n/DevToolsLocale.ts +87 -0
  48. package/lib/front_end/core/i18n/NumberFormatter.ts +82 -0
  49. package/lib/front_end/core/i18n/i18n.ts +17 -0
  50. package/lib/front_end/core/i18n/i18nImpl.ts +204 -0
  51. package/lib/front_end/core/i18n/i18nTypes.ts +10 -0
  52. package/lib/front_end/core/i18n/locales.js +14 -0
  53. package/lib/front_end/core/i18n/time-utilities.ts +174 -0
  54. package/lib/front_end/core/platform/ArrayUtilities.ts +271 -0
  55. package/lib/front_end/core/platform/Brand.ts +23 -0
  56. package/lib/front_end/core/platform/Constructor.ts +10 -0
  57. package/lib/front_end/core/platform/DOMUtilities.ts +138 -0
  58. package/lib/front_end/core/platform/DateUtilities.ts +15 -0
  59. package/lib/front_end/core/platform/DevToolsPath.ts +53 -0
  60. package/lib/front_end/core/platform/KeyboardUtilities.ts +38 -0
  61. package/lib/front_end/core/platform/MapUtilities.ts +95 -0
  62. package/lib/front_end/core/platform/MimeType.ts +175 -0
  63. package/lib/front_end/core/platform/NumberUtilities.ts +80 -0
  64. package/lib/front_end/core/platform/StringUtilities.ts +588 -0
  65. package/lib/front_end/core/platform/Timing.ts +17 -0
  66. package/lib/front_end/core/platform/TypedArrayUtilities.ts +189 -0
  67. package/lib/front_end/core/platform/TypescriptUtilities.ts +86 -0
  68. package/lib/front_end/core/platform/UIString.ts +39 -0
  69. package/lib/front_end/core/platform/UserVisibleError.ts +28 -0
  70. package/lib/front_end/core/platform/platform.ts +45 -0
  71. package/lib/front_end/core/protocol_client/ConnectionTransport.ts +26 -0
  72. package/lib/front_end/core/protocol_client/InspectorBackend.ts +1050 -0
  73. package/lib/front_end/core/protocol_client/NodeURL.ts +42 -0
  74. package/lib/front_end/core/protocol_client/protocol_client.ts +13 -0
  75. package/lib/front_end/core/root/Runtime.ts +609 -0
  76. package/lib/front_end/core/root/root.ts +6 -0
  77. package/lib/front_end/core/sdk/AccessibilityModel.ts +353 -0
  78. package/lib/front_end/core/sdk/AnimationModel.ts +1041 -0
  79. package/lib/front_end/core/sdk/AutofillModel.ts +184 -0
  80. package/lib/front_end/core/sdk/CPUProfilerModel.ts +148 -0
  81. package/lib/front_end/core/sdk/CPUThrottlingManager.ts +282 -0
  82. package/lib/front_end/core/sdk/CSSContainerQuery.ts +139 -0
  83. package/lib/front_end/core/sdk/CSSFontFace.ts +40 -0
  84. package/lib/front_end/core/sdk/CSSLayer.ts +30 -0
  85. package/lib/front_end/core/sdk/CSSMatchedStyles.ts +1646 -0
  86. package/lib/front_end/core/sdk/CSSMedia.ts +121 -0
  87. package/lib/front_end/core/sdk/CSSMetadata.ts +1647 -0
  88. package/lib/front_end/core/sdk/CSSModel.ts +1128 -0
  89. package/lib/front_end/core/sdk/CSSProperty.ts +384 -0
  90. package/lib/front_end/core/sdk/CSSPropertyParser.ts +681 -0
  91. package/lib/front_end/core/sdk/CSSPropertyParserMatchers.ts +1395 -0
  92. package/lib/front_end/core/sdk/CSSQuery.ts +72 -0
  93. package/lib/front_end/core/sdk/CSSRule.ts +465 -0
  94. package/lib/front_end/core/sdk/CSSScope.ts +30 -0
  95. package/lib/front_end/core/sdk/CSSStartingStyle.ts +29 -0
  96. package/lib/front_end/core/sdk/CSSStyleDeclaration.ts +313 -0
  97. package/lib/front_end/core/sdk/CSSStyleSheetHeader.ts +196 -0
  98. package/lib/front_end/core/sdk/CSSSupports.ts +33 -0
  99. package/lib/front_end/core/sdk/CategorizedBreakpoint.ts +64 -0
  100. package/lib/front_end/core/sdk/ChildTargetManager.ts +314 -0
  101. package/lib/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +62 -0
  102. package/lib/front_end/core/sdk/Connections.ts +293 -0
  103. package/lib/front_end/core/sdk/ConsoleModel.ts +808 -0
  104. package/lib/front_end/core/sdk/ConsoleModelTypes.ts +15 -0
  105. package/lib/front_end/core/sdk/Cookie.ts +319 -0
  106. package/lib/front_end/core/sdk/CookieModel.ts +239 -0
  107. package/lib/front_end/core/sdk/CookieParser.ts +185 -0
  108. package/lib/front_end/core/sdk/DOMDebuggerModel.ts +787 -0
  109. package/lib/front_end/core/sdk/DOMModel.ts +1961 -0
  110. package/lib/front_end/core/sdk/DebuggerModel.ts +1605 -0
  111. package/lib/front_end/core/sdk/EmulationModel.ts +648 -0
  112. package/lib/front_end/core/sdk/EnhancedTracesParser.ts +515 -0
  113. package/lib/front_end/core/sdk/EventBreakpointsModel.ts +183 -0
  114. package/lib/front_end/core/sdk/FrameAssociated.ts +11 -0
  115. package/lib/front_end/core/sdk/FrameManager.ts +259 -0
  116. package/lib/front_end/core/sdk/HeapProfilerModel.ts +225 -0
  117. package/lib/front_end/core/sdk/HttpReasonPhraseStrings.ts +77 -0
  118. package/lib/front_end/core/sdk/IOModel.ts +91 -0
  119. package/lib/front_end/core/sdk/IsolateManager.ts +257 -0
  120. package/lib/front_end/core/sdk/IssuesModel.ts +70 -0
  121. package/lib/front_end/core/sdk/LayerTreeBase.ts +169 -0
  122. package/lib/front_end/core/sdk/LogModel.ts +56 -0
  123. package/lib/front_end/core/sdk/NetworkManager.ts +2823 -0
  124. package/lib/front_end/core/sdk/NetworkRequest.ts +2253 -0
  125. package/lib/front_end/core/sdk/OverlayColorGenerator.ts +52 -0
  126. package/lib/front_end/core/sdk/OverlayModel.ts +1011 -0
  127. package/lib/front_end/core/sdk/OverlayPersistentHighlighter.ts +522 -0
  128. package/lib/front_end/core/sdk/PageLoad.ts +35 -0
  129. package/lib/front_end/core/sdk/PageResourceLoader.ts +435 -0
  130. package/lib/front_end/core/sdk/PaintProfiler.ts +110 -0
  131. package/lib/front_end/core/sdk/PerformanceMetricsModel.ts +84 -0
  132. package/lib/front_end/core/sdk/PreloadingModel.ts +863 -0
  133. package/lib/front_end/core/sdk/RehydratingConnection.ts +386 -0
  134. package/lib/front_end/core/sdk/RehydratingObject.ts +66 -0
  135. package/lib/front_end/core/sdk/RemoteObject.ts +1160 -0
  136. package/lib/front_end/core/sdk/Resource.ts +232 -0
  137. package/lib/front_end/core/sdk/ResourceTreeModel.ts +1160 -0
  138. package/lib/front_end/core/sdk/RuntimeModel.ts +732 -0
  139. package/lib/front_end/core/sdk/SDKModel.ts +65 -0
  140. package/lib/front_end/core/sdk/ScopeTreeCache.ts +45 -0
  141. package/lib/front_end/core/sdk/ScreenCaptureModel.ts +255 -0
  142. package/lib/front_end/core/sdk/Script.ts +534 -0
  143. package/lib/front_end/core/sdk/SecurityOriginManager.ts +76 -0
  144. package/lib/front_end/core/sdk/ServerSentEvents.ts +80 -0
  145. package/lib/front_end/core/sdk/ServerSentEventsProtocol.ts +122 -0
  146. package/lib/front_end/core/sdk/ServerTiming.ts +260 -0
  147. package/lib/front_end/core/sdk/ServiceWorkerCacheModel.ts +377 -0
  148. package/lib/front_end/core/sdk/ServiceWorkerManager.ts +605 -0
  149. package/lib/front_end/core/sdk/SourceMap.ts +867 -0
  150. package/lib/front_end/core/sdk/SourceMapCache.ts +54 -0
  151. package/lib/front_end/core/sdk/SourceMapFunctionRanges.ts +156 -0
  152. package/lib/front_end/core/sdk/SourceMapManager.ts +239 -0
  153. package/lib/front_end/core/sdk/SourceMapScopeChainEntry.ts +189 -0
  154. package/lib/front_end/core/sdk/SourceMapScopesInfo.ts +508 -0
  155. package/lib/front_end/core/sdk/StorageBucketsModel.ts +204 -0
  156. package/lib/front_end/core/sdk/StorageKeyManager.ts +98 -0
  157. package/lib/front_end/core/sdk/Target.ts +332 -0
  158. package/lib/front_end/core/sdk/TargetManager.ts +453 -0
  159. package/lib/front_end/core/sdk/TraceObject.ts +61 -0
  160. package/lib/front_end/core/sdk/WebAuthnModel.ts +104 -0
  161. package/lib/front_end/core/sdk/sdk.ts +174 -0
  162. package/lib/front_end/entrypoints/formatter_worker/FormatterActions.ts +59 -0
  163. package/lib/front_end/generated/InspectorBackendCommands.js +1617 -0
  164. package/lib/front_end/generated/SupportedCSSProperties.js +7512 -0
  165. package/lib/front_end/generated/protocol-proxy-api.d.ts +5022 -0
  166. package/lib/front_end/generated/protocol.ts +22014 -0
  167. package/lib/front_end/models/cpu_profile/CPUProfileDataModel.ts +571 -0
  168. package/lib/front_end/models/cpu_profile/ProfileTreeModel.ts +103 -0
  169. package/lib/front_end/models/cpu_profile/cpu_profile.ts +11 -0
  170. package/lib/front_end/models/formatter/FormatterWorkerPool.ts +219 -0
  171. package/lib/front_end/models/formatter/ScriptFormatter.ts +112 -0
  172. package/lib/front_end/models/formatter/formatter.ts +8 -0
  173. package/lib/front_end/models/text_utils/CodeMirrorUtils.ts +37 -0
  174. package/lib/front_end/models/text_utils/ContentData.ts +199 -0
  175. package/lib/front_end/models/text_utils/ContentProvider.ts +68 -0
  176. package/lib/front_end/models/text_utils/StaticContentProvider.ts +49 -0
  177. package/lib/front_end/models/text_utils/StreamingContentData.ts +108 -0
  178. package/lib/front_end/models/text_utils/Text.ts +90 -0
  179. package/lib/front_end/models/text_utils/TextCursor.ts +44 -0
  180. package/lib/front_end/models/text_utils/TextRange.ts +266 -0
  181. package/lib/front_end/models/text_utils/TextUtils.ts +401 -0
  182. package/lib/front_end/models/text_utils/WasmDisassembly.ts +87 -0
  183. package/lib/front_end/models/text_utils/text_utils.ts +27 -0
  184. package/lib/front_end/models/trace/EntityMapper.ts +141 -0
  185. package/lib/front_end/models/trace/EventsSerializer.ts +101 -0
  186. package/lib/front_end/models/trace/LanternComputationData.ts +438 -0
  187. package/lib/front_end/models/trace/ModelImpl.ts +236 -0
  188. package/lib/front_end/models/trace/Name.ts +136 -0
  189. package/lib/front_end/models/trace/Processor.ts +652 -0
  190. package/lib/front_end/models/trace/Styles.ts +1138 -0
  191. package/lib/front_end/models/trace/extras/FilmStrip.ts +78 -0
  192. package/lib/front_end/models/trace/extras/MainThreadActivity.ts +86 -0
  193. package/lib/front_end/models/trace/extras/ScriptDuplication.ts +236 -0
  194. package/lib/front_end/models/trace/extras/StackTraceForEvent.ts +203 -0
  195. package/lib/front_end/models/trace/extras/ThirdParties.ts +164 -0
  196. package/lib/front_end/models/trace/extras/TraceFilter.ts +62 -0
  197. package/lib/front_end/models/trace/extras/TraceTree.ts +701 -0
  198. package/lib/front_end/models/trace/extras/extras.ts +11 -0
  199. package/lib/front_end/models/trace/handlers/AnimationFramesHandler.ts +128 -0
  200. package/lib/front_end/models/trace/handlers/AnimationHandler.ts +36 -0
  201. package/lib/front_end/models/trace/handlers/AsyncJSCallsHandler.ts +239 -0
  202. package/lib/front_end/models/trace/handlers/AuctionWorkletsHandler.ts +183 -0
  203. package/lib/front_end/models/trace/handlers/DOMStatsHandler.ts +31 -0
  204. package/lib/front_end/models/trace/handlers/ExtensionTraceDataHandler.ts +306 -0
  205. package/lib/front_end/models/trace/handlers/FlowsHandler.ts +175 -0
  206. package/lib/front_end/models/trace/handlers/FramesHandler.ts +571 -0
  207. package/lib/front_end/models/trace/handlers/GPUHandler.ts +50 -0
  208. package/lib/front_end/models/trace/handlers/ImagePaintingHandler.ts +183 -0
  209. package/lib/front_end/models/trace/handlers/InitiatorsHandler.ts +193 -0
  210. package/lib/front_end/models/trace/handlers/InvalidationsHandler.ts +168 -0
  211. package/lib/front_end/models/trace/handlers/LargestImagePaintHandler.ts +109 -0
  212. package/lib/front_end/models/trace/handlers/LargestTextPaintHandler.ts +35 -0
  213. package/lib/front_end/models/trace/handlers/LayerTreeHandler.ts +123 -0
  214. package/lib/front_end/models/trace/handlers/LayoutShiftsHandler.ts +573 -0
  215. package/lib/front_end/models/trace/handlers/MemoryHandler.ts +31 -0
  216. package/lib/front_end/models/trace/handlers/MetaHandler.ts +525 -0
  217. package/lib/front_end/models/trace/handlers/ModelHandlers.ts +34 -0
  218. package/lib/front_end/models/trace/handlers/NetworkRequestsHandler.ts +672 -0
  219. package/lib/front_end/models/trace/handlers/PageFramesHandler.ts +52 -0
  220. package/lib/front_end/models/trace/handlers/PageLoadMetricsHandler.ts +460 -0
  221. package/lib/front_end/models/trace/handlers/RendererHandler.ts +428 -0
  222. package/lib/front_end/models/trace/handlers/SamplesHandler.ts +271 -0
  223. package/lib/front_end/models/trace/handlers/ScreenshotsHandler.ts +122 -0
  224. package/lib/front_end/models/trace/handlers/ScriptsHandler.ts +336 -0
  225. package/lib/front_end/models/trace/handlers/SelectorStatsHandler.ts +110 -0
  226. package/lib/front_end/models/trace/handlers/Threads.ts +139 -0
  227. package/lib/front_end/models/trace/handlers/UserInteractionsHandler.ts +400 -0
  228. package/lib/front_end/models/trace/handlers/UserTimingsHandler.ts +233 -0
  229. package/lib/front_end/models/trace/handlers/WarningsHandler.ts +162 -0
  230. package/lib/front_end/models/trace/handlers/WorkersHandler.ts +45 -0
  231. package/lib/front_end/models/trace/handlers/handlers.ts +8 -0
  232. package/lib/front_end/models/trace/handlers/helpers.ts +196 -0
  233. package/lib/front_end/models/trace/handlers/types.ts +75 -0
  234. package/lib/front_end/models/trace/helpers/Extensions.ts +54 -0
  235. package/lib/front_end/models/trace/helpers/Network.ts +129 -0
  236. package/lib/front_end/models/trace/helpers/SamplesIntegrator.ts +544 -0
  237. package/lib/front_end/models/trace/helpers/SyntheticEvents.ts +87 -0
  238. package/lib/front_end/models/trace/helpers/Timing.ts +248 -0
  239. package/lib/front_end/models/trace/helpers/Trace.ts +928 -0
  240. package/lib/front_end/models/trace/helpers/TreeHelpers.ts +320 -0
  241. package/lib/front_end/models/trace/helpers/helpers.ts +11 -0
  242. package/lib/front_end/models/trace/insights/CLSCulprits.ts +668 -0
  243. package/lib/front_end/models/trace/insights/Cache.ts +269 -0
  244. package/lib/front_end/models/trace/insights/Common.ts +453 -0
  245. package/lib/front_end/models/trace/insights/DOMSize.ts +223 -0
  246. package/lib/front_end/models/trace/insights/DocumentLatency.ts +319 -0
  247. package/lib/front_end/models/trace/insights/DuplicatedJavaScript.ts +126 -0
  248. package/lib/front_end/models/trace/insights/FontDisplay.ts +119 -0
  249. package/lib/front_end/models/trace/insights/ForcedReflow.ts +220 -0
  250. package/lib/front_end/models/trace/insights/INPBreakdown.ts +171 -0
  251. package/lib/front_end/models/trace/insights/ImageDelivery.ts +348 -0
  252. package/lib/front_end/models/trace/insights/LCPBreakdown.ts +268 -0
  253. package/lib/front_end/models/trace/insights/LCPDiscovery.ts +237 -0
  254. package/lib/front_end/models/trace/insights/LegacyJavaScript.ts +138 -0
  255. package/lib/front_end/models/trace/insights/Models.ts +22 -0
  256. package/lib/front_end/models/trace/insights/ModernHTTP.ts +257 -0
  257. package/lib/front_end/models/trace/insights/NetworkDependencyTree.ts +726 -0
  258. package/lib/front_end/models/trace/insights/RenderBlocking.ts +257 -0
  259. package/lib/front_end/models/trace/insights/SlowCSSSelector.ts +175 -0
  260. package/lib/front_end/models/trace/insights/Statistics.ts +101 -0
  261. package/lib/front_end/models/trace/insights/ThirdParties.ts +130 -0
  262. package/lib/front_end/models/trace/insights/Viewport.ts +138 -0
  263. package/lib/front_end/models/trace/insights/insights.ts +10 -0
  264. package/lib/front_end/models/trace/insights/types.ts +157 -0
  265. package/lib/front_end/models/trace/lantern/core/LanternError.ts +7 -0
  266. package/lib/front_end/models/trace/lantern/core/NetworkAnalyzer.ts +619 -0
  267. package/lib/front_end/models/trace/lantern/core/core.ts +6 -0
  268. package/lib/front_end/models/trace/lantern/graph/BaseNode.ts +345 -0
  269. package/lib/front_end/models/trace/lantern/graph/CPUNode.ts +80 -0
  270. package/lib/front_end/models/trace/lantern/graph/NetworkNode.ts +101 -0
  271. package/lib/front_end/models/trace/lantern/graph/PageDependencyGraph.ts +636 -0
  272. package/lib/front_end/models/trace/lantern/graph/graph.ts +8 -0
  273. package/lib/front_end/models/trace/lantern/lantern.ts +17 -0
  274. package/lib/front_end/models/trace/lantern/metrics/FirstContentfulPaint.ts +187 -0
  275. package/lib/front_end/models/trace/lantern/metrics/Interactive.ts +88 -0
  276. package/lib/front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts +92 -0
  277. package/lib/front_end/models/trace/lantern/metrics/MaxPotentialFID.ts +72 -0
  278. package/lib/front_end/models/trace/lantern/metrics/Metric.ts +126 -0
  279. package/lib/front_end/models/trace/lantern/metrics/SpeedIndex.ts +126 -0
  280. package/lib/front_end/models/trace/lantern/metrics/TBTUtils.ts +82 -0
  281. package/lib/front_end/models/trace/lantern/metrics/TotalBlockingTime.ts +112 -0
  282. package/lib/front_end/models/trace/lantern/metrics/metrics.ts +12 -0
  283. package/lib/front_end/models/trace/lantern/simulation/ConnectionPool.ts +150 -0
  284. package/lib/front_end/models/trace/lantern/simulation/Constants.ts +46 -0
  285. package/lib/front_end/models/trace/lantern/simulation/DNSCache.ts +61 -0
  286. package/lib/front_end/models/trace/lantern/simulation/SimulationTimingMap.ts +196 -0
  287. package/lib/front_end/models/trace/lantern/simulation/Simulator.ts +556 -0
  288. package/lib/front_end/models/trace/lantern/simulation/TCPConnection.ts +192 -0
  289. package/lib/front_end/models/trace/lantern/simulation/simulation.ts +10 -0
  290. package/lib/front_end/models/trace/lantern/types/Lantern.ts +220 -0
  291. package/lib/front_end/models/trace/lantern/types/types.ts +5 -0
  292. package/lib/front_end/models/trace/trace.ts +33 -0
  293. package/lib/front_end/models/trace/types/Configuration.ts +110 -0
  294. package/lib/front_end/models/trace/types/Extensions.ts +136 -0
  295. package/lib/front_end/models/trace/types/File.ts +281 -0
  296. package/lib/front_end/models/trace/types/Overlays.ts +138 -0
  297. package/lib/front_end/models/trace/types/Timing.ts +30 -0
  298. package/lib/front_end/models/trace/types/TraceEvents.ts +3277 -0
  299. package/lib/front_end/models/trace/types/types.ts +10 -0
  300. package/lib/front_end/third_party/i18n/LICENSE +202 -0
  301. package/lib/front_end/third_party/i18n/README.chromium +15 -0
  302. package/lib/front_end/third_party/i18n/i18n-impl.ts +61 -0
  303. package/lib/front_end/third_party/i18n/i18n.ts +11 -0
  304. package/lib/front_end/third_party/i18n/localized-string-set.ts +129 -0
  305. package/lib/front_end/third_party/intl-messageformat/LICENSE +33 -0
  306. package/lib/front_end/third_party/intl-messageformat/README.chromium +24 -0
  307. package/lib/front_end/third_party/intl-messageformat/intl-messageformat-tsconfig.json +16 -0
  308. package/lib/front_end/third_party/intl-messageformat/intl-messageformat.ts +6 -0
  309. package/lib/front_end/third_party/intl-messageformat/package/LICENSE.md +33 -0
  310. package/lib/front_end/third_party/intl-messageformat/package/README.md +3 -0
  311. package/lib/front_end/third_party/intl-messageformat/package/index.d.ts +6 -0
  312. package/lib/front_end/third_party/intl-messageformat/package/index.d.ts.map +1 -0
  313. package/lib/front_end/third_party/intl-messageformat/package/index.js +13 -0
  314. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.d.ts +5 -0
  315. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.esm.js +1710 -0
  316. package/lib/front_end/third_party/intl-messageformat/package/intl-messageformat.iife.js +1815 -0
  317. package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts +6 -0
  318. package/lib/front_end/third_party/intl-messageformat/package/lib/index.d.ts.map +1 -0
  319. package/lib/front_end/third_party/intl-messageformat/package/lib/index.js +10 -0
  320. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts +34 -0
  321. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.d.ts.map +1 -0
  322. package/lib/front_end/third_party/intl-messageformat/package/lib/src/core.js +229 -0
  323. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts +28 -0
  324. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.d.ts.map +1 -0
  325. package/lib/front_end/third_party/intl-messageformat/package/lib/src/error.js +48 -0
  326. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts +34 -0
  327. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.d.ts.map +1 -0
  328. package/lib/front_end/third_party/intl-messageformat/package/lib/src/formatters.js +179 -0
  329. package/lib/front_end/third_party/intl-messageformat/package/package.json +42 -0
  330. package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts +34 -0
  331. package/lib/front_end/third_party/intl-messageformat/package/src/core.d.ts.map +1 -0
  332. package/lib/front_end/third_party/intl-messageformat/package/src/core.js +230 -0
  333. package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts +28 -0
  334. package/lib/front_end/third_party/intl-messageformat/package/src/error.d.ts.map +1 -0
  335. package/lib/front_end/third_party/intl-messageformat/package/src/error.js +51 -0
  336. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts +34 -0
  337. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.d.ts.map +1 -0
  338. package/lib/front_end/third_party/intl-messageformat/package/src/formatters.js +182 -0
  339. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/error.d.ts +79 -0
  340. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/index.d.ts +15 -0
  341. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/parser.d.ts +153 -0
  342. package/lib/front_end/third_party/intl-messageformat/package/src/icu-messageformat-parser/types.d.ts +139 -0
  343. package/lib/front_end/third_party/legacy-javascript/LICENSE +202 -0
  344. package/lib/front_end/third_party/legacy-javascript/README.chromium +13 -0
  345. package/lib/front_end/third_party/legacy-javascript/legacy-javascript-tsconfig.json +8 -0
  346. package/lib/front_end/third_party/legacy-javascript/legacy-javascript.ts +3 -0
  347. package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.d.ts +18 -0
  348. package/lib/front_end/third_party/legacy-javascript/lib/legacy-javascript.js +943 -0
  349. package/lib/front_end/third_party/legacy-javascript/package.json +8 -0
  350. package/lib/front_end/third_party/legacy-javascript/rebuild.sh +9 -0
  351. package/lib/front_end/third_party/third-party-web/LICENSE +20 -0
  352. package/lib/front_end/third_party/third-party-web/README.chromium +13 -0
  353. package/lib/front_end/third_party/third-party-web/lib/nostats-subset.d.ts +2 -0
  354. package/lib/front_end/third_party/third-party-web/lib/nostats-subset.js +149 -0
  355. package/lib/front_end/third_party/third-party-web/package/LICENSE +20 -0
  356. package/lib/front_end/third_party/third-party-web/package/README.md +929 -0
  357. package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive-nostats.json +1 -0
  358. package/lib/front_end/third_party/third-party-web/package/dist/entities-httparchive.json +1 -0
  359. package/lib/front_end/third_party/third-party-web/package/dist/entities-nostats.json +1 -0
  360. package/lib/front_end/third_party/third-party-web/package/dist/entities.json +1 -0
  361. package/lib/front_end/third_party/third-party-web/package/facades.md +46 -0
  362. package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.d.ts +1 -0
  363. package/lib/front_end/third_party/third-party-web/package/httparchive-nostats-subset.js +1 -0
  364. package/lib/front_end/third_party/third-party-web/package/httparchive-subset.d.ts +1 -0
  365. package/lib/front_end/third_party/third-party-web/package/httparchive-subset.js +1 -0
  366. package/lib/front_end/third_party/third-party-web/package/lib/__snapshots__/index.test.js.snap +1006 -0
  367. package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.js +139 -0
  368. package/lib/front_end/third_party/third-party-web/package/lib/create-entity-finder-api.test.js +44 -0
  369. package/lib/front_end/third_party/third-party-web/package/lib/entities.test.js +27 -0
  370. package/lib/front_end/third_party/third-party-web/package/lib/index.d.ts +34 -0
  371. package/lib/front_end/third_party/third-party-web/package/lib/index.js +3 -0
  372. package/lib/front_end/third_party/third-party-web/package/lib/index.test.js +246 -0
  373. package/lib/front_end/third_party/third-party-web/package/lib/markdown/faqs.partial.md +36 -0
  374. package/lib/front_end/third_party/third-party-web/package/lib/markdown/goals.partial.md +9 -0
  375. package/lib/front_end/third_party/third-party-web/package/lib/markdown/methodology.partial.md +5 -0
  376. package/lib/front_end/third_party/third-party-web/package/lib/markdown/template.md +151 -0
  377. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-02-01.md +1 -0
  378. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-03-01.md +1 -0
  379. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-06.md +1 -0
  380. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2019-05-13.md +14 -0
  381. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2021-01-01.md +1 -0
  382. package/lib/front_end/third_party/third-party-web/package/lib/markdown/updates/2024-07-01.md +3 -0
  383. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.d.ts +1 -0
  384. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive-nostats.js +3 -0
  385. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.d.ts +1 -0
  386. package/lib/front_end/third_party/third-party-web/package/lib/subsets/httparchive.js +3 -0
  387. package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.d.ts +1 -0
  388. package/lib/front_end/third_party/third-party-web/package/lib/subsets/nostats.js +3 -0
  389. package/lib/front_end/third_party/third-party-web/package/nostats-subset.d.ts +1 -0
  390. package/lib/front_end/third_party/third-party-web/package/nostats-subset.js +1 -0
  391. package/lib/front_end/third_party/third-party-web/package/package.json +46 -0
  392. package/lib/front_end/third_party/third-party-web/package.json +8 -0
  393. package/lib/front_end/third_party/third-party-web/rebuild.sh +13 -0
  394. package/lib/front_end/third_party/third-party-web/third-party-web-tsconfig.json +8 -0
  395. package/lib/front_end/third_party/third-party-web/third-party-web.ts +3 -0
  396. package/package.json +24 -0
  397. package/patches/chrome-devtools-frontend+1.0.1533544.patch +187 -0
@@ -0,0 +1,31 @@
1
+ // Copyright 2023 The Chromium Authors
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as Platform from '../../../core/platform/platform.js';
6
+ import * as Types from '../types/types.js';
7
+
8
+ export interface MemoryData {
9
+ updateCountersByProcess: Map<Types.Events.ProcessID, Types.Events.UpdateCounters[]>;
10
+ }
11
+
12
+ let updateCountersByProcess: MemoryData['updateCountersByProcess'] = new Map();
13
+
14
+ export function reset(): void {
15
+ updateCountersByProcess = new Map();
16
+ }
17
+
18
+ export function handleEvent(event: Types.Events.Event): void {
19
+ if (Types.Events.isUpdateCounters(event)) {
20
+ const countersForProcess = Platform.MapUtilities.getWithDefault(updateCountersByProcess, event.pid, () => []);
21
+ countersForProcess.push(event);
22
+ updateCountersByProcess.set(event.pid, countersForProcess);
23
+ }
24
+ }
25
+
26
+ export async function finalize(): Promise<void> {
27
+ }
28
+
29
+ export function data(): MemoryData {
30
+ return {updateCountersByProcess};
31
+ }
@@ -0,0 +1,525 @@
1
+ // Copyright 2022 The Chromium Authors
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as Platform from '../../../core/platform/platform.js';
6
+ import * as Helpers from '../helpers/helpers.js';
7
+ import * as Types from '../types/types.js';
8
+
9
+ import type {FinalizeOptions} from './types.js';
10
+
11
+ let config: {showAllEvents: boolean};
12
+
13
+ // We track the renderer processes we see in each frame on the way through the trace.
14
+ let rendererProcessesByFrameId: FrameProcessData = new Map();
15
+
16
+ // We will often want to key data by Frame IDs, and commonly we'll care most
17
+ // about the main frame's ID, so we store and expose that.
18
+ let mainFrameId = '';
19
+ let mainFrameURL = '';
20
+
21
+ let framesByProcessId = new Map<Types.Events.ProcessID, Map<string, Types.Events.TraceFrame>>();
22
+
23
+ // We will often want to key data by the browser process, GPU process and top
24
+ // level renderer IDs, so keep a track on those.
25
+ let browserProcessId: Types.Events.ProcessID = Types.Events.ProcessID(-1);
26
+ let browserThreadId: Types.Events.ThreadID = Types.Events.ThreadID(-1);
27
+ let gpuProcessId: Types.Events.ProcessID = Types.Events.ProcessID(-1);
28
+ let gpuThreadId: Types.Events.ThreadID = Types.Events.ThreadID(-1);
29
+ let viewportRect: {x: number, y: number, width: number, height: number}|null = null;
30
+ let devicePixelRatio: number|null = null;
31
+
32
+ let processNames = new Map<Types.Events.ProcessID, Types.Events.ProcessName>();
33
+
34
+ let topLevelRendererIds = new Set<Types.Events.ProcessID>();
35
+
36
+ function makeNewTraceBounds(): Types.Timing.TraceWindowMicro {
37
+ return {
38
+ min: Types.Timing.Micro(Number.POSITIVE_INFINITY),
39
+ max: Types.Timing.Micro(Number.NEGATIVE_INFINITY),
40
+ range: Types.Timing.Micro(Number.POSITIVE_INFINITY),
41
+ };
42
+ }
43
+ let traceBounds: Types.Timing.TraceWindowMicro = makeNewTraceBounds();
44
+
45
+ /**
46
+ * These represent the user navigating. Values such as First Contentful Paint,
47
+ * etc, are relative to the navigation.
48
+ *
49
+ * We store navigation events both by the frame and navigation ID. This means
50
+ * when we need to look them up, we can use whichever ID we have.
51
+ *
52
+ * Note that these Maps will have the same values in them; these are just keyed
53
+ * differently to make look-ups easier.
54
+ *
55
+ * We also additionally maintain an array of only navigations that occurred on
56
+ * the main frame. In many places in the UI we only care about highlighting
57
+ * main frame navigations, so calculating this list here is better than
58
+ * filtering either of the below maps over and over again at the UI layer.
59
+ */
60
+ let navigationsByFrameId = new Map<string, Types.Events.NavigationStart[]>();
61
+ let navigationsByNavigationId = new Map<string, Types.Events.NavigationStart>();
62
+ let finalDisplayUrlByNavigationId = new Map<string, string>();
63
+ let mainFrameNavigations: Types.Events.NavigationStart[] = [];
64
+
65
+ // Represents all the threads in the trace, organized by process. This is mostly for internal
66
+ // bookkeeping so that during the finalize pass we can obtain the main and browser thread IDs.
67
+ let threadsInProcess = new Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.ThreadName>>();
68
+
69
+ let traceStartedTimeFromTracingStartedEvent = Types.Timing.Micro(-1);
70
+ const eventPhasesOfInterestForTraceBounds = new Set([
71
+ Types.Events.Phase.BEGIN,
72
+ Types.Events.Phase.END,
73
+ Types.Events.Phase.COMPLETE,
74
+ Types.Events.Phase.INSTANT,
75
+ ]);
76
+
77
+ // Tracks if the trace is a generic trace, which here means that it did not come from athe DevTools Performance Panel recording.
78
+ // We assume a trace is generic, and mark it as not generic if we see any of:
79
+ // - TracingStartedInPage
80
+ // - TracingStartedInBrowser
81
+ // - TracingSessionIdForWorker
82
+ // - CpuProfile
83
+ // These are all events which indicate this is a Chrome browser trace.
84
+ let traceIsGeneric = true;
85
+ const CHROME_WEB_TRACE_EVENTS = new Set([
86
+ Types.Events.Name.TRACING_STARTED_IN_PAGE,
87
+ Types.Events.Name.TRACING_SESSION_ID_FOR_WORKER,
88
+ Types.Events.Name.TRACING_STARTED_IN_BROWSER,
89
+ Types.Events.Name.CPU_PROFILE,
90
+ ]);
91
+
92
+ export function reset(): void {
93
+ navigationsByFrameId = new Map();
94
+ navigationsByNavigationId = new Map();
95
+ finalDisplayUrlByNavigationId = new Map();
96
+ processNames = new Map();
97
+ mainFrameNavigations = [];
98
+
99
+ browserProcessId = Types.Events.ProcessID(-1);
100
+ browserThreadId = Types.Events.ThreadID(-1);
101
+ gpuProcessId = Types.Events.ProcessID(-1);
102
+ gpuThreadId = Types.Events.ThreadID(-1);
103
+ viewportRect = null;
104
+ topLevelRendererIds = new Set();
105
+ threadsInProcess = new Map();
106
+ rendererProcessesByFrameId = new Map();
107
+ framesByProcessId = new Map();
108
+
109
+ traceBounds = makeNewTraceBounds();
110
+ traceStartedTimeFromTracingStartedEvent = Types.Timing.Micro(-1);
111
+
112
+ traceIsGeneric = true;
113
+ }
114
+
115
+ function updateRendererProcessByFrame(event: Types.Events.Event, frame: Types.Events.TraceFrame): void {
116
+ const framesInProcessById = Platform.MapUtilities.getWithDefault(framesByProcessId, frame.processId, () => new Map());
117
+ framesInProcessById.set(frame.frame, frame);
118
+
119
+ const rendererProcessInFrame = Platform.MapUtilities.getWithDefault(
120
+ rendererProcessesByFrameId, frame.frame,
121
+ () => new Map<
122
+ Types.Events.ProcessID, Array<{frame: Types.Events.TraceFrame, window: Types.Timing.TraceWindowMicro}>>());
123
+ const rendererProcessInfo = Platform.MapUtilities.getWithDefault(rendererProcessInFrame, frame.processId, () => {
124
+ return [];
125
+ });
126
+ const lastProcessData = rendererProcessInfo.at(-1);
127
+
128
+ // Only store a new entry if the URL changed, otherwise it's just
129
+ // redundant information.
130
+ if (lastProcessData && lastProcessData.frame.url === frame.url) {
131
+ return;
132
+ }
133
+ // For now we store the time of the event as the min. In the finalize we step
134
+ // through each of these windows and update their max and range values.
135
+ rendererProcessInfo.push({
136
+ frame,
137
+ window: {
138
+ min: event.ts,
139
+ max: Types.Timing.Micro(0),
140
+ range: Types.Timing.Micro(0),
141
+ },
142
+ });
143
+ }
144
+
145
+ export function handleEvent(event: Types.Events.Event): void {
146
+ if (traceIsGeneric && CHROME_WEB_TRACE_EVENTS.has(event.name as Types.Events.Name)) {
147
+ traceIsGeneric = false;
148
+ }
149
+
150
+ if (Types.Events.isProcessName(event)) {
151
+ processNames.set(event.pid, event);
152
+ }
153
+
154
+ // If there is a timestamp (which meta events do not have), and the event does
155
+ // not end with ::UMA then it, and the event is in the set of valid phases,
156
+ // then it should be included for the purposes of calculating the trace bounds.
157
+ // The UMA events in particular seem to be reported on page unloading, which
158
+ // often extends the bounds of the trace unhelpfully.
159
+ if (event.ts !== 0 && !event.name.endsWith('::UMA') && eventPhasesOfInterestForTraceBounds.has(event.ph)) {
160
+ traceBounds.min = Types.Timing.Micro(Math.min(event.ts, traceBounds.min));
161
+ const eventDuration = event.dur ?? Types.Timing.Micro(0);
162
+ traceBounds.max = Types.Timing.Micro(Math.max(event.ts + eventDuration, traceBounds.max));
163
+ }
164
+
165
+ if (Types.Events.isProcessName(event) && (event.args.name === 'Browser' || event.args.name === 'HeadlessBrowser')) {
166
+ browserProcessId = event.pid;
167
+ return;
168
+ }
169
+
170
+ if (Types.Events.isProcessName(event) && (event.args.name === 'Gpu' || event.args.name === 'GPU Process')) {
171
+ gpuProcessId = event.pid;
172
+ return;
173
+ }
174
+
175
+ if (Types.Events.isThreadName(event) && event.args.name === 'CrGpuMain') {
176
+ gpuThreadId = event.tid;
177
+ return;
178
+ }
179
+
180
+ if (Types.Events.isThreadName(event) && event.args.name === 'CrBrowserMain') {
181
+ browserThreadId = event.tid;
182
+ }
183
+
184
+ if (Types.Events.isMainFrameViewport(event) && viewportRect === null) {
185
+ const rectAsArray = event.args.data.viewport_rect;
186
+ const viewportX = rectAsArray[0];
187
+ const viewportY = rectAsArray[1];
188
+ const viewportWidth = rectAsArray[2];
189
+ const viewportHeight = rectAsArray[5];
190
+ viewportRect = {x: viewportX, y: viewportY, width: viewportWidth, height: viewportHeight};
191
+ devicePixelRatio = event.args.data.dpr;
192
+ }
193
+
194
+ // The TracingStartedInBrowser event includes the data on which frames are
195
+ // in scope at the start of the trace. We use this to identify the frame with
196
+ // no parent, i.e. the top level frame.
197
+ if (Types.Events.isTracingStartedInBrowser(event)) {
198
+ traceStartedTimeFromTracingStartedEvent = event.ts;
199
+
200
+ if (!event.args.data) {
201
+ throw new Error('No frames found in trace data');
202
+ }
203
+
204
+ for (const frame of (event.args.data.frames ?? [])) {
205
+ updateRendererProcessByFrame(event, frame);
206
+
207
+ if (!frame.parent) {
208
+ topLevelRendererIds.add(frame.processId);
209
+ }
210
+ /**
211
+ * The code here uses a few different methods to try to determine the main frame.
212
+ * The ideal is that the frames have two flags present:
213
+ *
214
+ * 1. isOutermostMainFrame (added in April 2024 - crrev.com/c/5424783)
215
+ * 2. isInPrimaryMainFrame (added in June 2024 - crrev.com/c/5595033)
216
+ *
217
+ * The frame where both of these are set to `true` is the main frame. The
218
+ * reason we need both of these flags to have 100% confidence is because
219
+ * with the introduction of MPArch and pre-rendering, we can have other
220
+ * frames that are the outermost frame, but are not the primary process.
221
+ * Relying on isOutermostMainFrame in isolation caused the engine to
222
+ * incorrectly identify the wrong frame as main (see crbug.com/343873756).
223
+ *
224
+ * See https://source.chromium.org/chromium/chromium/src/+/main:docs/frame_trees.md
225
+ * for a bit more context on FrameTrees in Chromium.
226
+ *
227
+ * To avoid breaking entirely for traces pre-June 2024 that don't have
228
+ * both of these flags, we will fallback to less accurate methods:
229
+ *
230
+ * 1. If we have isOutermostMainFrame, we will use that
231
+ * (and accept we might get it wrong)
232
+ * 2. If we don't have isOutermostMainFrame, we fallback to finding a
233
+ * frame that has a URL, but doesn't have a parent. This is a crude
234
+ * guess at the main frame...but better than nothing and is historically
235
+ * how DevTools identified the main frame.
236
+ */
237
+
238
+ const traceHasPrimaryMainFrameFlag = 'isInPrimaryMainFrame' in frame;
239
+ const traceHasOutermostMainFrameFlag = 'isOutermostMainFrame' in frame;
240
+
241
+ if (traceHasPrimaryMainFrameFlag && traceHasOutermostMainFrameFlag) {
242
+ // Ideal situation: identify the main frame as the one that has both these flags set to true.
243
+ if (frame.isInPrimaryMainFrame && frame.isOutermostMainFrame) {
244
+ mainFrameId = frame.frame;
245
+ mainFrameURL = frame.url;
246
+ }
247
+ } else if (traceHasOutermostMainFrameFlag) {
248
+ // Less ideal: "guess" at the main thread by using this flag.
249
+ if (frame.isOutermostMainFrame) {
250
+ mainFrameId = frame.frame;
251
+ mainFrameURL = frame.url;
252
+ }
253
+ // Worst case: guess by seeing if the frame doesn't have a parent, and does have a URL.
254
+ } else if (!frame.parent && frame.url) {
255
+ mainFrameId = frame.frame;
256
+ mainFrameURL = frame.url;
257
+ }
258
+ }
259
+
260
+ return;
261
+ }
262
+
263
+ // FrameCommittedInBrowser events tell us information about each frame
264
+ // and we use these to track how long each individual renderer is active
265
+ // for. We track all renderers here (top level and those in frames), but
266
+ // for convenience we also populate a set of top level renderer IDs.
267
+ if (Types.Events.isFrameCommittedInBrowser(event)) {
268
+ const frame = event.args.data;
269
+ if (!frame) {
270
+ return;
271
+ }
272
+
273
+ updateRendererProcessByFrame(event, frame);
274
+
275
+ if (frame.parent) {
276
+ return;
277
+ }
278
+
279
+ topLevelRendererIds.add(frame.processId);
280
+ return;
281
+ }
282
+
283
+ if (Types.Events.isCommitLoad(event)) {
284
+ const frameData = event.args.data;
285
+ if (!frameData) {
286
+ return;
287
+ }
288
+
289
+ const {frame, name, url} = frameData;
290
+ updateRendererProcessByFrame(event, {processId: event.pid, frame, name, url});
291
+ return;
292
+ }
293
+
294
+ // Track all threads based on the process & thread IDs.
295
+ if (Types.Events.isThreadName(event)) {
296
+ const threads = Platform.MapUtilities.getWithDefault(threadsInProcess, event.pid, () => new Map());
297
+ threads.set(event.tid, event);
298
+ return;
299
+ }
300
+
301
+ // Track all navigation events. Note that there can be navigation start events
302
+ // but where the documentLoaderURL is empty. As far as the trace rendering is
303
+ // concerned, these events are noise so we filter them out here.
304
+ // (The filtering of empty URLs is done in the isNavigationStart check)
305
+ if (Types.Events.isNavigationStart(event) && event.args.data) {
306
+ const navigationId = event.args.data.navigationId;
307
+ if (navigationsByNavigationId.has(navigationId)) {
308
+ // We have only ever seen this situation once, in crbug.com/1503982, where the user ran:
309
+ // window.location.href = 'javascript:console.log("foo")'
310
+ // In this situation two identical navigationStart events are emitted with the same data, URL and ID.
311
+ // So, in this situation we drop/ignore any subsequent navigations if we have already seen that ID.
312
+ return;
313
+ }
314
+ navigationsByNavigationId.set(navigationId, event);
315
+ finalDisplayUrlByNavigationId.set(navigationId, event.args.data.documentLoaderURL);
316
+
317
+ const frameId = event.args.frame;
318
+ const existingFrameNavigations = navigationsByFrameId.get(frameId) || [];
319
+ existingFrameNavigations.push(event);
320
+ navigationsByFrameId.set(frameId, existingFrameNavigations);
321
+ if (frameId === mainFrameId) {
322
+ mainFrameNavigations.push(event);
323
+ }
324
+ return;
325
+ }
326
+
327
+ // Update `finalDisplayUrlByNavigationId` to reflect the latest redirect for each navigation.
328
+ if (Types.Events.isResourceSendRequest(event)) {
329
+ if (event.args.data.resourceType !== 'Document') {
330
+ return;
331
+ }
332
+
333
+ const maybeNavigationId = event.args.data.requestId;
334
+ const navigation = navigationsByNavigationId.get(maybeNavigationId);
335
+ if (!navigation) {
336
+ return;
337
+ }
338
+
339
+ finalDisplayUrlByNavigationId.set(maybeNavigationId, event.args.data.url);
340
+ return;
341
+ }
342
+
343
+ // Update `finalDisplayUrlByNavigationId` to reflect history API navigations.
344
+ if (Types.Events.isDidCommitSameDocumentNavigation(event)) {
345
+ if (event.args.render_frame_host.frame_type !== 'PRIMARY_MAIN_FRAME') {
346
+ return;
347
+ }
348
+
349
+ const navigation = mainFrameNavigations.at(-1);
350
+ const key = navigation?.args.data?.navigationId ?? '';
351
+ finalDisplayUrlByNavigationId.set(key, event.args.url);
352
+ return;
353
+ }
354
+ }
355
+
356
+ export async function finalize(options?: FinalizeOptions): Promise<void> {
357
+ config = {showAllEvents: Boolean(options?.showAllEvents)};
358
+
359
+ // We try to set the minimum time by finding the event with the smallest
360
+ // timestamp. However, if we also got a timestamp from the
361
+ // TracingStartedInBrowser event, we should always use that.
362
+ // But in some traces (for example, CPU profiles) we do not get that event,
363
+ // hence why we need to check we got a timestamp from it before setting it.
364
+ if (traceStartedTimeFromTracingStartedEvent >= 0) {
365
+ traceBounds.min = traceStartedTimeFromTracingStartedEvent;
366
+ }
367
+ traceBounds.range = Types.Timing.Micro(traceBounds.max - traceBounds.min);
368
+
369
+ // If we go from foo.com to example.com we will get a new renderer, and
370
+ // therefore the "top level renderer" will have a different PID as it has
371
+ // changed. Here we step through each renderer process and updated its window
372
+ // bounds, such that we end up with the time ranges in the trace for when
373
+ // each particular renderer started and stopped being the main renderer
374
+ // process.
375
+ for (const [, processWindows] of rendererProcessesByFrameId) {
376
+ // Sort the windows by time; we cannot assume by default they arrive via
377
+ // events in time order. Because we set the window bounds per-process based
378
+ // on the time of the current + next window, we need them sorted in ASC
379
+ // order.
380
+ const processWindowValues = [...processWindows.values()].flat().sort((a, b) => {
381
+ return a.window.min - b.window.min;
382
+ });
383
+ for (let i = 0; i < processWindowValues.length; i++) {
384
+ const currentWindow = processWindowValues[i];
385
+ const nextWindow = processWindowValues[i + 1];
386
+
387
+ // For the last window we set its max to be positive infinity.
388
+ // TODO: Move the trace bounds handler into meta so we can clamp first and last windows.
389
+ if (!nextWindow) {
390
+ currentWindow.window.max = Types.Timing.Micro(traceBounds.max);
391
+ currentWindow.window.range = Types.Timing.Micro(traceBounds.max - currentWindow.window.min);
392
+ } else {
393
+ currentWindow.window.max = Types.Timing.Micro(nextWindow.window.min - 1);
394
+ currentWindow.window.range = Types.Timing.Micro(currentWindow.window.max - currentWindow.window.min);
395
+ }
396
+ }
397
+ }
398
+
399
+ // Frame ids which we didn't register using either the TracingStartedInBrowser or
400
+ // the FrameCommittedInBrowser events are considered noise, so we filter them out, as well
401
+ // as the navigations that belong to such frames.
402
+ for (const [frameId, navigations] of navigationsByFrameId) {
403
+ // The frames in the rendererProcessesByFrameId map come only from the
404
+ // TracingStartedInBrowser and FrameCommittedInBrowser events, so we can use it as point
405
+ // of comparison to determine if a frameId should be discarded.
406
+ if (rendererProcessesByFrameId.has(frameId)) {
407
+ continue;
408
+ }
409
+ navigationsByFrameId.delete(frameId);
410
+ for (const navigation of navigations) {
411
+ if (!navigation.args.data) {
412
+ continue;
413
+ }
414
+ navigationsByNavigationId.delete(navigation.args.data.navigationId);
415
+ }
416
+ }
417
+
418
+ // Sometimes in traces the TracingStartedInBrowser event can give us an
419
+ // incorrect initial URL for the main frame's URL - about:blank or the URL of
420
+ // the previous page. This doesn't matter too much except we often use this
421
+ // URL as the visual name of the trace shown to the user (e.g. in the history
422
+ // dropdown). We can be more accurate by finding the first main frame
423
+ // navigation, and using its URL, if we have it.
424
+ // However, to avoid doing this in a case where the first navigation is far
425
+ // into the trace's lifecycle, we only do this in situations where the first
426
+ // navigation happened very soon (0.5 seconds) after the trace started
427
+ // recording.
428
+ const firstMainFrameNav = mainFrameNavigations.at(0);
429
+ const firstNavTimeThreshold = Helpers.Timing.secondsToMicro(Types.Timing.Seconds(0.5));
430
+ if (firstMainFrameNav) {
431
+ const navigationIsWithinThreshold = firstMainFrameNav.ts - traceBounds.min < firstNavTimeThreshold;
432
+ if (firstMainFrameNav.args.data?.isOutermostMainFrame && firstMainFrameNav.args.data?.documentLoaderURL &&
433
+ navigationIsWithinThreshold) {
434
+ mainFrameURL = firstMainFrameNav.args.data.documentLoaderURL;
435
+ }
436
+ }
437
+ }
438
+
439
+ export interface MetaHandlerData {
440
+ config: {showAllEvents: boolean};
441
+ traceIsGeneric: boolean;
442
+ traceBounds: Types.Timing.TraceWindowMicro;
443
+ browserProcessId: Types.Events.ProcessID;
444
+ processNames: Map<Types.Events.ProcessID, Types.Events.ProcessName>;
445
+ browserThreadId: Types.Events.ThreadID;
446
+ gpuProcessId: Types.Events.ProcessID;
447
+ navigationsByFrameId: Map<string, Types.Events.NavigationStart[]>;
448
+ navigationsByNavigationId: Map<string, Types.Events.NavigationStart>;
449
+ /**
450
+ * The user-visible URL displayed to users in the address bar.
451
+ * This captures:
452
+ * - resolving all redirects
453
+ * - history API pushState
454
+ *
455
+ * Given no redirects or history API usages, this is just the navigation event's documentLoaderURL.
456
+ *
457
+ * Note: empty string special case denotes the duration of the trace between the start
458
+ * and the first navigation. If there is no history API navigation during this time,
459
+ * there will be no value for empty string.
460
+ **/
461
+ finalDisplayUrlByNavigationId: Map<string, string>;
462
+ threadsInProcess: Map<Types.Events.ProcessID, Map<Types.Events.ThreadID, Types.Events.ThreadName>>;
463
+ mainFrameId: string;
464
+ mainFrameURL: string;
465
+ /**
466
+ * A frame can have multiple renderer processes, at the same time,
467
+ * a renderer process can have multiple URLs. This map tracks the
468
+ * processes active on a given frame, with the time window in which
469
+ * they were active. Because a renderer process might have multiple
470
+ * URLs, each process in each frame has an array of windows, with an
471
+ * entry for each URL it had.
472
+ */
473
+ rendererProcessesByFrame: FrameProcessData;
474
+ topLevelRendererIds: Set<Types.Events.ProcessID>;
475
+ frameByProcessId: Map<Types.Events.ProcessID, Map<string, Types.Events.TraceFrame>>;
476
+ mainFrameNavigations: Types.Events.NavigationStart[];
477
+ gpuThreadId?: Types.Events.ThreadID;
478
+ viewportRect?: {x: number, y: number, width: number, height: number};
479
+ devicePixelRatio?: number;
480
+ }
481
+
482
+ /**
483
+ * Each frame has a single render process at a given time but it can have
484
+ * multiple render processes during a trace, for example if a navigation
485
+ * occurred in the frame. This map tracks the process that was active for
486
+ * each frame at each point in time. Also, because a process can be
487
+ * assigned to multiple URLs, there is a window for each URL a process
488
+ * was assigned.
489
+ *
490
+ * Note that different sites always end up in different render
491
+ * processes, however two different URLs can point to the same site.
492
+ * For example: https://google.com and https://maps.google.com point to
493
+ * the same site.
494
+ * Read more about this in
495
+ * https://developer.chrome.com/articles/renderingng-architecture/#threads
496
+ * and https://web.dev/same-site-same-origin/
497
+ **/
498
+ export type FrameProcessData =
499
+ Map<string,
500
+ Map<Types.Events.ProcessID, Array<{frame: Types.Events.TraceFrame, window: Types.Timing.TraceWindowMicro}>>>;
501
+
502
+ export function data(): MetaHandlerData {
503
+ return {
504
+ config,
505
+ traceBounds,
506
+ browserProcessId,
507
+ browserThreadId,
508
+ processNames,
509
+ gpuProcessId,
510
+ gpuThreadId: gpuThreadId === Types.Events.ThreadID(-1) ? undefined : gpuThreadId,
511
+ viewportRect: viewportRect || undefined,
512
+ devicePixelRatio: devicePixelRatio ?? undefined,
513
+ mainFrameId,
514
+ mainFrameURL,
515
+ navigationsByFrameId,
516
+ navigationsByNavigationId,
517
+ finalDisplayUrlByNavigationId,
518
+ threadsInProcess,
519
+ rendererProcessesByFrame: rendererProcessesByFrameId,
520
+ topLevelRendererIds,
521
+ frameByProcessId: framesByProcessId,
522
+ mainFrameNavigations,
523
+ traceIsGeneric,
524
+ };
525
+ }
@@ -0,0 +1,34 @@
1
+ // Copyright 2022 The Chromium Authors
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ export * as AnimationFrames from './AnimationFramesHandler.js';
6
+ export * as Animations from './AnimationHandler.js';
7
+ export * as AsyncJSCalls from './AsyncJSCallsHandler.js';
8
+ export * as AuctionWorklets from './AuctionWorkletsHandler.js';
9
+ export * as DOMStats from './DOMStatsHandler.js';
10
+ export * as ExtensionTraceData from './ExtensionTraceDataHandler.js';
11
+ export * as Flows from './FlowsHandler.js';
12
+ export * as Frames from './FramesHandler.js';
13
+ export * as GPU from './GPUHandler.js';
14
+ export * as ImagePainting from './ImagePaintingHandler.js';
15
+ export * as Initiators from './InitiatorsHandler.js';
16
+ export * as Invalidations from './InvalidationsHandler.js';
17
+ export * as LargestImagePaint from './LargestImagePaintHandler.js';
18
+ export * as LargestTextPaint from './LargestTextPaintHandler.js';
19
+ export * as LayerTree from './LayerTreeHandler.js';
20
+ export * as LayoutShifts from './LayoutShiftsHandler.js';
21
+ export * as Memory from './MemoryHandler.js';
22
+ export * as Meta from './MetaHandler.js';
23
+ export * as NetworkRequests from './NetworkRequestsHandler.js';
24
+ export * as PageFrames from './PageFramesHandler.js';
25
+ export * as PageLoadMetrics from './PageLoadMetricsHandler.js';
26
+ export * as Renderer from './RendererHandler.js';
27
+ export * as Samples from './SamplesHandler.js';
28
+ export * as Screenshots from './ScreenshotsHandler.js';
29
+ export * as Scripts from './ScriptsHandler.js';
30
+ export * as SelectorStats from './SelectorStatsHandler.js';
31
+ export * as UserInteractions from './UserInteractionsHandler.js';
32
+ export * as UserTimings from './UserTimingsHandler.js';
33
+ export * as Warnings from './WarningsHandler.js';
34
+ export * as Workers from './WorkersHandler.js';