chrome-devtools-frontend 1.0.1662965 → 1.0.1664496

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 (273) hide show
  1. package/.agents/skills/{creating-a-model → devtools-model-management}/SKILL.md +0 -1
  2. package/.agents/skills/devtools-ux-writing-refactor/SKILL.md +2 -1
  3. package/.agents/skills/fixing-skipped-tests/SKILL.md +3 -3
  4. package/.agents/skills/merging-devtools-module/SKILL.md +1 -1
  5. package/.agents/skills/migrate-chromium-test/SKILL.md +3 -2
  6. package/.agents/skills/repro-flaky-tests/SKILL.md +71 -31
  7. package/.agents/skills/ui-eng-vision-widget-promoter/SKILL.md +1 -0
  8. package/docs/ui_engineering.md +2 -0
  9. package/eslint.config.mjs +1 -0
  10. package/front_end/core/common/Settings.ts +75 -0
  11. package/front_end/core/protocol_client/PuppeteerDevToolsConnection.ts +112 -0
  12. package/front_end/core/sdk/CPUProfilerModel.ts +21 -13
  13. package/front_end/core/sdk/CSSContainerQuery.ts +1 -1
  14. package/front_end/core/sdk/CSSLayer.ts +1 -1
  15. package/front_end/core/sdk/CSSMedia.ts +1 -1
  16. package/front_end/core/sdk/CSSModel.ts +1 -1
  17. package/front_end/core/sdk/CSSNavigation.ts +1 -1
  18. package/front_end/core/sdk/CSSProperty.ts +1 -1
  19. package/front_end/core/sdk/CSSQuery.ts +1 -1
  20. package/front_end/core/sdk/CSSRule.ts +1 -1
  21. package/front_end/core/sdk/CSSScope.ts +1 -1
  22. package/front_end/core/sdk/CSSStartingStyle.ts +1 -1
  23. package/front_end/core/sdk/CSSStyleDeclaration.ts +1 -1
  24. package/front_end/core/sdk/CSSStyleSheetHeader.ts +1 -1
  25. package/front_end/core/sdk/CSSSupports.ts +1 -1
  26. package/front_end/core/sdk/CompilerSourceMappingContentProvider.ts +1 -1
  27. package/front_end/core/sdk/NetworkManager.ts +1 -1
  28. package/front_end/core/sdk/NetworkRequest.ts +7 -7
  29. package/front_end/core/sdk/Resource.ts +1 -1
  30. package/front_end/core/sdk/ScopeTreeCache.ts +1 -1
  31. package/front_end/core/sdk/Script.ts +1 -1
  32. package/front_end/core/sdk/ServerSentEvents.ts +1 -1
  33. package/front_end/core/sdk/SourceMap.ts +1 -1
  34. package/front_end/core/sdk/SourceMapScopesInfo.ts +1 -1
  35. package/front_end/core/sdk/sdk-meta.ts +3 -3
  36. package/front_end/{models → core}/text_utils/ContentProvider.ts +4 -6
  37. package/front_end/{models → core}/text_utils/StaticContentProvider.ts +4 -6
  38. package/front_end/{models → core}/text_utils/StreamingContentData.ts +1 -2
  39. package/front_end/{models → core}/text_utils/TextRange.ts +6 -3
  40. package/front_end/{models → core}/text_utils/TextUtils.ts +7 -7
  41. package/front_end/{models → core}/text_utils/WasmDisassembly.ts +2 -2
  42. package/front_end/core/text_utils/text_utils.ts +27 -0
  43. package/front_end/entrypoints/formatter_worker/AcornTokenizer.ts +1 -1
  44. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +1 -1
  45. package/front_end/entrypoints/main/MainImpl.ts +14 -1
  46. package/front_end/foundation/Universe.ts +1 -1
  47. package/front_end/models/ai_assistance/AgentProject.ts +1 -1
  48. package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +3 -6
  49. package/front_end/models/ai_assistance/agents/AiAgent.ts +1 -1
  50. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +19 -11
  51. package/front_end/models/ai_assistance/agents/PerformanceAgent.snapshot.txt +2 -2
  52. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +23 -10
  53. package/front_end/models/ai_assistance/agents/StorageAgent.ts +19 -18
  54. package/front_end/models/ai_assistance/agents/StylingAgent.ts +2 -3
  55. package/front_end/models/ai_assistance/contexts/FileContext.ts +7 -3
  56. package/front_end/models/ai_assistance/contexts/PerformanceTraceContext.ts +39 -11
  57. package/front_end/models/ai_assistance/data_formatters/FileFormatter.ts +6 -3
  58. package/front_end/models/ai_assistance/data_formatters/NetworkRequestFormatter.ts +1 -1
  59. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +4 -4
  60. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +8 -8
  61. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +76 -3
  62. package/front_end/models/ai_assistance/tools/ListNetworkRequests.ts +11 -1
  63. package/front_end/models/badges/AiExplorerBadge.ts +8 -3
  64. package/front_end/models/badges/Badge.ts +1 -0
  65. package/front_end/models/badges/UserBadges.ts +11 -5
  66. package/front_end/models/bindings/CompilerScriptMapping.ts +1 -1
  67. package/front_end/models/bindings/ContentProviderBasedProject.ts +1 -1
  68. package/front_end/models/bindings/DebuggerLanguagePlugins.ts +2 -2
  69. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +1 -1
  70. package/front_end/models/bindings/DefaultScriptMapping.ts +1 -1
  71. package/front_end/models/bindings/FileUtils.ts +1 -1
  72. package/front_end/models/bindings/PresentationConsoleMessageHelper.ts +7 -10
  73. package/front_end/models/bindings/ResourceMapping.ts +1 -1
  74. package/front_end/models/bindings/ResourceScriptMapping.ts +1 -1
  75. package/front_end/models/bindings/SASSSourceMapping.ts +1 -1
  76. package/front_end/models/bindings/StylesSourceMapping.ts +1 -1
  77. package/front_end/models/breakpoints/BreakpointManager.ts +1 -1
  78. package/front_end/models/crux-manager/CrUXManager.ts +1 -1
  79. package/front_end/models/emulation/EmulatedDevices.ts +3 -2
  80. package/front_end/models/har/Importer.ts +1 -1
  81. package/front_end/models/har/Writer.ts +1 -1
  82. package/front_end/models/issues_manager/IssueAggregator.ts +9 -0
  83. package/front_end/models/issues_manager/IssuesManager.ts +5 -0
  84. package/front_end/models/issues_manager/LazyLoadImageIssue.ts +76 -0
  85. package/front_end/models/issues_manager/descriptions/lazyLoadImageZeroSize.md +7 -0
  86. package/front_end/models/issues_manager/issues_manager.ts +2 -0
  87. package/front_end/models/javascript_metadata/NativeFunctions.js +9 -10
  88. package/front_end/models/live-metrics/LiveMetrics.ts +2 -3
  89. package/front_end/models/logs/NetworkLog.ts +4 -3
  90. package/front_end/models/logs/logs-meta.ts +3 -3
  91. package/front_end/models/network_time_calculator/NetworkTimeCalculator.ts +4 -4
  92. package/front_end/models/persistence/Automapping.ts +1 -1
  93. package/front_end/models/persistence/AutomaticFileSystemWorkspaceBinding.ts +2 -2
  94. package/front_end/models/persistence/FileSystemWorkspaceBinding.ts +1 -1
  95. package/front_end/models/persistence/IsolatedFileSystem.ts +2 -2
  96. package/front_end/models/persistence/NetworkPersistenceManager.ts +1 -1
  97. package/front_end/models/persistence/PersistenceImpl.ts +1 -1
  98. package/front_end/models/persistence/PlatformFileSystem.ts +1 -1
  99. package/front_end/models/source_map_scopes/FunctionCodeResolver.ts +1 -1
  100. package/front_end/models/source_map_scopes/NamesResolver.ts +1 -1
  101. package/front_end/models/text_utils/text_utils.ts +2 -24
  102. package/front_end/models/trace/insights/ImageDelivery.ts +2 -2
  103. package/front_end/models/trace/insights/LegacyJavaScript.ts +1 -1
  104. package/front_end/models/trace/insights/RenderBlocking.ts +1 -1
  105. package/front_end/models/trace/insights/ThirdParties.ts +1 -1
  106. package/front_end/models/workspace/FileManager.ts +1 -1
  107. package/front_end/models/workspace/UISourceCode.ts +1 -1
  108. package/front_end/models/workspace/WorkspaceImpl.ts +1 -1
  109. package/front_end/models/workspace_diff/WorkspaceDiff.ts +1 -1
  110. package/front_end/panels/accessibility/AccessibilityNodeView.ts +1 -1
  111. package/front_end/panels/accessibility/AccessibilityStrings.ts +2 -2
  112. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +1 -1
  113. package/front_end/panels/ai_assistance/ExportConversation.ts +1 -1
  114. package/front_end/panels/ai_assistance/ai_assistance-meta.ts +1 -1
  115. package/front_end/panels/ai_assistance/components/ChatMessage.ts +1 -1
  116. package/front_end/panels/application/AppManifestView.ts +4 -4
  117. package/front_end/panels/application/ApplicationPanelSidebar.ts +1 -2
  118. package/front_end/panels/application/CrashReportContextView.ts +1 -1
  119. package/front_end/panels/application/DOMStorageItemsView.ts +1 -1
  120. package/front_end/panels/application/DeviceBoundSessionsView.ts +4 -4
  121. package/front_end/panels/application/ExtensionStorageItemsView.ts +1 -1
  122. package/front_end/panels/application/FrameDetailsView.ts +1 -1
  123. package/front_end/panels/application/ServiceWorkerCacheTreeElement.ts +12 -2
  124. package/front_end/panels/application/ServiceWorkerCacheViews.ts +1 -1
  125. package/front_end/panels/application/application.ts +2 -0
  126. package/front_end/panels/application/components/BackForwardCacheView.ts +21 -5
  127. package/front_end/panels/application/components/CrashReportContextGrid.ts +1 -1
  128. package/front_end/panels/application/components/TrustTokensView.ts +2 -2
  129. package/front_end/panels/application/preloading/PreloadingView.ts +1 -1
  130. package/front_end/panels/application/preloading/components/PreloadingDisabledInfobar.ts +2 -2
  131. package/front_end/panels/application/preloading/components/PreloadingString.ts +2 -2
  132. package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +4 -4
  133. package/front_end/panels/autofill/AutofillView.ts +1 -1
  134. package/front_end/panels/common/AiCodeCompletionTeaser.ts +1 -1
  135. package/front_end/panels/common/ExtensionServer.ts +1 -1
  136. package/front_end/panels/console/ConsoleFilter.ts +1 -1
  137. package/front_end/panels/console/ConsoleSidebar.ts +1 -1
  138. package/front_end/panels/console/ConsoleView.ts +1 -1
  139. package/front_end/panels/console/ConsoleViewMessage.ts +1 -1
  140. package/front_end/panels/console/PromptBuilder.ts +1 -1
  141. package/front_end/panels/coverage/CoverageDecorationManager.ts +9 -1
  142. package/front_end/panels/coverage/CoverageModel.ts +1 -1
  143. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +1 -1
  144. package/front_end/panels/developer_resources/DeveloperResourcesListView.ts +1 -1
  145. package/front_end/panels/developer_resources/DeveloperResourcesView.ts +1 -1
  146. package/front_end/panels/elements/AccessibilityTreeView.ts +38 -3
  147. package/front_end/panels/elements/AdoptedStyleSheetTreeElement.ts +1 -1
  148. package/front_end/panels/elements/ElementIssueUtils.ts +2 -2
  149. package/front_end/panels/elements/ElementsTreeElement.ts +10 -3
  150. package/front_end/panels/elements/StandaloneStylesContainer.ts +1 -1
  151. package/front_end/panels/elements/StylePropertiesSection.ts +1 -1
  152. package/front_end/panels/elements/StylePropertyTreeElement.ts +1 -1
  153. package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +1 -1
  154. package/front_end/panels/elements/StylesContainer.ts +1 -1
  155. package/front_end/panels/elements/StylesSidebarPane.ts +1 -1
  156. package/front_end/panels/elements/components/CSSPropertyDocsView.ts +1 -1
  157. package/front_end/panels/explain/components/ConsoleInsight.ts +2 -2
  158. package/front_end/panels/issues/AffectedLazyLoadImagesView.ts +76 -0
  159. package/front_end/panels/issues/AffectedResourcesView.ts +1 -1
  160. package/front_end/panels/issues/CorsIssueDetailsView.ts +1 -1
  161. package/front_end/panels/issues/IssueView.ts +2 -0
  162. package/front_end/panels/issues/issues.ts +2 -0
  163. package/front_end/panels/layer_viewer/Layers3DView.ts +1 -1
  164. package/front_end/panels/lighthouse/LighthouseController.ts +5 -0
  165. package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +1 -1
  166. package/front_end/panels/network/BinaryResourceView.ts +1 -1
  167. package/front_end/panels/network/NetworkDataGridNode.ts +29 -7
  168. package/front_end/panels/network/NetworkLogView.ts +1 -1
  169. package/front_end/panels/network/NetworkLogViewColumns.ts +6 -6
  170. package/front_end/panels/network/NetworkPanel.ts +4 -4
  171. package/front_end/panels/network/NetworkSearchScope.ts +1 -1
  172. package/front_end/panels/network/RequestConditionsDrawer.ts +1 -1
  173. package/front_end/panels/network/RequestHTMLView.ts +1 -1
  174. package/front_end/panels/network/RequestPayloadView.ts +1 -1
  175. package/front_end/panels/network/RequestPreviewView.ts +1 -1
  176. package/front_end/panels/network/RequestResponseView.ts +1 -1
  177. package/front_end/panels/network/ResourceChunkView.ts +1 -1
  178. package/front_end/panels/network/ResourceDirectSocketChunkView.ts +1 -1
  179. package/front_end/panels/network/ResourceWebSocketFrameView.ts +1 -1
  180. package/front_end/panels/network/components/ResponseHeaderSection.ts +1 -1
  181. package/front_end/panels/network/forward/UIRequestLocation.ts +1 -1
  182. package/front_end/panels/network/network-meta.ts +3 -3
  183. package/front_end/panels/profiler/HeapProfileView.ts +6 -6
  184. package/front_end/panels/profiler/HeapSnapshotView.ts +1 -1
  185. package/front_end/panels/profiler/ProfileDataGrid.ts +12 -8
  186. package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +1 -1
  187. package/front_end/panels/recorder/RecorderPanel.ts +493 -381
  188. package/front_end/panels/recorder/RecordingListView.ts +8 -37
  189. package/front_end/panels/recorder/RecordingView.ts +54 -27
  190. package/front_end/panels/recorder/SelectorPicker.ts +0 -13
  191. package/front_end/panels/recorder/StepEditor.ts +6 -14
  192. package/front_end/panels/recorder/StepView.ts +36 -105
  193. package/front_end/panels/search/SearchResultsPane.ts +1 -1
  194. package/front_end/panels/security/SecurityPanel.ts +3 -3
  195. package/front_end/panels/settings/AISettingsTab.ts +4 -4
  196. package/front_end/panels/settings/components/SyncSection.ts +4 -4
  197. package/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +3 -3
  198. package/front_end/panels/snippets/ScriptSnippetFileSystem.ts +1 -1
  199. package/front_end/panels/sources/BreakpointsView.ts +1 -1
  200. package/front_end/panels/sources/CoveragePlugin.ts +1 -1
  201. package/front_end/panels/sources/DebuggerPlugin.ts +4 -4
  202. package/front_end/panels/sources/FilteredUISourceCodeListProvider.ts +27 -3
  203. package/front_end/panels/sources/NavigatorView.ts +1 -1
  204. package/front_end/panels/sources/PersistenceActions.ts +1 -1
  205. package/front_end/panels/sources/SourcesNavigator.ts +1 -1
  206. package/front_end/panels/sources/SourcesSearchScope.ts +1 -1
  207. package/front_end/panels/sources/TabbedEditorContainer.ts +3 -3
  208. package/front_end/panels/sources/UISourceCodeFrame.ts +1 -1
  209. package/front_end/panels/sources/components/HeadersView.ts +1 -1
  210. package/front_end/panels/sources/filteredUISourceCodeListProvider.css +12 -1
  211. package/front_end/panels/sources/sources-meta.ts +1 -1
  212. package/front_end/panels/timeline/StatusDialog.ts +1 -1
  213. package/front_end/panels/timeline/TimelineController.ts +24 -3
  214. package/front_end/panels/timeline/TimelinePanel.ts +116 -25
  215. package/front_end/panels/timeline/TimelineSelectorStatsView.ts +2 -2
  216. package/front_end/panels/timeline/TimelineUIUtils.ts +1 -1
  217. package/front_end/panels/timeline/components/CWVMetrics.ts +1 -1
  218. package/front_end/panels/timeline/components/IgnoreListSetting.ts +1 -1
  219. package/front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts +2 -2
  220. package/front_end/panels/timeline/timeline-meta.ts +13 -0
  221. package/front_end/services/tracing/TracingManager.ts +27 -2
  222. package/front_end/third_party/chromium/README.chromium +1 -1
  223. package/front_end/third_party/lighthouse/README.chromium +2 -2
  224. package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +1418 -1413
  225. package/front_end/third_party/lighthouse/locales/en-US.json +12 -6
  226. package/front_end/third_party/lighthouse/locales/en-XL.json +12 -6
  227. package/front_end/third_party/lighthouse/report-assets/report-generator.mjs +1 -1
  228. package/front_end/third_party/puppeteer/puppeteer.ts +20 -1
  229. package/front_end/ui/components/highlighting/HighlightElement.ts +4 -1
  230. package/front_end/ui/components/highlighting/HighlightManager.ts +1 -1
  231. package/front_end/ui/components/highlighting/MarkupHighlight.ts +1 -1
  232. package/front_end/ui/components/markdown_view/MarkdownView.ts +46 -2
  233. package/front_end/ui/components/markdown_view/markdownView.css +23 -0
  234. package/front_end/ui/components/text_editor/config.ts +1 -1
  235. package/front_end/ui/components/tree_outline/TreeOutline.ts +7 -1
  236. package/front_end/ui/legacy/Infobar.ts +1 -1
  237. package/front_end/ui/legacy/InspectorView.ts +12 -7
  238. package/front_end/ui/legacy/SuggestBox.ts +1 -1
  239. package/front_end/ui/legacy/TextPrompt.ts +1 -1
  240. package/front_end/ui/legacy/Toolbar.ts +5 -2
  241. package/front_end/ui/legacy/Treeoutline.ts +26 -7
  242. package/front_end/ui/legacy/components/color_picker/Spectrum.ts +1 -1
  243. package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +1 -1
  244. package/front_end/ui/legacy/components/data_grid/ViewportDataGrid.ts +1 -1
  245. package/front_end/ui/legacy/components/data_grid/dataGrid.css +1 -1
  246. package/front_end/ui/legacy/components/inline_editor/AnimationTimingUI.ts +27 -13
  247. package/front_end/ui/legacy/components/inline_editor/BezierEditor.ts +5 -2
  248. package/front_end/ui/legacy/components/inline_editor/CSSLinearEasingModel.ts +23 -0
  249. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +161 -54
  250. package/front_end/ui/legacy/components/quick_open/FilteredListWidget.ts +1 -1
  251. package/front_end/ui/legacy/components/source_frame/BinaryResourceViewFactory.ts +1 -1
  252. package/front_end/ui/legacy/components/source_frame/FontView.ts +1 -1
  253. package/front_end/ui/legacy/components/source_frame/ImageView.ts +1 -1
  254. package/front_end/ui/legacy/components/source_frame/JSONView.ts +105 -115
  255. package/front_end/ui/legacy/components/source_frame/PreviewFactory.ts +1 -1
  256. package/front_end/ui/legacy/components/source_frame/ResourceSourceFrame.ts +1 -1
  257. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +3 -3
  258. package/front_end/ui/legacy/components/source_frame/StreamingContentHexView.ts +1 -1
  259. package/front_end/ui/legacy/components/source_frame/XMLView.ts +5 -1
  260. package/front_end/ui/legacy/components/source_frame/jsonView.css +4 -0
  261. package/front_end/ui/legacy/components/utils/Linkifier.ts +1 -1
  262. package/front_end/ui/legacy/inspectorCommon.css +6 -2
  263. package/front_end/ui/settings/SettingUIRegistration.ts +105 -0
  264. package/front_end/ui/settings/settings.ts +9 -0
  265. package/front_end/ui/visual_logging/KnownContextValues.ts +13 -0
  266. package/mcp/mcp.ts +1 -0
  267. package/package.json +1 -1
  268. /package/.agents/skills/{verification → devtools-verification}/SKILL.md +0 -0
  269. /package/front_end/{models → core}/text_utils/CodeMirrorUtils.ts +0 -0
  270. /package/front_end/{models → core}/text_utils/ContentData.ts +0 -0
  271. /package/front_end/{models → core}/text_utils/Text.ts +0 -0
  272. /package/front_end/{models → core}/text_utils/TextCursor.ts +0 -0
  273. /package/front_end/{models → core}/text_utils/TextUtils.snapshot.txt +0 -0
@@ -3,10 +3,10 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import type * as Protocol from '../../generated/protocol.js';
6
- import * as TextUtils from '../../models/text_utils/text_utils.js';
7
6
  import * as Common from '../common/common.js';
8
7
  import * as i18n from '../i18n/i18n.js';
9
8
  import * as Platform from '../platform/platform.js';
9
+ import * as TextUtils from '../text_utils/text_utils.js';
10
10
 
11
11
  import type {CSSModel} from './CSSModel.js';
12
12
  import {DeferredDOMNode} from './DOMModel.js';
@@ -3,7 +3,7 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import type * as Protocol from '../../generated/protocol.js';
6
- import * as TextUtils from '../../models/text_utils/text_utils.js';
6
+ import * as TextUtils from '../text_utils/text_utils.js';
7
7
 
8
8
  import type {CSSModel} from './CSSModel.js';
9
9
  import {CSSQuery} from './CSSQuery.js';
@@ -2,10 +2,10 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
- import * as TextUtils from '../../models/text_utils/text_utils.js';
6
5
  import type * as Common from '../common/common.js';
7
6
  import * as i18n from '../i18n/i18n.js';
8
7
  import type * as Platform from '../platform/platform.js';
8
+ import * as TextUtils from '../text_utils/text_utils.js';
9
9
 
10
10
  import type {PageResourceLoader, PageResourceLoadInitiator} from './PageResourceLoader.js';
11
11
 
@@ -4,11 +4,11 @@
4
4
 
5
5
  import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
6
6
  import * as Protocol from '../../generated/protocol.js';
7
- import * as TextUtils from '../../models/text_utils/text_utils.js';
8
7
  import * as Common from '../common/common.js';
9
8
  import * as i18n from '../i18n/i18n.js';
10
9
  import * as Platform from '../platform/platform.js';
11
10
  import * as Root from '../root/root.js';
11
+ import * as TextUtils from '../text_utils/text_utils.js';
12
12
 
13
13
  import {Cookie} from './Cookie.js';
14
14
  import {
@@ -3,10 +3,10 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import * as Protocol from '../../generated/protocol.js';
6
- import * as TextUtils from '../../models/text_utils/text_utils.js';
7
6
  import * as Common from '../common/common.js';
8
7
  import * as i18n from '../i18n/i18n.js';
9
8
  import * as Platform from '../platform/platform.js';
9
+ import * as TextUtils from '../text_utils/text_utils.js';
10
10
 
11
11
  import {Attribute, type Cookie} from './Cookie.js';
12
12
  import {CookieModel} from './CookieModel.js';
@@ -33,11 +33,11 @@ const UIStrings = {
33
33
  /**
34
34
  * @description Tooltip to explain why a cookie was blocked
35
35
  */
36
- notOnPath: 'This cookie was blocked because its path was not an exact match for or a superdirectory of the request url\'s path.',
36
+ notOnPath: 'This cookie was blocked because its path was not an exact match for or a superdirectory of the request urls path.',
37
37
  /**
38
38
  * @description Tooltip to explain why a cookie was blocked
39
39
  */
40
- domainMismatch: 'This cookie was blocked because neither did the request URL\'s domain exactly match the cookie\'s domain, nor was the request URL\'s domain a subdomain of the cookie\'s Domain attribute value.',
40
+ domainMismatch: 'This cookie was blocked because neither did the request URLs domain exactly match the cookies domain, nor was the request URLs domain a subdomain of the cookies Domain attribute value.',
41
41
  /**
42
42
  * @description Tooltip to explain why a cookie was blocked
43
43
  */
@@ -49,7 +49,7 @@ const UIStrings = {
49
49
  /**
50
50
  * @description Tooltip to explain why a cookie was blocked
51
51
  */
52
- sameSiteUnspecifiedTreatedAsLax: 'This cookie didn\'t specify a "`SameSite`" attribute when it was stored and was defaulted to "SameSite=Lax," and was blocked because the request was made from a different site and was not initiated by a top-level navigation. The cookie had to have been set with "`SameSite=None`" to enable cross-site usage.',
52
+ sameSiteUnspecifiedTreatedAsLax: 'This cookie didnt specify a "`SameSite`" attribute when it was stored and was defaulted to "SameSite=Lax," and was blocked because the request was made from a different site and was not initiated by a top-level navigation. The cookie had to have been set with "`SameSite=None`" to enable cross-site usage.',
53
53
  /**
54
54
  * @description Tooltip to explain why a cookie was blocked
55
55
  */
@@ -77,7 +77,7 @@ const UIStrings = {
77
77
  /**
78
78
  * @description Tooltip to explain why a cookie was blocked due to Schemeful Same-Site
79
79
  */
80
- schemefulSameSiteUnspecifiedTreatedAsLax: 'This cookie didn\'t specify a "`SameSite`" attribute when it was stored, was defaulted to "`SameSite=Lax"`, and was blocked because the request was cross-site and was not initiated by a top-level navigation. This request is considered cross-site because the URL has a different scheme than the current site.',
80
+ schemefulSameSiteUnspecifiedTreatedAsLax: 'This cookie didnt specify a "`SameSite`" attribute when it was stored, was defaulted to "`SameSite=Lax"`, and was blocked because the request was cross-site and was not initiated by a top-level navigation. This request is considered cross-site because the URL has a different scheme than the current site.',
81
81
  /**
82
82
  * @description Tooltip to explain why a cookie was blocked due to exceeding the maximum size
83
83
  */
@@ -114,7 +114,7 @@ const UIStrings = {
114
114
  /**
115
115
  * @description Tooltip to explain why a cookie was blocked due to Schemeful Same-Site
116
116
  */
117
- thisSetcookieDidntSpecifyASamesite: 'This `Set-Cookie` header didn\'t specify a "`SameSite`" attribute, was defaulted to "`SameSite=Lax"`, and was blocked because it came from a cross-site response which was not the response to a top-level navigation. This response is considered cross-site because the URL has a different scheme than the current site.',
117
+ thisSetcookieDidntSpecifyASamesite: 'This `Set-Cookie` header didnt specify a "`SameSite`" attribute, was defaulted to "`SameSite=Lax"`, and was blocked because it came from a cross-site response which was not the response to a top-level navigation. This response is considered cross-site because the URL has a different scheme than the current site.',
118
118
  /**
119
119
  * @description Tooltip to explain why an attempt to set a cookie via a `Set-Cookie` HTTP header on a request's response was blocked.
120
120
  */
@@ -127,7 +127,7 @@ const UIStrings = {
127
127
  /**
128
128
  * @description Tooltip to explain why an attempt to set a cookie via a `Set-Cookie` HTTP header on a request's response was blocked.
129
129
  */
130
- blockedReasonSameSiteUnspecifiedTreatedAsLax: 'This `Set-Cookie` header didn\'t specify a "`SameSite`" attribute and was defaulted to "`SameSite=Lax,`" and was blocked because it came from a cross-site response which was not the response to a top-level navigation. The `Set-Cookie` had to have been set with "`SameSite=None`" to enable cross-site usage.',
130
+ blockedReasonSameSiteUnspecifiedTreatedAsLax: 'This `Set-Cookie` header didnt specify a "`SameSite`" attribute and was defaulted to "`SameSite=Lax,`" and was blocked because it came from a cross-site response which was not the response to a top-level navigation. The `Set-Cookie` had to have been set with "`SameSite=None`" to enable cross-site usage.',
131
131
  /**
132
132
  * @description Tooltip to explain why an attempt to set a cookie via a `Set-Cookie` HTTP header on a request's response was blocked.
133
133
  */
@@ -31,9 +31,9 @@
31
31
  */
32
32
 
33
33
  import type * as Protocol from '../../generated/protocol.js';
34
- import * as TextUtils from '../../models/text_utils/text_utils.js';
35
34
  import * as Common from '../common/common.js';
36
35
  import * as Platform from '../platform/platform.js';
36
+ import * as TextUtils from '../text_utils/text_utils.js';
37
37
 
38
38
  import type {NetworkRequest} from './NetworkRequest.js';
39
39
  import type {ResourceTreeFrame, ResourceTreeModel} from './ResourceTreeModel.js';
@@ -3,7 +3,7 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import * as Formatter from '../../models/formatter/formatter.js';
6
- import * as TextUtils from '../../models/text_utils/text_utils.js';
6
+ import * as TextUtils from '../text_utils/text_utils.js';
7
7
 
8
8
  import type {Script} from './Script.js';
9
9
 
@@ -29,9 +29,9 @@
29
29
 
30
30
  import * as Platform from '../../core/platform/platform.js';
31
31
  import * as Protocol from '../../generated/protocol.js';
32
- import * as TextUtils from '../../models/text_utils/text_utils.js';
33
32
  import * as Common from '../common/common.js';
34
33
  import * as i18n from '../i18n/i18n.js';
34
+ import * as TextUtils from '../text_utils/text_utils.js';
35
35
 
36
36
  import {
37
37
  COND_BREAKPOINT_SOURCE_URL,
@@ -2,7 +2,7 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
- import * as TextUtils from '../../models/text_utils/text_utils.js';
5
+ import * as TextUtils from '../text_utils/text_utils.js';
6
6
 
7
7
  import {Events, type EventSourceMessage, type NetworkRequest} from './NetworkRequest.js';
8
8
  import {ServerSentEventsParser} from './ServerSentEventsProtocol.js';
@@ -2,10 +2,10 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
- import * as TextUtils from '../../models/text_utils/text_utils.js';
6
5
  import * as ScopesCodec from '../../third_party/source-map-scopes-codec/source-map-scopes-codec.js';
7
6
  import * as Common from '../common/common.js';
8
7
  import * as Platform from '../platform/platform.js';
8
+ import * as TextUtils from '../text_utils/text_utils.js';
9
9
 
10
10
  import type {CallFrame, ScopeChainEntry} from './DebuggerModel.js';
11
11
  import {scopeTreeForScript} from './ScopeTreeCache.js';
@@ -4,9 +4,9 @@
4
4
 
5
5
  import * as Protocol from '../../generated/protocol.js';
6
6
  import * as Formatter from '../../models/formatter/formatter.js';
7
- import type * as TextUtils from '../../models/text_utils/text_utils.js';
8
7
  import type * as ScopesCodec from '../../third_party/source-map-scopes-codec/source-map-scopes-codec.js';
9
8
  import type * as Platform from '../platform/platform.js';
9
+ import type * as TextUtils from '../text_utils/text_utils.js';
10
10
 
11
11
  import type {CallFrame, ScopeChainEntry} from './DebuggerModel.js';
12
12
  import type {SourceMap} from './SourceMap.js';
@@ -9,11 +9,11 @@ const UIStrings = {
9
9
  /**
10
10
  * @description Title of a setting under the Console category that can be invoked through the Command Menu
11
11
  */
12
- preserveLogUponNavigation: 'Preserve log upon navigation',
12
+ preserveLogUponNavigation: 'Keep log on navigation',
13
13
  /**
14
14
  * @description Title of a setting under the Console category that can be invoked through the Command Menu
15
15
  */
16
- doNotPreserveLogUponNavigation: 'Do not preserve log upon navigation',
16
+ doNotPreserveLogUponNavigation: 'Don’t keep log on navigation',
17
17
  /**
18
18
  * @description Text for pausing the debugger on exceptions
19
19
  */
@@ -53,7 +53,7 @@ const UIStrings = {
53
53
  /**
54
54
  * @description Text of a setting that do turn off the measuring rulers when hover over a target
55
55
  */
56
- doNotShowRulersOnHover: 'Don\'t show rulers on hover',
56
+ doNotShowRulersOnHover: 'Dont show rulers on hover',
57
57
  /**
58
58
  * @description Title of a setting that turns on grid area name labels
59
59
  */
@@ -17,9 +17,8 @@ export interface ContentProvider {
17
17
  }
18
18
 
19
19
  export class SearchMatch {
20
- constructor(
21
- readonly lineNumber: number, readonly lineContent: string, readonly columnNumber: number,
22
- readonly matchLength: number) {
20
+ constructor(readonly lineNumber: number, readonly lineContent: string, readonly columnNumber: number,
21
+ readonly matchLength: number) {
23
22
  }
24
23
 
25
24
  static comparator(a: SearchMatch, b: SearchMatch): number {
@@ -27,9 +26,8 @@ export class SearchMatch {
27
26
  }
28
27
  }
29
28
 
30
- export const contentAsDataURL = function(
31
- content: string|null, mimeType: string, contentEncoded: boolean, charset?: string|null,
32
- limitSize = true): string|null {
29
+ export const contentAsDataURL = function(content: string|null, mimeType: string, contentEncoded: boolean,
30
+ charset?: string|null, limitSize = true): string|null {
33
31
  const maxDataUrlSize = 1024 * 1024;
34
32
  if (content === undefined || content === null || (limitSize && content.length > maxDataUrlSize)) {
35
33
  return null;
@@ -14,17 +14,15 @@ export class StaticContentProvider implements ContentProvider {
14
14
  readonly #contentType: Common.ResourceType.ResourceType;
15
15
  readonly #lazyContent: () => Promise<ContentDataOrError>;
16
16
 
17
- constructor(
18
- contentURL: Platform.DevToolsPath.UrlString, contentType: Common.ResourceType.ResourceType,
19
- lazyContent: () => Promise<ContentDataOrError>) {
17
+ constructor(contentURL: Platform.DevToolsPath.UrlString, contentType: Common.ResourceType.ResourceType,
18
+ lazyContent: () => Promise<ContentDataOrError>) {
20
19
  this.#contentURL = contentURL;
21
20
  this.#contentType = contentType;
22
21
  this.#lazyContent = lazyContent;
23
22
  }
24
23
 
25
- static fromString(
26
- contentURL: Platform.DevToolsPath.UrlString, contentType: Common.ResourceType.ResourceType,
27
- content: string): StaticContentProvider {
24
+ static fromString(contentURL: Platform.DevToolsPath.UrlString, contentType: Common.ResourceType.ResourceType,
25
+ content: string): StaticContentProvider {
28
26
  const lazyContent = (): Promise<ContentData> =>
29
27
  Promise.resolve(new ContentData(content, /* isBase64 */ false, contentType.canonicalMimeType()));
30
28
  return new StaticContentProvider(contentURL, contentType, lazyContent);
@@ -86,8 +86,7 @@ export class StreamingContentData extends Common.ObjectWrapper.ObjectWrapper<Eve
86
86
  export type StreamingContentDataOrError = StreamingContentData|{error: string};
87
87
 
88
88
  export const isError = function(contentDataOrError: StreamingContentDataOrError): contentDataOrError is {
89
- error:
90
- string,
89
+ error: string,
91
90
  } {
92
91
  return 'error' in contentDataOrError;
93
92
  };
@@ -26,9 +26,8 @@ export class TextRange {
26
26
  }
27
27
 
28
28
  static fromObject(serializedTextRange: SerializedTextRange): TextRange {
29
- return new TextRange(
30
- serializedTextRange.startLine, serializedTextRange.startColumn, serializedTextRange.endLine,
31
- serializedTextRange.endColumn);
29
+ return new TextRange(serializedTextRange.startLine, serializedTextRange.startColumn, serializedTextRange.endLine,
30
+ serializedTextRange.endColumn);
32
31
  }
33
32
 
34
33
  static comparator(range1: TextRange, range2: TextRange): number {
@@ -263,4 +262,8 @@ export class TextRange {
263
262
  export class SourceRange {
264
263
  constructor(public offset: number, public length: number) {
265
264
  }
265
+
266
+ cssValue(): string {
267
+ return `${this.offset},${this.length}`;
268
+ }
266
269
  }
@@ -310,8 +310,8 @@ export const isMinified = function(text: string): boolean {
310
310
  *
311
311
  * @returns empty search matches if `contentData` is an error or not text content.
312
312
  */
313
- export const performSearchInContentData = function(
314
- contentData: ContentDataOrError, query: string, caseSensitive: boolean, isRegex: boolean): SearchMatch[] {
313
+ export const performSearchInContentData = function(contentData: ContentDataOrError, query: string,
314
+ caseSensitive: boolean, isRegex: boolean): SearchMatch[] {
315
315
  if (ContentData.isError(contentData) || !contentData.isTextContent) {
316
316
  return [];
317
317
  }
@@ -322,8 +322,8 @@ export const performSearchInContentData = function(
322
322
  * @returns One {@link SearchMatch} per match. Multiple matches on the same line each
323
323
  * result in their own `SearchMatchExact` instance.
324
324
  */
325
- export const performSearchInContent = function(
326
- text: Text, query: string, caseSensitive: boolean, isRegex: boolean): SearchMatch[] {
325
+ export const performSearchInContent = function(text: Text, query: string, caseSensitive: boolean,
326
+ isRegex: boolean): SearchMatch[] {
327
327
  const regex = Platform.StringUtilities.createSearchRegex(query, caseSensitive, isRegex);
328
328
 
329
329
  const result = [];
@@ -343,9 +343,9 @@ export const performSearchInContent = function(
343
343
  * @param matches is deliberatedly typed as an object literal so we can pass the
344
344
  * CDP search result type.
345
345
  */
346
- export const performSearchInSearchMatches = function(
347
- matches: Array<{lineNumber: number, lineContent: string}>, query: string, caseSensitive: boolean,
348
- isRegex: boolean): SearchMatch[] {
346
+ export const performSearchInSearchMatches = function(matches: Array<{lineNumber: number, lineContent: string}>,
347
+ query: string, caseSensitive: boolean,
348
+ isRegex: boolean): SearchMatch[] {
349
349
  const regex = Platform.StringUtilities.createSearchRegex(query, caseSensitive, isRegex);
350
350
  const result = [];
351
351
 
@@ -51,8 +51,8 @@ export class WasmDisassembly extends ContentData {
51
51
  }
52
52
 
53
53
  bytecodeOffsetToLineNumber(bytecodeOffset: number): number {
54
- return Platform.ArrayUtilities.upperBound(
55
- this.#offsets, bytecodeOffset, Platform.ArrayUtilities.DEFAULT_COMPARATOR) -
54
+ return Platform.ArrayUtilities.upperBound(this.#offsets, bytecodeOffset,
55
+ Platform.ArrayUtilities.DEFAULT_COMPARATOR) -
56
56
  1;
57
57
  }
58
58
 
@@ -0,0 +1,27 @@
1
+ // Copyright 2019 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 CodeMirrorUtils from './CodeMirrorUtils.js';
6
+ import * as ContentData from './ContentData.js';
7
+ import * as ContentProvider from './ContentProvider.js';
8
+ import * as StaticContentProvider from './StaticContentProvider.js';
9
+ import * as StreamingContentData from './StreamingContentData.js';
10
+ import * as Text from './Text.js';
11
+ import * as TextCursor from './TextCursor.js';
12
+ import * as TextRange from './TextRange.js';
13
+ import * as TextUtils from './TextUtils.js';
14
+ import * as WasmDisassembly from './WasmDisassembly.js';
15
+
16
+ export {
17
+ CodeMirrorUtils,
18
+ ContentData,
19
+ ContentProvider,
20
+ StaticContentProvider,
21
+ StreamingContentData,
22
+ Text,
23
+ TextCursor,
24
+ TextRange,
25
+ TextUtils,
26
+ WasmDisassembly,
27
+ };
@@ -3,7 +3,7 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import * as Platform from '../../core/platform/platform.js';
6
- import * as TextUtils from '../../models/text_utils/text_utils.js';
6
+ import * as TextUtils from '../../core/text_utils/text_utils.js';
7
7
  import * as Acorn from '../../third_party/acorn/acorn.js';
8
8
 
9
9
  export type TokenOrComment = Acorn.Token|Acorn.Comment;
@@ -4,7 +4,7 @@
4
4
 
5
5
  import type * as PlatformApi from '../../core/platform/api/api.js';
6
6
  import * as Platform from '../../core/platform/platform.js';
7
- import * as TextUtils from '../../models/text_utils/text_utils.js';
7
+ import * as TextUtils from '../../core/text_utils/text_utils.js';
8
8
 
9
9
  import {type HeapSnapshotHeader, HeapSnapshotProgress, JSHeapSnapshot, type Profile} from './HeapSnapshot.js';
10
10
  import type {HeapSnapshotWorkerDispatcher} from './HeapSnapshotWorkerDispatcher.js';
@@ -460,7 +460,7 @@ export class MainImpl {
460
460
  targetManager.addEventListener(
461
461
  SDK.TargetManager.Events.SUSPEND_STATE_CHANGED, this.#onSuspendStateChanged.bind(this));
462
462
 
463
- new Bindings.PresentationConsoleMessageHelper.PresentationConsoleMessageManager();
463
+ new Bindings.PresentationConsoleMessageHelper.PresentationConsoleMessageManager(targetManager);
464
464
  targetManager.setScopeTarget(targetManager.primaryPageTarget());
465
465
  UI.Context.Context.instance().addFlavorChangeListener(SDK.Target.Target, ({data}) => {
466
466
  const outermostTarget = data?.outermostTarget();
@@ -488,6 +488,7 @@ export class MainImpl {
488
488
  () => Snackbar.Snackbar.Snackbar.show({message: i18nString(UIStrings.aiModelDownloaded)}));
489
489
 
490
490
  new PauseListener();
491
+ new ConsoleProfileFinishedListener();
491
492
 
492
493
  const actionRegistryInstance = UI.ActionRegistry.ActionRegistry.instance({forceNew: true});
493
494
  // Required for legacy a11y layout tests
@@ -961,6 +962,18 @@ export class PauseListener {
961
962
  }
962
963
  }
963
964
 
965
+ export class ConsoleProfileFinishedListener {
966
+ constructor() {
967
+ SDK.TargetManager.TargetManager.instance().addModelListener(SDK.CPUProfilerModel.CPUProfilerModel,
968
+ SDK.CPUProfilerModel.Events.CONSOLE_PROFILE_FINISHED,
969
+ this.#consoleProfileFinished, this);
970
+ }
971
+
972
+ #consoleProfileFinished(event: Common.EventTarget.EventTargetEvent<SDK.CPUProfilerModel.ProfileFinishedData>): void {
973
+ void Common.Revealer.reveal(event.data);
974
+ }
975
+ }
976
+
964
977
  /** Unused but mentioned at https://chromedevtools.github.io/devtools-protocol/#:~:text=use%20Main.MainImpl.-,sendOverProtocol,-()%20in%20the **/
965
978
  export function sendOverProtocol(
966
979
  method: ProtocolClient.InspectorBackend.QualifiedName, params: Object|null): Promise<unknown[]|null> {
@@ -188,7 +188,7 @@ export class Universe {
188
188
  const liveMetrics = new LiveMetrics.LiveMetrics(targetManager, deviceModeModel);
189
189
  context.set(LiveMetrics.LiveMetrics, liveMetrics);
190
190
 
191
- const userBadges = new Badges.UserBadges(settings, gdpClient);
191
+ const userBadges = new Badges.UserBadges(settings, gdpClient, options.inspectorFrontendHost);
192
192
  context.set(Badges.UserBadges, userBadges);
193
193
 
194
194
  const aiHistoryStorage = new AiAssistance.AiHistoryStorage.AiHistoryStorage(settings);
@@ -2,9 +2,9 @@
2
2
  // Use of this source code is governed by a BSD-style license that can be
3
3
  // found in the LICENSE file.
4
4
 
5
+ import * as TextUtils from '../../core/text_utils/text_utils.js';
5
6
  import * as Diff from '../../third_party/diff/diff.js';
6
7
  import * as Persistence from '../persistence/persistence.js';
7
- import * as TextUtils from '../text_utils/text_utils.js';
8
8
  import type * as Workspace from '../workspace/workspace.js';
9
9
 
10
10
  import {debugLog} from './debug.js';
@@ -125,7 +125,7 @@ export class AccessibilityAgent extends AiAgent<LHModel.ReporterTypes.ReportJSON
125
125
  }
126
126
 
127
127
  protected override async preRun(): Promise<void> {
128
- const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();
128
+ const target = this.targetManager.primaryPageTarget();
129
129
  const domModel = target?.model(SDK.DOMModel.DOMModel);
130
130
  // We need to ensure the document is requested so that #getDocumentBodyNode()
131
131
  // can return a valid node for the JavaScript execution context.
@@ -144,10 +144,7 @@ export class AccessibilityAgent extends AiAgent<LHModel.ReporterTypes.ReportJSON
144
144
  * so that the AI has a valid $0 to start with.
145
145
  */
146
146
  #getDocumentBodyNode(): SDK.DOMModel.DOMNode|null {
147
- const document = SDK.TargetManager.TargetManager.instance()
148
- .primaryPageTarget()
149
- ?.model(SDK.DOMModel.DOMModel)
150
- ?.existingDocument();
147
+ const document = this.targetManager.primaryPageTarget()?.model(SDK.DOMModel.DOMModel)?.existingDocument();
151
148
  return document?.body ?? document ?? null;
152
149
  }
153
150
 
@@ -168,7 +165,7 @@ export class AccessibilityAgent extends AiAgent<LHModel.ReporterTypes.ReportJSON
168
165
  }
169
166
 
170
167
  async #resolvePathToNode(path: string): Promise<SDK.DOMModel.DOMNode|null> {
171
- const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();
168
+ const target = this.targetManager.primaryPageTarget();
172
169
  if (!target) {
173
170
  return null;
174
171
  }
@@ -7,9 +7,9 @@ import type {UrlString} from '../../../core/platform/DevToolsPath.js';
7
7
  import type * as Platform from '../../../core/platform/platform.js';
8
8
  import * as Root from '../../../core/root/root.js';
9
9
  import * as SDK from '../../../core/sdk/sdk.js';
10
+ import type * as TextUtils from '../../../core/text_utils/text_utils.js';
10
11
  import type * as Protocol from '../../../generated/protocol.js';
11
12
  import type * as LHModel from '../../lighthouse/lighthouse.js';
12
- import type * as TextUtils from '../../text_utils/text_utils.js';
13
13
  import type * as Trace from '../../trace/trace.js';
14
14
  import type * as Workspace from '../../workspace/workspace.js';
15
15
  import {areOriginsEquivalent, extractContextOrigin, isOpaqueOrigin} from '../AiOrigins.js';
@@ -74,6 +74,14 @@ Your role is to understand the user's query, identify the appropriate specialize
74
74
  * The only available types are \`#req\` for network request and \`#file\` for source files. Only use ID inside the link, never ask about user selecting by ID.
75
75
  `;
76
76
 
77
+ export interface ContextSelectionAgentOptions extends AgentOptions {
78
+ performanceRecordAndReload?: () => Promise<Trace.TraceModel.ParsedTrace>;
79
+ onInspectElement?: () => Promise<SDK.DOMModel.DOMNode|null>;
80
+ networkTimeCalculator?: NetworkTimeCalculator.NetworkTransferTimeCalculator;
81
+ networkLog?: Logs.NetworkLog.NetworkLog;
82
+ workspace?: Workspace.Workspace.WorkspaceImpl;
83
+ }
84
+
77
85
  /**
78
86
  * One agent instance handles one conversation. Create a new agent
79
87
  * instance for a new conversation.
@@ -101,13 +109,13 @@ export class ContextSelectionAgent extends AiAgent<never> {
101
109
  readonly #lighthouseRecording?:
102
110
  (overrides?: LHModel.RunTypes.RunOverrides) => Promise<LHModel.ReporterTypes.ReportJSON|null>;
103
111
  #allowedOrigin: () => AllowedOriginResult;
112
+ readonly #networkLog: Logs.NetworkLog.NetworkLog;
113
+ readonly #workspace: Workspace.Workspace.WorkspaceImpl;
104
114
 
105
- constructor(opts: AgentOptions&{
106
- performanceRecordAndReload?: () => Promise<Trace.TraceModel.ParsedTrace>,
107
- onInspectElement?: () => Promise<SDK.DOMModel.DOMNode|null>,
108
- networkTimeCalculator?: NetworkTimeCalculator.NetworkTransferTimeCalculator,
109
- }) {
115
+ constructor(opts: ContextSelectionAgentOptions) {
110
116
  super(opts);
117
+ this.#networkLog = opts.networkLog ?? Logs.NetworkLog.NetworkLog.instance();
118
+ this.#workspace = opts.workspace ?? Workspace.Workspace.WorkspaceImpl.instance();
111
119
  this.#performanceRecordAndReload = opts.performanceRecordAndReload;
112
120
  this.#lighthouseRecording = opts.lighthouseRecording;
113
121
  this.#onInspectElement = opts.onInspectElement;
@@ -146,7 +154,7 @@ export class ContextSelectionAgent extends AiAgent<never> {
146
154
 
147
155
  let hasCrossOriginRequest = false;
148
156
  const requestsToShow: NetworkRequest[] = [];
149
- for (const request of Logs.NetworkLog.NetworkLog.instance().requests()) {
157
+ for (const request of this.#networkLog.requests()) {
150
158
  const requestOrigin = getRequestContextOrigin(request);
151
159
  /**
152
160
  * NOTE: this origin check does not ensure that all the requests are
@@ -226,7 +234,7 @@ export class ContextSelectionAgent extends AiAgent<never> {
226
234
  error: 'No request found',
227
235
  };
228
236
  }
229
- const request = Logs.NetworkLog.NetworkLog.instance().requests().find(req => {
237
+ const request = this.#networkLog.requests().find(req => {
230
238
  if (req.requestId() !== id) {
231
239
  return false;
232
240
  }
@@ -281,7 +289,7 @@ export class ContextSelectionAgent extends AiAgent<never> {
281
289
 
282
290
  const files: Array<{file: string, id: number | undefined}> = [];
283
291
  const uiSourceCodes: Workspace.UISourceCode.UISourceCode[] = [];
284
- for (const file of ContextSelectionAgent.getUISourceCodes()) {
292
+ for (const file of ContextSelectionAgent.getUISourceCodes(this.#workspace)) {
285
293
  const fileUrl = file.url();
286
294
  const fileOrigin = Common.ParsedURL.ParsedURL.extractOrigin(fileUrl);
287
295
 
@@ -339,7 +347,7 @@ export class ContextSelectionAgent extends AiAgent<never> {
339
347
  }
340
348
  const origin = allowedOriginResult.origin;
341
349
 
342
- const file = ContextSelectionAgent.getUISourceCodes().find(file => {
350
+ const file = ContextSelectionAgent.getUISourceCodes(this.#workspace).find(file => {
343
351
  if (ContextSelectionAgent.uiSourceCodeId.get(file) !== params.id) {
344
352
  return false;
345
353
  }
@@ -554,8 +562,8 @@ export class ContextSelectionAgent extends AiAgent<never> {
554
562
  * coming from SourceMaps (usually only one) as that has simple code and
555
563
  * usually is what the user authored.
556
564
  */
557
- static getUISourceCodes(): Workspace.UISourceCode.UISourceCode[] {
558
- const workspace = Workspace.Workspace.WorkspaceImpl.instance();
565
+ static getUISourceCodes(workspace: Workspace.Workspace.WorkspaceImpl = Workspace.Workspace.WorkspaceImpl.instance()):
566
+ Workspace.UISourceCode.UISourceCode[] {
559
567
  const projects =
560
568
  workspace.projects().filter(project => project.type() === Workspace.Workspace.projectTypes.Network);
561
569
  const uiSourceCodes = new Map<string, Workspace.UISourceCode.UISourceCode>();