blob: c28a305043439b859deace618b52656b3fe37d45 [file] [log] [blame]
Danil Somsikov4ba8f352021-06-09 12:27:221// Copyright 2021 The Chromium Authors. All rights reserved.
Wolfgang Beyer760462e2020-07-13 15:01:352// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Tim van der Lippe1bd5e212021-05-06 10:54:295import * as Common from '../../../core/common/common.js';
6import * as i18n from '../../../core/i18n/i18n.js';
Danil Somsikovc48b2b12022-06-24 15:03:037import * as Platform from '../../../core/platform/platform.js';
Tim van der Lippe1bd5e212021-05-06 10:54:298import * as Root from '../../../core/root/root.js';
Tim van der Lippec2cbf322021-07-26 14:35:339import * as SDK from '../../../core/sdk/sdk.js';
Tim van der Lippe229a54f2021-05-14 16:59:0510import * as Protocol from '../../../generated/protocol.js';
Wolfgang Beyer61baf652023-10-16 16:18:1911import * as Bindings from '../../../models/bindings/bindings.js';
12import * as Workspace from '../../../models/workspace/workspace.js';
13import * as NetworkForward from '../../../panels/network/forward/forward.js';
14import * as CspEvaluator from '../../../third_party/csp_evaluator/csp_evaluator.js';
Kateryna Prokopenko6eb3be52024-05-24 14:53:2315import * as Buttons from '../../../ui/components/buttons/buttons.js';
Wolfgang Beyer61baf652023-10-16 16:18:1916import * as ExpandableList from '../../../ui/components/expandable_list/expandable_list.js';
Wolfgang Beyer61baf652023-10-16 16:18:1917import * as LegacyWrapper from '../../../ui/components/legacy_wrapper/legacy_wrapper.js';
Wolfgang Beyerffae99f2021-07-08 08:46:5318import * as Coordinator from '../../../ui/components/render_coordinator/render_coordinator.js';
Wolfgang Beyer61baf652023-10-16 16:18:1919import * as ReportView from '../../../ui/components/report_view/report_view.js';
20import * as Components from '../../../ui/legacy/components/utils/utils.js';
21import * as LitHtml from '../../../ui/lit-html/lit-html.js';
Kateryna Prokopenko223ac542024-01-09 17:36:4222import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js';
Wolfgang Beyer760462e2020-07-13 15:01:3523
Kriti Sapra9db87f52021-07-14 12:51:1224import frameDetailsReportViewStyles from './frameDetailsReportView.css.js';
Benedikt Meurer5eb9e242023-12-27 13:40:5225import {OriginTrialTreeView} from './OriginTrialTreeView.js';
Wolfgang Beyer61baf652023-10-16 16:18:1926import {
27 PermissionsPolicySection,
28 type PermissionsPolicySectionData,
29 renderIconLink,
30} from './PermissionsPolicySection.js';
31import {StackTrace, type StackTraceData} from './StackTrace.js';
Kriti Sapra9db87f52021-07-14 12:51:1232
Simon Zünd697fb0b2021-03-01 10:12:4233const UIStrings = {
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0134 /**
Jack Franklinfd72c072022-12-21 11:45:0135 *@description Section header in the Frame Details view
36 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0137 additionalInformation: 'Additional Information',
38 /**
Jack Franklinfd72c072022-12-21 11:45:0139 *@description Explanation for why the additional information section is being shown
40 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0141 thisAdditionalDebugging:
42 'This additional (debugging) information is shown because the \'Protocol Monitor\' experiment is enabled.',
43 /**
Jack Franklinfd72c072022-12-21 11:45:0144 *@description Label for subtitle of frame details view
45 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0146 frameId: 'Frame ID',
47 /**
Jack Franklinfd72c072022-12-21 11:45:0148 *@description Name of a network resource type
49 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0150 document: 'Document',
51 /**
Jack Franklinfd72c072022-12-21 11:45:0152 *@description A web URL (for a lot of languages this does not need to be translated, please translate only where necessary)
53 */
Wolfgang Beyer5e451ff2021-12-08 16:44:3554 url: 'URL',
55 /**
56 /**
Jack Franklinfd72c072022-12-21 11:45:0157 *@description Title for a link to the Sources panel
58 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0159 clickToRevealInSourcesPanel: 'Click to reveal in Sources panel',
60 /**
Jack Franklinfd72c072022-12-21 11:45:0161 *@description Title for a link to the Network panel
62 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0163 clickToRevealInNetworkPanel: 'Click to reveal in Network panel',
64 /**
Jack Franklinfd72c072022-12-21 11:45:0165 *@description Title for unreachable URL field
66 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0167 unreachableUrl: 'Unreachable URL',
68 /**
Jack Franklinfd72c072022-12-21 11:45:0169 *@description Title for a link that applies a filter to the network panel
70 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0171 clickToRevealInNetworkPanelMight: 'Click to reveal in Network panel (might require page reload)',
72 /**
Jack Franklinfd72c072022-12-21 11:45:0173 *@description The origin of a URL (https://web.dev/same-site-same-origin/#origin)
74 *(for a lot of languages this does not need to be translated, please translate only where necessary)
75 */
Wolfgang Beyer5e451ff2021-12-08 16:44:3576 origin: 'Origin',
77 /**
78 /**
Jack Franklinfd72c072022-12-21 11:45:0179 *@description Related node label in Timeline UIUtils of the Performance panel
80 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0181 ownerElement: 'Owner Element',
82 /**
Jack Franklinfd72c072022-12-21 11:45:0183 *@description Title for a link to the Elements panel
84 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0185 clickToRevealInElementsPanel: 'Click to reveal in Elements panel',
86 /**
Jack Franklinfd72c072022-12-21 11:45:0187 *@description Title for ad frame type field
88 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0189 adStatus: 'Ad Status',
90 /**
Jack Franklinfd72c072022-12-21 11:45:0191 *@description Description for ad frame type
92 */
Sigurd Schneidercc9a02e2021-06-16 06:20:3393 rootDescription: 'This frame has been identified as the root frame of an ad',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0194 /**
Jack Franklinfd72c072022-12-21 11:45:0195 *@description Value for ad frame type
96 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0197 root: 'root',
98 /**
Jack Franklinfd72c072022-12-21 11:45:0199 *@description Description for ad frame type
100 */
Sigurd Schneidercc9a02e2021-06-16 06:20:33101 childDescription: 'This frame has been identified as a child frame of an ad',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01102 /**
Jack Franklinfd72c072022-12-21 11:45:01103 *@description Value for ad frame type
104 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01105 child: 'child',
106 /**
Jack Franklinfd72c072022-12-21 11:45:01107 *@description Section header in the Frame Details view
108 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01109 securityIsolation: 'Security & Isolation',
110 /**
Wolfgang Beyer61baf652023-10-16 16:18:19111 *@description Section header in the Frame Details view
112 */
113 contentSecurityPolicy: 'Content Security Policy (CSP)',
114 /**
Jack Franklinfd72c072022-12-21 11:45:01115 *@description Row title for in the Frame Details view
116 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01117 secureContext: 'Secure Context',
118 /**
Jack Franklinfd72c072022-12-21 11:45:01119 *@description Text in Timeline indicating that input has happened recently
120 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01121 yes: 'Yes',
122 /**
Jack Franklinfd72c072022-12-21 11:45:01123 *@description Text in Timeline indicating that input has not happened recently
124 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01125 no: 'No',
126 /**
Jack Franklinfd72c072022-12-21 11:45:01127 *@description Label for whether a frame is cross-origin isolated
128 *(https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/)
129 *(for a lot of languages this does not need to be translated, please translate only where necessary)
130 */
Wolfgang Beyer5e451ff2021-12-08 16:44:35131 crossoriginIsolated: 'Cross-Origin Isolated',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01132 /**
Jack Franklinfd72c072022-12-21 11:45:01133 *@description Explanatory text in the Frame Details view
134 */
Wolfgang Beyerdbf211e2021-11-23 10:23:54135 localhostIsAlwaysASecureContext: '`Localhost` is always a secure context',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01136 /**
Jack Franklinfd72c072022-12-21 11:45:01137 *@description Explanatory text in the Frame Details view
138 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01139 aFrameAncestorIsAnInsecure: 'A frame ancestor is an insecure context',
140 /**
Jack Franklinfd72c072022-12-21 11:45:01141 *@description Explanatory text in the Frame Details view
142 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01143 theFramesSchemeIsInsecure: 'The frame\'s scheme is insecure',
144 /**
Jack Franklinfd72c072022-12-21 11:45:01145 *@description This label specifies the server endpoints to which the server is reporting errors
146 *and warnings through the Report-to API. Following this label will be the URL of the server.
147 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01148 reportingTo: 'reporting to',
149 /**
Jack Franklinfd72c072022-12-21 11:45:01150 *@description Section header in the Frame Details view
151 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01152 apiAvailability: 'API availability',
153 /**
Jack Franklinfd72c072022-12-21 11:45:01154 *@description Explanation of why cross-origin isolation is important
155 *(https://web.dev/why-coop-coep/)
156 *(for a lot of languages 'cross-origin isolation' does not need to be translated, please translate only where necessary)
157 */
Wolfgang Beyer5e451ff2021-12-08 16:44:35158 availabilityOfCertainApisDepends: 'Availability of certain APIs depends on the document being cross-origin isolated.',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01159 /**
Jack Franklinfd72c072022-12-21 11:45:01160 *@description Description of the SharedArrayBuffer status
161 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01162 availableTransferable: 'available, transferable',
163 /**
Jack Franklinfd72c072022-12-21 11:45:01164 *@description Description of the SharedArrayBuffer status
165 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01166 availableNotTransferable: 'available, not transferable',
167 /**
Jack Franklinfd72c072022-12-21 11:45:01168 *@description Explanation for the SharedArrayBuffer availability status
169 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01170 unavailable: 'unavailable',
171 /**
Jack Franklinfd72c072022-12-21 11:45:01172 *@description Tooltip for the SharedArrayBuffer availability status
173 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01174 sharedarraybufferConstructorIs:
Wolfgang Beyerdbf211e2021-11-23 10:23:54175 '`SharedArrayBuffer` constructor is available and `SABs` can be transferred via `postMessage`',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01176 /**
Jack Franklinfd72c072022-12-21 11:45:01177 *@description Tooltip for the SharedArrayBuffer availability status
178 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01179 sharedarraybufferConstructorIsAvailable:
Wolfgang Beyerdbf211e2021-11-23 10:23:54180 '`SharedArrayBuffer` constructor is available but `SABs` cannot be transferred via `postMessage`',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01181 /**
Jack Franklinfd72c072022-12-21 11:45:01182 *@description Explanation why SharedArrayBuffer will not be available in the future
183 *(https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/)
184 *(for a lot of languages 'cross-origin isolation' does not need to be translated, please translate only where necessary)
185 */
Wolfgang Beyer5e451ff2021-12-08 16:44:35186 willRequireCrossoriginIsolated: '⚠️ will require cross-origin isolated context in the future',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01187 /**
Jack Franklinfd72c072022-12-21 11:45:01188 *@description Explanation why SharedArrayBuffer is not available
189 *(https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/)
190 *(for a lot of languages 'cross-origin isolation' does not need to be translated, please translate only where necessary).
191 */
Wolfgang Beyer5e451ff2021-12-08 16:44:35192 requiresCrossoriginIsolated: 'requires cross-origin isolated context',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01193 /**
Sigurd Schneiderf7e58be2021-05-14 14:41:52194 *@description Explanation for the SharedArrayBuffer availability status in case the transfer of a SAB requires the
195 * permission policy `cross-origin-isolated` to be enabled (e.g. because the message refers to the situation in an iframe).
196 */
197 transferRequiresCrossoriginIsolatedPermission:
198 '`SharedArrayBuffer` transfer requires enabling the permission policy:',
Sigurd Schneider2a450252021-05-04 07:13:15199 /**
Jack Franklinfd72c072022-12-21 11:45:01200 *@description Explanation for the Measure Memory availability status
201 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01202 available: 'available',
203 /**
Jack Franklinfd72c072022-12-21 11:45:01204 *@description Tooltip for the Measure Memory availability status
205 */
Wolfgang Beyerdbf211e2021-11-23 10:23:54206 thePerformanceAPI: 'The `performance.measureUserAgentSpecificMemory()` API is available',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01207 /**
Jack Franklinfd72c072022-12-21 11:45:01208 *@description Tooltip for the Measure Memory availability status
209 */
Wolfgang Beyerdbf211e2021-11-23 10:23:54210 thePerformancemeasureuseragentspecificmemory:
211 'The `performance.measureUserAgentSpecificMemory()` API is not available',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01212 /**
Jack Franklinfd72c072022-12-21 11:45:01213 *@description Entry in the API availability section of the frame details view
214 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01215 measureMemory: 'Measure Memory',
216 /**
Jack Franklinfd72c072022-12-21 11:45:01217 *@description Text that is usually a hyperlink to more documentation
218 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01219 learnMore: 'Learn more',
Wolfgang Beyer19093942021-03-15 15:00:34220 /**
Jack Franklinfd72c072022-12-21 11:45:01221 *@description Label for a stack trace. If a frame is created programmatically (i.e. via JavaScript), there is a
222 * stack trace for the line of code which caused the creation of the iframe. This is the stack trace we are showing here.
223 */
Wolfgang Beyerdbf211e2021-11-23 10:23:54224 creationStackTrace: 'Frame Creation `Stack Trace`',
Wolfgang Beyer19093942021-03-15 15:00:34225 /**
Jack Franklinfd72c072022-12-21 11:45:01226 *@description Tooltip for 'Frame Creation Stack Trace' explaining that the stack
227 *trace shows where in the code the frame has been created programmatically
228 */
Wolfgang Beyerdbf211e2021-11-23 10:23:54229 creationStackTraceExplanation:
230 'This frame was created programmatically. The `stack trace` shows where this happened.',
Wolfgang Beyer4751c1c2021-03-24 15:32:35231 /**
Jack Franklinfd72c072022-12-21 11:45:01232 *@description Text descripting why a frame has been indentified as an advertisement.
233 */
Sigurd Schneidercc9a02e2021-06-16 06:20:33234 parentIsAdExplanation: 'This frame is considered an ad frame because its parent frame is an ad frame.',
235 /**
Jack Franklinfd72c072022-12-21 11:45:01236 *@description Text descripting why a frame has been indentified as an advertisement.
237 */
Sigurd Schneidercc9a02e2021-06-16 06:20:33238 matchedBlockingRuleExplanation:
239 'This frame is considered an ad frame because its current (or previous) main document is an ad resource.',
240 /**
Jack Franklinfd72c072022-12-21 11:45:01241 *@description Text descripting why a frame has been indentified as an advertisement.
242 */
Sigurd Schneidercc9a02e2021-06-16 06:20:33243 createdByAdScriptExplanation:
Wolfgang Beyerdbf211e2021-11-23 10:23:54244 'There was an ad script in the `(async) stack` when this frame was created. Examining the creation `stack trace` of this frame might provide more insight.',
Wolfgang Beyer1a432c42022-01-20 09:30:14245 /**
Jack Franklinfd72c072022-12-21 11:45:01246 *@description Label for a link to an ad script, which created the current iframe.
247 */
Danil Somsikovc48b2b12022-06-24 15:03:03248 creatorAdScript: 'Creator Ad Script',
Wolfgang Beyer61baf652023-10-16 16:18:19249 /**
250 *@description Text describing the absence of a value.
251 */
252 none: 'None',
Benedikt Meurer5eb9e242023-12-27 13:40:52253 /**
254 *@description Explanation of what origin trials are
255 *(https://developer.chrome.com/docs/web-platform/origin-trials/)
256 *(please don't translate 'origin trials').
257 */
258 originTrialsExplanation: 'Origin trials give you access to a new or experimental feature.',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01259};
Tim van der Lippe1bd5e212021-05-06 10:54:29260const str_ = i18n.i18n.registerUIStrings('panels/application/components/FrameDetailsView.ts', UIStrings);
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01261const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
Wolfgang Beyer3b4747f2020-08-12 07:30:46262
Wolfgang Beyerffae99f2021-07-08 08:46:53263const coordinator = Coordinator.RenderCoordinator.RenderCoordinator.instance();
264
Wolfgang Beyer92395c92021-02-02 10:43:23265export interface FrameDetailsReportViewData {
266 frame: SDK.ResourceTreeModel.ResourceTreeFrame;
Danil Somsikovc48b2b12022-06-24 15:03:03267 target?: SDK.Target.Target;
Alex Rudenkob8b48602022-10-17 12:59:58268 adScriptId: Protocol.Page.AdScriptId|null;
Wolfgang Beyer92395c92021-02-02 10:43:23269}
270
Danil Somsikov091da102023-06-09 21:56:03271export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.WrappableComponent {
Jack Franklinaf799b32021-07-01 08:37:18272 static readonly litTagName = LitHtml.literal`devtools-resources-frame-details-view`;
Tim van der Lippec3f835a2021-12-15 13:28:32273 readonly #shadow = this.attachShadow({mode: 'open'});
274 #frame?: SDK.ResourceTreeModel.ResourceTreeFrame;
Danil Somsikovc48b2b12022-06-24 15:03:03275 #target?: SDK.Target.Target;
Tim van der Lippec3f835a2021-12-15 13:28:32276 #protocolMonitorExperimentEnabled = false;
277 #permissionsPolicies: Promise<Protocol.Page.PermissionsPolicyFeatureState[]|null>|null = null;
278 #permissionsPolicySectionData: PermissionsPolicySectionData = {policies: [], showDetails: false};
279 #originTrialTreeView: OriginTrialTreeView = new OriginTrialTreeView();
Danil Somsikovc48b2b12022-06-24 15:03:03280 #linkifier = new Components.Linkifier.Linkifier();
Alex Rudenkob8b48602022-10-17 12:59:58281 #adScriptId: Protocol.Page.AdScriptId|null = null;
Wolfgang Beyere5d1a9f2021-02-05 09:42:43282
Danil Somsikov5875b3b2023-05-17 21:41:36283 constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) {
284 super();
285 this.#frame = frame;
Danil Somsikov091da102023-06-09 21:56:03286 void this.render();
Danil Somsikov5875b3b2023-05-17 21:41:36287 }
288
Wolfgang Beyere5d1a9f2021-02-05 09:42:43289 connectedCallback(): void {
Danil Somsikov2d619e12023-07-10 10:13:52290 this.parentElement?.classList.add('overflow-auto');
Danil Somsikov8a8f4fa2024-02-19 09:51:12291 this.#protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocol-monitor');
Tim van der Lippec3f835a2021-12-15 13:28:32292 this.#shadow.adoptedStyleSheets = [frameDetailsReportViewStyles];
Wolfgang Beyere5d1a9f2021-02-05 09:42:43293 }
Wolfgang Beyer92395c92021-02-02 10:43:23294
Danil Somsikov5875b3b2023-05-17 21:41:36295 override async render(): Promise<void> {
296 this.#adScriptId = (await this.#frame?.parentFrame()?.getAdScriptId(this.#frame?.id)) || null;
297 const debuggerModel = this.#adScriptId?.debuggerId ?
298 await SDK.DebuggerModel.DebuggerModel.modelForDebuggerId(this.#adScriptId?.debuggerId) :
299 null;
300 this.#target = debuggerModel?.target();
Tim van der Lippec3f835a2021-12-15 13:28:32301 if (!this.#permissionsPolicies && this.#frame) {
302 this.#permissionsPolicies = this.#frame.getPermissionsPolicyState();
Wolfgang Beyerffae99f2021-07-08 08:46:53303 }
Wolfgang Beyerffae99f2021-07-08 08:46:53304 await coordinator.write('FrameDetailsView render', () => {
Tim van der Lippec3f835a2021-12-15 13:28:32305 if (!this.#frame) {
Wolfgang Beyerffae99f2021-07-08 08:46:53306 return;
307 }
Wolfgang Beyer92395c92021-02-02 10:43:23308
Wolfgang Beyerffae99f2021-07-08 08:46:53309 // Disabled until https://crbug.com/1079231 is fixed.
310 // clang-format off
Wolfgang Beyerffae99f2021-07-08 08:46:53311 LitHtml.render(LitHtml.html`
Kateryna Prokopenko223ac542024-01-09 17:36:42312 <${ReportView.ReportView.Report.litTagName} .data=${{reportTitle: this.#frame.displayName()} as ReportView.ReportView.ReportData}
Danil Somsikov0cb97462024-01-30 15:11:29313 jslog=${VisualLogging.pane('frames')}>
Tim van der Lippec3f835a2021-12-15 13:28:32314 ${this.#renderDocumentSection()}
315 ${this.#renderIsolationSection()}
316 ${this.#renderApiAvailabilitySection()}
317 ${this.#renderOriginTrial()}
318 ${LitHtml.Directives.until(this.#permissionsPolicies?.then(policies => {
319 this.#permissionsPolicySectionData.policies = policies || [];
Wolfgang Beyerffae99f2021-07-08 08:46:53320 return LitHtml.html`
321 <${PermissionsPolicySection.litTagName}
Tim van der Lippec3f835a2021-12-15 13:28:32322 .data=${this.#permissionsPolicySectionData as PermissionsPolicySectionData}
Wolfgang Beyerffae99f2021-07-08 08:46:53323 >
324 </${PermissionsPolicySection.litTagName}>
325 `;
326 }), LitHtml.nothing)}
Tim van der Lippec3f835a2021-12-15 13:28:32327 ${this.#protocolMonitorExperimentEnabled ? this.#renderAdditionalInfoSection() : LitHtml.nothing}
Wolfgang Beyerffae99f2021-07-08 08:46:53328 </${ReportView.ReportView.Report.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32329 `, this.#shadow, {host: this});
Wolfgang Beyerffae99f2021-07-08 08:46:53330 // clang-format on
331 });
Wolfgang Beyer92395c92021-02-02 10:43:23332 }
Wolfgang Beyer1525b1f2021-02-02 14:12:30333
Jack Franklind7508302022-05-09 14:22:21334 #renderOriginTrial(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32335 if (!this.#frame) {
Charlie Hu2086be52021-07-02 16:12:12336 return LitHtml.nothing;
337 }
Charlie Hu6c295cf2021-08-10 15:38:48338
Tim van der Lippec3f835a2021-12-15 13:28:32339 this.#originTrialTreeView.classList.add('span-cols');
Charlie Hu6c295cf2021-08-10 15:38:48340
Benedikt Meurer5eb9e242023-12-27 13:40:52341 void this.#frame.getOriginTrials().then(trials => {
342 this.#originTrialTreeView.data = {trials};
343 });
Charlie Hu6c295cf2021-08-10 15:38:48344
Benedikt Meurer5eb9e242023-12-27 13:40:52345 // clang-format off
Charlie Hu2086be52021-07-02 16:12:12346 return LitHtml.html`
Benedikt Meurer5eb9e242023-12-27 13:40:52347 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18n.i18n.lockedString('Origin trials')}</${ReportView.ReportView.ReportSectionHeader.litTagName}>
348 <div class="span-cols">
349 ${i18nString(UIStrings.originTrialsExplanation)}
Kateryna Prokopenko223ac542024-01-09 17:36:42350 <x-link href="https://developer.chrome.com/docs/web-platform/origin-trials/" class="link"
Danil Somsikov0cb97462024-01-30 15:11:29351 jslog=${VisualLogging.link('learn-more.origin-trials').track({click: true})}>${i18nString(UIStrings.learnMore)}</x-link>
Benedikt Meurer5eb9e242023-12-27 13:40:52352 </div>
Tim van der Lippec3f835a2021-12-15 13:28:32353 ${this.#originTrialTreeView}
Benedikt Meurer5eb9e242023-12-27 13:40:52354 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ReportView.ReportView.ReportSectionDivider.litTagName}>
Charlie Hu2086be52021-07-02 16:12:12355 `;
Benedikt Meurer5eb9e242023-12-27 13:40:52356 // clang-format on
Charlie Hu2086be52021-07-02 16:12:12357 }
358
Jack Franklind7508302022-05-09 14:22:21359 #renderDocumentSection(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32360 if (!this.#frame) {
Wolfgang Beyer1525b1f2021-02-02 14:12:30361 return LitHtml.nothing;
362 }
363
364 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36365 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.document)}</${
366 ReportView.ReportView.ReportSectionHeader.litTagName}>
Wolfgang Beyer5e451ff2021-12-08 16:44:35367 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.url)}</${
Kriti Sapra74915452021-05-13 11:57:36368 ReportView.ReportView.ReportKey.litTagName}>
369 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30370 <div class="inline-items">
Tim van der Lippec3f835a2021-12-15 13:28:32371 ${this.#maybeRenderSourcesLinkForURL()}
372 ${this.#maybeRenderNetworkLinkForURL()}
373 <div class="text-ellipsis" title=${this.#frame.url}>${this.#frame.url}</div>
Wolfgang Beyer1525b1f2021-02-02 14:12:30374 </div>
Kriti Sapra74915452021-05-13 11:57:36375 </${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32376 ${this.#maybeRenderUnreachableURL()}
377 ${this.#maybeRenderOrigin()}
378 ${LitHtml.Directives.until(this.#renderOwnerElement(), LitHtml.nothing)}
379 ${this.#maybeRenderCreationStacktrace()}
380 ${this.#maybeRenderAdStatus()}
Kriti Sapra74915452021-05-13 11:57:36381 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
382 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30383 `;
384 }
385
Jack Franklind7508302022-05-09 14:22:21386 #maybeRenderSourcesLinkForURL(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32387 if (!this.#frame || this.#frame.unreachableUrl()) {
Wolfgang Beyer1525b1f2021-02-02 14:12:30388 return LitHtml.nothing;
389 }
Tim van der Lippec3f835a2021-12-15 13:28:32390 const sourceCode = this.#uiSourceCodeForFrame(this.#frame);
Wolfgang Beyerffae99f2021-07-08 08:46:53391 return renderIconLink(
Wolfgang Beyerf64d63e2023-04-04 14:47:38392 'breakpoint-circle',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01393 i18nString(UIStrings.clickToRevealInSourcesPanel),
Danil Somsikovacd635c2024-02-09 12:56:51394 () => Common.Revealer.reveal(sourceCode),
Kateryna Prokopenko223ac542024-01-09 17:36:42395 'reveal-in-sources',
Wolfgang Beyer1525b1f2021-02-02 14:12:30396 );
397 }
398
Jack Franklind7508302022-05-09 14:22:21399 #maybeRenderNetworkLinkForURL(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32400 if (this.#frame) {
401 const resource = this.#frame.resourceForURL(this.#frame.url);
Wolfgang Beyer1525b1f2021-02-02 14:12:30402 if (resource && resource.request) {
403 const request = resource.request;
Danil Somsikovacd635c2024-02-09 12:56:51404 return renderIconLink('arrow-up-down-circle', i18nString(UIStrings.clickToRevealInNetworkPanel), () => {
405 const requestLocation = NetworkForward.UIRequestLocation.UIRequestLocation.tab(
406 request, NetworkForward.UIRequestLocation.UIRequestTabs.HeadersComponent);
407 return Common.Revealer.reveal(requestLocation);
408 }, 'reveal-in-network');
Wolfgang Beyer1525b1f2021-02-02 14:12:30409 }
410 }
411 return LitHtml.nothing;
412 }
413
Tim van der Lippec3f835a2021-12-15 13:28:32414 #uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode|null {
Wolfgang Beyer1525b1f2021-02-02 14:12:30415 for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) {
416 const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project);
417 if (projectTarget && projectTarget === frame.resourceTreeModel().target()) {
418 const uiSourceCode = project.uiSourceCodeForURL(frame.url);
419 if (uiSourceCode) {
420 return uiSourceCode;
421 }
422 }
423 }
424 return null;
425 }
426
Jack Franklind7508302022-05-09 14:22:21427 #maybeRenderUnreachableURL(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32428 if (!this.#frame || !this.#frame.unreachableUrl()) {
Wolfgang Beyer1525b1f2021-02-02 14:12:30429 return LitHtml.nothing;
430 }
431 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36432 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.unreachableUrl)}</${
433 ReportView.ReportView.ReportKey.litTagName}>
434 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30435 <div class="inline-items">
Tim van der Lippec3f835a2021-12-15 13:28:32436 ${this.#renderNetworkLinkForUnreachableURL()}
437 <div class="text-ellipsis" title=${this.#frame.unreachableUrl()}>${this.#frame.unreachableUrl()}</div>
Wolfgang Beyer1525b1f2021-02-02 14:12:30438 </div>
Kriti Sapra74915452021-05-13 11:57:36439 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30440 `;
441 }
442
Jack Franklind7508302022-05-09 14:22:21443 #renderNetworkLinkForUnreachableURL(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32444 if (this.#frame) {
445 const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(this.#frame.unreachableUrl());
Wolfgang Beyer1525b1f2021-02-02 14:12:30446 if (unreachableUrl) {
Wolfgang Beyerffae99f2021-07-08 08:46:53447 return renderIconLink(
Wolfgang Beyerf64d63e2023-04-04 14:47:38448 'arrow-up-down-circle',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01449 i18nString(UIStrings.clickToRevealInNetworkPanelMight),
Wolfgang Beyer1525b1f2021-02-02 14:12:30450 ():
451 void => {
Tim van der Lippe2d9a95c2022-01-04 15:18:03452 void Common.Revealer.reveal(NetworkForward.UIFilter.UIRequestFilter.filters([
Wolfgang Beyer1525b1f2021-02-02 14:12:30453 {
Sigurd Schneider30722582021-06-16 06:54:16454 filterType: NetworkForward.UIFilter.FilterType.Domain,
Wolfgang Beyer1525b1f2021-02-02 14:12:30455 filterValue: unreachableUrl.domain(),
456 },
457 {
458 filterType: null,
459 filterValue: unreachableUrl.path,
460 },
Sigurd Schneider30722582021-06-16 06:54:16461 ]));
Wolfgang Beyer1525b1f2021-02-02 14:12:30462 },
Kateryna Prokopenko223ac542024-01-09 17:36:42463 'unreachable-url.reveal-in-network',
Wolfgang Beyer1525b1f2021-02-02 14:12:30464 );
465 }
466 }
467 return LitHtml.nothing;
468 }
469
Jack Franklind7508302022-05-09 14:22:21470 #maybeRenderOrigin(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32471 if (this.#frame && this.#frame.securityOrigin && this.#frame.securityOrigin !== '://') {
Wolfgang Beyer1525b1f2021-02-02 14:12:30472 return LitHtml.html`
Wolfgang Beyer5e451ff2021-12-08 16:44:35473 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.origin)}</${
Kriti Sapra74915452021-05-13 11:57:36474 ReportView.ReportView.ReportKey.litTagName}>
475 <${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32476 <div class="text-ellipsis" title=${this.#frame.securityOrigin}>${this.#frame.securityOrigin}</div>
Kriti Sapra74915452021-05-13 11:57:36477 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30478 `;
479 }
480 return LitHtml.nothing;
481 }
482
Jack Franklind7508302022-05-09 14:22:21483 async #renderOwnerElement(): Promise<LitHtml.LitTemplate> {
Tim van der Lippec3f835a2021-12-15 13:28:32484 if (this.#frame) {
485 const linkTargetDOMNode = await this.#frame.getOwnerDOMNodeOrDocument();
Wolfgang Beyerf0d985e2021-02-05 12:56:52486 if (linkTargetDOMNode) {
487 // Disabled until https://crbug.com/1079231 is fixed.
488 // clang-format off
Wolfgang Beyerf0d985e2021-02-05 12:56:52489 return LitHtml.html`
Wolfgang Beyerf64d63e2023-04-04 14:47:38490 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.ownerElement)}</${ReportView.ReportView.ReportKey.litTagName}>
Kriti Sapra74915452021-05-13 11:57:36491 <${ReportView.ReportView.ReportValue.litTagName} class="without-min-width">
Wolfgang Beyerf64d63e2023-04-04 14:47:38492 <div class="inline-items">
Wolfgang Beyerf64d63e2023-04-04 14:47:38493 <button class="link text-link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToRevealInElementsPanel)}
Danil Somsikovacd635c2024-02-09 12:56:51494 @mouseenter=${() => this.#frame?.highlight()}
495 @mouseleave=${() => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()}
496 @click=${() => Common.Revealer.reveal(linkTargetDOMNode)}
Danil Somsikov0cb97462024-01-30 15:11:29497 jslog=${VisualLogging.action('reveal-in-elements').track({click: true})}
Wolfgang Beyerf64d63e2023-04-04 14:47:38498 >
499 &lt;${linkTargetDOMNode.nodeName().toLocaleLowerCase()}&gt;
500 </button>
501 </div>
Kriti Sapra74915452021-05-13 11:57:36502 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyerf0d985e2021-02-05 12:56:52503 `;
504 // clang-format on
Wolfgang Beyer1525b1f2021-02-02 14:12:30505 }
506 }
507 return LitHtml.nothing;
508 }
509
Jack Franklind7508302022-05-09 14:22:21510 #maybeRenderCreationStacktrace(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32511 const creationStackTraceData = this.#frame?.getCreationStackTraceData();
Wolfgang Beyera20485a2021-04-21 07:22:19512 if (creationStackTraceData && creationStackTraceData.creationStackTrace) {
Wolfgang Beyera036d0c2021-03-19 09:09:33513 // Disabled until https://crbug.com/1079231 is fixed.
514 // clang-format off
Wolfgang Beyer19093942021-03-15 15:00:34515 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36516 <${ReportView.ReportView.ReportKey.litTagName} title=${i18nString(UIStrings.creationStackTraceExplanation)}>${
517 i18nString(UIStrings.creationStackTrace)}</${ReportView.ReportView.ReportKey.litTagName}>
Kateryna Prokopenko223ac542024-01-09 17:36:42518 <${ReportView.ReportView.ReportValue.litTagName}
Danil Somsikov0cb97462024-01-30 15:11:29519 jslog=${VisualLogging.section('frame-creation-stack-trace')}
Kateryna Prokopenko223ac542024-01-09 17:36:42520 >
Kriti Sapra74915452021-05-13 11:57:36521 <${StackTrace.litTagName} .data=${{
Tim van der Lippec3f835a2021-12-15 13:28:32522 frame: this.#frame,
Wolfgang Beyera036d0c2021-03-19 09:09:33523 buildStackTraceRows: Components.JSPresentationUtils.buildStackTraceRows,
524 } as StackTraceData}>
Kriti Sapra74915452021-05-13 11:57:36525 </${StackTrace.litTagName}>
526 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer19093942021-03-15 15:00:34527 `;
Wolfgang Beyera036d0c2021-03-19 09:09:33528 // clang-format on
Wolfgang Beyer19093942021-03-15 15:00:34529 }
530 return LitHtml.nothing;
531 }
532
Tim van der Lippec3f835a2021-12-15 13:28:32533 #getAdFrameTypeStrings(type: Protocol.Page.AdFrameType.Child|Protocol.Page.AdFrameType.Root):
Sigurd Schneidercc9a02e2021-06-16 06:20:33534 {value: Platform.UIString.LocalizedString, description: Platform.UIString.LocalizedString} {
535 switch (type) {
536 case Protocol.Page.AdFrameType.Child:
537 return {value: i18nString(UIStrings.child), description: i18nString(UIStrings.childDescription)};
538 case Protocol.Page.AdFrameType.Root:
539 return {value: i18nString(UIStrings.root), description: i18nString(UIStrings.rootDescription)};
Wolfgang Beyer1525b1f2021-02-02 14:12:30540 }
Sigurd Schneidercc9a02e2021-06-16 06:20:33541 }
542
Tim van der Lippec3f835a2021-12-15 13:28:32543 #getAdFrameExplanationString(explanation: Protocol.Page.AdFrameExplanation): Platform.UIString.LocalizedString {
Sigurd Schneidercc9a02e2021-06-16 06:20:33544 switch (explanation) {
545 case Protocol.Page.AdFrameExplanation.CreatedByAdScript:
546 return i18nString(UIStrings.createdByAdScriptExplanation);
547 case Protocol.Page.AdFrameExplanation.MatchedBlockingRule:
548 return i18nString(UIStrings.matchedBlockingRuleExplanation);
549 case Protocol.Page.AdFrameExplanation.ParentIsAd:
550 return i18nString(UIStrings.parentIsAdExplanation);
551 }
552 }
553
Jack Franklind7508302022-05-09 14:22:21554 #maybeRenderAdStatus(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32555 if (!this.#frame) {
Sigurd Schneidercc9a02e2021-06-16 06:20:33556 return LitHtml.nothing;
557 }
Tim van der Lippec3f835a2021-12-15 13:28:32558 const adFrameType = this.#frame.adFrameType();
Sigurd Schneidercc9a02e2021-06-16 06:20:33559 if (adFrameType === Protocol.Page.AdFrameType.None) {
560 return LitHtml.nothing;
561 }
Tim van der Lippec3f835a2021-12-15 13:28:32562 const typeStrings = this.#getAdFrameTypeStrings(adFrameType);
Jack Franklina31102b2021-12-03 15:01:22563 const rows = [LitHtml.html`<div title=${typeStrings.description}>${typeStrings.value}</div>`];
Tim van der Lippec3f835a2021-12-15 13:28:32564 for (const explanation of this.#frame.adFrameStatus()?.explanations || []) {
565 rows.push(LitHtml.html`<div>${this.#getAdFrameExplanationString(explanation)}</div>`);
Sigurd Schneidercc9a02e2021-06-16 06:20:33566 }
Danil Somsikovc48b2b12022-06-24 15:03:03567
Alex Rudenkob8b48602022-10-17 12:59:58568 const adScriptLinkElement = this.#target ? this.#linkifier.linkifyScriptLocation(
569 this.#target, this.#adScriptId?.scriptId || null,
570 Platform.DevToolsPath.EmptyUrlString, undefined, undefined) :
571 null;
Danil Somsikovc48b2b12022-06-24 15:03:03572
573 // Disabled until https://crbug.com/1079231 is fixed.
574 // clang-format off
Sigurd Schneidercc9a02e2021-06-16 06:20:33575 return LitHtml.html`
576 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.adStatus)}</${
577 ReportView.ReportView.ReportKey.litTagName}>
Kateryna Prokopenko223ac542024-01-09 17:36:42578 <${ReportView.ReportView.ReportValue.litTagName}
Danil Somsikov0cb97462024-01-30 15:11:29579 jslog=${VisualLogging.section('ad-status')}>
Danil Somsikovc48b2b12022-06-24 15:03:03580 <${ExpandableList.ExpandableList.ExpandableList.litTagName} .data=${
Elorm Coch956a3c92024-01-08 20:08:25581 {rows, title: i18nString(UIStrings.adStatus)} as ExpandableList.ExpandableList.ExpandableListData}></${
Sigurd Schneidercc9a02e2021-06-16 06:20:33582 ExpandableList.ExpandableList.ExpandableList.litTagName}></${ReportView.ReportView.ReportValue.litTagName}>
Danil Somsikovc48b2b12022-06-24 15:03:03583 ${this.#target ? LitHtml.html`
584 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.creatorAdScript)}</${
585 ReportView.ReportView.ReportKey.litTagName}>
Danil Somsikov0cb97462024-01-30 15:11:29586 <${ReportView.ReportView.ReportValue.litTagName} class="ad-script-link">${adScriptLinkElement?.setAttribute('jslog', `${VisualLogging.link('ad-script').track({click: true})}`)}</${
Danil Somsikovc48b2b12022-06-24 15:03:03587 ReportView.ReportView.ReportValue.litTagName}>
588 ` : LitHtml.nothing}
589 `;
590 // clang-format on
Wolfgang Beyer1525b1f2021-02-02 14:12:30591 }
Wolfgang Beyerabfc8472021-02-04 11:29:50592
Jack Franklind7508302022-05-09 14:22:21593 #renderIsolationSection(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32594 if (!this.#frame) {
Wolfgang Beyerabfc8472021-02-04 11:29:50595 return LitHtml.nothing;
596 }
597 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36598 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.securityIsolation)}</${
599 ReportView.ReportView.ReportSectionHeader.litTagName}>
600 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.secureContext)}</${
601 ReportView.ReportView.ReportKey.litTagName}>
602 <${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32603 ${this.#frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}\xA0${
604 this.#maybeRenderSecureContextExplanation()}
Kriti Sapra74915452021-05-13 11:57:36605 </${ReportView.ReportView.ReportValue.litTagName}>
606 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.crossoriginIsolated)}</${
607 ReportView.ReportView.ReportKey.litTagName}>
608 <${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32609 ${this.#frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
Kriti Sapra74915452021-05-13 11:57:36610 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer61baf652023-10-16 16:18:19611 ${LitHtml.Directives.until(this.#maybeRenderCoopCoepCSPStatus(), LitHtml.nothing)}
Kriti Sapra74915452021-05-13 11:57:36612 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
613 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyerabfc8472021-02-04 11:29:50614 `;
615 }
616
Jack Franklind7508302022-05-09 14:22:21617 #maybeRenderSecureContextExplanation(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32618 const explanation = this.#getSecureContextExplanation();
Wolfgang Beyerabfc8472021-02-04 11:29:50619 if (explanation) {
Tim van der Lippe0005b802021-06-03 10:47:59620 return LitHtml.html`<span class="inline-comment">${explanation}</span>`;
Wolfgang Beyerabfc8472021-02-04 11:29:50621 }
622 return LitHtml.nothing;
623 }
624
Tim van der Lippec3f835a2021-12-15 13:28:32625 #getSecureContextExplanation(): Platform.UIString.LocalizedString|null {
626 switch (this.#frame?.getSecureContextType()) {
Wolfgang Beyerabfc8472021-02-04 11:29:50627 case Protocol.Page.SecureContextType.Secure:
628 return null;
629 case Protocol.Page.SecureContextType.SecureLocalhost:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01630 return i18nString(UIStrings.localhostIsAlwaysASecureContext);
Wolfgang Beyerabfc8472021-02-04 11:29:50631 case Protocol.Page.SecureContextType.InsecureAncestor:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01632 return i18nString(UIStrings.aFrameAncestorIsAnInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50633 case Protocol.Page.SecureContextType.InsecureScheme:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01634 return i18nString(UIStrings.theFramesSchemeIsInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50635 }
636 return null;
637 }
638
Wolfgang Beyer61baf652023-10-16 16:18:19639 async #maybeRenderCoopCoepCSPStatus(): Promise<LitHtml.LitTemplate> {
Tim van der Lippec3f835a2021-12-15 13:28:32640 if (this.#frame) {
641 const model = this.#frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager);
642 const info = model && await model.getSecurityIsolationStatus(this.#frame.id);
Wolfgang Beyerabfc8472021-02-04 11:29:50643 if (info) {
644 return LitHtml.html`
645 ${
Tim van der Lippec3f835a2021-12-15 13:28:32646 this.#maybeRenderCrossOriginStatus(
Wolfgang Beyerdbf211e2021-11-23 10:23:54647 info.coep, i18n.i18n.lockedString('Cross-Origin Embedder Policy (COEP)'),
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01648 Protocol.Network.CrossOriginEmbedderPolicyValue.None)}
Wolfgang Beyerabfc8472021-02-04 11:29:50649 ${
Tim van der Lippec3f835a2021-12-15 13:28:32650 this.#maybeRenderCrossOriginStatus(
Wolfgang Beyerdbf211e2021-11-23 10:23:54651 info.coop, i18n.i18n.lockedString('Cross-Origin Opener Policy (COOP)'),
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01652 Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)}
Wolfgang Beyer61baf652023-10-16 16:18:19653 ${this.#renderCSPSection(info.csp)}
Wolfgang Beyerabfc8472021-02-04 11:29:50654 `;
655 }
656 }
657 return LitHtml.nothing;
658 }
659
Tim van der Lippec3f835a2021-12-15 13:28:32660 #maybeRenderCrossOriginStatus(
Wolfgang Beyerabfc8472021-02-04 11:29:50661 info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined,
662 policyName: string,
663 noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue|
Jack Franklind7508302022-05-09 14:22:21664 Protocol.Network.CrossOriginOpenerPolicyValue): LitHtml.LitTemplate {
Wolfgang Beyerabfc8472021-02-04 11:29:50665 if (!info) {
666 return LitHtml.nothing;
667 }
668 const isEnabled = info.value !== noneValue;
669 const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue);
670 const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint;
671 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36672 <${ReportView.ReportView.ReportKey.litTagName}>${policyName}</${ReportView.ReportView.ReportKey.litTagName}>
673 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyerabfc8472021-02-04 11:29:50674 ${isEnabled ? info.value : info.reportOnlyValue}
675 ${isReportOnly ? LitHtml.html`<span class="inline-comment">report-only</span>` : LitHtml.nothing}
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01676 ${
677 endpoint ? LitHtml.html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` :
678 LitHtml.nothing}
Kriti Sapra74915452021-05-13 11:57:36679 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyerabfc8472021-02-04 11:29:50680 `;
681 }
Wolfgang Beyer6a6efe62021-02-04 15:56:21682
Wolfgang Beyer61baf652023-10-16 16:18:19683 #renderEffectiveDirectives(directives: string): LitHtml.LitTemplate[] {
684 const parsedDirectives = new CspEvaluator.CspParser.CspParser(directives).csp.directives;
685 const result = [];
686 for (const directive in parsedDirectives) {
687 result.push(LitHtml.html`<div><span class="bold">${directive}</span>${
688 ': ' + parsedDirectives[directive]?.join(', ')}</div>`);
689 }
690 return result;
691 }
692
693 #renderSingleCSP(cspInfo: Protocol.Network.ContentSecurityPolicyStatus): LitHtml.LitTemplate {
694 // Disabled until https://crbug.com/1079231 is fixed.
695 // clang-format off
696 return LitHtml.html`
697 <${ReportView.ReportView.ReportKey.litTagName}>${
698 cspInfo.isEnforced ? i18n.i18n.lockedString('Content-Security-Policy') :
699 LitHtml.html`${
700 i18n.i18n.lockedString('Content-Security-Policy-Report-Only')
Kateryna Prokopenko6eb3be52024-05-24 14:53:23701 }<${Buttons.Button.Button.litTagName}
702 .iconName=${'help'}
703 class='help-button'
704 .variant=${Buttons.Button.Variant.ICON}
705 .size=${Buttons.Button.Size.SMALL}
706 @click=${()=> {window.location.href = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only';}}
Kateryna Prokopenko17cba892024-07-26 13:33:56707 jslog=${VisualLogging.link('learn-more.csp-report-only').track({click: true})}
708 ></${Buttons.Button.Button.litTagName}>`
Wolfgang Beyer61baf652023-10-16 16:18:19709 }
710 </${ReportView.ReportView.ReportKey.litTagName}>
711 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer61baf652023-10-16 16:18:19712 ${cspInfo.source === Protocol.Network.ContentSecurityPolicySource.HTTP ? i18n.i18n.lockedString('HTTP header') : i18n.i18n.lockedString('Meta tag')}
713 ${this.#renderEffectiveDirectives(cspInfo.effectiveDirectives)}
714 </${ReportView.ReportView.ReportValue.litTagName}>
715 `;
716 // clang-format on
717 }
718
719 #renderCSPSection(cspInfos: Protocol.Network.ContentSecurityPolicyStatus[]|undefined): LitHtml.LitTemplate {
720 // Disabled until https://crbug.com/1079231 is fixed.
721 // clang-format off
722 return LitHtml.html`
723 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ReportView.ReportView.ReportSectionDivider.litTagName}>
724 <${ReportView.ReportView.ReportSectionHeader.litTagName}>
725 ${i18nString(UIStrings.contentSecurityPolicy)}
726 </${ReportView.ReportView.ReportSectionHeader.litTagName}>
727 ${(cspInfos && cspInfos.length) ? cspInfos.map(cspInfo => this.#renderSingleCSP(cspInfo)) : LitHtml.html`
728 <${ReportView.ReportView.ReportKey.litTagName}>${
729 i18n.i18n.lockedString('Content-Security-Policy')}</${
730 ReportView.ReportView.ReportKey.litTagName}>
731 <${ReportView.ReportView.ReportValue.litTagName}>
732 ${i18nString(UIStrings.none)}
733 </${ReportView.ReportView.ReportValue.litTagName}>
734 `}
735 `;
736 // clang-format on
737 }
738
Jack Franklind7508302022-05-09 14:22:21739 #renderApiAvailabilitySection(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32740 if (!this.#frame) {
Wolfgang Beyer6a6efe62021-02-04 15:56:21741 return LitHtml.nothing;
742 }
743
744 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36745 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.apiAvailability)}</${
746 ReportView.ReportView.ReportSectionHeader.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21747 <div class="span-cols">
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01748 ${i18nString(UIStrings.availabilityOfCertainApisDepends)}
Kateryna Prokopenko223ac542024-01-09 17:36:42749 <x-link href="https://web.dev/why-coop-coep/" class="link" jslog=${
Danil Somsikov0cb97462024-01-30 15:11:29750 VisualLogging.link('learn-more.coop-coep').track({click: true})}>${i18nString(UIStrings.learnMore)}</x-link>
Wolfgang Beyer6a6efe62021-02-04 15:56:21751 </div>
Tim van der Lippec3f835a2021-12-15 13:28:32752 ${this.#renderSharedArrayBufferAvailability()}
753 ${this.#renderMeasureMemoryAvailability()}
Kriti Sapra74915452021-05-13 11:57:36754 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
755 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21756 `;
757 }
758
Jack Franklind7508302022-05-09 14:22:21759 #renderSharedArrayBufferAvailability(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32760 if (this.#frame) {
761 const features = this.#frame.getGatedAPIFeatures();
Wolfgang Beyer6a6efe62021-02-04 15:56:21762 if (features) {
763 const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers);
764 const sabTransferAvailable =
765 sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed);
766 const availabilityText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01767 i18nString(UIStrings.availableTransferable) :
768 (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable));
Wolfgang Beyer6a6efe62021-02-04 15:56:21769 const tooltipText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01770 i18nString(UIStrings.sharedarraybufferConstructorIs) :
771 (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : '');
Wolfgang Beyer6a6efe62021-02-04 15:56:21772
Jack Franklind7508302022-05-09 14:22:21773 function renderHint(frame: SDK.ResourceTreeModel.ResourceTreeFrame): LitHtml.LitTemplate {
Sigurd Schneider2a450252021-05-04 07:13:15774 switch (frame.getCrossOriginIsolatedContextType()) {
775 case Protocol.Page.CrossOriginIsolatedContextType.Isolated:
776 return LitHtml.nothing;
777 case Protocol.Page.CrossOriginIsolatedContextType.NotIsolated:
778 if (sabAvailable) {
779 return LitHtml.html`<span class="inline-comment">${
780 i18nString(UIStrings.willRequireCrossoriginIsolated)}</span>`;
781 }
782 return LitHtml.html`<span class="inline-comment">${
783 i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`;
784 case Protocol.Page.CrossOriginIsolatedContextType.NotIsolatedFeatureDisabled:
785 if (!sabTransferAvailable) {
786 return LitHtml.html`<span class="inline-comment">${
787 i18nString(
788 UIStrings
789 .transferRequiresCrossoriginIsolatedPermission)} <code>cross-origin-isolated</code></span>`;
790 }
791 break;
792 }
793 return LitHtml.nothing;
794 }
795
Peter Marshall0e1cd822021-02-24 10:52:42796 // SharedArrayBuffer is an API name, so we don't translate it.
Wolfgang Beyer6a6efe62021-02-04 15:56:21797 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36798 <${ReportView.ReportView.ReportKey.litTagName}>SharedArrayBuffers</${
799 ReportView.ReportView.ReportKey.litTagName}>
800 <${ReportView.ReportView.ReportValue.litTagName} title=${tooltipText}>
Tim van der Lippec3f835a2021-12-15 13:28:32801 ${availabilityText}\xA0${renderHint(this.#frame)}
Kriti Sapra74915452021-05-13 11:57:36802 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21803 `;
Wolfgang Beyer6a6efe62021-02-04 15:56:21804 }
805 }
806 return LitHtml.nothing;
807 }
808
Jack Franklind7508302022-05-09 14:22:21809 #renderMeasureMemoryAvailability(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32810 if (this.#frame) {
811 const measureMemoryAvailable = this.#frame.isCrossOriginIsolated();
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01812 const availabilityText =
813 measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable);
814 const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) :
815 i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory);
Wolfgang Beyer6a6efe62021-02-04 15:56:21816 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36817 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.measureMemory)}</${
818 ReportView.ReportView.ReportKey.litTagName}>
819 <${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippe0005b802021-06-03 10:47:59820 <span title=${tooltipText}>${
Kateryna Prokopenko223ac542024-01-09 17:36:42821 availabilityText}</span>\xA0<x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/" jslog=${
Danil Somsikov0cb97462024-01-30 15:11:29822 VisualLogging.link('learn-more.monitor-memory-usage').track({click: true})}>${
Wolfgang Beyer09b0e8e2021-02-09 13:39:48823 i18nString(UIStrings.learnMore)}</x-link>
Kriti Sapra74915452021-05-13 11:57:36824 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21825 `;
826 }
827 return LitHtml.nothing;
828 }
Wolfgang Beyere5d1a9f2021-02-05 09:42:43829
Jack Franklind7508302022-05-09 14:22:21830 #renderAdditionalInfoSection(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32831 if (!this.#frame) {
Wolfgang Beyere5d1a9f2021-02-05 09:42:43832 return LitHtml.nothing;
833 }
834
835 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36836 <${ReportView.ReportView.ReportSectionHeader.litTagName}
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01837 title=${i18nString(UIStrings.thisAdditionalDebugging)}
Kriti Sapra74915452021-05-13 11:57:36838 >${i18nString(UIStrings.additionalInformation)}</${ReportView.ReportView.ReportSectionHeader.litTagName}>
839 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.frameId)}</${
840 ReportView.ReportView.ReportKey.litTagName}>
841 <${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32842 <div class="text-ellipsis" title=${this.#frame.id}>${this.#frame.id}</div>
Kriti Sapra74915452021-05-13 11:57:36843 </${ReportView.ReportView.ReportValue.litTagName}>
844 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
845 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43846 `;
847 }
Wolfgang Beyer92395c92021-02-02 10:43:23848}
849
Benedikt Meurerd87daa62024-02-20 11:00:38850customElements.define('devtools-resources-frame-details-view', FrameDetailsReportView);
Wolfgang Beyer92395c92021-02-02 10:43:23851
852declare global {
Wolfgang Beyer92395c92021-02-02 10:43:23853 interface HTMLElementTagNameMap {
854 'devtools-resources-frame-details-view': FrameDetailsReportView;
855 }
856}