chrome-devtools-frontend 1.0.1543082 → 1.0.1544076

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 (149) hide show
  1. package/AUTHORS +2 -0
  2. package/front_end/core/common/Gzip.ts +4 -4
  3. package/front_end/core/common/common.ts +0 -2
  4. package/front_end/core/host/AidaClient.ts +10 -7
  5. package/front_end/core/host/DispatchHttpRequestClient.ts +18 -3
  6. package/front_end/core/root/DevToolsContext.ts +60 -0
  7. package/front_end/core/root/Runtime.ts +8 -7
  8. package/front_end/core/root/root.ts +6 -1
  9. package/front_end/core/sdk/CPUThrottlingManager.ts +0 -4
  10. package/front_end/core/sdk/CSSMatchedStyles.ts +7 -9
  11. package/front_end/core/sdk/CSSModel.ts +1 -1
  12. package/front_end/core/sdk/CSSRule.ts +18 -6
  13. package/front_end/core/sdk/ChildTargetManager.ts +2 -2
  14. package/front_end/core/sdk/TargetManager.ts +5 -6
  15. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +2 -0
  16. package/front_end/entrypoints/inspector_main/InspectorMain.ts +1 -13
  17. package/front_end/entrypoints/main/MainImpl.ts +2 -20
  18. package/front_end/foundation/Universe.ts +24 -1
  19. package/front_end/models/ai_assistance/agents/AiAgent.ts +10 -8
  20. package/front_end/models/ai_assistance/agents/PatchAgent.ts +7 -1
  21. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +0 -5
  22. package/front_end/models/ai_assistance/agents/StylingAgent.ts +4 -8
  23. package/front_end/models/ai_code_completion/AiCodeCompletion.ts +1 -1
  24. package/front_end/models/ai_code_generation/AiCodeGeneration.ts +5 -3
  25. package/front_end/models/bindings/CSSWorkspaceBinding.ts +8 -7
  26. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +19 -15
  27. package/front_end/models/bindings/ResourceMapping.ts +57 -15
  28. package/front_end/models/live-metrics/LiveMetrics.ts +12 -20
  29. package/front_end/models/trace/handlers/SamplesHandler.ts +64 -6
  30. package/front_end/models/trace/types/TraceEvents.ts +16 -0
  31. package/front_end/models/workspace/IgnoreListManager.ts +10 -9
  32. package/front_end/models/workspace/WorkspaceImpl.ts +5 -10
  33. package/front_end/panels/accessibility/AccessibilityNodeView.ts +6 -2
  34. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +1 -1
  35. package/front_end/panels/ai_assistance/components/ChatView.ts +2 -4
  36. package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +2 -1
  37. package/front_end/panels/animation/AnimationTimeline.ts +6 -6
  38. package/front_end/panels/application/ApplicationPanelSidebar.ts +0 -1
  39. package/front_end/panels/application/OpenedWindowDetailsView.ts +0 -2
  40. package/front_end/panels/application/ServiceWorkersView.ts +0 -2
  41. package/front_end/panels/application/StorageView.ts +0 -1
  42. package/front_end/panels/application/components/FrameDetailsView.ts +468 -447
  43. package/front_end/panels/application/components/ReportsGrid.ts +7 -2
  44. package/front_end/panels/application/components/SharedStorageAccessGrid.ts +5 -3
  45. package/front_end/panels/application/components/TrustTokensView.ts +7 -1
  46. package/front_end/panels/application/preloading/PreloadingView.ts +10 -4
  47. package/front_end/panels/application/preloading/components/PreloadingDisabledInfobar.ts +7 -11
  48. package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +15 -3
  49. package/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts +12 -13
  50. package/front_end/panels/{elements → common}/DOMLinkifier.ts +6 -6
  51. package/front_end/panels/common/common.ts +1 -0
  52. package/front_end/panels/console/ConsoleView.ts +9 -7
  53. package/front_end/panels/console/ConsoleViewMessage.ts +23 -13
  54. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +2 -1
  55. package/front_end/panels/elements/ElementsTreeElement.ts +3 -1
  56. package/front_end/panels/elements/StylePropertiesSection.ts +52 -15
  57. package/front_end/panels/elements/StylePropertyTreeElement.ts +8 -3
  58. package/front_end/panels/elements/StylesSidebarPane.ts +24 -14
  59. package/front_end/panels/elements/elements-meta.ts +11 -2
  60. package/front_end/panels/elements/elements.ts +0 -3
  61. package/front_end/panels/explain/components/ConsoleInsight.ts +333 -318
  62. package/front_end/panels/issues/AffectedResourcesView.ts +2 -1
  63. package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +2 -1
  64. package/front_end/panels/network/NetworkLogView.ts +1 -1
  65. package/front_end/panels/recorder/RecorderController.ts +7 -1
  66. package/front_end/panels/settings/SettingsScreen.ts +3 -6
  67. package/front_end/panels/settings/components/SyncSection.ts +218 -226
  68. package/front_end/panels/settings/components/syncSection.css +81 -80
  69. package/front_end/panels/sources/AiCodeCompletionPlugin.ts +42 -294
  70. package/front_end/panels/sources/DebuggerPausedMessage.ts +3 -3
  71. package/front_end/panels/sources/DebuggerPlugin.ts +3 -1
  72. package/front_end/panels/sources/ResourceOriginPlugin.ts +7 -3
  73. package/front_end/panels/sources/SourcesPanel.ts +5 -1
  74. package/front_end/panels/timeline/TimelinePanel.ts +0 -21
  75. package/front_end/panels/timeline/TimelineUIUtils.ts +3 -2
  76. package/front_end/panels/timeline/components/LiveMetricsView.ts +7 -4
  77. package/front_end/panels/timeline/components/insights/NodeLink.ts +3 -2
  78. package/front_end/third_party/puppeteer/README.chromium +2 -2
  79. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts +1 -0
  80. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
  81. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.js +4 -1
  82. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.js.map +1 -1
  83. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.d.ts +1 -0
  84. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.d.ts.map +1 -1
  85. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.js +8 -0
  86. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.js.map +1 -1
  87. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
  88. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.js +22 -0
  89. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.js.map +1 -1
  90. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
  91. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +3 -3
  92. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +3 -3
  93. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js.map +1 -1
  94. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
  95. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  96. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  97. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +34 -6
  98. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts +1 -0
  99. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
  100. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.js +4 -1
  101. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.js.map +1 -1
  102. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.d.ts +1 -0
  103. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.d.ts.map +1 -1
  104. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.js +8 -0
  105. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.js.map +1 -1
  106. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
  107. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.js +22 -0
  108. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.js.map +1 -1
  109. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +3 -3
  110. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +3 -3
  111. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js.map +1 -1
  112. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  113. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  114. package/front_end/third_party/puppeteer/package/package.json +2 -2
  115. package/front_end/third_party/puppeteer/package/src/cdp/HTTPRequest.ts +5 -1
  116. package/front_end/third_party/puppeteer/package/src/cdp/NetworkEventManager.ts +16 -1
  117. package/front_end/third_party/puppeteer/package/src/cdp/NetworkManager.ts +28 -0
  118. package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
  119. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  120. package/front_end/ui/components/docs/component_docs.ts +0 -4
  121. package/front_end/ui/components/report_view/ReportView.ts +4 -1
  122. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +8 -5
  123. package/front_end/ui/i18n/i18n.ts +16 -0
  124. package/front_end/ui/legacy/ReportView.ts +0 -5
  125. package/front_end/ui/legacy/TextPrompt.ts +65 -19
  126. package/front_end/ui/legacy/UIUtils.ts +1 -1
  127. package/front_end/ui/legacy/Widget.ts +56 -25
  128. package/front_end/ui/legacy/XLink.ts +0 -2
  129. package/front_end/ui/legacy/components/object_ui/JavaScriptREPL.ts +8 -4
  130. package/front_end/ui/legacy/components/object_ui/ObjectPopoverHelper.ts +3 -1
  131. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +239 -284
  132. package/front_end/ui/legacy/components/object_ui/RemoteObjectPreviewFormatter.ts +114 -184
  133. package/front_end/ui/legacy/components/utils/Linkifier.ts +1 -1
  134. package/front_end/ui/legacy/inspectorCommon.css +0 -4
  135. package/front_end/ui/{components/docs/theme_colors/basic.ts → legacy/theme_support/ThemeColors.docs.ts} +33 -23
  136. package/mcp/mcp.ts +1 -0
  137. package/package.json +1 -1
  138. package/front_end/core/common/QueryParamHandler.ts +0 -7
  139. package/front_end/ui/components/docs/input/basic.html +0 -31
  140. package/front_end/ui/components/docs/input/basic.ts +0 -12
  141. package/front_end/ui/components/docs/report/basic.html +0 -27
  142. package/front_end/ui/components/docs/report/basic.ts +0 -48
  143. package/front_end/ui/components/docs/theme_colors/basic.html +0 -56
  144. package/front_end/ui/components/docs/toggle_dark_mode.ts +0 -36
  145. package/front_end/ui/components/docs/toggle_fonts.ts +0 -74
  146. package/front_end/ui/components/docs/user_agent_client_hints/basic.html +0 -25
  147. package/front_end/ui/components/docs/user_agent_client_hints/basic.ts +0 -26
  148. package/front_end/ui/components/expandable_list/ExpandableList.docs.ts +0 -30
  149. /package/front_end/panels/{elements → common}/domLinkifier.css +0 -0
@@ -9,7 +9,7 @@ import './StackTrace.js';
9
9
 
10
10
  import * as Common from '../../../core/common/common.js';
11
11
  import * as i18n from '../../../core/i18n/i18n.js';
12
- import * as Platform from '../../../core/platform/platform.js';
12
+ import type * as Platform from '../../../core/platform/platform.js';
13
13
  import * as Root from '../../../core/root/root.js';
14
14
  import * as SDK from '../../../core/sdk/sdk.js';
15
15
  import * as Protocol from '../../../generated/protocol.js';
@@ -24,7 +24,7 @@ import * as RenderCoordinator from '../../../ui/components/render_coordinator/re
24
24
  import type * as ReportView from '../../../ui/components/report_view/report_view.js';
25
25
  import * as Components from '../../../ui/legacy/components/utils/utils.js';
26
26
  import * as UI from '../../../ui/legacy/legacy.js';
27
- import * as Lit from '../../../ui/lit/lit.js';
27
+ import {Directives, html, type LitTemplate, nothing, render} from '../../../ui/lit/lit.js';
28
28
  import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
29
29
 
30
30
  import frameDetailsReportViewStyles from './frameDetailsReportView.css.js';
@@ -35,7 +35,7 @@ import {
35
35
  } from './PermissionsPolicySection.js';
36
36
  import type {StackTraceData} from './StackTrace.js';
37
37
 
38
- const {html} = Lit;
38
+ const {until} = Directives;
39
39
  const {widgetConfig} = UI.Widget;
40
40
 
41
41
  const UIStrings = {
@@ -278,85 +278,50 @@ export interface FrameDetailsReportViewData {
278
278
  adScriptAncestry: Protocol.Page.AdScriptAncestry|null;
279
279
  }
280
280
 
281
- export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.WrappableComponent {
282
- readonly #shadow = this.attachShadow({mode: 'open'});
283
- #frame?: SDK.ResourceTreeModel.ResourceTreeFrame;
284
- #target: SDK.Target.Target|null = null;
285
- #protocolMonitorExperimentEnabled = false;
286
- #permissionsPolicies: Promise<Protocol.Page.PermissionsPolicyFeatureState[]|null>|null = null;
287
- #permissionsPolicySectionData: PermissionsPolicySectionData = {policies: [], showDetails: false};
288
- #linkifier = new Components.Linkifier.Linkifier();
289
- #adScriptAncestry: Protocol.Page.AdScriptAncestry|null = null;
281
+ interface FrameDetailsViewInput {
282
+ frame: SDK.ResourceTreeModel.ResourceTreeFrame;
283
+ target: SDK.Target.Target|null;
284
+ adScriptAncestry: Protocol.Page.AdScriptAncestry|null;
285
+ linkTargetDOMNode?: Promise<SDK.DOMModel.DOMNode|null>;
286
+ permissionsPolicies: Promise<Protocol.Page.PermissionsPolicyFeatureState[]|null>|null;
287
+ protocolMonitorExperimentEnabled: boolean;
288
+ trials: Protocol.Page.OriginTrial[]|null;
289
+ securityIsolationInfo?: Promise<Protocol.Network.SecurityIsolationStatus|null>;
290
+ onRevealInSources: () => void;
291
+ }
290
292
 
291
- constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) {
292
- super();
293
- this.#frame = frame;
294
- void this.render();
293
+ function renderFrameDetailsView(input: FrameDetailsViewInput, target: ShadowRoot): void {
294
+ if (!input.frame) {
295
+ return;
295
296
  }
297
+ // clang-format off
298
+ render(html`
299
+ <style>${frameDetailsReportViewStyles}</style>
300
+ <devtools-report .data=${{reportTitle: input.frame.displayName()} as ReportView.ReportView.ReportData}
301
+ jslog=${VisualLogging.pane('frames')}>
302
+ ${renderDocumentSection(input)}
303
+ ${renderIsolationSection(input)}
304
+ ${renderApiAvailabilitySection(input.frame)}
305
+ ${renderOriginTrial(input.trials)}
306
+ ${until(input.permissionsPolicies?.then?.(policies =>
307
+ html`
308
+ <devtools-resources-permissions-policy-section .data=${{policies, showDetails: false} as PermissionsPolicySectionData}>
309
+ </devtools-resources-permissions-policy-section>
310
+ `), nothing)}
311
+ ${input.protocolMonitorExperimentEnabled ? renderAdditionalInfoSection(input.frame) : nothing}
312
+ </devtools-report>
313
+ `, target);
314
+ // clang-format on
315
+ }
296
316
 
297
- connectedCallback(): void {
298
- this.parentElement?.classList.add('overflow-auto');
299
- this.#protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocol-monitor');
300
- }
301
-
302
- override async render(): Promise<void> {
303
- const result = await this.#frame?.parentFrame()?.getAdScriptAncestry(this.#frame?.id);
304
- if (result && result.ancestryChain.length > 0) {
305
- this.#adScriptAncestry = result;
306
-
307
- // Obtain the Target associated with the first ad script, because in most scenarios all
308
- // scripts share the same debuggerId. However, discrepancies might arise when content scripts
309
- // from browser extensions are involved. We will monitor the debugging experiences and revisit
310
- // this approach if it proves problematic.
311
- const firstScript = this.#adScriptAncestry.ancestryChain[0];
312
- const debuggerModel = firstScript?.debuggerId ?
313
- await SDK.DebuggerModel.DebuggerModel.modelForDebuggerId(firstScript.debuggerId) :
314
- null;
315
- this.#target = debuggerModel?.target() ?? null;
316
- }
317
-
318
- if (!this.#permissionsPolicies && this.#frame) {
319
- this.#permissionsPolicies = this.#frame.getPermissionsPolicyState();
320
- }
321
- await RenderCoordinator.write('FrameDetailsView render', async () => {
322
- if (!this.#frame) {
323
- return;
324
- }
325
-
326
- // Disabled until https://crbug.com/1079231 is fixed.
327
- // clang-format off
328
- Lit.render(html`
329
- <style>${frameDetailsReportViewStyles}</style>
330
- <devtools-report .data=${{reportTitle: this.#frame.displayName()} as ReportView.ReportView.ReportData}
331
- jslog=${VisualLogging.pane('frames')}>
332
- ${this.#renderDocumentSection()}
333
- ${this.#renderIsolationSection()}
334
- ${this.#renderApiAvailabilitySection()}
335
- ${await this.#renderOriginTrial()}
336
- ${Lit.Directives.until(this.#permissionsPolicies?.then(policies => {
337
- this.#permissionsPolicySectionData.policies = policies || [];
338
- return html`
339
- <devtools-resources-permissions-policy-section
340
- .data=${this.#permissionsPolicySectionData}
341
- >
342
- </devtools-resources-permissions-policy-section>
343
- `;
344
- }), Lit.nothing)}
345
- ${this.#protocolMonitorExperimentEnabled ? this.#renderAdditionalInfoSection() : Lit.nothing}
346
- </devtools-report>
347
- `, this.#shadow, {host: this});
348
- // clang-format on
349
- });
317
+ function renderOriginTrial(trials: Protocol.Page.OriginTrial[]|null): LitTemplate {
318
+ if (!trials) {
319
+ return nothing;
350
320
  }
351
321
 
352
- async #renderOriginTrial(): Promise<Lit.LitTemplate> {
353
- if (!this.#frame) {
354
- return Lit.nothing;
355
- }
356
-
357
- const data = {trials: await this.#frame.getOriginTrials()};
358
- // clang-format off
359
- return html`
322
+ const data = {trials};
323
+ // clang-format off
324
+ return html`
360
325
  <devtools-report-section-header>
361
326
  ${i18n.i18n.lockedString('Origin trials')}
362
327
  </devtools-report-section-header>
@@ -372,166 +337,146 @@ export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.Wrappabl
372
337
  <devtools-widget class="span-cols" .widgetConfig=${widgetConfig(OriginTrialTreeView, {data})}>
373
338
  </devtools-widget>
374
339
  <devtools-report-divider></devtools-report-divider>`;
375
- // clang-format on
376
- }
340
+ // clang-format on
341
+ }
377
342
 
378
- #renderDocumentSection(): Lit.LitTemplate {
379
- if (!this.#frame) {
380
- return Lit.nothing;
381
- }
343
+ function renderDocumentSection(input: FrameDetailsViewInput): LitTemplate {
344
+ if (!input.frame) {
345
+ return nothing;
346
+ }
382
347
 
383
- return html`
348
+ return html`
384
349
  <devtools-report-section-header>${i18nString(UIStrings.document)}</devtools-report-section-header>
385
350
  <devtools-report-key>${i18nString(UIStrings.url)}</devtools-report-key>
386
351
  <devtools-report-value>
387
352
  <div class="inline-items">
388
- ${this.#maybeRenderSourcesLinkForURL()}
389
- ${this.#maybeRenderNetworkLinkForURL()}
390
- <div class="text-ellipsis" title=${this.#frame.url}>${this.#frame.url}</div>
353
+ ${maybeRenderSourcesLinkForURL(input.frame, input.onRevealInSources)}
354
+ ${maybeRenderNetworkLinkForURL(input.frame)}
355
+ <div class="text-ellipsis" title=${input.frame.url}>${input.frame.url}</div>
391
356
  </div>
392
357
  </devtools-report-value>
393
- ${this.#maybeRenderUnreachableURL()}
394
- ${this.#maybeRenderOrigin()}
395
- ${Lit.Directives.until(this.#renderOwnerElement(), Lit.nothing)}
396
- ${this.#maybeRenderCreationStacktrace()}
397
- ${this.#maybeRenderAdStatus()}
398
- ${this.#maybeRenderCreatorAdScriptAncestry()}
358
+ ${maybeRenderUnreachableURL(input.frame)}
359
+ ${maybeRenderOrigin(input.frame)}
360
+ ${until(input.linkTargetDOMNode?.then?.(value => renderOwnerElement(input.frame, value)), nothing)}
361
+ ${maybeRenderCreationStacktrace(input.frame)}
362
+ ${maybeRenderAdStatus(input.frame)}
363
+ ${maybeRenderCreatorAdScriptAncestry(input.frame, input.target, input.adScriptAncestry)}
399
364
  <devtools-report-divider></devtools-report-divider>
400
365
  `;
401
- }
366
+ }
402
367
 
403
- #maybeRenderSourcesLinkForURL(): Lit.LitTemplate {
404
- const frame = this.#frame;
405
- if (!frame || frame.unreachableUrl()) {
406
- return Lit.nothing;
407
- }
408
- return renderIconLink(
409
- 'label',
410
- i18nString(UIStrings.clickToOpenInSourcesPanel),
411
- async () => {
412
- const sourceCode = this.#uiSourceCodeForFrame(frame);
413
- if (sourceCode) {
414
- await Common.Revealer.reveal(sourceCode);
415
- }
416
- },
417
- 'reveal-in-sources',
418
- );
419
- }
420
-
421
- #maybeRenderNetworkLinkForURL(): Lit.LitTemplate {
422
- if (this.#frame) {
423
- const resource = this.#frame.resourceForURL(this.#frame.url);
424
- if (resource?.request) {
425
- const request = resource.request;
426
- return renderIconLink('arrow-up-down-circle', i18nString(UIStrings.clickToOpenInNetworkPanel), () => {
427
- const requestLocation = NetworkForward.UIRequestLocation.UIRequestLocation.tab(
428
- request, NetworkForward.UIRequestLocation.UIRequestTabs.HEADERS_COMPONENT);
429
- return Common.Revealer.reveal(requestLocation);
430
- }, 'reveal-in-network');
431
- }
432
- }
433
- return Lit.nothing;
368
+ function maybeRenderSourcesLinkForURL(
369
+ frame: SDK.ResourceTreeModel.ResourceTreeFrame|null, onRevealInSources: () => void): LitTemplate {
370
+ if (!frame || frame.unreachableUrl()) {
371
+ return nothing;
434
372
  }
373
+ return renderIconLink(
374
+ 'label',
375
+ i18nString(UIStrings.clickToOpenInSourcesPanel),
376
+ onRevealInSources,
377
+ 'reveal-in-sources',
378
+ );
379
+ }
435
380
 
436
- #uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode|null {
437
- for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) {
438
- const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project);
439
- if (projectTarget && projectTarget === frame.resourceTreeModel().target()) {
440
- const uiSourceCode = project.uiSourceCodeForURL(frame.url);
441
- if (uiSourceCode) {
442
- return uiSourceCode;
443
- }
444
- }
381
+ function maybeRenderNetworkLinkForURL(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
382
+ if (frame) {
383
+ const resource = frame.resourceForURL(frame.url);
384
+ if (resource?.request) {
385
+ const request = resource.request;
386
+ return renderIconLink('arrow-up-down-circle', i18nString(UIStrings.clickToOpenInNetworkPanel), () => {
387
+ const requestLocation = NetworkForward.UIRequestLocation.UIRequestLocation.tab(
388
+ request, NetworkForward.UIRequestLocation.UIRequestTabs.HEADERS_COMPONENT);
389
+ return Common.Revealer.reveal(requestLocation);
390
+ }, 'reveal-in-network');
445
391
  }
446
- return null;
447
392
  }
393
+ return nothing;
394
+ }
448
395
 
449
- #maybeRenderUnreachableURL(): Lit.LitTemplate {
450
- if (!this.#frame || !this.#frame.unreachableUrl()) {
451
- return Lit.nothing;
452
- }
453
- return html`
396
+ function maybeRenderUnreachableURL(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
397
+ if (!frame?.unreachableUrl()) {
398
+ return nothing;
399
+ }
400
+ return html`
454
401
  <devtools-report-key>${i18nString(UIStrings.unreachableUrl)}</devtools-report-key>
455
402
  <devtools-report-value>
456
403
  <div class="inline-items">
457
- ${this.#renderNetworkLinkForUnreachableURL()}
458
- <div class="text-ellipsis" title=${this.#frame.unreachableUrl()}>${this.#frame.unreachableUrl()}</div>
404
+ ${renderNetworkLinkForUnreachableURL(frame)}
405
+ <div class="text-ellipsis" title=${frame.unreachableUrl()}>${frame.unreachableUrl()}</div>
459
406
  </div>
460
407
  </devtools-report-value>
461
408
  `;
462
- }
409
+ }
463
410
 
464
- #renderNetworkLinkForUnreachableURL(): Lit.LitTemplate {
465
- if (this.#frame) {
466
- const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(this.#frame.unreachableUrl());
467
- if (unreachableUrl) {
468
- return renderIconLink(
469
- 'arrow-up-down-circle',
470
- i18nString(UIStrings.clickToOpenInNetworkPanelMight),
471
- ():
472
- void => {
473
- void Common.Revealer.reveal(NetworkForward.UIFilter.UIRequestFilter.filters([
474
- {
475
- filterType: NetworkForward.UIFilter.FilterType.Domain,
476
- filterValue: unreachableUrl.domain(),
477
- },
478
- {
479
- filterType: null,
480
- filterValue: unreachableUrl.path,
481
- },
482
- ]));
483
- },
484
- 'unreachable-url.reveal-in-network',
485
- );
486
- }
411
+ function renderNetworkLinkForUnreachableURL(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
412
+ if (frame) {
413
+ const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(frame.unreachableUrl());
414
+ if (unreachableUrl) {
415
+ return renderIconLink(
416
+ 'arrow-up-down-circle',
417
+ i18nString(UIStrings.clickToOpenInNetworkPanelMight),
418
+ ():
419
+ void => {
420
+ void Common.Revealer.reveal(NetworkForward.UIFilter.UIRequestFilter.filters([
421
+ {
422
+ filterType: NetworkForward.UIFilter.FilterType.Domain,
423
+ filterValue: unreachableUrl.domain(),
424
+ },
425
+ {
426
+ filterType: null,
427
+ filterValue: unreachableUrl.path,
428
+ },
429
+ ]));
430
+ },
431
+ 'unreachable-url.reveal-in-network',
432
+ );
487
433
  }
488
- return Lit.nothing;
489
434
  }
435
+ return nothing;
436
+ }
490
437
 
491
- #maybeRenderOrigin(): Lit.LitTemplate {
492
- if (this.#frame && this.#frame.securityOrigin && this.#frame.securityOrigin !== '://') {
493
- return html`
438
+ function maybeRenderOrigin(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
439
+ if (frame?.securityOrigin && frame?.securityOrigin !== '://') {
440
+ return html`
494
441
  <devtools-report-key>${i18nString(UIStrings.origin)}</devtools-report-key>
495
442
  <devtools-report-value>
496
- <div class="text-ellipsis" title=${this.#frame.securityOrigin}>${this.#frame.securityOrigin}</div>
443
+ <div class="text-ellipsis" title=${frame.securityOrigin}>${frame.securityOrigin}</div>
497
444
  </devtools-report-value>
498
445
  `;
499
- }
500
- return Lit.nothing;
501
- }
502
-
503
- async #renderOwnerElement(): Promise<Lit.LitTemplate> {
504
- if (this.#frame) {
505
- const linkTargetDOMNode = await this.#frame.getOwnerDOMNodeOrDocument();
506
- if (linkTargetDOMNode) {
507
- // Disabled until https://crbug.com/1079231 is fixed.
508
- // clang-format off
509
- return html`
510
- <devtools-report-key>${i18nString(UIStrings.ownerElement)}</devtools-report-key>
511
- <devtools-report-value class="without-min-width">
512
- <div class="inline-items">
513
- <button class="link text-link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToOpenInElementsPanel)}
514
- @mouseenter=${() => this.#frame?.highlight()}
515
- @mouseleave=${() => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()}
516
- @click=${() => Common.Revealer.reveal(linkTargetDOMNode)}
517
- jslog=${VisualLogging.action('reveal-in-elements').track({click: true})}
518
- >
519
- &lt;${linkTargetDOMNode.nodeName().toLocaleLowerCase()}&gt;
520
- </button>
521
- </div>
522
- </devtools-report-value>
523
- `;
524
- // clang-format on
525
- }
526
- }
527
- return Lit.nothing;
528
446
  }
447
+ return nothing;
448
+ }
449
+
450
+ function renderOwnerElement(
451
+ frame: SDK.ResourceTreeModel.ResourceTreeFrame|null, linkTargetDOMNode: SDK.DOMModel.DOMNode|null): LitTemplate {
452
+ if (linkTargetDOMNode) {
453
+ // Disabled until https://crbug.com/1079231 is fixed.
454
+ // clang-format off
455
+ return html`
456
+ <devtools-report-key>${i18nString(UIStrings.ownerElement)}</devtools-report-key>
457
+ <devtools-report-value class="without-min-width">
458
+ <div class="inline-items">
459
+ <button class="link text-link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToOpenInElementsPanel)}
460
+ @mouseenter=${() => frame?.highlight()}
461
+ @mouseleave=${() => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()}
462
+ @click=${() => Common.Revealer.reveal(linkTargetDOMNode)}
463
+ jslog=${VisualLogging.action('reveal-in-elements').track({click: true})}
464
+ >
465
+ &lt;${linkTargetDOMNode.nodeName().toLocaleLowerCase()}&gt;
466
+ </button>
467
+ </div>
468
+ </devtools-report-value>
469
+ `;
470
+ // clang-format on
471
+ }
472
+ return nothing;
473
+ }
529
474
 
530
- #maybeRenderCreationStacktrace(): Lit.LitTemplate {
531
- const creationStackTraceData = this.#frame?.getCreationStackTraceData();
532
- if (creationStackTraceData?.creationStackTrace) {
533
- // Disabled until https://crbug.com/1079231 is fixed.
534
- // clang-format off
475
+ function maybeRenderCreationStacktrace(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
476
+ const creationStackTraceData = frame?.getCreationStackTraceData();
477
+ if (creationStackTraceData?.creationStackTrace) {
478
+ // Disabled until https://crbug.com/1079231 is fixed.
479
+ // clang-format off
535
480
  return html`
536
481
  <devtools-report-key title=${i18nString(UIStrings.creationStackTraceExplanation)}>${
537
482
  i18nString(UIStrings.creationStackTrace)}</devtools-report-key>
@@ -539,54 +484,54 @@ export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.Wrappabl
539
484
  jslog=${VisualLogging.section('frame-creation-stack-trace')}
540
485
  >
541
486
  <devtools-resources-stack-trace .data=${{
542
- frame: this.#frame,
487
+ frame,
543
488
  buildStackTraceRows: Components.JSPresentationUtils.buildStackTraceRowsForLegacyRuntimeStackTrace,
544
489
  } as StackTraceData}>
545
490
  </devtools-resources-stack-trace>
546
491
  </devtools-report-value>
547
492
  `;
548
- // clang-format on
549
- }
550
- return Lit.nothing;
493
+ // clang-format on
551
494
  }
495
+ return nothing;
496
+ }
552
497
 
553
- #getAdFrameTypeStrings(type: Protocol.Page.AdFrameType.Child|Protocol.Page.AdFrameType.Root):
554
- {value: Platform.UIString.LocalizedString, description: Platform.UIString.LocalizedString} {
555
- switch (type) {
556
- case Protocol.Page.AdFrameType.Child:
557
- return {value: i18nString(UIStrings.child), description: i18nString(UIStrings.childDescription)};
558
- case Protocol.Page.AdFrameType.Root:
559
- return {value: i18nString(UIStrings.root), description: i18nString(UIStrings.rootDescription)};
560
- }
498
+ function getAdFrameTypeStrings(type: Protocol.Page.AdFrameType.Child|Protocol.Page.AdFrameType.Root):
499
+ {value: Platform.UIString.LocalizedString, description: Platform.UIString.LocalizedString} {
500
+ switch (type) {
501
+ case Protocol.Page.AdFrameType.Child:
502
+ return {value: i18nString(UIStrings.child), description: i18nString(UIStrings.childDescription)};
503
+ case Protocol.Page.AdFrameType.Root:
504
+ return {value: i18nString(UIStrings.root), description: i18nString(UIStrings.rootDescription)};
561
505
  }
506
+ }
562
507
 
563
- #getAdFrameExplanationString(explanation: Protocol.Page.AdFrameExplanation): Platform.UIString.LocalizedString {
564
- switch (explanation) {
565
- case Protocol.Page.AdFrameExplanation.CreatedByAdScript:
566
- return i18nString(UIStrings.createdByAdScriptExplanation);
567
- case Protocol.Page.AdFrameExplanation.MatchedBlockingRule:
568
- return i18nString(UIStrings.matchedBlockingRuleExplanation);
569
- case Protocol.Page.AdFrameExplanation.ParentIsAd:
570
- return i18nString(UIStrings.parentIsAdExplanation);
571
- }
508
+ function getAdFrameExplanationString(explanation: Protocol.Page.AdFrameExplanation): Platform.UIString.LocalizedString {
509
+ switch (explanation) {
510
+ case Protocol.Page.AdFrameExplanation.CreatedByAdScript:
511
+ return i18nString(UIStrings.createdByAdScriptExplanation);
512
+ case Protocol.Page.AdFrameExplanation.MatchedBlockingRule:
513
+ return i18nString(UIStrings.matchedBlockingRuleExplanation);
514
+ case Protocol.Page.AdFrameExplanation.ParentIsAd:
515
+ return i18nString(UIStrings.parentIsAdExplanation);
572
516
  }
517
+ }
573
518
 
574
- #maybeRenderAdStatus(): Lit.LitTemplate {
575
- if (!this.#frame) {
576
- return Lit.nothing;
577
- }
578
- const adFrameType = this.#frame.adFrameType();
579
- if (adFrameType === Protocol.Page.AdFrameType.None) {
580
- return Lit.nothing;
581
- }
582
- const typeStrings = this.#getAdFrameTypeStrings(adFrameType);
583
- const rows = [html`<div title=${typeStrings.description}>${typeStrings.value}</div>`];
584
- for (const explanation of this.#frame.adFrameStatus()?.explanations || []) {
585
- rows.push(html`<div>${this.#getAdFrameExplanationString(explanation)}</div>`);
586
- }
519
+ function maybeRenderAdStatus(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
520
+ if (!frame) {
521
+ return nothing;
522
+ }
523
+ const adFrameType = frame.adFrameType();
524
+ if (adFrameType === Protocol.Page.AdFrameType.None) {
525
+ return nothing;
526
+ }
527
+ const typeStrings = getAdFrameTypeStrings(adFrameType);
528
+ const rows = [html`<div title=${typeStrings.description}>${typeStrings.value}</div>`];
529
+ for (const explanation of frame.adFrameStatus()?.explanations || []) {
530
+ rows.push(html`<div>${getAdFrameExplanationString(explanation)}</div>`);
531
+ }
587
532
 
588
- // Disabled until https://crbug.com/1079231 is fixed.
589
- // clang-format off
533
+ // Disabled until https://crbug.com/1079231 is fixed.
534
+ // clang-format off
590
535
  return html`
591
536
  <devtools-report-key>${i18nString(UIStrings.adStatus)}</devtools-report-key>
592
537
  <devtools-report-value class="ad-status-list" jslog=${VisualLogging.section('ad-status')}>
@@ -594,40 +539,39 @@ export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.Wrappabl
594
539
  {rows, title: i18nString(UIStrings.adStatus)} as ExpandableList.ExpandableList.ExpandableListData}>
595
540
  </devtools-expandable-list>
596
541
  </devtools-report-value>`;
597
- // clang-format on
598
- }
599
-
600
- #maybeRenderCreatorAdScriptAncestry(): Lit.LitTemplate {
601
- if (!this.#frame) {
602
- return Lit.nothing;
603
- }
604
- const adFrameType = this.#frame.adFrameType();
605
- if (adFrameType === Protocol.Page.AdFrameType.None) {
606
- return Lit.nothing;
607
- }
608
-
609
- if (!this.#target || !this.#adScriptAncestry || this.#adScriptAncestry.ancestryChain.length === 0) {
610
- return Lit.nothing;
611
- }
612
-
613
- const rows = this.#adScriptAncestry.ancestryChain.map(adScriptId => {
614
- const adScriptLinkElement = this.#linkifier.linkifyScriptLocation(
615
- this.#target,
616
- adScriptId.scriptId || null,
617
- Platform.DevToolsPath.EmptyUrlString,
618
- undefined,
619
- undefined,
620
- );
621
-
622
- adScriptLinkElement?.setAttribute('jslog', `${VisualLogging.link('ad-script').track({click: true})}`);
542
+ // clang-format on
543
+ }
623
544
 
624
- return html`<div>${adScriptLinkElement}</div>`;
625
- });
545
+ function maybeRenderCreatorAdScriptAncestry(
546
+ frame: SDK.ResourceTreeModel.ResourceTreeFrame|null, target: SDK.Target.Target|null,
547
+ adScriptAncestry: Protocol.Page.AdScriptAncestry|null): LitTemplate {
548
+ if (!frame) {
549
+ return nothing;
550
+ }
551
+ const adFrameType = frame.adFrameType();
552
+ if (adFrameType === Protocol.Page.AdFrameType.None) {
553
+ return nothing;
554
+ }
626
555
 
627
- const shouldRenderFilterlistRule = (this.#adScriptAncestry.rootScriptFilterlistRule !== undefined);
556
+ if (!target || !adScriptAncestry || adScriptAncestry.ancestryChain.length === 0) {
557
+ return nothing;
558
+ }
628
559
 
560
+ const rows = adScriptAncestry.ancestryChain.map(adScriptId => {
629
561
  // Disabled until https://crbug.com/1079231 is fixed.
630
562
  // clang-format off
563
+ return html`<div>
564
+ <devtools-widget .widgetConfig=${widgetConfig(Components.Linkifier.ScriptLocationLink, {
565
+ target, scriptId: adScriptId.scriptId, options: {jslogContext: 'ad-script'}})}>
566
+ </devtools-widget>
567
+ </div>`;
568
+ // clang-format on
569
+ });
570
+
571
+ const shouldRenderFilterlistRule = (adScriptAncestry.rootScriptFilterlistRule !== undefined);
572
+
573
+ // Disabled until https://crbug.com/1079231 is fixed.
574
+ // clang-format off
631
575
  return html`
632
576
  <devtools-report-key>${i18nString(UIStrings.creatorAdScriptAncestry)}</devtools-report-key>
633
577
  <devtools-report-value class="creator-ad-script-ancestry-list" jslog=${VisualLogging.section('creator-ad-script-ancestry')}>
@@ -637,142 +581,138 @@ export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.Wrappabl
637
581
  </devtools-report-value>
638
582
  ${shouldRenderFilterlistRule ? html`
639
583
  <devtools-report-key>${i18nString(UIStrings.rootScriptFilterlistRule)}</devtools-report-key>
640
- <devtools-report-value jslog=${VisualLogging.section('root-script-filterlist-rule')}>${this.#adScriptAncestry.rootScriptFilterlistRule}</devtools-report-value>
641
- ` : Lit.nothing}
584
+ <devtools-report-value jslog=${VisualLogging.section('root-script-filterlist-rule')}>${adScriptAncestry.rootScriptFilterlistRule}</devtools-report-value>
585
+ ` : nothing}
642
586
  `;
643
- // clang-format on
644
- }
587
+ // clang-format on
588
+ }
645
589
 
646
- #renderIsolationSection(): Lit.LitTemplate {
647
- if (!this.#frame) {
648
- return Lit.nothing;
649
- }
650
- return html`
590
+ function renderIsolationSection(input: FrameDetailsViewInput): LitTemplate {
591
+ if (!input.frame) {
592
+ return nothing;
593
+ }
594
+ return html`
651
595
  <devtools-report-section-header>${i18nString(UIStrings.securityIsolation)}</devtools-report-section-header>
652
596
  <devtools-report-key>${i18nString(UIStrings.secureContext)}</devtools-report-key>
653
597
  <devtools-report-value>
654
- ${this.#frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}\xA0${
655
- this.#maybeRenderSecureContextExplanation()}
598
+ ${input.frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}\xA0${
599
+ maybeRenderSecureContextExplanation(input.frame)}
656
600
  </devtools-report-value>
657
601
  <devtools-report-key>${i18nString(UIStrings.crossoriginIsolated)}</devtools-report-key>
658
602
  <devtools-report-value>
659
- ${this.#frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
603
+ ${input.frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
660
604
  </devtools-report-value>
661
- ${Lit.Directives.until(this.#maybeRenderCoopCoepCSPStatus(), Lit.nothing)}
605
+ ${until(input.securityIsolationInfo?.then?.(value => maybeRenderCoopCoepCSPStatus(value)), nothing)}
662
606
  <devtools-report-divider></devtools-report-divider>
663
607
  `;
608
+ }
609
+
610
+ function maybeRenderSecureContextExplanation(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
611
+ const explanation = getSecureContextExplanation(frame);
612
+ if (explanation) {
613
+ return html`<span class="inline-comment">${explanation}</span>`;
664
614
  }
615
+ return nothing;
616
+ }
665
617
 
666
- #maybeRenderSecureContextExplanation(): Lit.LitTemplate {
667
- const explanation = this.#getSecureContextExplanation();
668
- if (explanation) {
669
- return html`<span class="inline-comment">${explanation}</span>`;
670
- }
671
- return Lit.nothing;
672
- }
673
-
674
- #getSecureContextExplanation(): Platform.UIString.LocalizedString|null {
675
- switch (this.#frame?.getSecureContextType()) {
676
- case Protocol.Page.SecureContextType.Secure:
677
- return null;
678
- case Protocol.Page.SecureContextType.SecureLocalhost:
679
- return i18nString(UIStrings.localhostIsAlwaysASecureContext);
680
- case Protocol.Page.SecureContextType.InsecureAncestor:
681
- return i18nString(UIStrings.aFrameAncestorIsAnInsecure);
682
- case Protocol.Page.SecureContextType.InsecureScheme:
683
- return i18nString(UIStrings.theFramesSchemeIsInsecure);
684
- }
685
- return null;
618
+ function getSecureContextExplanation(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null):
619
+ Platform.UIString.LocalizedString|null {
620
+ switch (frame?.getSecureContextType()) {
621
+ case Protocol.Page.SecureContextType.Secure:
622
+ return null;
623
+ case Protocol.Page.SecureContextType.SecureLocalhost:
624
+ return i18nString(UIStrings.localhostIsAlwaysASecureContext);
625
+ case Protocol.Page.SecureContextType.InsecureAncestor:
626
+ return i18nString(UIStrings.aFrameAncestorIsAnInsecure);
627
+ case Protocol.Page.SecureContextType.InsecureScheme:
628
+ return i18nString(UIStrings.theFramesSchemeIsInsecure);
686
629
  }
630
+ return null;
631
+ }
687
632
 
688
- async #maybeRenderCoopCoepCSPStatus(): Promise<Lit.LitTemplate> {
689
- if (this.#frame) {
690
- const model = this.#frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager);
691
- const info = model && await model.getSecurityIsolationStatus(this.#frame.id);
692
- if (info) {
693
- return html`
633
+ async function maybeRenderCoopCoepCSPStatus(info: Protocol.Network.SecurityIsolationStatus|null): Promise<LitTemplate> {
634
+ if (info) {
635
+ return html`
694
636
  ${
695
- this.#maybeRenderCrossOriginStatus(
696
- info.coep, i18n.i18n.lockedString('Cross-Origin Embedder Policy (COEP)'),
697
- Protocol.Network.CrossOriginEmbedderPolicyValue.None)}
637
+ maybeRenderCrossOriginStatus(
638
+ info.coep, i18n.i18n.lockedString('Cross-Origin Embedder Policy (COEP)'),
639
+ Protocol.Network.CrossOriginEmbedderPolicyValue.None)}
698
640
  ${
699
- this.#maybeRenderCrossOriginStatus(
700
- info.coop, i18n.i18n.lockedString('Cross-Origin Opener Policy (COOP)'),
701
- Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)}
702
- ${this.#renderCSPSection(info.csp)}
641
+ maybeRenderCrossOriginStatus(
642
+ info.coop, i18n.i18n.lockedString('Cross-Origin Opener Policy (COOP)'),
643
+ Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)}
644
+ ${renderCSPSection(info.csp)}
703
645
  `;
704
- }
705
- }
706
- return Lit.nothing;
707
646
  }
647
+ return nothing;
648
+ }
708
649
 
709
- #maybeRenderCrossOriginStatus(
710
- info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined,
711
- policyName: string,
712
- noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue|
713
- Protocol.Network.CrossOriginOpenerPolicyValue): Lit.LitTemplate {
714
- if (!info) {
715
- return Lit.nothing;
716
- }
717
- function crossOriginValueToString(
718
- value: Protocol.Network.CrossOriginEmbedderPolicyValue|Protocol.Network.CrossOriginOpenerPolicyValue): string {
719
- switch (value) {
720
- case Protocol.Network.CrossOriginEmbedderPolicyValue.Credentialless:
721
- return 'credentialless';
722
- case Protocol.Network.CrossOriginEmbedderPolicyValue.None:
723
- return 'none';
724
- case Protocol.Network.CrossOriginEmbedderPolicyValue.RequireCorp:
725
- return 'require-corp';
726
- case Protocol.Network.CrossOriginOpenerPolicyValue.NoopenerAllowPopups:
727
- return 'noopenener-allow-popups';
728
- case Protocol.Network.CrossOriginOpenerPolicyValue.SameOrigin:
729
- return 'same-origin';
730
- case Protocol.Network.CrossOriginOpenerPolicyValue.SameOriginAllowPopups:
731
- return 'same-origin-allow-popups';
732
- case Protocol.Network.CrossOriginOpenerPolicyValue.SameOriginPlusCoep:
733
- return 'same-origin-plus-coep';
734
- case Protocol.Network.CrossOriginOpenerPolicyValue.RestrictProperties:
735
- return 'restrict-properties';
736
- case Protocol.Network.CrossOriginOpenerPolicyValue.RestrictPropertiesPlusCoep:
737
- return 'restrict-properties-plus-coep';
738
- case Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone:
739
- return 'unsafe-none';
740
- }
650
+ function maybeRenderCrossOriginStatus(
651
+ info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined,
652
+ policyName: string,
653
+ noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue|
654
+ Protocol.Network.CrossOriginOpenerPolicyValue): LitTemplate {
655
+ if (!info) {
656
+ return nothing;
657
+ }
658
+ function crossOriginValueToString(
659
+ value: Protocol.Network.CrossOriginEmbedderPolicyValue|Protocol.Network.CrossOriginOpenerPolicyValue): string {
660
+ switch (value) {
661
+ case Protocol.Network.CrossOriginEmbedderPolicyValue.Credentialless:
662
+ return 'credentialless';
663
+ case Protocol.Network.CrossOriginEmbedderPolicyValue.None:
664
+ return 'none';
665
+ case Protocol.Network.CrossOriginEmbedderPolicyValue.RequireCorp:
666
+ return 'require-corp';
667
+ case Protocol.Network.CrossOriginOpenerPolicyValue.NoopenerAllowPopups:
668
+ return 'noopenener-allow-popups';
669
+ case Protocol.Network.CrossOriginOpenerPolicyValue.SameOrigin:
670
+ return 'same-origin';
671
+ case Protocol.Network.CrossOriginOpenerPolicyValue.SameOriginAllowPopups:
672
+ return 'same-origin-allow-popups';
673
+ case Protocol.Network.CrossOriginOpenerPolicyValue.SameOriginPlusCoep:
674
+ return 'same-origin-plus-coep';
675
+ case Protocol.Network.CrossOriginOpenerPolicyValue.RestrictProperties:
676
+ return 'restrict-properties';
677
+ case Protocol.Network.CrossOriginOpenerPolicyValue.RestrictPropertiesPlusCoep:
678
+ return 'restrict-properties-plus-coep';
679
+ case Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone:
680
+ return 'unsafe-none';
741
681
  }
682
+ }
742
683
 
743
- const isEnabled = info.value !== noneValue;
744
- const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue);
745
- const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint;
746
- return html`
684
+ const isEnabled = info.value !== noneValue;
685
+ const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue);
686
+ const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint;
687
+ return html`
747
688
  <devtools-report-key>${policyName}</devtools-report-key>
748
689
  <devtools-report-value>
749
690
  ${crossOriginValueToString(isEnabled ? info.value : info.reportOnlyValue)}
750
- ${isReportOnly ? html`<span class="inline-comment">report-only</span>` : Lit.nothing}
751
- ${
752
- endpoint ? html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` : Lit.nothing}
691
+ ${isReportOnly ? html`<span class="inline-comment">report-only</span>` : nothing}
692
+ ${endpoint ? html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` : nothing}
753
693
  </devtools-report-value>
754
694
  `;
755
- }
695
+ }
756
696
 
757
- #renderEffectiveDirectives(directives: string): Lit.LitTemplate[] {
758
- const parsedDirectives = new CspEvaluator.CspParser.CspParser(directives).csp.directives;
759
- const result = [];
760
- for (const directive in parsedDirectives) {
761
- // Disabled until https://crbug.com/1079231 is fixed.
762
- // clang-format off
697
+ function renderEffectiveDirectives(directives: string): LitTemplate[] {
698
+ const parsedDirectives = new CspEvaluator.CspParser.CspParser(directives).csp.directives;
699
+ const result = [];
700
+ for (const directive in parsedDirectives) {
701
+ // Disabled until https://crbug.com/1079231 is fixed.
702
+ // clang-format off
763
703
  result.push(html`
764
704
  <div>
765
705
  <span class="bold">${directive}</span>
766
706
  ${': ' + parsedDirectives[directive]?.join(', ')}
767
707
  </div>`);
768
- // clang-format on
769
- }
770
- return result;
708
+ // clang-format on
771
709
  }
710
+ return result;
711
+ }
772
712
 
773
- #renderSingleCSP(cspInfo: Protocol.Network.ContentSecurityPolicyStatus, divider: boolean): Lit.LitTemplate {
774
- // Disabled until https://crbug.com/1079231 is fixed.
775
- // clang-format off
713
+ function renderSingleCSP(cspInfo: Protocol.Network.ContentSecurityPolicyStatus, divider: boolean): LitTemplate {
714
+ // Disabled until https://crbug.com/1079231 is fixed.
715
+ // clang-format off
776
716
  return html`
777
717
  <devtools-report-key>
778
718
  ${cspInfo.isEnforced ? i18n.i18n.lockedString('Content-Security-Policy') : html`
@@ -789,22 +729,22 @@ export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.Wrappabl
789
729
  <devtools-report-value>
790
730
  ${cspInfo.source === Protocol.Network.ContentSecurityPolicySource.HTTP ?
791
731
  i18n.i18n.lockedString('HTTP header') : i18n.i18n.lockedString('Meta tag')}
792
- ${this.#renderEffectiveDirectives(cspInfo.effectiveDirectives)}
732
+ ${renderEffectiveDirectives(cspInfo.effectiveDirectives)}
793
733
  </devtools-report-value>
794
- ${divider ? html`<devtools-report-divider class="subsection-divider"></devtools-report-divider>` : Lit.nothing}
734
+ ${divider ? html`<devtools-report-divider class="subsection-divider"></devtools-report-divider>` : nothing}
795
735
  `;
796
- // clang-format on
797
- }
736
+ // clang-format on
737
+ }
798
738
 
799
- #renderCSPSection(cspInfos: Protocol.Network.ContentSecurityPolicyStatus[]|undefined): Lit.LitTemplate {
800
- // Disabled until https://crbug.com/1079231 is fixed.
801
- // clang-format off
739
+ function renderCSPSection(cspInfos: Protocol.Network.ContentSecurityPolicyStatus[]|undefined): LitTemplate {
740
+ // Disabled until https://crbug.com/1079231 is fixed.
741
+ // clang-format off
802
742
  return html`
803
743
  <devtools-report-divider></devtools-report-divider>
804
744
  <devtools-report-section-header>
805
745
  ${i18nString(UIStrings.contentSecurityPolicy)}
806
746
  </devtools-report-section-header>
807
- ${(cspInfos?.length) ? cspInfos.map((cspInfo, index) => this.#renderSingleCSP(cspInfo, index < cspInfos?.length - 1)) : html`
747
+ ${(cspInfos?.length) ? cspInfos.map((cspInfo, index) => renderSingleCSP(cspInfo, index < cspInfos?.length - 1)) : html`
808
748
  <devtools-report-key>
809
749
  ${i18n.i18n.lockedString('Content-Security-Policy')}
810
750
  </devtools-report-key>
@@ -813,16 +753,16 @@ export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.Wrappabl
813
753
  </devtools-report-value>
814
754
  `}
815
755
  `;
816
- // clang-format on
817
- }
756
+ // clang-format on
757
+ }
818
758
 
819
- #renderApiAvailabilitySection(): Lit.LitTemplate {
820
- if (!this.#frame) {
821
- return Lit.nothing;
822
- }
759
+ function renderApiAvailabilitySection(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
760
+ if (!frame) {
761
+ return nothing;
762
+ }
823
763
 
824
- // Disabled until https://crbug.com/1079231 is fixed.
825
- // clang-format off
764
+ // Disabled until https://crbug.com/1079231 is fixed.
765
+ // clang-format off
826
766
  return html`
827
767
  <devtools-report-section-header>
828
768
  ${i18nString(UIStrings.apiAvailability)}
@@ -837,102 +777,183 @@ export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.Wrappabl
837
777
  </x-link>
838
778
  </span>
839
779
  </devtools-report-section>
840
- ${this.#renderSharedArrayBufferAvailability()}
841
- ${this.#renderMeasureMemoryAvailability()}
780
+ ${renderSharedArrayBufferAvailability(frame)}
781
+ ${renderMeasureMemoryAvailability(frame)}
842
782
  <devtools-report-divider></devtools-report-divider>`;
843
- // clang-format on
844
- }
783
+ // clang-format on
784
+ }
845
785
 
846
- #renderSharedArrayBufferAvailability(): Lit.LitTemplate {
847
- if (this.#frame) {
848
- const features = this.#frame.getGatedAPIFeatures();
849
- if (features) {
850
- const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers);
851
- const sabTransferAvailable =
852
- sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed);
853
- const availabilityText = sabTransferAvailable ?
854
- i18nString(UIStrings.availableTransferable) :
855
- (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable));
856
- const tooltipText = sabTransferAvailable ?
857
- i18nString(UIStrings.sharedarraybufferConstructorIs) :
858
- (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : '');
859
-
860
- function renderHint(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Lit.LitTemplate {
861
- switch (frame.getCrossOriginIsolatedContextType()) {
862
- case Protocol.Page.CrossOriginIsolatedContextType.Isolated:
863
- return Lit.nothing;
864
- case Protocol.Page.CrossOriginIsolatedContextType.NotIsolated:
865
- if (sabAvailable) {
866
- // clang-format off
786
+ function renderSharedArrayBufferAvailability(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
787
+ if (frame) {
788
+ const features = frame.getGatedAPIFeatures();
789
+ if (features) {
790
+ const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers);
791
+ const sabTransferAvailable =
792
+ sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed);
793
+ const availabilityText = sabTransferAvailable ?
794
+ i18nString(UIStrings.availableTransferable) :
795
+ (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable));
796
+ const tooltipText = sabTransferAvailable ?
797
+ i18nString(UIStrings.sharedarraybufferConstructorIs) :
798
+ (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : '');
799
+
800
+ function renderHint(frame: SDK.ResourceTreeModel.ResourceTreeFrame): LitTemplate {
801
+ switch (frame.getCrossOriginIsolatedContextType()) {
802
+ case Protocol.Page.CrossOriginIsolatedContextType.Isolated:
803
+ return nothing;
804
+ case Protocol.Page.CrossOriginIsolatedContextType.NotIsolated:
805
+ if (sabAvailable) {
806
+ // clang-format off
867
807
  return html`
868
808
  <span class="inline-comment">
869
809
  ${i18nString(UIStrings.willRequireCrossoriginIsolated)}
870
810
  </span>`;
871
- // clang-format on
872
- }
873
- return html`<span class="inline-comment">${i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`;
874
- case Protocol.Page.CrossOriginIsolatedContextType.NotIsolatedFeatureDisabled:
875
- if (!sabTransferAvailable) {
876
- // clang-format off
811
+ // clang-format on
812
+ }
813
+ return html`<span class="inline-comment">${i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`;
814
+ case Protocol.Page.CrossOriginIsolatedContextType.NotIsolatedFeatureDisabled:
815
+ if (!sabTransferAvailable) {
816
+ // clang-format off
877
817
  return html`
878
818
  <span class="inline-comment">
879
819
  ${i18nString(UIStrings.transferRequiresCrossoriginIsolatedPermission)}
880
820
  <code> cross-origin-isolated</code>
881
821
  </span>`;
882
- // clang-format on
883
- }
884
- break;
885
- }
886
- return Lit.nothing;
822
+ // clang-format on
823
+ }
824
+ break;
887
825
  }
826
+ return nothing;
827
+ }
888
828
 
889
- // SharedArrayBuffer is an API name, so we don't translate it.
890
- return html`
829
+ // SharedArrayBuffer is an API name, so we don't translate it.
830
+ return html`
891
831
  <devtools-report-key>SharedArrayBuffers</devtools-report-key>
892
832
  <devtools-report-value title=${tooltipText}>
893
- ${availabilityText}\xA0${renderHint(this.#frame)}
833
+ ${availabilityText}\xA0${renderHint(frame)}
894
834
  </devtools-report-value>
895
835
  `;
896
- }
897
836
  }
898
- return Lit.nothing;
899
837
  }
838
+ return nothing;
839
+ }
900
840
 
901
- #renderMeasureMemoryAvailability(): Lit.LitTemplate {
902
- if (this.#frame) {
903
- const measureMemoryAvailable = this.#frame.isCrossOriginIsolated();
904
- const availabilityText =
905
- measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable);
906
- const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) :
907
- i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory);
908
- return html`
841
+ function renderMeasureMemoryAvailability(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
842
+ if (frame) {
843
+ const measureMemoryAvailable = frame.isCrossOriginIsolated();
844
+ const availabilityText =
845
+ measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable);
846
+ const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) :
847
+ i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory);
848
+ return html`
909
849
  <devtools-report-key>${i18nString(UIStrings.measureMemory)}</devtools-report-key>
910
850
  <devtools-report-value>
911
851
  <span title=${tooltipText}>${
912
- availabilityText}</span>\xA0<x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/" jslog=${
913
- VisualLogging.link('learn-more.monitor-memory-usage').track({click: true})}>${
914
- i18nString(UIStrings.learnMore)}</x-link>
852
+ availabilityText}</span>\xA0<x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/" jslog=${
853
+ VisualLogging.link('learn-more.monitor-memory-usage').track({click: true})}>${
854
+ i18nString(UIStrings.learnMore)}</x-link>
915
855
  </devtools-report-value>
916
856
  `;
917
- }
918
- return Lit.nothing;
919
857
  }
858
+ return nothing;
859
+ }
920
860
 
921
- #renderAdditionalInfoSection(): Lit.LitTemplate {
922
- if (!this.#frame) {
923
- return Lit.nothing;
924
- }
861
+ function renderAdditionalInfoSection(frame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitTemplate {
862
+ if (!frame) {
863
+ return nothing;
864
+ }
925
865
 
926
- return html`
866
+ return html`
927
867
  <devtools-report-section-header
928
868
  title=${i18nString(UIStrings.thisAdditionalDebugging)}
929
869
  >${i18nString(UIStrings.additionalInformation)}</devtools-report-section-header>
930
870
  <devtools-report-key>${i18nString(UIStrings.frameId)}</devtools-report-key>
931
871
  <devtools-report-value>
932
- <div class="text-ellipsis" title=${this.#frame.id}>${this.#frame.id}</div>
872
+ <div class="text-ellipsis" title=${frame.id}>${frame.id}</div>
933
873
  </devtools-report-value>
934
874
  <devtools-report-divider></devtools-report-divider>
935
875
  `;
876
+ }
877
+
878
+ export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.WrappableComponent {
879
+ readonly #shadow = this.attachShadow({mode: 'open'});
880
+ #frame?: SDK.ResourceTreeModel.ResourceTreeFrame;
881
+ #target: SDK.Target.Target|null = null;
882
+ #protocolMonitorExperimentEnabled = false;
883
+ #permissionsPolicies: Promise<Protocol.Page.PermissionsPolicyFeatureState[]|null>|null = null;
884
+ #linkifier = new Components.Linkifier.Linkifier();
885
+ #adScriptAncestry: Protocol.Page.AdScriptAncestry|null = null;
886
+
887
+ constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) {
888
+ super();
889
+ this.#frame = frame;
890
+ void this.render();
891
+ }
892
+
893
+ connectedCallback(): void {
894
+ this.parentElement?.classList.add('overflow-auto');
895
+ this.#protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocol-monitor');
896
+ }
897
+
898
+ override async render(): Promise<void> {
899
+ const result = await this.#frame?.parentFrame()?.getAdScriptAncestry(this.#frame?.id);
900
+ if (result && result.ancestryChain.length > 0) {
901
+ this.#adScriptAncestry = result;
902
+
903
+ // Obtain the Target associated with the first ad script, because in most scenarios all
904
+ // scripts share the same debuggerId. However, discrepancies might arise when content scripts
905
+ // from browser extensions are involved. We will monitor the debugging experiences and revisit
906
+ // this approach if it proves problematic.
907
+ const firstScript = this.#adScriptAncestry.ancestryChain[0];
908
+ const debuggerModel = firstScript?.debuggerId ?
909
+ await SDK.DebuggerModel.DebuggerModel.modelForDebuggerId(firstScript.debuggerId) :
910
+ null;
911
+ this.#target = debuggerModel?.target() ?? null;
912
+ }
913
+
914
+ if (!this.#permissionsPolicies && this.#frame) {
915
+ this.#permissionsPolicies = this.#frame.getPermissionsPolicyState();
916
+ }
917
+ await RenderCoordinator.write('FrameDetailsView render', async () => {
918
+ const frame = this.#frame;
919
+ if (!frame) {
920
+ return;
921
+ }
922
+ const networkManager = frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager);
923
+ const securityIsolationInfo = networkManager?.getSecurityIsolationStatus(frame.id);
924
+ const linkTargetDOMNode = frame.getOwnerDOMNodeOrDocument();
925
+ const input = {
926
+ frame,
927
+ target: this.#target,
928
+ protocolMonitorExperimentEnabled: this.#protocolMonitorExperimentEnabled,
929
+ permissionsPolicies: this.#permissionsPolicies,
930
+ adScriptAncestry: this.#adScriptAncestry,
931
+ linkifier: this.#linkifier,
932
+ linkTargetDOMNode,
933
+ trials: await frame.getOriginTrials(),
934
+ securityIsolationInfo,
935
+ onRevealInSources: async () => {
936
+ const sourceCode = this.#uiSourceCodeForFrame(frame);
937
+ if (sourceCode) {
938
+ await Common.Revealer.reveal(sourceCode);
939
+ }
940
+ },
941
+ };
942
+ renderFrameDetailsView(input, this.#shadow);
943
+ });
944
+ }
945
+
946
+ #uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode|null {
947
+ for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) {
948
+ const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project);
949
+ if (projectTarget && projectTarget === frame.resourceTreeModel().target()) {
950
+ const uiSourceCode = project.uiSourceCodeForURL(frame.url);
951
+ if (uiSourceCode) {
952
+ return uiSourceCode;
953
+ }
954
+ }
955
+ }
956
+ return null;
936
957
  }
937
958
  }
938
959