chrome-devtools-frontend 1.0.1566234 → 1.0.1567721

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 (188) hide show
  1. package/docs/contributing/performance.md +24 -0
  2. package/front_end/core/common/Base64.ts +21 -2
  3. package/front_end/core/common/ResourceType.ts +7 -0
  4. package/front_end/core/host/InspectorFrontendHostStub.ts +3 -0
  5. package/front_end/core/host/UserMetrics.ts +20 -0
  6. package/front_end/core/sdk/NetworkManager.ts +3 -3
  7. package/front_end/entrypoints/main/MainImpl.ts +1 -7
  8. package/front_end/generated/Deprecation.ts +0 -8
  9. package/front_end/generated/InspectorBackendCommands.ts +1 -1
  10. package/front_end/generated/SupportedCSSProperties.js +39 -49
  11. package/front_end/generated/protocol.ts +4 -0
  12. package/front_end/models/ai_assistance/agents/AiAgent.ts +2 -1
  13. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +98 -105
  14. package/front_end/models/emulation/DeviceModeModel.ts +1 -1
  15. package/front_end/models/formatter/FormatterWorkerPool.ts +8 -6
  16. package/front_end/models/javascript_metadata/NativeFunctions.js +4 -9
  17. package/front_end/models/persistence/PersistenceImpl.ts +8 -0
  18. package/front_end/models/text_utils/TextUtils.snapshot.txt +83 -0
  19. package/front_end/panels/ai_assistance/ai_assistance-meta.ts +0 -1
  20. package/front_end/panels/ai_assistance/components/ArtifactsViewer.ts +28 -4
  21. package/front_end/panels/ai_assistance/components/ChatView.ts +52 -169
  22. package/front_end/panels/ai_assistance/components/CollapsibleAssistanceContentWidget.ts +27 -8
  23. package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +19 -4
  24. package/front_end/panels/application/ApplicationPanelSidebar.ts +1 -0
  25. package/front_end/panels/application/DeviceBoundSessionsModel.ts +42 -0
  26. package/front_end/panels/application/DeviceBoundSessionsTreeElement.ts +60 -11
  27. package/front_end/panels/application/DeviceBoundSessionsView.ts +947 -103
  28. package/front_end/panels/application/ResourcesPanel.ts +7 -0
  29. package/front_end/panels/application/deviceBoundSessionsView.css +10 -1
  30. package/front_end/panels/common/AiCodeGenerationUpgradeDialog.ts +115 -0
  31. package/front_end/panels/common/aiCodeGenerationUpgradeDialog.css +79 -0
  32. package/front_end/panels/common/common.ts +1 -0
  33. package/front_end/panels/console/ConsoleInsightTeaser.ts +17 -3
  34. package/front_end/panels/issues/AffectedSourcesView.ts +0 -1
  35. package/front_end/panels/issues/IssuesPane.ts +0 -4
  36. package/front_end/panels/network/RequestTimingView.ts +5 -20
  37. package/front_end/panels/network/networkTimingTable.css +5 -5
  38. package/front_end/panels/recorder/components/StepEditor.ts +15 -8
  39. package/front_end/panels/settings/AISettingsTab.ts +31 -2
  40. package/front_end/panels/sources/InplaceFormatterEditorAction.ts +8 -6
  41. package/front_end/panels/sources/UISourceCodeFrame.ts +9 -3
  42. package/front_end/panels/timeline/TimelinePanel.ts +12 -4
  43. package/front_end/panels/timeline/components/insights/DuplicatedJavaScript.ts +1 -1
  44. package/front_end/third_party/chromium/README.chromium +1 -1
  45. package/front_end/third_party/puppeteer/README.chromium +2 -2
  46. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.d.ts +9 -2
  47. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.d.ts.map +1 -1
  48. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.js.map +1 -1
  49. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts +8 -0
  50. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts.map +1 -1
  51. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.js +8 -0
  52. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.js.map +1 -1
  53. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Browser.d.ts +2 -1
  54. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Browser.d.ts.map +1 -1
  55. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Browser.js +2 -2
  56. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Browser.js.map +1 -1
  57. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/BrowserContext.d.ts.map +1 -1
  58. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/BrowserContext.js +3 -1
  59. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/BrowserContext.js.map +1 -1
  60. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Frame.d.ts.map +1 -1
  61. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Frame.js +1 -1
  62. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Frame.js.map +1 -1
  63. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
  64. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js +3 -3
  65. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
  66. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/UserContext.d.ts +1 -0
  67. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/UserContext.d.ts.map +1 -1
  68. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/UserContext.js +1 -0
  69. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/UserContext.js.map +1 -1
  70. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts.map +1 -1
  71. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js +1 -0
  72. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js.map +1 -1
  73. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts.map +1 -1
  74. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js +33 -31
  75. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js.map +1 -1
  76. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebWorker.d.ts +2 -2
  77. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebWorker.d.ts.map +1 -1
  78. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebWorker.js +1 -4
  79. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebWorker.js.map +1 -1
  80. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConsoleMessage.d.ts +7 -1
  81. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConsoleMessage.d.ts.map +1 -1
  82. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConsoleMessage.js +11 -1
  83. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConsoleMessage.js.map +1 -1
  84. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Cookie.d.ts +2 -2
  85. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
  86. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +2 -2
  87. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +2 -2
  88. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
  89. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  90. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  91. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +13 -4
  92. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +62 -42
  93. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.d.ts +9 -2
  94. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.d.ts.map +1 -1
  95. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.js.map +1 -1
  96. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts +8 -0
  97. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts.map +1 -1
  98. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.js +8 -0
  99. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.js.map +1 -1
  100. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Browser.d.ts +2 -1
  101. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Browser.d.ts.map +1 -1
  102. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Browser.js +2 -2
  103. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Browser.js.map +1 -1
  104. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/BrowserContext.d.ts.map +1 -1
  105. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/BrowserContext.js +3 -1
  106. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/BrowserContext.js.map +1 -1
  107. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Frame.d.ts.map +1 -1
  108. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Frame.js +1 -1
  109. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Frame.js.map +1 -1
  110. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
  111. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js +3 -3
  112. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
  113. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/UserContext.d.ts +1 -0
  114. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/UserContext.d.ts.map +1 -1
  115. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/UserContext.js +1 -0
  116. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/UserContext.js.map +1 -1
  117. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts.map +1 -1
  118. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js +1 -0
  119. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js.map +1 -1
  120. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts.map +1 -1
  121. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js +33 -31
  122. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js.map +1 -1
  123. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebWorker.d.ts +2 -2
  124. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebWorker.d.ts.map +1 -1
  125. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebWorker.js +1 -4
  126. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebWorker.js.map +1 -1
  127. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConsoleMessage.d.ts +7 -1
  128. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConsoleMessage.d.ts.map +1 -1
  129. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConsoleMessage.js +11 -1
  130. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConsoleMessage.js.map +1 -1
  131. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Cookie.d.ts +2 -2
  132. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +2 -2
  133. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +2 -2
  134. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  135. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  136. package/front_end/third_party/puppeteer/package/lib/types.d.ts +13 -4
  137. package/front_end/third_party/puppeteer/package/package.json +3 -3
  138. package/front_end/third_party/puppeteer/package/src/api/Browser.ts +11 -3
  139. package/front_end/third_party/puppeteer/package/src/api/Page.ts +9 -0
  140. package/front_end/third_party/puppeteer/package/src/bidi/Browser.ts +3 -3
  141. package/front_end/third_party/puppeteer/package/src/bidi/BrowserContext.ts +3 -1
  142. package/front_end/third_party/puppeteer/package/src/bidi/Frame.ts +1 -0
  143. package/front_end/third_party/puppeteer/package/src/bidi/core/BrowsingContext.ts +3 -5
  144. package/front_end/third_party/puppeteer/package/src/bidi/core/UserContext.ts +2 -0
  145. package/front_end/third_party/puppeteer/package/src/cdp/Browser.ts +1 -0
  146. package/front_end/third_party/puppeteer/package/src/cdp/Page.ts +43 -45
  147. package/front_end/third_party/puppeteer/package/src/cdp/WebWorker.ts +3 -11
  148. package/front_end/third_party/puppeteer/package/src/common/ConsoleMessage.ts +12 -0
  149. package/front_end/third_party/puppeteer/package/src/common/Cookie.ts +2 -2
  150. package/front_end/third_party/puppeteer/package/src/revisions.ts +2 -2
  151. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  152. package/front_end/third_party/source-map-scopes-codec/README.chromium +2 -5
  153. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +1 -1
  154. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +1 -1
  155. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +1 -1
  156. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +1 -1
  157. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +1 -1
  158. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +1 -1
  159. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +1 -1
  160. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +1 -1
  161. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +1 -1
  162. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +1 -1
  163. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts +130 -0
  164. package/front_end/third_party/source-map-scopes-codec/package/_dist/src/scopes.d.ts.map +1 -0
  165. package/front_end/third_party/source-map-scopes-codec/package/deno.json +1 -1
  166. package/front_end/third_party/source-map-scopes-codec/package/package.json +1 -1
  167. package/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +1 -1
  168. package/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +1 -1
  169. package/front_end/third_party/source-map-scopes-codec/package/src/codec.js +4 -0
  170. package/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +1 -1
  171. package/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +4 -0
  172. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +30 -13
  173. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +1 -1
  174. package/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +35 -17
  175. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +1 -1
  176. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +1 -1
  177. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +1 -1
  178. package/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +2 -2
  179. package/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +1 -1
  180. package/front_end/third_party/source-map-scopes-codec/package/src/scopes.js +7 -0
  181. package/front_end/third_party/source-map-scopes-codec/package/src/scopes.js.map +1 -0
  182. package/front_end/third_party/source-map-scopes-codec/package/src/util.ts +1 -1
  183. package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +4 -0
  184. package/front_end/ui/visual_logging/KnownContextValues.ts +11 -0
  185. package/mcp/mcp.ts +1 -0
  186. package/package.json +1 -2
  187. package/front_end/third_party/source-map-scopes-codec/package/src/scopes-tsconfig.json +0 -8
  188. /package/front_end/third_party/source-map-scopes-codec/package/src/{scopes.d.ts → scopes.ts} +0 -0
@@ -0,0 +1,24 @@
1
+ # Performance testing
2
+
3
+ Performance tests run in Chromium infra to measure panel loading times. The `devtools_frontend` Crossbench benchmark collects the load time for the five major panels (elements, console, network, sources, resources) against three pages: [blank](about:blank), [speedometertests](https://chromium-workloads.web.app/speedometer/v3.1/?iterationCount=1&startAutomatically&suites=TodoMVC-Angular-Complex-DOM,TodoMVC-JavaScript-ES5-Complex-DOM,TodoMVC-React-Complex-DOM), and [dailybroadcast](https://browserben.ch/speedometer/v3.1/resources/newssite/news-next/dist/index.html).
4
+
5
+ Official results can be viewed on this [Skia-perf page](https://chrome-perf.corp.goog/m?begin=1767637318&end=1768242118&shortcut=53b911343bb42697c4a8e9f750aa421d&totalGraphs=1).
6
+
7
+ ## How to run perf benchmark locally
8
+
9
+ Crossbench is available within the Chromium repository at `./tools/perf` and is kept up-to-date by running `gclient sync`. Alternatively you can clone the Crossbench [repo](sso://chromium/crossbench). The Crossbench executable is named `cb.py`.
10
+
11
+ To execute the full DevTools benchmark:
12
+ `./cb.py devtools_frontend --repeat=N`.
13
+ When --repeat argument is missing we run every scenario 2 times.
14
+
15
+ To execute the benchmark against a subset of panels and/or sites:
16
+ `./cb.py devtools_frontend --panels=elements,resources --sites=blank,dailybroadcast`
17
+
18
+ To run the benchmark against a local Chromium build, specify the path to your browser executable:
19
+ `./cb.py devtools_frontend --browser=path/to/chrome`
20
+
21
+ To run the benchmark against your local DevTools build:
22
+ `./cb.py devtools-frontend --browser=path/to/chrome -- --custom-devtools-frontend=file://$(realpath ./path/to/devtools)`
23
+
24
+ At the end of each run, Crossbench generates a report and outputs its path. Review the `devtools_frontend_load_time.json` file in the report folder and compare your numbers with the official performance runs.
@@ -32,13 +32,32 @@ export function decode(input: string): Uint8Array<ArrayBuffer> {
32
32
  return bytes;
33
33
  }
34
34
 
35
+ /**
36
+ * Note: if input can be very large (larger than the max string size), callers should
37
+ * expect this to throw an error.
38
+ */
35
39
  export function encode(input: BlobPart): Promise<string> {
36
40
  return new Promise((resolve, reject) => {
37
41
  const reader = new FileReader();
38
- reader.onerror = () => reject(new Error('failed to convert to base64'));
42
+ reader.onerror = () => reject(new Error('failed to convert to base64: internal error'));
39
43
  reader.onload = () => {
44
+ // The input was too large to encode as a string. The caller should anticipate
45
+ // this and use a workaround. See TimelinePanel.ts innerSaveToFile for an example.
46
+ // For more information, see crbug.com/436482118.
47
+ if (reader.result === '') {
48
+ reject(new Error('failed to convert to base64: input too large to encode as base64 string'));
49
+ return;
50
+ }
51
+
52
+ // This string can be very large, so take care to not double memory. `split`
53
+ // was used here before, which always results in new strings in V8. By using
54
+ // slice instead, we leverage the sliced string optimization in V8 and avoid
55
+ // doubling the memory requirement (even if temporarily: that is a potential
56
+ // source of OOM crashes given large enough input, such as is common with
57
+ // Performance traces).
40
58
  const blobAsUrl = reader.result as string;
41
- const [, base64] = blobAsUrl.split(',', 2);
59
+ const index = blobAsUrl.indexOf(',');
60
+ const base64 = blobAsUrl.slice(index + 1);
42
61
  resolve(base64);
43
62
  };
44
63
 
@@ -250,6 +250,13 @@ export class ResourceType {
250
250
  return regex.test(contentType) ? 'application/json' : contentType;
251
251
  }
252
252
 
253
+ /**
254
+ * Checks whether the given MIME type represents JavaScript content.
255
+ */
256
+ static isJavaScriptMimeType(mimeType: string): boolean {
257
+ return mimeType === 'application/javascript' || mimeType === 'text/javascript';
258
+ }
259
+
253
260
  /**
254
261
  * Adds suffixes iff the mimeType is 'text/javascript' to denote whether the JS is minified or from
255
262
  * a source map.
@@ -147,6 +147,9 @@ export class InspectorFrontendHostStub implements InspectorFrontendHostAPI {
147
147
  }
148
148
 
149
149
  inspectedURLChanged(url: Platform.DevToolsPath.UrlString): void {
150
+ if (!('document' in globalThis)) {
151
+ return;
152
+ }
150
153
  document.title = i18nString(UIStrings.devtoolsS, {PH1: url.replace(/^https?:\/\//, '')});
151
154
  }
152
155
 
@@ -317,6 +317,26 @@ export class UserMetrics {
317
317
  InspectorFrontendHostInstance.recordPerformanceHistogram(
318
318
  'DevTools.Insights.TeaserFirstChunkGenerationTime', timeInMilliseconds);
319
319
  }
320
+
321
+ consoleInsightTeaserAbortedAfterFirstCharacter(timeInMilliseconds: number): void {
322
+ InspectorFrontendHostInstance.recordPerformanceHistogram(
323
+ 'DevTools.Insights.TeaserAfterFirstCharacterAbortionTime', timeInMilliseconds);
324
+ }
325
+
326
+ consoleInsightTeaserAbortedBeforeFirstCharacter(timeInMilliseconds: number): void {
327
+ InspectorFrontendHostInstance.recordPerformanceHistogram(
328
+ 'DevTools.Insights.TeaserBeforeFirstCharacterAbortionTime', timeInMilliseconds);
329
+ }
330
+
331
+ consoleInsightLongTeaserGenerated(timeInMilliseconds: number): void {
332
+ InspectorFrontendHostInstance.recordPerformanceHistogram(
333
+ 'DevTools.Insights.LongTeaserGenerationTime', timeInMilliseconds);
334
+ }
335
+
336
+ consoleInsightShortTeaserGenerated(timeInMilliseconds: number): void {
337
+ InspectorFrontendHostInstance.recordPerformanceHistogram(
338
+ 'DevTools.Insights.ShortTeaserGenerationTime', timeInMilliseconds);
339
+ }
320
340
  }
321
341
 
322
342
  /**
@@ -1913,10 +1913,10 @@ export class RequestConditions extends Common.ObjectWrapper.ObjectWrapper<Reques
1913
1913
  matchedNetworkConditions.push({ruleIds, urlPattern, conditions});
1914
1914
  }
1915
1915
  }
1916
+ }
1916
1917
 
1917
- if (globalConditions) {
1918
- matchedNetworkConditions.push({conditions: globalConditions});
1919
- }
1918
+ if (globalConditions) {
1919
+ matchedNetworkConditions.push({conditions: globalConditions});
1920
1920
  }
1921
1921
 
1922
1922
  const promises: Array<Promise<unknown>> = [];
@@ -971,7 +971,6 @@ export class MainMenuItem implements UI.Toolbar.Provider {
971
971
  const persistence = viewExtension.persistence();
972
972
  const title = viewExtension.title();
973
973
  const id = viewExtension.viewId();
974
- const promotionId = viewExtension.featurePromotionId();
975
974
 
976
975
  if (id === 'issues-pane') {
977
976
  moreTools.defaultSection().appendItem(title, () => {
@@ -988,14 +987,9 @@ export class MainMenuItem implements UI.Toolbar.Provider {
988
987
  continue;
989
988
  }
990
989
 
991
- let additionalElement = undefined;
992
- if (promotionId) {
993
- additionalElement = UI.UIUtils.maybeCreateNewBadge(promotionId);
994
- }
995
-
996
990
  moreTools.defaultSection().appendItem(title, () => {
997
991
  void UI.ViewManager.ViewManager.instance().showView(id, true, false);
998
- }, {additionalElement, isPreviewFeature: viewExtension.isPreviewFeature(), jslogContext: id});
992
+ }, {isPreviewFeature: viewExtension.isPreviewFeature(), jslogContext: id});
999
993
  }
1000
994
 
1001
995
  const helpSubMenu = contextMenu.footerSection().appendSubMenuItem(i18nString(UIStrings.help), false, 'help');
@@ -242,10 +242,6 @@ export const UIStrings = {
242
242
  * @description Warning displayed to developers. It is shown when the `XMLHttpRequest` API is used in a way that it slows down the page load of the next page. The `main thread` refers to an operating systems thread used to run most of the processing of HTML documents, so please use a consistent wording.
243
243
  */
244
244
  XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload: "Synchronous `XMLHttpRequest` on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.",
245
- /**
246
- * @description Warning displayed to developers that they are using externally loaded entities in an XML document that constitutes a part of the web page. Externally loaded entities are a technical concept of XML document processing.
247
- */
248
- XMLNoExternalEntities: "Externally loaded entities in XML parsing have been deprecated and will be removed from this browser soon.",
249
245
  /**
250
246
  * @description Warning displayed to developers that they are using either the XSLTProcessor API, or XSLT processing instructions, both of which have been deprecated and are scheduled to be removed.
251
247
  */
@@ -374,10 +370,6 @@ export const DEPRECATIONS_METADATA: Partial<Record<string, DeprecationDescriptor
374
370
  "XHRJSONEncodingDetection": {
375
371
  "milestone": 93
376
372
  },
377
- "XMLNoExternalEntities": {
378
- "chromeStatusFeature": 6734457763659776,
379
- "milestone": 144
380
- },
381
373
  "XSLT": {
382
374
  "chromeStatusFeature": 4709671889534976,
383
375
  "milestone": 143
@@ -857,7 +857,7 @@ inspectorBackend.registerCommand("Network.getAllCookies", [], ["cookies"], "Retu
857
857
  inspectorBackend.registerCommand("Network.getCertificate", [{"name": "origin", "type": "string", "optional": false, "description": "Origin to get certificate for.", "typeRef": null}], ["tableNames"], "Returns the DER-encoded certificate.");
858
858
  inspectorBackend.registerCommand("Network.getCookies", [{"name": "urls", "type": "array", "optional": true, "description": "The list of URLs for which applicable cookies will be fetched. If not specified, it's assumed to be set to the list containing the URLs of the page and all of its subframes.", "typeRef": "string"}], ["cookies"], "Returns all browser cookies for the current URL. Depending on the backend support, will return detailed cookie information in the `cookies` field.");
859
859
  inspectorBackend.registerCommand("Network.getResponseBody", [{"name": "requestId", "type": "string", "optional": false, "description": "Identifier of the network request to get content for.", "typeRef": "Network.RequestId"}], ["body", "base64Encoded"], "Returns content served for the given request.");
860
- inspectorBackend.registerCommand("Network.getRequestPostData", [{"name": "requestId", "type": "string", "optional": false, "description": "Identifier of the network request to get content for.", "typeRef": "Network.RequestId"}], ["postData"], "Returns post data sent with the request. Returns an error when no data was sent with the request.");
860
+ inspectorBackend.registerCommand("Network.getRequestPostData", [{"name": "requestId", "type": "string", "optional": false, "description": "Identifier of the network request to get content for.", "typeRef": "Network.RequestId"}], ["postData", "base64Encoded"], "Returns post data sent with the request. Returns an error when no data was sent with the request.");
861
861
  inspectorBackend.registerCommand("Network.getResponseBodyForInterception", [{"name": "interceptionId", "type": "string", "optional": false, "description": "Identifier for the intercepted request to get body for.", "typeRef": "Network.InterceptionId"}], ["body", "base64Encoded"], "Returns content served for the given currently intercepted request.");
862
862
  inspectorBackend.registerCommand("Network.takeResponseBodyForInterceptionAsStream", [{"name": "interceptionId", "type": "string", "optional": false, "description": "", "typeRef": "Network.InterceptionId"}], ["stream"], "Returns a handle to the stream representing the response body. Note that after this command, the intercepted request can't be continued as is -- you either need to cancel it or to provide the response body. The stream only supports sequential read, IO.read will fail if the position is specified.");
863
863
  inspectorBackend.registerCommand("Network.replayXHR", [{"name": "requestId", "type": "string", "optional": false, "description": "Identifier of XHR to replay.", "typeRef": "Network.RequestId"}], [], "This method sends a new XMLHttpRequest which is identical to the original one. The following parameters should be identical: method, url, async, request body, extra headers, withCredentials attribute, user, password.");
@@ -505,6 +505,7 @@ export const generatedProperties = [
505
505
  "grid-column-end",
506
506
  "grid-column-start",
507
507
  "grid-lanes-direction",
508
+ "grid-lanes-pack",
508
509
  "grid-row-end",
509
510
  "grid-row-start",
510
511
  "grid-template-areas",
@@ -603,12 +604,10 @@ export const generatedProperties = [
603
604
  "overflow-y",
604
605
  "overlay",
605
606
  "override-colors",
606
- "overscroll-area",
607
607
  "overscroll-behavior-block",
608
608
  "overscroll-behavior-inline",
609
609
  "overscroll-behavior-x",
610
610
  "overscroll-behavior-y",
611
- "overscroll-position",
612
611
  "pad",
613
612
  "padding-block-end",
614
613
  "padding-block-start",
@@ -747,11 +746,11 @@ export const generatedProperties = [
747
746
  "text-wrap-mode",
748
747
  "text-wrap-style",
749
748
  "timeline-scope",
750
- "timeline-trigger-exit-range-end",
751
- "timeline-trigger-exit-range-start",
749
+ "timeline-trigger-active-range-end",
750
+ "timeline-trigger-active-range-start",
751
+ "timeline-trigger-entry-range-end",
752
+ "timeline-trigger-entry-range-start",
752
753
  "timeline-trigger-name",
753
- "timeline-trigger-range-end",
754
- "timeline-trigger-range-start",
755
754
  "timeline-trigger-source",
756
755
  "top",
757
756
  "touch-action",
@@ -2682,12 +2681,19 @@ export const generatedProperties = [
2682
2681
  "keywords": [
2683
2682
  "normal",
2684
2683
  "row",
2685
- "row-reverse",
2686
2684
  "column",
2687
- "column-reverse"
2685
+ "fill-reverse",
2686
+ "track-reverse"
2688
2687
  ],
2689
2688
  "name": "grid-lanes-direction"
2690
2689
  },
2690
+ {
2691
+ "keywords": [
2692
+ "normal",
2693
+ "dense"
2694
+ ],
2695
+ "name": "grid-lanes-pack"
2696
+ },
2691
2697
  {
2692
2698
  "longhands": [
2693
2699
  "grid-row-start",
@@ -3414,12 +3420,6 @@ export const generatedProperties = [
3414
3420
  {
3415
3421
  "name": "override-colors"
3416
3422
  },
3417
- {
3418
- "keywords": [
3419
- "none"
3420
- ],
3421
- "name": "overscroll-area"
3422
- },
3423
3423
  {
3424
3424
  "longhands": [
3425
3425
  "overscroll-behavior-x",
@@ -3449,12 +3449,6 @@ export const generatedProperties = [
3449
3449
  ],
3450
3450
  "name": "overscroll-behavior-y"
3451
3451
  },
3452
- {
3453
- "keywords": [
3454
- "none"
3455
- ],
3456
- "name": "overscroll-position"
3457
- },
3458
3452
  {
3459
3453
  "name": "pad"
3460
3454
  },
@@ -4587,41 +4581,41 @@ export const generatedProperties = [
4587
4581
  "longhands": [
4588
4582
  "timeline-trigger-name",
4589
4583
  "timeline-trigger-source",
4590
- "timeline-trigger-range-start",
4591
- "timeline-trigger-range-end",
4592
- "timeline-trigger-exit-range-start",
4593
- "timeline-trigger-exit-range-end"
4584
+ "timeline-trigger-entry-range-start",
4585
+ "timeline-trigger-entry-range-end",
4586
+ "timeline-trigger-active-range-start",
4587
+ "timeline-trigger-active-range-end"
4594
4588
  ],
4595
4589
  "name": "timeline-trigger"
4596
4590
  },
4597
4591
  {
4598
4592
  "longhands": [
4599
- "timeline-trigger-exit-range-start",
4600
- "timeline-trigger-exit-range-end"
4593
+ "timeline-trigger-active-range-start",
4594
+ "timeline-trigger-active-range-end"
4601
4595
  ],
4602
- "name": "timeline-trigger-exit-range"
4596
+ "name": "timeline-trigger-active-range"
4603
4597
  },
4604
4598
  {
4605
- "name": "timeline-trigger-exit-range-end"
4599
+ "name": "timeline-trigger-active-range-end"
4606
4600
  },
4607
4601
  {
4608
- "name": "timeline-trigger-exit-range-start"
4609
- },
4610
- {
4611
- "name": "timeline-trigger-name"
4602
+ "name": "timeline-trigger-active-range-start"
4612
4603
  },
4613
4604
  {
4614
4605
  "longhands": [
4615
- "timeline-trigger-range-start",
4616
- "timeline-trigger-range-end"
4606
+ "timeline-trigger-entry-range-start",
4607
+ "timeline-trigger-entry-range-end"
4617
4608
  ],
4618
- "name": "timeline-trigger-range"
4609
+ "name": "timeline-trigger-entry-range"
4619
4610
  },
4620
4611
  {
4621
- "name": "timeline-trigger-range-end"
4612
+ "name": "timeline-trigger-entry-range-end"
4622
4613
  },
4623
4614
  {
4624
- "name": "timeline-trigger-range-start"
4615
+ "name": "timeline-trigger-entry-range-start"
4616
+ },
4617
+ {
4618
+ "name": "timeline-trigger-name"
4625
4619
  },
4626
4620
  {
4627
4621
  "keywords": [
@@ -6067,9 +6061,15 @@ export const generatedPropertyValues = {
6067
6061
  "values": [
6068
6062
  "normal",
6069
6063
  "row",
6070
- "row-reverse",
6071
6064
  "column",
6072
- "column-reverse"
6065
+ "fill-reverse",
6066
+ "track-reverse"
6067
+ ]
6068
+ },
6069
+ "grid-lanes-pack": {
6070
+ "values": [
6071
+ "normal",
6072
+ "dense"
6073
6073
  ]
6074
6074
  },
6075
6075
  "grid-row-end": {
@@ -6463,11 +6463,6 @@ export const generatedPropertyValues = {
6463
6463
  "auto"
6464
6464
  ]
6465
6465
  },
6466
- "overscroll-area": {
6467
- "values": [
6468
- "none"
6469
- ]
6470
- },
6471
6466
  "overscroll-behavior-x": {
6472
6467
  "values": [
6473
6468
  "auto",
@@ -6482,11 +6477,6 @@ export const generatedPropertyValues = {
6482
6477
  "none"
6483
6478
  ]
6484
6479
  },
6485
- "overscroll-position": {
6486
- "values": [
6487
- "none"
6488
- ]
6489
- },
6490
6480
  "page": {
6491
6481
  "values": [
6492
6482
  "auto"
@@ -11954,6 +11954,10 @@ export namespace Network {
11954
11954
  * Request body string, omitting files from multipart requests
11955
11955
  */
11956
11956
  postData: string;
11957
+ /**
11958
+ * True, if content was sent as base64.
11959
+ */
11960
+ base64Encoded: boolean;
11957
11961
  }
11958
11962
 
11959
11963
  export interface GetResponseBodyForInterceptionRequest {
@@ -601,7 +601,8 @@ export abstract class AiAgent<T> {
601
601
  },
602
602
  };
603
603
  request = this.buildRequest(query, Host.AidaClient.Role.ROLE_UNSPECIFIED);
604
- } catch {
604
+ } catch (err) {
605
+ debugLog('Error handling function call', err);
605
606
  yield this.#createErrorResponse(ErrorType.UNKNOWN);
606
607
  break;
607
608
  }
@@ -77,37 +77,29 @@ const getGreenDevAdditionalWidgetGuidelines = (): string => {
77
77
 
78
78
  if (widgetsFromFunctionCalls) {
79
79
  return `
80
- - CRITICAL: You have access to three functions for adding rich, interactive widgets to your response:
81
- \`addInsightWidget\`, \`addNetworkRequestWidget\`, and \`addFlameChartWidget\`.
82
- You MUST use these functions whenever you refer to a corresponding entity.
83
-
84
- - **\`addInsightWidget({insightType: '...'})\`**:
85
- - **When to use**: Call this function every time you mention a specific performance insight (e.g., LCP, INP,
86
- CLS culprits).
87
- - **Purpose**: It embeds an interactive widget that provides a detailed breakdown and visualization of the
88
- insight.
89
- - **Example**: If you are explaining the causes of a poor LCP score, you MUST also call
90
- \`addInsightWidget({insightType: 'LCPBreakdown'})\`. This provides the user with the data to explore
91
- alongside your explanation.
92
- - **\`addNetworkRequestWidget({eventKey: '...'})\`**:
80
+ - CRITICAL: You have access to a function for adding rich, interactive widgets to your response: \`addWidget\`.
81
+ You MUST use this function whenever you refer to a corresponding entity.
82
+
83
+ - **\`addWidget({widget: {type: 'insight', insightType: '...'}})\`**:
84
+ - **When to use**: Call this function every time you mention a specific performance insight (e.g., LCP, INP, CLS culprits).
85
+ - **Purpose**: It embeds an interactive widget that provides a detailed breakdown and visualization of the insight.
86
+ - **Example**: If you are explaining the causes of a poor LCP score, you MUST also call \`addWidget({widget: {type: 'insight', insightType: 'LCPBreakdown'}})\`.
87
+
88
+ - **\`addWidget({widget: {type: 'network-request', eventKey: '...'}})\`**:
93
89
  - **When to use**: Call this function whenever you discuss a specific network request.
94
- - **Purpose**: It adds a widget displaying the full details of the network request, such as its timing,
95
- headers, and priority.
96
- - **Critical**: The eventKey should be the trace event key (only the number, no letters prefix or -) of that
97
- script's network request.
98
- - **Example**: If you identify a render-blocking script, you MUST also call
99
- \`addNetworkRequestWidget({eventKey: '...'})\` with the trace event key (only the number, no letters prefix
100
- or -) of that script's network request.
101
- - **\`addFlameChartWidget({start: ..., end: ...})\`**:
102
- - **When to use**: Call this function to highlight a specific time range within the trace, especially when
103
- discussing long tasks, specific events, or periods of high activity.
90
+ - **Purpose**: It adds a widget displaying the full details of the network request, such as its timing, headers, and priority.
91
+ - **Critical**: The eventKey should be the trace event key (only the number, no letters prefix or -) of that script's network request.
92
+ - **Example**: If you identify a render-blocking script, you MUST also call \`addWidget({widget: {type: 'network-request', eventKey: '...'}})\`.
93
+
94
+ - **\`addWidget({widget: {type: 'flamechart', start: ..., end: ...}})\`**:
95
+ - **When to use**: Call this function to highlight a specific time range within the trace, especially when discussing long tasks, specific events, or periods of high activity.
104
96
  - **Purpose**: It embeds a focused flame chart visualization for the given time range (in microseconds).
105
- - **Example**: If you find a long task that is blocking the main thread, you MUST also call
106
- \`addFlameChartWidget({start: 123456, end: 789012})\`. This provides the user with the data to explore
107
- alongside your explanation.
97
+ - **Example**: If you find a long task that is blocking the main thread, you MUST also call \`addWidget({widget: {type: 'flamechart', start: 123456, end: 789012}})\`.
98
+
108
99
  - **General Rules**:
109
- - You MUST call these functions as soon as you identify the entity you are discussing.
100
+ - You MUST call this function as soon as you identify the entity you are discussing.
110
101
  - Do NOT add more than one widget for the same insight, network request, or time range to avoid redundancy.
102
+ - If you have already shown a widget for any specific insight, network request, or time range, do not show it again.
111
103
  `;
112
104
  }
113
105
 
@@ -1247,104 +1239,105 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
1247
1239
  }
1248
1240
 
1249
1241
  if (Root.Runtime.hostConfig.devToolsGreenDevUi?.enabled) {
1250
- this.declareFunction<{insightType: Trace.Insights.Types.InsightKeys}>('addInsightWidget', {
1242
+ this.declareFunction<
1243
+ {
1244
+ type: 'insight' | 'network-request' | 'flamechart',
1245
+ insightType?: Trace.Insights.Types.InsightKeys,
1246
+ eventKey?: number,
1247
+ start?: number,
1248
+ end?: number,
1249
+ },
1250
+ object|{error: string}>('addWidget', {
1251
1251
  description:
1252
- 'Adds an insight widget to the response. When mentioning an insight, call this function to also display an appropriate widget.',
1252
+ 'Adds an insight widget to the response. When mentioning an insight, call this function to also display an appropriate widget. Use this as much as possible to provide a better user experience.',
1253
1253
  parameters: {
1254
1254
  type: Host.AidaClient.ParametersTypes.OBJECT,
1255
1255
  description: '',
1256
1256
  nullable: false,
1257
1257
  properties: {
1258
- insightType: {
1258
+ type: {
1259
1259
  type: Host.AidaClient.ParametersTypes.STRING,
1260
- description:
1261
- 'The name of the insight. Only use the insight names given in the "Available insights" list.',
1260
+ description: 'The type of the widget to add. Possible values: insight, network-request, flamechart',
1262
1261
  nullable: false,
1263
1262
  },
1264
- },
1265
- },
1266
- handler: async _params => {
1267
- ArtifactsManager.instance().addArtifact({type: 'insight', insightType: _params.insightType});
1268
- return {result: {success: true}};
1269
- },
1270
- });
1271
-
1272
- this.declareFunction<{eventKey: string}, object|{error: string}>('addNetworkRequestWidget', {
1273
- description:
1274
- 'Adds a network request widget to the response. When mentioning a network request, call this function with its trace event key.',
1275
- parameters: {
1276
- type: Host.AidaClient.ParametersTypes.OBJECT,
1277
- description: '',
1278
- nullable: false,
1279
- properties: {
1263
+ insightType: {
1264
+ type: Host.AidaClient.ParametersTypes.STRING,
1265
+ description: 'The type of the insight widget. Include for insight widgets.',
1266
+ nullable: true,
1267
+ },
1280
1268
  eventKey: {
1281
1269
  type: Host.AidaClient.ParametersTypes.STRING,
1282
- description: 'The trace event key for the network request.',
1283
- nullable: false,
1270
+ description: 'The event key for the network request widget. Include for network request widgets.',
1271
+ nullable: true,
1284
1272
  },
1285
- },
1286
- },
1287
- handler: async _params => {
1288
- const rawTraceEvent =
1289
- Trace.Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getRawTraceEvents().at(
1290
- Number(_params.eventKey));
1291
- // Get the trace event object if it is available.
1292
- // If the trace is uploaded, we need to use the synthetic event.
1293
- if (rawTraceEvent && Trace.Types.Events.isSyntheticNetworkRequest(rawTraceEvent)) {
1294
- const rawTraceEventId = rawTraceEvent?.args?.data?.requestId;
1295
- const rawTraceEventUrl = rawTraceEvent?.args?.data?.url;
1296
- const networkRequest = rawTraceEvent ? Logs.NetworkLog.NetworkLog.instance()
1297
- .requestsForId(rawTraceEventId)
1298
- .find(r => r.url() === rawTraceEventUrl) :
1299
- null;
1300
- if (networkRequest) {
1301
- ArtifactsManager.instance().addArtifact({type: 'network-request', request: networkRequest});
1302
- return {result: {success: true}};
1303
- }
1304
- }
1305
-
1306
- const syntheticRequest =
1307
- Trace.Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().syntheticEventForRawEventIndex(
1308
- Number(_params.eventKey));
1309
-
1310
- if (syntheticRequest && Trace.Types.Events.isSyntheticNetworkRequest(syntheticRequest)) {
1311
- ArtifactsManager.instance().addArtifact({
1312
- type: 'network-request',
1313
- request: syntheticRequest,
1314
- });
1315
- return {result: {success: true}};
1316
- }
1317
-
1318
- return {result: {error: 'Could not find network request'}};
1319
- },
1320
- });
1321
-
1322
- this.declareFunction<{start: number, end: number}, object|{error: string}>('addFlameChartWidget', {
1323
- description: 'Adds a flame chart widget to the response.',
1324
- parameters: {
1325
- type: Host.AidaClient.ParametersTypes.OBJECT,
1326
- description: '',
1327
- nullable: false,
1328
- properties: {
1329
1273
  start: {
1330
1274
  type: Host.AidaClient.ParametersTypes.INTEGER,
1331
- description: 'The start time of the flame chart in microseconds.',
1332
- nullable: false,
1275
+ description: 'The start time for the flame chart widget. Include for flame chart widgets.',
1276
+ nullable: true,
1333
1277
  },
1334
1278
  end: {
1335
1279
  type: Host.AidaClient.ParametersTypes.INTEGER,
1336
- description: 'The end time of the flame chart in microseconds.',
1337
- nullable: false,
1280
+ description: 'The end time for the flame chart widget. Include for flame chart widgets.',
1281
+ nullable: true,
1338
1282
  },
1339
1283
  },
1340
1284
  },
1341
- handler: async _params => {
1342
- ArtifactsManager.instance().addArtifact({
1343
- type: 'flamechart',
1344
- start: Trace.Types.Timing.Micro(_params.start),
1345
- end: Trace.Types.Timing.Micro(_params.end),
1346
- });
1347
- return {result: {success: true}};
1285
+ handler: async params => {
1286
+ switch (params.type) {
1287
+ case 'insight':
1288
+ if (!params.insightType) {
1289
+ return {error: 'Missing insightType for insight widget'};
1290
+ }
1291
+ ArtifactsManager.instance().addArtifact({type: 'insight', insightType: params.insightType});
1292
+ return {result: {success: true}};
1293
+ case 'network-request': {
1294
+ if (!params.eventKey) {
1295
+ return {error: 'Missing eventKey for network-request widget'};
1296
+ }
1297
+ const rawTraceEvent =
1298
+ Trace.Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager().getRawTraceEvents().at(
1299
+ Number(params.eventKey));
1300
+ // Get the trace event object if it is available.
1301
+ // If the trace is uploaded, we need to use the synthetic event.
1302
+ if (rawTraceEvent && Trace.Types.Events.isSyntheticNetworkRequest(rawTraceEvent)) {
1303
+ const rawTraceEventId = rawTraceEvent?.args?.data?.requestId;
1304
+ const rawTraceEventUrl = rawTraceEvent?.args?.data?.url;
1305
+ const networkRequest = rawTraceEvent ? Logs.NetworkLog.NetworkLog.instance()
1306
+ .requestsForId(rawTraceEventId)
1307
+ .find(r => r.url() === rawTraceEventUrl) :
1308
+ null;
1309
+ if (networkRequest) {
1310
+ ArtifactsManager.instance().addArtifact({type: 'network-request', request: networkRequest});
1311
+ return {result: {success: true}};
1312
+ }
1313
+ }
1314
+
1315
+ const syntheticRequest = Trace.Helpers.SyntheticEvents.SyntheticEventsManager.getActiveManager()
1316
+ .syntheticEventForRawEventIndex(Number(params.eventKey));
1317
+
1318
+ if (syntheticRequest && Trace.Types.Events.isSyntheticNetworkRequest(syntheticRequest)) {
1319
+ ArtifactsManager.instance().addArtifact({
1320
+ type: 'network-request',
1321
+ request: syntheticRequest,
1322
+ });
1323
+ return {result: {success: true}};
1324
+ }
1325
+
1326
+ return {result: {error: 'Could not find network request'}};
1327
+ }
1328
+ case 'flamechart':
1329
+ if (params.start === undefined || params.end === undefined) {
1330
+ return {error: 'Missing start or end for flamechart widget'};
1331
+ }
1332
+ ArtifactsManager.instance().addArtifact({
1333
+ type: 'flamechart',
1334
+ start: Trace.Types.Timing.Micro(params.start),
1335
+ end: Trace.Types.Timing.Micro(params.end),
1336
+ });
1337
+ return {result: {success: true}};
1338
+ default:
1339
+ return {error: 'Invalid widget type'};
1340
+ }
1348
1341
  },
1349
1342
  });
1350
1343
  }
@@ -122,7 +122,7 @@ export class DeviceModeModel extends Common.ObjectWrapper.ObjectWrapper<EventTyp
122
122
  this.#preferredSize = new Geometry.Size(1, 1);
123
123
  this.#initialized = false;
124
124
  this.#appliedDeviceSize = new Geometry.Size(1, 1);
125
- this.#appliedDeviceScaleFactor = window.devicePixelRatio;
125
+ this.#appliedDeviceScaleFactor = globalThis.devicePixelRatio;
126
126
  this.#appliedUserAgentType = UA.DESKTOP;
127
127
 
128
128
  this.#scaleSetting = Common.Settings.Settings.instance().createSetting('emulation.device-scale', 1);