chrome-devtools-frontend 1.0.1636056 → 1.0.1640418

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 (171) hide show
  1. package/front_end/core/common/Color.ts +0 -4
  2. package/front_end/core/host/AidaClientTypes.ts +8 -6
  3. package/front_end/core/root/Runtime.ts +2 -2
  4. package/front_end/core/sdk/DOMStorageModel.ts +1 -1
  5. package/front_end/core/sdk/SourceMap.ts +8 -3
  6. package/front_end/core/sdk/TargetManager.ts +14 -1
  7. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +147 -0
  8. package/front_end/generated/ARIAProperties.js +17 -4
  9. package/front_end/generated/InspectorBackendCommands.ts +13 -7
  10. package/front_end/generated/SupportedCSSProperties.js +1 -0
  11. package/front_end/generated/protocol-mapping.d.ts +7 -0
  12. package/front_end/generated/protocol-proxy-api.d.ts +14 -0
  13. package/front_end/generated/protocol.ts +120 -2
  14. package/front_end/global_typings/global_defs.d.ts +13 -0
  15. package/front_end/models/ai_assistance/AiAgent2.ts +116 -0
  16. package/front_end/models/ai_assistance/AiConversation.ts +22 -36
  17. package/front_end/models/ai_assistance/AiHistoryStorage.ts +0 -1
  18. package/front_end/models/ai_assistance/AiOrigins.ts +46 -0
  19. package/front_end/models/ai_assistance/AiUtils.ts +9 -0
  20. package/front_end/models/ai_assistance/README.md +16 -0
  21. package/front_end/models/ai_assistance/StorageItem.ts +30 -26
  22. package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +12 -5
  23. package/front_end/models/ai_assistance/agents/AiAgent.ts +86 -32
  24. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +2 -2
  25. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +31 -10
  26. package/front_end/models/ai_assistance/agents/ConversationSummaryAgent.ts +1 -1
  27. package/front_end/models/ai_assistance/agents/FileAgent.ts +2 -2
  28. package/front_end/models/ai_assistance/agents/GreenDevAgent.ts +1 -3
  29. package/front_end/models/ai_assistance/agents/NetworkAgent.snapshot.txt +19 -0
  30. package/front_end/models/ai_assistance/agents/NetworkAgent.ts +9 -4
  31. package/front_end/models/ai_assistance/agents/PerformanceAgent.snapshot.txt +2 -2
  32. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +41 -12
  33. package/front_end/models/ai_assistance/agents/StorageAgent.ts +442 -122
  34. package/front_end/models/ai_assistance/agents/StylingAgent.ts +2 -2
  35. package/front_end/models/ai_assistance/ai_assistance.ts +4 -2
  36. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +2 -2
  37. package/front_end/models/ai_assistance/performance/AIContext.ts +7 -8
  38. package/front_end/models/ai_assistance/skills/README.md +40 -0
  39. package/front_end/models/ai_assistance/skills/Skill.ts +13 -0
  40. package/front_end/models/ai_assistance/skills/SkillRegistry.ts +10 -0
  41. package/front_end/models/ai_assistance/skills/styling.md +6 -0
  42. package/front_end/models/bindings/CompilerScriptMapping.ts +12 -4
  43. package/front_end/models/breakpoints/BreakpointManager.ts +54 -2
  44. package/front_end/models/greendev/Prototypes.ts +0 -7
  45. package/front_end/models/heap_snapshot/HeapSnapshotModel.ts +20 -0
  46. package/front_end/models/heap_snapshot/HeapSnapshotProxy.ts +5 -0
  47. package/front_end/models/issues_manager/EmailVerificationRequestIssue.ts +293 -0
  48. package/front_end/models/issues_manager/IssuesManager.ts +5 -0
  49. package/front_end/models/issues_manager/descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
  50. package/front_end/models/issues_manager/descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
  51. package/front_end/models/issues_manager/descriptions/emailVerificationRequestInvalidEmail.md +1 -0
  52. package/front_end/models/issues_manager/descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
  53. package/front_end/models/issues_manager/descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
  54. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
  55. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
  56. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
  57. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
  58. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
  59. package/front_end/models/issues_manager/descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
  60. package/front_end/models/issues_manager/descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
  61. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
  62. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
  63. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
  64. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
  65. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
  66. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
  67. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
  68. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
  69. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
  70. package/front_end/models/issues_manager/descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -0
  71. package/front_end/models/issues_manager/issues_manager.ts +2 -0
  72. package/front_end/models/javascript_metadata/NativeFunctions.js +1748 -1739
  73. package/front_end/models/live-metrics/web-vitals-injected/web-vitals-injected.ts +1 -1
  74. package/front_end/models/stack_trace/DetailedErrorStackParser.ts +9 -1
  75. package/front_end/models/stack_trace/StackTraceImpl.ts +29 -9
  76. package/front_end/models/stack_trace/StackTraceModel.ts +23 -11
  77. package/front_end/models/stack_trace/Trie.ts +11 -1
  78. package/front_end/models/trace/extras/TraceTree.ts +20 -1
  79. package/front_end/models/trace/insights/Common.ts +9 -0
  80. package/front_end/models/trace/lantern/core/NetworkAnalyzer.ts +21 -25
  81. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +19 -75
  82. package/front_end/panels/ai_assistance/components/AccessibilityAgentMarkdownRenderer.ts +10 -3
  83. package/front_end/panels/ai_assistance/components/ChatMessage.ts +148 -2
  84. package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +2 -3
  85. package/front_end/panels/ai_assistance/components/chatMessage.css +27 -0
  86. package/front_end/panels/application/CookieItemsView.ts +24 -0
  87. package/front_end/panels/application/DOMStorageItemsView.ts +9 -4
  88. package/front_end/panels/application/preloading/components/PreloadingString.ts +6 -0
  89. package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +4 -4
  90. package/front_end/panels/console/ConsoleViewMessage.ts +13 -102
  91. package/front_end/panels/elements/StandaloneStylesContainer.ts +10 -0
  92. package/front_end/panels/elements/StylePropertiesSection.ts +6 -2
  93. package/front_end/panels/elements/StylePropertyTreeElement.ts +30 -1
  94. package/front_end/panels/elements/StylesContainer.ts +3 -0
  95. package/front_end/panels/elements/StylesSidebarPane.ts +54 -4
  96. package/front_end/panels/elements/elements-meta.ts +14 -0
  97. package/front_end/panels/layer_viewer/layerDetailsView.css +1 -1
  98. package/front_end/panels/lighthouse/LighthouseController.ts +1 -1
  99. package/front_end/panels/lighthouse/LighthouseProtocolService.ts +4 -4
  100. package/front_end/panels/network/NetworkDataGridNode.ts +14 -0
  101. package/front_end/panels/network/NetworkLogViewColumns.ts +2 -2
  102. package/front_end/panels/network/RequestHeadersView.ts +55 -19
  103. package/front_end/panels/network/networkTimingTable.css +2 -4
  104. package/front_end/panels/recorder/components/ReplaySection.ts +28 -16
  105. package/front_end/panels/recorder/converters/LighthouseConverter.snapshot.txt +47 -0
  106. package/front_end/panels/recorder/converters/PuppeteerConverter.snapshot.txt +49 -0
  107. package/front_end/panels/recorder/converters/PuppeteerReplayConverter.snapshot.txt +33 -0
  108. package/front_end/panels/settings/SettingsScreen.ts +1 -2
  109. package/front_end/panels/sources/BreakpointsView.ts +23 -42
  110. package/front_end/panels/sources/DebuggerPlugin.ts +12 -5
  111. package/front_end/panels/sources/ScopeChainSidebarPane.ts +169 -106
  112. package/front_end/panels/timeline/components/IgnoreListSetting.ts +1 -0
  113. package/front_end/third_party/chromium/README.chromium +1 -1
  114. package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +2 -2
  115. package/front_end/third_party/marked/README.chromium +3 -6
  116. package/front_end/third_party/marked/package/README.md +5 -5
  117. package/front_end/third_party/marked/package/bin/main.js +27 -22
  118. package/front_end/third_party/marked/package/bin/marked.js +2 -1
  119. package/front_end/third_party/marked/package/lib/marked.esm.d.ts +346 -256
  120. package/front_end/third_party/marked/package/lib/marked.esm.js +67 -2698
  121. package/front_end/third_party/marked/package/lib/marked.esm.js.map +7 -1
  122. package/front_end/third_party/marked/package/lib/marked.umd.js +69 -2722
  123. package/front_end/third_party/marked/package/lib/marked.umd.js.map +7 -1
  124. package/front_end/third_party/marked/package/man/marked.1 +4 -2
  125. package/front_end/third_party/marked/package/man/marked.1.md +2 -1
  126. package/front_end/third_party/marked/package/package.json +49 -57
  127. package/front_end/third_party/puppeteer-replay/README.chromium +2 -2
  128. package/front_end/third_party/puppeteer-replay/package/lib/cli.js +84 -80
  129. package/front_end/third_party/puppeteer-replay/package/lib/cli.js.map +1 -1
  130. package/front_end/third_party/puppeteer-replay/package/lib/extension-test.js +79 -83
  131. package/front_end/third_party/puppeteer-replay/package/lib/extension-test.js.map +1 -1
  132. package/front_end/third_party/puppeteer-replay/package/lib/main.d.ts +43 -171
  133. package/front_end/third_party/puppeteer-replay/package/lib/main.js +51 -206
  134. package/front_end/third_party/puppeteer-replay/package/lib/main.js.map +1 -1
  135. package/front_end/third_party/puppeteer-replay/package/package.json +37 -67
  136. package/front_end/tsconfig.json +1 -1
  137. package/front_end/ui/components/markdown_view/CodeBlock.ts +17 -6
  138. package/front_end/ui/components/markdown_view/MarkdownView.ts +39 -3
  139. package/front_end/ui/components/markdown_view/codeBlock.css +11 -0
  140. package/front_end/ui/components/markdown_view/markdownView.css +17 -0
  141. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +0 -79
  142. package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +16 -4
  143. package/front_end/ui/visual_logging/KnownContextValues.ts +4 -0
  144. package/inspector_overlay/testing/InspectorOverlayHelpers.ts +2 -0
  145. package/mcp/mcp.ts +1 -6
  146. package/package.json +14 -16
  147. package/front_end/models/ai_assistance/agents/BreakpointDebuggerAgent.ts +0 -1015
  148. package/front_end/models/ai_assistance/agents/BreakpointDebuggerAgentOverlay.ts +0 -87
  149. package/front_end/third_party/marked/package/bin/marked +0 -215
  150. package/front_end/third_party/marked/package/lib/marked.cjs +0 -2726
  151. package/front_end/third_party/marked/package/lib/marked.cjs.map +0 -1
  152. package/front_end/third_party/marked/package/lib/marked.d.cts +0 -670
  153. package/front_end/third_party/marked/package/lib/marked.js +0 -2780
  154. package/front_end/third_party/marked/package/man/marked.1.txt +0 -86
  155. package/front_end/third_party/marked/package/marked.min.js +0 -6
  156. package/front_end/third_party/marked/package/src/Lexer.js +0 -492
  157. package/front_end/third_party/marked/package/src/Parser.js +0 -286
  158. package/front_end/third_party/marked/package/src/Renderer.js +0 -166
  159. package/front_end/third_party/marked/package/src/Slugger.js +0 -49
  160. package/front_end/third_party/marked/package/src/TextRenderer.js +0 -42
  161. package/front_end/third_party/marked/package/src/Tokenizer.js +0 -755
  162. package/front_end/third_party/marked/package/src/defaults.js +0 -29
  163. package/front_end/third_party/marked/package/src/helpers.js +0 -249
  164. package/front_end/third_party/marked/package/src/marked.js +0 -350
  165. package/front_end/third_party/marked/package/src/rules.js +0 -285
  166. package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.cjs +0 -2099
  167. package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.cjs.map +0 -1
  168. package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.d.cts +0 -686
  169. package/front_end/third_party/puppeteer-replay/package/lib/cjs/main.d.ts +0 -35
  170. package/mcp/HostBindings.ts +0 -319
  171. /package/front_end/third_party/marked/package/{LICENSE.md → LICENSE} +0 -0
@@ -105,7 +105,7 @@ window[Spec.INTERNAL_KILL_SWITCH] = () => {
105
105
 
106
106
  function sendEventToDevTools(event: Spec.WebVitalsEvent): void {
107
107
  const payload = JSON.stringify(event);
108
- window[Spec.EVENT_BINDING_NAME](payload);
108
+ window[Spec.EVENT_BINDING_NAME]?.(payload);
109
109
  }
110
110
 
111
111
  /**
@@ -180,7 +180,7 @@ export function parseMessage(stack: string): string {
180
180
  */
181
181
  export function augmentRawFramesWithScriptIds(
182
182
  rawFrames: RawFrame[], protocolStackTrace: Protocol.Runtime.StackTrace): void {
183
- for (const rawFrame of rawFrames) {
183
+ function augmentFrame(rawFrame: RawFrame): void {
184
184
  const isWasm = rawFrame.parsedFrameInfo?.isWasm;
185
185
  const protocolFrame = protocolStackTrace.callFrames.find(frame => {
186
186
  if (isWasm) {
@@ -196,5 +196,13 @@ export function augmentRawFramesWithScriptIds(
196
196
  // @ts-expect-error scriptId is a readonly property.
197
197
  rawFrame.scriptId = protocolFrame.scriptId;
198
198
  }
199
+
200
+ if (rawFrame.parsedFrameInfo?.evalOrigin) {
201
+ augmentFrame(rawFrame.parsedFrameInfo.evalOrigin);
202
+ }
203
+ }
204
+
205
+ for (const rawFrame of rawFrames) {
206
+ augmentFrame(rawFrame);
199
207
  }
200
208
  }
@@ -7,7 +7,7 @@ import type * as SDK from '../../core/sdk/sdk.js';
7
7
  import type * as Workspace from '../workspace/workspace.js';
8
8
 
9
9
  import type * as StackTrace from './stack_trace.js';
10
- import type {FrameNode, ParsedFrameInfo} from './Trie.js';
10
+ import type {EvalOrigin, FrameNode, ParsedFrameInfo} from './Trie.js';
11
11
 
12
12
  export type AnyStackTraceImpl = StackTraceImpl<FragmentImpl|DebuggableFragmentImpl|ParsedErrorStackFragmentImpl>;
13
13
 
@@ -102,6 +102,28 @@ export class FrameImpl implements StackTrace.StackTrace.Frame {
102
102
  }
103
103
  }
104
104
 
105
+ /**
106
+ * Converts the internal recursive `EvalOrigin` trie representation into the public-facing
107
+ * linear `ParsedErrorStackFrameImpl` representation.
108
+ *
109
+ * NOTE: The V8 Error#stack format only allows serializing a single location descriptor
110
+ * per nested eval origin level (e.g. `eval at functionName (location)`). Therefore, the
111
+ * public-facing API only surfaces the top-most logical frame (`evalOrigin.frames[0]`) at each
112
+ * eval level. Any other inlined caller frames at that specific level are technically dropped
113
+ * in the public API, but they are fully preserved in the internal trie representation for
114
+ * debugging, navigation, and ignore list correlation.
115
+ */
116
+ function createParsedErrorStackFrameImplFromEvalOrigin(
117
+ evalOrigin: EvalOrigin|undefined, parsedFrameInfo?: ParsedFrameInfo): ParsedErrorStackFrameImpl|undefined {
118
+ if (!evalOrigin || evalOrigin.frames.length === 0) {
119
+ return undefined;
120
+ }
121
+ const frame = evalOrigin.frames[0];
122
+ const nestedOrigin = createParsedErrorStackFrameImplFromEvalOrigin(
123
+ evalOrigin.evalOrigin, parsedFrameInfo?.evalOrigin?.parsedFrameInfo);
124
+ return new ParsedErrorStackFrameImpl(frame, parsedFrameInfo?.evalOrigin?.parsedFrameInfo, nestedOrigin);
125
+ }
126
+
105
127
  export class ParsedErrorStackFragmentImpl implements StackTrace.StackTrace.ParsedErrorStackFragment {
106
128
  constructor(readonly fragment: FragmentImpl) {
107
129
  }
@@ -114,8 +136,9 @@ export class ParsedErrorStackFragmentImpl implements StackTrace.StackTrace.Parse
114
136
  const frames: ParsedErrorStackFrameImpl[] = [];
115
137
 
116
138
  for (const node of this.fragment.node.getCallStack()) {
139
+ const evalOrigin = createParsedErrorStackFrameImplFromEvalOrigin(node.evalOrigin, node.parsedFrameInfo);
117
140
  for (const frame of node.frames) {
118
- frames.push(new ParsedErrorStackFrameImpl(frame, node.parsedFrameInfo, node.evalOriginFrames));
141
+ frames.push(new ParsedErrorStackFrameImpl(frame, node.parsedFrameInfo, evalOrigin));
119
142
  }
120
143
  }
121
144
 
@@ -126,12 +149,12 @@ export class ParsedErrorStackFragmentImpl implements StackTrace.StackTrace.Parse
126
149
  export class ParsedErrorStackFrameImpl implements StackTrace.StackTrace.ParsedErrorStackFrame {
127
150
  readonly #frame: FrameImpl;
128
151
  readonly #parsedFrameInfo?: ParsedFrameInfo;
129
- readonly #evalOriginFrames?: FrameImpl[];
152
+ readonly #evalOrigin?: ParsedErrorStackFrameImpl;
130
153
 
131
- constructor(frame: FrameImpl, parsedFrameInfo?: ParsedFrameInfo, evalOriginFrames?: FrameImpl[]) {
154
+ constructor(frame: FrameImpl, parsedFrameInfo?: ParsedFrameInfo, evalOrigin?: ParsedErrorStackFrameImpl) {
132
155
  this.#frame = frame;
133
156
  this.#parsedFrameInfo = parsedFrameInfo;
134
- this.#evalOriginFrames = evalOriginFrames;
157
+ this.#evalOrigin = evalOrigin;
135
158
  }
136
159
 
137
160
  get url(): string|undefined {
@@ -166,10 +189,7 @@ export class ParsedErrorStackFrameImpl implements StackTrace.StackTrace.ParsedEr
166
189
  return this.#parsedFrameInfo?.isEval;
167
190
  }
168
191
  get evalOrigin(): ParsedErrorStackFrameImpl|undefined {
169
- if (!this.#evalOriginFrames || this.#evalOriginFrames.length === 0) {
170
- return undefined;
171
- }
172
- return new ParsedErrorStackFrameImpl(this.#evalOriginFrames[0], this.#parsedFrameInfo?.evalOrigin?.parsedFrameInfo);
192
+ return this.#evalOrigin;
173
193
  }
174
194
  get isWasm(): boolean|undefined {
175
195
  return this.#parsedFrameInfo?.isWasm;
@@ -18,7 +18,7 @@ import {
18
18
  ParsedErrorStackFragmentImpl,
19
19
  StackTraceImpl
20
20
  } from './StackTraceImpl.js';
21
- import {type FrameNode, type RawFrame, Trie} from './Trie.js';
21
+ import {EvalOrigin, type FrameNode, type RawFrame, Trie} from './Trie.js';
22
22
 
23
23
  /**
24
24
  * A stack trace translation function.
@@ -135,7 +135,6 @@ export class StackTraceModel extends SDK.SDKModel.SDKModel<unknown> {
135
135
  stackTraceOrPausedEvent: Protocol.Runtime.StackTrace|SDK.DebuggerModel.DebuggerPausedDetails,
136
136
  rawFramesToUIFrames: TranslateRawFrames): Promise<AsyncFragmentImpl[]> {
137
137
  const asyncFragments: Array<Promise<AsyncFragmentImpl>> = [];
138
-
139
138
  const debuggerModel = this.target().model(SDK.DebuggerModel.DebuggerModel);
140
139
  if (debuggerModel) {
141
140
  for await (
@@ -185,15 +184,16 @@ export class StackTraceModel extends SDK.SDKModel.SDKModel<unknown> {
185
184
  const uiFrames = await rawFramesToUIFrames(rawFrames, this.target());
186
185
  console.assert(rawFrames.length === uiFrames.length, 'Broken rawFramesToUIFrames implementation');
187
186
 
188
- const evalOriginPromises: Array<ReturnType<TranslateRawFrames>> = [];
187
+ const evalOriginPromises: Array<Promise<EvalOrigin|undefined>> = [];
189
188
  for (const node of fragment.node.getCallStack()) {
190
189
  if (node.parsedFrameInfo?.evalOrigin) {
191
190
  // Evaluate each eval origin individually, as they are not a contiguous stack trace.
192
- evalOriginPromises.push(rawFramesToUIFrames([node.parsedFrameInfo.evalOrigin], this.target()));
191
+ evalOriginPromises.push(
192
+ translateEvalOrigin(node.parsedFrameInfo.evalOrigin, rawFramesToUIFrames, this.target()));
193
193
  }
194
194
  }
195
195
 
196
- const evalUiFrames = await Promise.all(evalOriginPromises);
196
+ const evalOrigins = await Promise.all(evalOriginPromises);
197
197
 
198
198
  let i = 0;
199
199
  let evalI = 0;
@@ -204,12 +204,7 @@ export class StackTraceModel extends SDK.SDKModel.SDKModel<unknown> {
204
204
  node.rawFrame.functionName));
205
205
 
206
206
  if (node.parsedFrameInfo?.evalOrigin) {
207
- const evalOriginRawFrame = node.parsedFrameInfo.evalOrigin;
208
- // evalUiFrames[evalI] is Array<Array<Frame>>, and since we passed a 1-element array, we take [0]
209
- node.evalOriginFrames = evalUiFrames[evalI++][0].map(
210
- frame => new FrameImpl(
211
- frame.url, frame.uiSourceCode, frame.name, frame.line, frame.column, frame.missingDebugInfo,
212
- evalOriginRawFrame.functionName));
207
+ node.evalOrigin = evalOrigins[evalI++];
213
208
  }
214
209
  }
215
210
  }
@@ -241,4 +236,21 @@ export class StackTraceModel extends SDK.SDKModel.SDKModel<unknown> {
241
236
  }
242
237
  }
243
238
 
239
+ async function translateEvalOrigin(
240
+ rawFrame: RawFrame, rawFramesToUIFrames: TranslateRawFrames,
241
+ target: SDK.Target.Target): Promise<EvalOrigin|undefined> {
242
+ const uiFrames = await rawFramesToUIFrames([rawFrame], target);
243
+ const frames = uiFrames[0].map(
244
+ frame => new FrameImpl(
245
+ frame.url, frame.uiSourceCode, frame.name, frame.line, frame.column, frame.missingDebugInfo,
246
+ rawFrame.functionName));
247
+
248
+ let parentEvalOrigin: EvalOrigin|undefined;
249
+ if (rawFrame.parsedFrameInfo?.evalOrigin) {
250
+ parentEvalOrigin = await translateEvalOrigin(rawFrame.parsedFrameInfo.evalOrigin, rawFramesToUIFrames, target);
251
+ }
252
+
253
+ return new EvalOrigin(frames, parentEvalOrigin);
254
+ }
255
+
244
256
  SDK.SDKModel.SDKModel.register(StackTraceModel, {capabilities: SDK.Target.Capability.NONE, autostart: false});
@@ -41,6 +41,16 @@ export function isBuiltinFrame(rawFrame: RawFrame): boolean {
41
41
  !Boolean(rawFrame.url);
42
42
  }
43
43
 
44
+ export class EvalOrigin {
45
+ readonly frames: FrameImpl[];
46
+ readonly evalOrigin?: EvalOrigin;
47
+
48
+ constructor(frames: FrameImpl[], evalOrigin?: EvalOrigin) {
49
+ this.frames = frames;
50
+ this.evalOrigin = evalOrigin;
51
+ }
52
+ }
53
+
44
54
  interface FrameNodeBase<ChildT, ParentT> {
45
55
  readonly parent: ParentT;
46
56
  readonly children: ChildT[];
@@ -58,7 +68,7 @@ export class FrameNode implements FrameNodeBase<FrameNode, AnyFrameNode> {
58
68
 
59
69
  fragment?: FragmentImpl;
60
70
  parsedFrameInfo?: ParsedFrameInfo;
61
- evalOriginFrames?: FrameImpl[];
71
+ evalOrigin?: EvalOrigin;
62
72
 
63
73
  constructor(rawFrame: RawFrame, parent: AnyFrameNode) {
64
74
  this.rawFrame = rawFrame;
@@ -406,6 +406,17 @@ export class BottomUpRootNode extends Node {
406
406
  const eventGroupIdCallback = this.eventGroupIdCallback;
407
407
  const forceGroupIdCallback = this.forceGroupIdCallback;
408
408
 
409
+ const idToIsCacheHit = new Map<string, boolean>();
410
+ for (const e of this.events) {
411
+ if (Types.Events.isReceivedDataEvent(e) && e.name === 'ResourceReceiveResponse') {
412
+ let id = generateEventID(e);
413
+ if (this.forceGroupIdCallback && this.eventGroupIdCallback) {
414
+ id = `${id}-${this.eventGroupIdCallback(e)}`;
415
+ }
416
+ idToIsCacheHit.set(id, e.args.data.fromCache || false);
417
+ }
418
+ }
419
+
409
420
  // encodedDataLength is provided solely on instant events.
410
421
  const sumTransferSizeOfInstantEvent = (e: Types.Events.Event): void => {
411
422
  if (Types.Events.isReceivedDataEvent(e)) {
@@ -424,7 +435,15 @@ export class BottomUpRootNode extends Node {
424
435
  // ResourceReceivedData events tally up the transfer size over time, but the
425
436
  // ResourceReceiveResponse / ResourceFinish events hold the final result.
426
437
  if (e.name === 'ResourceReceivedData') {
427
- node.transferSize += e.args.data.encodedDataLength;
438
+ if (idToIsCacheHit.get(id)) {
439
+ // It's a cache hit, so the actual network transfer size is 0.
440
+ // We overwrite the tallied sum (which is uncompressed body size) with 0.
441
+ node.transferSize = 0;
442
+ } else {
443
+ node.transferSize += e.args.data.encodedDataLength;
444
+ }
445
+ } else if (e.name === 'ResourceFinish' && e.args.data.encodedDataLength === 0 && idToIsCacheHit.get(id)) {
446
+ node.transferSize = 0;
428
447
  } else if (e.args.data.encodedDataLength > 0) {
429
448
  // For some reason, ResourceFinish can be zero even if data was sent.
430
449
  // Ignore that case.
@@ -417,6 +417,15 @@ export function calculateDocFirstByteTs(docRequest: Types.Events.SyntheticNetwor
417
417
  return docRequest.ts;
418
418
  }
419
419
 
420
+ // @ts-expect-error
421
+ const isLightrider = globalThis.isLightrider;
422
+ if (isLightrider) {
423
+ const lrServerResponseTime = docRequest.args.data.lrServerResponseTime;
424
+ if (lrServerResponseTime !== undefined) {
425
+ return Types.Timing.Micro(docRequest.ts + Helpers.Timing.milliToMicro(lrServerResponseTime));
426
+ }
427
+ }
428
+
420
429
  const timing = docRequest.args.data.timing;
421
430
  if (!timing) {
422
431
  // Older traces do not have timings.
@@ -4,8 +4,6 @@
4
4
 
5
5
  import type * as Lantern from '../types/types.js';
6
6
 
7
- import {LanternError} from './LanternError.js';
8
-
9
7
  class UrlUtils {
10
8
  /**
11
9
  * There is fancy URL rewriting logic for the chrome://settings page that we need to work around.
@@ -100,6 +98,12 @@ class NetworkAnalyzer {
100
98
  const grouped = new Map();
101
99
  records.forEach(item => {
102
100
  const key = item.parsedURL.securityOrigin;
101
+
102
+ // We never care about requests for extensions.
103
+ if (key.startsWith('chrome-extension:')) {
104
+ return;
105
+ }
106
+
103
107
  const group = grouped.get(key) || [];
104
108
  group.push(item);
105
109
  grouped.set(key, group);
@@ -458,30 +462,25 @@ class NetworkAnalyzer {
458
462
  }
459
463
  }
460
464
 
461
- if (!estimatesByOrigin.size) {
462
- throw new LanternError('No timing information available');
463
- }
464
465
  return NetworkAnalyzer.summarize(estimatesByOrigin);
465
466
  }
466
467
 
468
+ static estimateMinimumRTTByOrigin(records: Lantern.NetworkRequest[], options?: RTTEstimateOptions):
469
+ Map<string, number> {
470
+ const rttByOrigin = new Map<string, number>();
471
+ for (const [origin, summary] of NetworkAnalyzer.estimateRTTByOrigin(records, options).entries()) {
472
+ rttByOrigin.set(origin, summary.min);
473
+ }
474
+ return rttByOrigin;
475
+ }
476
+
467
477
  /**
468
- * Estimates the server response time of each origin. RTT times can be passed in or will be
469
- * estimated automatically if not provided.
478
+ * Estimates the server response time of each origin. RTT times must be passed in.
470
479
  */
471
- static estimateServerResponseTimeByOrigin(records: Lantern.NetworkRequest[], options?: RTTEstimateOptions&{
472
- rttByOrigin?: Map<string, number>,
480
+ static estimateServerResponseTimeByOrigin(records: Lantern.NetworkRequest[], options: {
481
+ rttByOrigin: Map<string, number>,
473
482
  }): Map<string, Summary> {
474
- let rttByOrigin = options?.rttByOrigin;
475
- if (!rttByOrigin) {
476
- rttByOrigin = new Map();
477
-
478
- const rttSummaryByOrigin = NetworkAnalyzer.estimateRTTByOrigin(records, options);
479
- for (const [origin, summary] of rttSummaryByOrigin.entries()) {
480
- rttByOrigin.set(origin, summary.min);
481
- }
482
- }
483
-
484
- const estimatesByOrigin = NetworkAnalyzer.estimateResponseTimeByOrigin(records, rttByOrigin);
483
+ const estimatesByOrigin = NetworkAnalyzer.estimateResponseTimeByOrigin(records, options.rttByOrigin);
485
484
  return NetworkAnalyzer.summarize(estimatesByOrigin);
486
485
  }
487
486
 
@@ -546,14 +545,11 @@ class NetworkAnalyzer {
546
545
  static computeRTTAndServerResponseTime(records: Lantern.NetworkRequest[]):
547
546
  {rtt: number, additionalRttByOrigin: Map<string, number>, serverResponseTimeByOrigin: Map<string, number>} {
548
547
  // First pass compute the estimated observed RTT to each origin's servers.
549
- const rttByOrigin = new Map<string, number>();
550
- for (const [origin, summary] of NetworkAnalyzer.estimateRTTByOrigin(records).entries()) {
551
- rttByOrigin.set(origin, summary.min);
552
- }
548
+ const rttByOrigin = NetworkAnalyzer.estimateMinimumRTTByOrigin(records);
553
549
 
554
550
  // We'll use the minimum RTT as the assumed connection latency since we care about how much addt'l
555
551
  // latency each origin introduces as Lantern will be simulating with its own connection latency.
556
- const minimumRtt = Math.min(...Array.from(rttByOrigin.values()));
552
+ const minimumRtt = rttByOrigin.size ? Math.min(...Array.from(rttByOrigin.values())) : 0;
557
553
  // We'll use the observed RTT information to help estimate the server response time
558
554
  const responseTimeSummaries = NetworkAnalyzer.estimateServerResponseTimeByOrigin(records, {
559
555
  rttByOrigin,
@@ -185,6 +185,10 @@ const UIStringsNotTranslate = {
185
185
  * @description Placeholder text for the chat UI input with branding Gemini (do not translate)
186
186
  */
187
187
  inputPlaceholderForNoContextBranded: 'Ask Gemini',
188
+ /**
189
+ * @description Placeholder text for the chat UI input when AIAgent2 is enabled.
190
+ */
191
+ inputPlaceholderForV2: 'Ask a question (AIAgent2 enabled)',
188
192
  /**
189
193
  * @description Disclaimer text right after the chat input.
190
194
  */
@@ -332,13 +336,6 @@ async function getEmptyStateSuggestions(conversation?: AiAssistanceModel.AiConve
332
336
  {title: 'What performance issues exist with my page?', jslogContext: 'performance-default'},
333
337
  ];
334
338
  }
335
- case AiAssistanceModel.AiHistoryStorage.ConversationType.BREAKPOINT: {
336
- return [
337
- {title: 'Why did the code pause here?'},
338
- {title: 'What function does this breakpoint belong to?'},
339
- {title: 'Why is this error thrown?'},
340
- ];
341
- }
342
339
 
343
340
  case AiAssistanceModel.AiHistoryStorage.ConversationType.NONE: {
344
341
  return [
@@ -383,9 +380,8 @@ function getMarkdownRenderer(conversation?: AiAssistanceModel.AiConversation.AiC
383
380
  return new StylingAgentMarkdownRenderer(mainFrameId);
384
381
  } else if (conversation?.type === AiAssistanceModel.AiHistoryStorage.ConversationType.ACCESSIBILITY) {
385
382
  const domModel = SDK.TargetManager.TargetManager.instance().primaryPageTarget()?.model(SDK.DOMModel.DOMModel);
386
- const resourceTreeModel = domModel?.target().model(SDK.ResourceTreeModel.ResourceTreeModel);
387
- const mainFrameId = resourceTreeModel?.mainFrame?.id;
388
- return new AccessibilityAgentMarkdownRenderer(mainFrameId);
383
+ const mainDocumentURL = domModel?.existingDocument()?.documentURL;
384
+ return new AccessibilityAgentMarkdownRenderer(mainDocumentURL);
389
385
  }
390
386
 
391
387
  return new MarkdownRendererWithCodeBlock();
@@ -526,8 +522,7 @@ function defaultView(input: ViewInput, output: PanelViewOutput, target: HTMLElem
526
522
  }
527
523
  }
528
524
 
529
- if (Root.Runtime.hostConfig.devToolsAiAssistanceV2?.enabled ||
530
- Greendev.Prototypes.instance().isEnabled('breakpointDebuggerAgent')) {
525
+ if (Root.Runtime.hostConfig.devToolsAiAssistanceV2?.enabled) {
531
526
 
532
527
  const shouldShowWalkthrough = input.state === ViewState.CHAT_VIEW && input.props.walkthrough.isExpanded;
533
528
  /**
@@ -590,14 +585,6 @@ function createFileContext(file: Workspace.UISourceCode.UISourceCode|null): AiAs
590
585
  return new AiAssistanceModel.FileAgent.FileContext(file);
591
586
  }
592
587
 
593
- function createBreakpointContext(uiLocation: Workspace.UISourceCode.UILocation|null):
594
- AiAssistanceModel.BreakpointDebuggerAgent.BreakpointContext|null {
595
- if (!uiLocation) {
596
- return null;
597
- }
598
- return new AiAssistanceModel.BreakpointDebuggerAgent.BreakpointContext(uiLocation);
599
- }
600
-
601
588
  function createAccessibilityContext(report: LighthousePanel.LighthousePanel.ActiveLighthouseReport|null):
602
589
  AiAssistanceModel.AccessibilityAgent.AccessibilityContext|null {
603
590
  if (!report) {
@@ -684,7 +671,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
684
671
  #selectedElement: AiAssistanceModel.StylingAgent.NodeContext|null = null;
685
672
  #selectedPerformanceTrace: AiAssistanceModel.PerformanceAgent.PerformanceTraceContext|null = null;
686
673
  #selectedRequest: AiAssistanceModel.NetworkAgent.RequestContext|null = null;
687
- #selectedBreakpoint: AiAssistanceModel.BreakpointDebuggerAgent.BreakpointContext|null = null;
674
+
688
675
  #selectedAccessibility: AiAssistanceModel.AccessibilityAgent.AccessibilityContext|null = null;
689
676
  #selectedStorage: AiAssistanceModel.StorageAgent.StorageContext|null = null;
690
677
 
@@ -1017,10 +1004,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1017
1004
  targetConversationType = AiAssistanceModel.AiHistoryStorage.ConversationType.STYLING;
1018
1005
  } else if (isNetworkPanelVisible && hostConfig.devToolsAiAssistanceNetworkAgent?.enabled) {
1019
1006
  targetConversationType = AiAssistanceModel.AiHistoryStorage.ConversationType.NETWORK;
1020
- } else if (
1021
- isSourcesPanelVisible &&
1022
- this.#conversation?.type === AiAssistanceModel.AiHistoryStorage.ConversationType.BREAKPOINT) {
1023
- targetConversationType = AiAssistanceModel.AiHistoryStorage.ConversationType.BREAKPOINT;
1007
+
1024
1008
  } else if (isSourcesPanelVisible && hostConfig.devToolsAiAssistanceFileAgent?.enabled) {
1025
1009
  targetConversationType = AiAssistanceModel.AiHistoryStorage.ConversationType.FILE;
1026
1010
  } else if (isPerformancePanelVisible && hostConfig.devToolsAiAssistancePerformanceAgent?.enabled) {
@@ -1127,30 +1111,6 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1127
1111
  this.requestUpdate();
1128
1112
  }
1129
1113
 
1130
- async handleBreakpointConversation(uiLocation: Workspace.UISourceCode.UILocation, errorMsg?: string): Promise<void> {
1131
- const context = new AiAssistanceModel.BreakpointDebuggerAgent.BreakpointContext(uiLocation);
1132
- this.#selectedBreakpoint = context;
1133
- const conversation = new AiAssistanceModel.AiConversation.AiConversation({
1134
- type: AiAssistanceModel.AiHistoryStorage.ConversationType.BREAKPOINT,
1135
- data: [],
1136
- isReadOnly: false,
1137
- aidaClient: this.#aidaClient,
1138
- changeManager: this.#changeManager,
1139
- isExternal: false,
1140
- performanceRecordAndReload: this.#handlePerformanceRecordAndReload.bind(this),
1141
- onInspectElement: this.#handleInspectElement.bind(this),
1142
- networkTimeCalculator: NetworkPanel.NetworkPanel.NetworkPanel.instance().networkLogView.timeCalculator(),
1143
- lighthouseRecording: this.#handleLighthouseRun.bind(this),
1144
- });
1145
- this.#updateConversationState(conversation);
1146
- this.#conversation?.setContext(context);
1147
- this.requestUpdate();
1148
- await UI.ViewManager.ViewManager.instance().showView(AiAssistancePanel.panelName);
1149
- const prompt = errorMsg ? `debug the error "${errorMsg}" using breakpoint debugging agent` :
1150
- 'debug the error using breakpoint debugging agent';
1151
- await this.#startConversation(prompt);
1152
- }
1153
-
1154
1114
  override wasShown(): void {
1155
1115
  super.wasShown();
1156
1116
  this.#viewOutput.chatView?.restoreScrollPosition();
@@ -1163,8 +1123,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1163
1123
  this.#selectedPerformanceTrace =
1164
1124
  createPerformanceTraceContext(UI.Context.Context.instance().flavor(AiAssistanceModel.AIContext.AgentFocus));
1165
1125
  this.#selectedFile = createFileContext(UI.Context.Context.instance().flavor(Workspace.UISourceCode.UISourceCode));
1166
- this.#selectedBreakpoint =
1167
- createBreakpointContext(UI.Context.Context.instance().flavor(Workspace.UISourceCode.UILocation));
1126
+
1168
1127
  this.#selectedAccessibility = createAccessibilityContext(
1169
1128
  UI.Context.Context.instance().flavor(LighthousePanel.LighthousePanel.ActiveLighthouseReport));
1170
1129
  this.#selectedStorage =
@@ -1186,8 +1145,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1186
1145
 
1187
1146
  UI.Context.Context.instance().addFlavorChangeListener(
1188
1147
  Workspace.UISourceCode.UISourceCode, this.#handleUISourceCodeFlavorChange);
1189
- UI.Context.Context.instance().addFlavorChangeListener(
1190
- Workspace.UISourceCode.UILocation, this.#handleBreakpointFlavorChange);
1148
+
1191
1149
  UI.Context.Context.instance().addFlavorChangeListener(
1192
1150
  LighthousePanel.LighthousePanel.ActiveLighthouseReport, this.#handleLighthouseReportFlavorChange);
1193
1151
 
@@ -1328,17 +1286,6 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1328
1286
  this.#updateConversationState(this.#conversation);
1329
1287
  };
1330
1288
 
1331
- #handleBreakpointFlavorChange =
1332
- (ev: Common.EventTarget.EventTargetEvent<Workspace.UISourceCode.UILocation>): void => {
1333
- const newBreakpoint = ev.data;
1334
-
1335
- if (!newBreakpoint || this.#selectedBreakpoint?.getItem() === newBreakpoint) {
1336
- return;
1337
- }
1338
- this.#selectedBreakpoint = new AiAssistanceModel.BreakpointDebuggerAgent.BreakpointContext(newBreakpoint);
1339
- this.#updateConversationState(this.#conversation);
1340
- };
1341
-
1342
1289
  #handleLighthouseReportFlavorChange =
1343
1290
  (ev: Common.EventTarget.EventTargetEvent<LighthousePanel.LighthousePanel.ActiveLighthouseReport>): void => {
1344
1291
  const newReport = ev.data;
@@ -1420,6 +1367,10 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1420
1367
  return i18nString(UIStrings.followTheSteps);
1421
1368
  }
1422
1369
 
1370
+ if (Root.Runtime.hostConfig.devToolsAiV2Architecture?.enabled) {
1371
+ return lockedString(UIStringsNotTranslate.inputPlaceholderForV2);
1372
+ }
1373
+
1423
1374
  if (this.#conversation && this.#conversation.isBlockedByOrigin) {
1424
1375
  return lockedString(UIStringsNotTranslate.crossOriginError);
1425
1376
  }
@@ -1447,8 +1398,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1447
1398
 
1448
1399
  return lockedString(UIStringsNotTranslate.inputPlaceholderForPerformanceWithNoRecording);
1449
1400
  }
1450
- case AiAssistanceModel.AiHistoryStorage.ConversationType.BREAKPOINT:
1451
- return lockedString(UIStringsNotTranslate.inputPlaceholderForNoContext);
1401
+
1452
1402
  case AiAssistanceModel.AiHistoryStorage.ConversationType.ACCESSIBILITY:
1453
1403
  return this.#conversation.selectedContext ?
1454
1404
  lockedString(UIStringsNotTranslate.inputPlaceholderForAccessibility) :
@@ -1510,8 +1460,6 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1510
1460
  }
1511
1461
  return lockedString(UIStringsNotTranslate.inputDisclaimerForAccessibilityEnterpriseNoLogging);
1512
1462
 
1513
- case AiAssistanceModel.AiHistoryStorage.ConversationType.BREAKPOINT:
1514
-
1515
1463
  case AiAssistanceModel.AiHistoryStorage.ConversationType.STORAGE:
1516
1464
  case AiAssistanceModel.AiHistoryStorage.ConversationType.NONE:
1517
1465
  if (loggingEnabled) {
@@ -1763,8 +1711,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1763
1711
  return this.#selectedRequest;
1764
1712
  case AiAssistanceModel.AiHistoryStorage.ConversationType.PERFORMANCE:
1765
1713
  return this.#selectedPerformanceTrace;
1766
- case AiAssistanceModel.AiHistoryStorage.ConversationType.BREAKPOINT:
1767
- return this.#selectedBreakpoint;
1714
+
1768
1715
  case AiAssistanceModel.AiHistoryStorage.ConversationType.ACCESSIBILITY:
1769
1716
  return this.#selectedAccessibility;
1770
1717
  case AiAssistanceModel.AiHistoryStorage.ConversationType.STORAGE:
@@ -1786,8 +1733,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1786
1733
  this.#selectedRequest = data;
1787
1734
  } else if (data instanceof AiAssistanceModel.PerformanceAgent.PerformanceTraceContext) {
1788
1735
  this.#selectedPerformanceTrace = data;
1789
- } else if (data instanceof AiAssistanceModel.BreakpointDebuggerAgent.BreakpointContext) {
1790
- this.#selectedBreakpoint = data;
1736
+
1791
1737
  } else if (data instanceof AiAssistanceModel.AccessibilityAgent.AccessibilityContext) {
1792
1738
  this.#selectedAccessibility = data;
1793
1739
  } else if (data instanceof AiAssistanceModel.StorageAgent.StorageContext) {
@@ -1946,9 +1892,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
1946
1892
  // This ensures that when a user asks a new question, the sidebar updates
1947
1893
  // immediately to show the "loading" state of the new walkthrough.
1948
1894
  const isSidebarWalkthroughOpen = this.#walkthrough.isExpanded && !this.#walkthrough.isInlined;
1949
- if (isSidebarWalkthroughOpen ||
1950
- (Greendev.Prototypes.instance().isEnabled('breakpointDebuggerAgent') &&
1951
- this.#conversation?.type === AiAssistanceModel.AiHistoryStorage.ConversationType.BREAKPOINT)) {
1895
+ if (isSidebarWalkthroughOpen) {
1952
1896
  this.#openWalkthrough(systemMessage);
1953
1897
  }
1954
1898
  break;
@@ -2,8 +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 type * as Platform from '../../../core/platform/platform.js';
5
6
  import * as SDK from '../../../core/sdk/sdk.js';
6
7
  import type * as Protocol from '../../../generated/protocol.js';
8
+ import * as AiAssistanceModel from '../../../models/ai_assistance/ai_assistance.js';
7
9
  import type * as Marked from '../../../third_party/marked/marked.js';
8
10
  import * as Lit from '../../../ui/lit/lit.js';
9
11
  import * as PanelsCommon from '../../common/common.js';
@@ -27,11 +29,16 @@ type ParsedLink = {
27
29
 
28
30
  export class AccessibilityAgentMarkdownRenderer extends MarkdownRendererWithCodeBlock {
29
31
  constructor(
30
- private mainFrameId = '',
32
+ private mainDocumentURL: Platform.DevToolsPath.UrlString = '' as Platform.DevToolsPath.UrlString,
31
33
  ) {
32
34
  super();
33
35
  }
34
36
 
37
+ #isSameOrigin(node: SDK.DOMModel.DOMNode): boolean {
38
+ const nodeDocumentURL = node.ownerDocument?.documentURL ?? '' as Platform.DevToolsPath.UrlString;
39
+ return AiAssistanceModel.AiUtils.isSameOrigin(this.mainDocumentURL, nodeDocumentURL);
40
+ }
41
+
35
42
  override templateForToken(token: Marked.Marked.MarkedToken): Lit.LitTemplate|null {
36
43
  if (token.type === 'link' && token.href.startsWith('#')) {
37
44
  const parsed = this.#parseLink(token.href);
@@ -98,7 +105,7 @@ export class AccessibilityAgentMarkdownRenderer extends MarkdownRendererWithCode
98
105
  return;
99
106
  }
100
107
 
101
- if (node.frameId() !== this.mainFrameId) {
108
+ if (!this.#isSameOrigin(node)) {
102
109
  return;
103
110
  }
104
111
 
@@ -123,7 +130,7 @@ export class AccessibilityAgentMarkdownRenderer extends MarkdownRendererWithCode
123
130
  if (!node) {
124
131
  return;
125
132
  }
126
- if (node.frameId() !== this.mainFrameId) {
133
+ if (!this.#isSameOrigin(node)) {
127
134
  return;
128
135
  }
129
136
  const linkedNode = PanelsCommon.DOMLinkifier.Linkifier.instance().linkify(node, {textContent: label});