blob: 5bf18ca44767e6b858acc1d600638e61d572ae00 [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
Jack Franklin3a802602022-07-13 08:39:425import {StackTrace, type StackTraceData} from './StackTrace.js';
6
7import {
8 PermissionsPolicySection,
9 renderIconLink,
10 type PermissionsPolicySectionData,
11} from './PermissionsPolicySection.js';
Tim van der Lippe1bd5e212021-05-06 10:54:2912import * as Bindings from '../../../models/bindings/bindings.js';
13import * as Common from '../../../core/common/common.js';
14import * as i18n from '../../../core/i18n/i18n.js';
Sigurd Schneider2e36ec62021-06-11 06:14:2715import * as NetworkForward from '../../../panels/network/forward/forward.js';
Danil Somsikovc48b2b12022-06-24 15:03:0316import * as Platform from '../../../core/platform/platform.js';
Tim van der Lippe1bd5e212021-05-06 10:54:2917import * as Root from '../../../core/root/root.js';
Tim van der Lippec2cbf322021-07-26 14:35:3318import * as SDK from '../../../core/sdk/sdk.js';
Paul Lewis01f49392021-05-10 13:54:2019import * as LitHtml from '../../../ui/lit-html/lit-html.js';
Sigurd Schneidercc9a02e2021-06-16 06:20:3320import * as ExpandableList from '../../../ui/components/expandable_list/expandable_list.js';
Kriti Sapra74915452021-05-13 11:57:3621import * as ReportView from '../../../ui/components/report_view/report_view.js';
22import * as IconButton from '../../../ui/components/icon_button/icon_button.js';
Tim van der Lippe1bd5e212021-05-06 10:54:2923import * as ComponentHelpers from '../../../ui/components/helpers/helpers.js';
Danil Somsikov5875b3b2023-05-17 21:41:3624import * as LegacyWrapper from '../../../ui/components/legacy_wrapper/legacy_wrapper.js';
Tim van der Lippe1bd5e212021-05-06 10:54:2925import * as Workspace from '../../../models/workspace/workspace.js';
26import * as Components from '../../../ui/legacy/components/utils/utils.js';
Tim van der Lippe229a54f2021-05-14 16:59:0527import * as Protocol from '../../../generated/protocol.js';
Jack Franklin3a802602022-07-13 08:39:4228
29import {OriginTrialTreeView, type OriginTrialTreeViewData} from './OriginTrialTreeView.js';
Wolfgang Beyerffae99f2021-07-08 08:46:5330import * as Coordinator from '../../../ui/components/render_coordinator/render_coordinator.js';
Wolfgang Beyer760462e2020-07-13 15:01:3531
Kriti Sapra9db87f52021-07-14 12:51:1232import frameDetailsReportViewStyles from './frameDetailsReportView.css.js';
Robert Lin449f9332022-07-06 14:05:4533import {Prerender2ReasonDescription} from './Prerender2.js';
Kriti Sapra9db87f52021-07-14 12:51:1234
Simon Zünd697fb0b2021-03-01 10:12:4235const UIStrings = {
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0136 /**
Jack Franklinfd72c072022-12-21 11:45:0137 *@description Section header in the Frame Details view
38 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0139 additionalInformation: 'Additional Information',
40 /**
Jack Franklinfd72c072022-12-21 11:45:0141 *@description Explanation for why the additional information section is being shown
42 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0143 thisAdditionalDebugging:
44 'This additional (debugging) information is shown because the \'Protocol Monitor\' experiment is enabled.',
45 /**
Jack Franklinfd72c072022-12-21 11:45:0146 *@description Label for subtitle of frame details view
47 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0148 frameId: 'Frame ID',
49 /**
Jack Franklinfd72c072022-12-21 11:45:0150 *@description Name of a network resource type
51 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0152 document: 'Document',
53 /**
Jack Franklinfd72c072022-12-21 11:45:0154 *@description A web URL (for a lot of languages this does not need to be translated, please translate only where necessary)
55 */
Wolfgang Beyer5e451ff2021-12-08 16:44:3556 url: 'URL',
57 /**
58 /**
Jack Franklinfd72c072022-12-21 11:45:0159 *@description Title for a link to the Sources panel
60 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0161 clickToRevealInSourcesPanel: 'Click to reveal in Sources panel',
62 /**
Jack Franklinfd72c072022-12-21 11:45:0163 *@description Title for a link to the Network panel
64 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0165 clickToRevealInNetworkPanel: 'Click to reveal in Network panel',
66 /**
Jack Franklinfd72c072022-12-21 11:45:0167 *@description Title for unreachable URL field
68 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0169 unreachableUrl: 'Unreachable URL',
70 /**
Jack Franklinfd72c072022-12-21 11:45:0171 *@description Title for a link that applies a filter to the network panel
72 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0173 clickToRevealInNetworkPanelMight: 'Click to reveal in Network panel (might require page reload)',
74 /**
Jack Franklinfd72c072022-12-21 11:45:0175 *@description The origin of a URL (https://web.dev/same-site-same-origin/#origin)
76 *(for a lot of languages this does not need to be translated, please translate only where necessary)
77 */
Wolfgang Beyer5e451ff2021-12-08 16:44:3578 origin: 'Origin',
79 /**
80 /**
Jack Franklinfd72c072022-12-21 11:45:0181 *@description Related node label in Timeline UIUtils of the Performance panel
82 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0183 ownerElement: 'Owner Element',
84 /**
Jack Franklinfd72c072022-12-21 11:45:0185 *@description Title for a link to the Elements panel
86 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0187 clickToRevealInElementsPanel: 'Click to reveal in Elements panel',
88 /**
Jack Franklinfd72c072022-12-21 11:45:0189 *@description Title for ad frame type field
90 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0191 adStatus: 'Ad Status',
92 /**
Jack Franklinfd72c072022-12-21 11:45:0193 *@description Description for ad frame type
94 */
Sigurd Schneidercc9a02e2021-06-16 06:20:3395 rootDescription: 'This frame has been identified as the root frame of an ad',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0196 /**
Jack Franklinfd72c072022-12-21 11:45:0197 *@description Value for ad frame type
98 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0199 root: 'root',
100 /**
Jack Franklinfd72c072022-12-21 11:45:01101 *@description Description for ad frame type
102 */
Sigurd Schneidercc9a02e2021-06-16 06:20:33103 childDescription: 'This frame has been identified as a child frame of an ad',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01104 /**
Jack Franklinfd72c072022-12-21 11:45:01105 *@description Value for ad frame type
106 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01107 child: 'child',
108 /**
Jack Franklinfd72c072022-12-21 11:45:01109 *@description Section header in the Frame Details view
110 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01111 securityIsolation: 'Security & Isolation',
112 /**
Jack Franklinfd72c072022-12-21 11:45:01113 *@description Row title for in the Frame Details view
114 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01115 secureContext: 'Secure Context',
116 /**
Jack Franklinfd72c072022-12-21 11:45:01117 *@description Text in Timeline indicating that input has happened recently
118 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01119 yes: 'Yes',
120 /**
Jack Franklinfd72c072022-12-21 11:45:01121 *@description Text in Timeline indicating that input has not happened recently
122 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01123 no: 'No',
124 /**
Jack Franklinfd72c072022-12-21 11:45:01125 *@description Label for whether a frame is cross-origin isolated
126 *(https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/)
127 *(for a lot of languages this does not need to be translated, please translate only where necessary)
128 */
Wolfgang Beyer5e451ff2021-12-08 16:44:35129 crossoriginIsolated: 'Cross-Origin Isolated',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01130 /**
Jack Franklinfd72c072022-12-21 11:45:01131 *@description Explanatory text in the Frame Details view
132 */
Wolfgang Beyerdbf211e2021-11-23 10:23:54133 localhostIsAlwaysASecureContext: '`Localhost` is always a secure context',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01134 /**
Jack Franklinfd72c072022-12-21 11:45:01135 *@description Explanatory text in the Frame Details view
136 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01137 aFrameAncestorIsAnInsecure: 'A frame ancestor is an insecure context',
138 /**
Jack Franklinfd72c072022-12-21 11:45:01139 *@description Explanatory text in the Frame Details view
140 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01141 theFramesSchemeIsInsecure: 'The frame\'s scheme is insecure',
142 /**
Jack Franklinfd72c072022-12-21 11:45:01143 *@description This label specifies the server endpoints to which the server is reporting errors
144 *and warnings through the Report-to API. Following this label will be the URL of the server.
145 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01146 reportingTo: 'reporting to',
147 /**
Jack Franklinfd72c072022-12-21 11:45:01148 *@description Section header in the Frame Details view
149 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01150 apiAvailability: 'API availability',
151 /**
Jack Franklinfd72c072022-12-21 11:45:01152 *@description Explanation of why cross-origin isolation is important
153 *(https://web.dev/why-coop-coep/)
154 *(for a lot of languages 'cross-origin isolation' does not need to be translated, please translate only where necessary)
155 */
Wolfgang Beyer5e451ff2021-12-08 16:44:35156 availabilityOfCertainApisDepends: 'Availability of certain APIs depends on the document being cross-origin isolated.',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01157 /**
Jack Franklinfd72c072022-12-21 11:45:01158 *@description Description of the SharedArrayBuffer status
159 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01160 availableTransferable: 'available, transferable',
161 /**
Jack Franklinfd72c072022-12-21 11:45:01162 *@description Description of the SharedArrayBuffer status
163 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01164 availableNotTransferable: 'available, not transferable',
165 /**
Jack Franklinfd72c072022-12-21 11:45:01166 *@description Explanation for the SharedArrayBuffer availability status
167 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01168 unavailable: 'unavailable',
169 /**
Jack Franklinfd72c072022-12-21 11:45:01170 *@description Tooltip for the SharedArrayBuffer availability status
171 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01172 sharedarraybufferConstructorIs:
Wolfgang Beyerdbf211e2021-11-23 10:23:54173 '`SharedArrayBuffer` constructor is available and `SABs` can be transferred via `postMessage`',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01174 /**
Jack Franklinfd72c072022-12-21 11:45:01175 *@description Tooltip for the SharedArrayBuffer availability status
176 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01177 sharedarraybufferConstructorIsAvailable:
Wolfgang Beyerdbf211e2021-11-23 10:23:54178 '`SharedArrayBuffer` constructor is available but `SABs` cannot be transferred via `postMessage`',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01179 /**
Jack Franklinfd72c072022-12-21 11:45:01180 *@description Explanation why SharedArrayBuffer will not be available in the future
181 *(https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/)
182 *(for a lot of languages 'cross-origin isolation' does not need to be translated, please translate only where necessary)
183 */
Wolfgang Beyer5e451ff2021-12-08 16:44:35184 willRequireCrossoriginIsolated: '⚠️ will require cross-origin isolated context in the future',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01185 /**
Jack Franklinfd72c072022-12-21 11:45:01186 *@description Explanation why SharedArrayBuffer is not available
187 *(https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/)
188 *(for a lot of languages 'cross-origin isolation' does not need to be translated, please translate only where necessary).
189 */
Wolfgang Beyer5e451ff2021-12-08 16:44:35190 requiresCrossoriginIsolated: 'requires cross-origin isolated context',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01191 /**
Sigurd Schneiderf7e58be2021-05-14 14:41:52192 *@description Explanation for the SharedArrayBuffer availability status in case the transfer of a SAB requires the
193 * permission policy `cross-origin-isolated` to be enabled (e.g. because the message refers to the situation in an iframe).
194 */
195 transferRequiresCrossoriginIsolatedPermission:
196 '`SharedArrayBuffer` transfer requires enabling the permission policy:',
Sigurd Schneider2a450252021-05-04 07:13:15197 /**
Jack Franklinfd72c072022-12-21 11:45:01198 *@description Explanation for the Measure Memory availability status
199 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01200 available: 'available',
201 /**
Jack Franklinfd72c072022-12-21 11:45:01202 *@description Tooltip for the Measure Memory availability status
203 */
Wolfgang Beyerdbf211e2021-11-23 10:23:54204 thePerformanceAPI: 'The `performance.measureUserAgentSpecificMemory()` API is available',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01205 /**
Jack Franklinfd72c072022-12-21 11:45:01206 *@description Tooltip for the Measure Memory availability status
207 */
Wolfgang Beyerdbf211e2021-11-23 10:23:54208 thePerformancemeasureuseragentspecificmemory:
209 'The `performance.measureUserAgentSpecificMemory()` API is not available',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01210 /**
Jack Franklinfd72c072022-12-21 11:45:01211 *@description Entry in the API availability section of the frame details view
212 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01213 measureMemory: 'Measure Memory',
214 /**
Jack Franklinfd72c072022-12-21 11:45:01215 *@description Text that is usually a hyperlink to more documentation
216 */
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01217 learnMore: 'Learn more',
Wolfgang Beyer19093942021-03-15 15:00:34218 /**
Jack Franklinfd72c072022-12-21 11:45:01219 *@description Label for a stack trace. If a frame is created programmatically (i.e. via JavaScript), there is a
220 * stack trace for the line of code which caused the creation of the iframe. This is the stack trace we are showing here.
221 */
Wolfgang Beyerdbf211e2021-11-23 10:23:54222 creationStackTrace: 'Frame Creation `Stack Trace`',
Wolfgang Beyer19093942021-03-15 15:00:34223 /**
Jack Franklinfd72c072022-12-21 11:45:01224 *@description Tooltip for 'Frame Creation Stack Trace' explaining that the stack
225 *trace shows where in the code the frame has been created programmatically
226 */
Wolfgang Beyerdbf211e2021-11-23 10:23:54227 creationStackTraceExplanation:
228 'This frame was created programmatically. The `stack trace` shows where this happened.',
Wolfgang Beyer4751c1c2021-03-24 15:32:35229 /**
Jack Franklinfd72c072022-12-21 11:45:01230 *@description Text descripting why a frame has been indentified as an advertisement.
231 */
Sigurd Schneidercc9a02e2021-06-16 06:20:33232 parentIsAdExplanation: 'This frame is considered an ad frame because its parent frame is an ad frame.',
233 /**
Jack Franklinfd72c072022-12-21 11:45:01234 *@description Text descripting why a frame has been indentified as an advertisement.
235 */
Sigurd Schneidercc9a02e2021-06-16 06:20:33236 matchedBlockingRuleExplanation:
237 'This frame is considered an ad frame because its current (or previous) main document is an ad resource.',
238 /**
Jack Franklinfd72c072022-12-21 11:45:01239 *@description Text descripting why a frame has been indentified as an advertisement.
240 */
Sigurd Schneidercc9a02e2021-06-16 06:20:33241 createdByAdScriptExplanation:
Wolfgang Beyerdbf211e2021-11-23 10:23:54242 '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:14243 /**
Jack Franklinfd72c072022-12-21 11:45:01244 *@description Label for a button which when clicked causes some information to be refreshed/updated.
245 */
Wolfgang Beyer1a432c42022-01-20 09:30:14246 refresh: 'Refresh',
Danil Somsikov325f2182022-05-16 09:40:39247 /**
Jack Franklinfd72c072022-12-21 11:45:01248 *@description Label for section of frame details view
249 */
Danil Somsikov325f2182022-05-16 09:40:39250 prerendering: 'Prerendering',
251 /**
Jack Franklinfd72c072022-12-21 11:45:01252 *@description Label for subtitle of frame details view
253 */
Danil Somsikov325f2182022-05-16 09:40:39254 prerenderingStatus: 'Prerendering Status',
Danil Somsikovc48b2b12022-06-24 15:03:03255 /**
Jack Franklinfd72c072022-12-21 11:45:01256 *@description Label for a link to an ad script, which created the current iframe.
257 */
Danil Somsikovc48b2b12022-06-24 15:03:03258 creatorAdScript: 'Creator Ad Script',
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;
Robert Lin48a925e2022-11-02 11:55:56268 prerenderedUrl?: string;
Alex Rudenkob8b48602022-10-17 12:59:58269 adScriptId: Protocol.Page.AdScriptId|null;
Wolfgang Beyer92395c92021-02-02 10:43:23270}
271
Danil Somsikov091da102023-06-09 21:56:03272export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.WrappableComponent {
Jack Franklinaf799b32021-07-01 08:37:18273 static readonly litTagName = LitHtml.literal`devtools-resources-frame-details-view`;
Tim van der Lippec3f835a2021-12-15 13:28:32274 readonly #shadow = this.attachShadow({mode: 'open'});
275 #frame?: SDK.ResourceTreeModel.ResourceTreeFrame;
Danil Somsikovc48b2b12022-06-24 15:03:03276 #target?: SDK.Target.Target;
Robert Lin48a925e2022-11-02 11:55:56277 #prerenderedUrl?: string;
Tim van der Lippec3f835a2021-12-15 13:28:32278 #protocolMonitorExperimentEnabled = false;
279 #permissionsPolicies: Promise<Protocol.Page.PermissionsPolicyFeatureState[]|null>|null = null;
280 #permissionsPolicySectionData: PermissionsPolicySectionData = {policies: [], showDetails: false};
281 #originTrialTreeView: OriginTrialTreeView = new OriginTrialTreeView();
Danil Somsikovc48b2b12022-06-24 15:03:03282 #linkifier = new Components.Linkifier.Linkifier();
Alex Rudenkob8b48602022-10-17 12:59:58283 #adScriptId: Protocol.Page.AdScriptId|null = null;
Wolfgang Beyere5d1a9f2021-02-05 09:42:43284
Danil Somsikov5875b3b2023-05-17 21:41:36285 constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) {
286 super();
287 this.#frame = frame;
288 this.#prerenderedUrl = '';
Danil Somsikov5875b3b2023-05-17 21:41:36289
290 SDK.TargetManager.TargetManager.instance().addModelListener(
291 SDK.ChildTargetManager.ChildTargetManager, SDK.ChildTargetManager.Events.TargetInfoChanged, this.targetChanged,
292 this);
293 frame.resourceTreeModel().addEventListener(
Danil Somsikov091da102023-06-09 21:56:03294 SDK.ResourceTreeModel.Events.PrerenderingStatusUpdated, this.render, this);
295 void this.render();
Danil Somsikov5875b3b2023-05-17 21:41:36296 }
297
298 targetChanged(event: Common.EventTarget.EventTargetEvent<Protocol.Target.TargetInfo>): void {
299 const targetInfo = event.data;
300 if (targetInfo.subtype === 'prerender') {
301 this.#prerenderedUrl = targetInfo.url;
Danil Somsikov091da102023-06-09 21:56:03302 void this.render();
Danil Somsikov5875b3b2023-05-17 21:41:36303 }
304 }
305
Wolfgang Beyere5d1a9f2021-02-05 09:42:43306 connectedCallback(): void {
Danil Somsikov2d619e12023-07-10 10:13:52307 this.parentElement?.classList.add('overflow-auto');
Tim van der Lippec3f835a2021-12-15 13:28:32308 this.#protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocolMonitor');
309 this.#shadow.adoptedStyleSheets = [frameDetailsReportViewStyles];
Wolfgang Beyere5d1a9f2021-02-05 09:42:43310 }
Wolfgang Beyer92395c92021-02-02 10:43:23311
Danil Somsikov5875b3b2023-05-17 21:41:36312 override async render(): Promise<void> {
313 this.#adScriptId = (await this.#frame?.parentFrame()?.getAdScriptId(this.#frame?.id)) || null;
314 const debuggerModel = this.#adScriptId?.debuggerId ?
315 await SDK.DebuggerModel.DebuggerModel.modelForDebuggerId(this.#adScriptId?.debuggerId) :
316 null;
317 this.#target = debuggerModel?.target();
Tim van der Lippec3f835a2021-12-15 13:28:32318 if (!this.#permissionsPolicies && this.#frame) {
319 this.#permissionsPolicies = this.#frame.getPermissionsPolicyState();
Wolfgang Beyerffae99f2021-07-08 08:46:53320 }
Wolfgang Beyerffae99f2021-07-08 08:46:53321 await coordinator.write('FrameDetailsView render', () => {
Tim van der Lippec3f835a2021-12-15 13:28:32322 if (!this.#frame) {
Wolfgang Beyerffae99f2021-07-08 08:46:53323 return;
324 }
Wolfgang Beyer92395c92021-02-02 10:43:23325
Wolfgang Beyerffae99f2021-07-08 08:46:53326 // Disabled until https://crbug.com/1079231 is fixed.
327 // clang-format off
Wolfgang Beyerffae99f2021-07-08 08:46:53328 LitHtml.render(LitHtml.html`
Tim van der Lippec3f835a2021-12-15 13:28:32329 <${ReportView.ReportView.Report.litTagName} .data=${{reportTitle: this.#frame.displayName()} as ReportView.ReportView.ReportData}>
330 ${this.#renderDocumentSection()}
331 ${this.#renderIsolationSection()}
332 ${this.#renderApiAvailabilitySection()}
333 ${this.#renderOriginTrial()}
334 ${LitHtml.Directives.until(this.#permissionsPolicies?.then(policies => {
335 this.#permissionsPolicySectionData.policies = policies || [];
Wolfgang Beyerffae99f2021-07-08 08:46:53336 return LitHtml.html`
337 <${PermissionsPolicySection.litTagName}
Tim van der Lippec3f835a2021-12-15 13:28:32338 .data=${this.#permissionsPolicySectionData as PermissionsPolicySectionData}
Wolfgang Beyerffae99f2021-07-08 08:46:53339 >
340 </${PermissionsPolicySection.litTagName}>
341 `;
342 }), LitHtml.nothing)}
Danil Somsikov325f2182022-05-16 09:40:39343 ${this.#renderPrerenderingSection()}
Tim van der Lippec3f835a2021-12-15 13:28:32344 ${this.#protocolMonitorExperimentEnabled ? this.#renderAdditionalInfoSection() : LitHtml.nothing}
Wolfgang Beyerffae99f2021-07-08 08:46:53345 </${ReportView.ReportView.Report.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32346 `, this.#shadow, {host: this});
Wolfgang Beyerffae99f2021-07-08 08:46:53347 // clang-format on
348 });
Wolfgang Beyer92395c92021-02-02 10:43:23349 }
Wolfgang Beyer1525b1f2021-02-02 14:12:30350
Jack Franklind7508302022-05-09 14:22:21351 #renderOriginTrial(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32352 if (!this.#frame) {
Charlie Hu2086be52021-07-02 16:12:12353 return LitHtml.nothing;
354 }
Charlie Hu6c295cf2021-08-10 15:38:48355
Tim van der Lippec3f835a2021-12-15 13:28:32356 this.#originTrialTreeView.classList.add('span-cols');
Charlie Hu6c295cf2021-08-10 15:38:48357
Tim van der Lippec3f835a2021-12-15 13:28:32358 const frame = this.#frame;
Charlie Hu6c295cf2021-08-10 15:38:48359 const refreshOriginTrials: () => void = () => {
Tim van der Lippe2d9a95c2022-01-04 15:18:03360 void frame.getOriginTrials().then(trials => {
Tim van der Lippec3f835a2021-12-15 13:28:32361 this.#originTrialTreeView.data = {trials} as OriginTrialTreeViewData;
Charlie Hu6c295cf2021-08-10 15:38:48362 });
363 };
364 refreshOriginTrials();
365
Charlie Hu2086be52021-07-02 16:12:12366 return LitHtml.html`
Charlie Hu6c295cf2021-08-10 15:38:48367 <${ReportView.ReportView.ReportSectionHeader.litTagName}>
Wolfgang Beyerdbf211e2021-11-23 10:23:54368 ${i18n.i18n.lockedString('Origin Trials')}
Jack Franklina31102b2021-12-03 15:01:22369 <${IconButton.IconButton.IconButton.litTagName} class="inline-button" .data=${{
Charlie Hu6c295cf2021-08-10 15:38:48370 clickHandler: refreshOriginTrials,
371 groups: [
372 {
Wolfgang Beyerb6703942023-04-04 11:53:43373 iconName: 'refresh',
Wolfgang Beyer1a432c42022-01-20 09:30:14374 text: i18nString(UIStrings.refresh),
Wolfgang Beyerb6703942023-04-04 11:53:43375 iconColor: 'var(--icon-default-hover)',
376 iconWidth: '14px',
377 iconHeight: '14px',
Charlie Hu6c295cf2021-08-10 15:38:48378 } as IconButton.IconButton.IconWithTextData,
379 ],
Jack Franklina31102b2021-12-03 15:01:22380 } as IconButton.IconButton.IconButtonData}>
Charlie Hu6c295cf2021-08-10 15:38:48381 </${IconButton.IconButton.IconButton.litTagName}>
Charlie Hu2086be52021-07-02 16:12:12382 </${ReportView.ReportView.ReportSectionHeader.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32383 ${this.#originTrialTreeView}
Charlie Hu2086be52021-07-02 16:12:12384 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
385 ReportView.ReportView.ReportSectionDivider.litTagName}>
386 `;
387 }
388
Jack Franklind7508302022-05-09 14:22:21389 #renderDocumentSection(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32390 if (!this.#frame) {
Wolfgang Beyer1525b1f2021-02-02 14:12:30391 return LitHtml.nothing;
392 }
393
394 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36395 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.document)}</${
396 ReportView.ReportView.ReportSectionHeader.litTagName}>
Wolfgang Beyer5e451ff2021-12-08 16:44:35397 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.url)}</${
Kriti Sapra74915452021-05-13 11:57:36398 ReportView.ReportView.ReportKey.litTagName}>
399 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30400 <div class="inline-items">
Tim van der Lippec3f835a2021-12-15 13:28:32401 ${this.#maybeRenderSourcesLinkForURL()}
402 ${this.#maybeRenderNetworkLinkForURL()}
403 <div class="text-ellipsis" title=${this.#frame.url}>${this.#frame.url}</div>
Wolfgang Beyer1525b1f2021-02-02 14:12:30404 </div>
Kriti Sapra74915452021-05-13 11:57:36405 </${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32406 ${this.#maybeRenderUnreachableURL()}
407 ${this.#maybeRenderOrigin()}
408 ${LitHtml.Directives.until(this.#renderOwnerElement(), LitHtml.nothing)}
409 ${this.#maybeRenderCreationStacktrace()}
410 ${this.#maybeRenderAdStatus()}
Kriti Sapra74915452021-05-13 11:57:36411 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
412 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30413 `;
414 }
415
Jack Franklind7508302022-05-09 14:22:21416 #maybeRenderSourcesLinkForURL(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32417 if (!this.#frame || this.#frame.unreachableUrl()) {
Wolfgang Beyer1525b1f2021-02-02 14:12:30418 return LitHtml.nothing;
419 }
Tim van der Lippec3f835a2021-12-15 13:28:32420 const sourceCode = this.#uiSourceCodeForFrame(this.#frame);
Wolfgang Beyerffae99f2021-07-08 08:46:53421 return renderIconLink(
Wolfgang Beyerf64d63e2023-04-04 14:47:38422 'breakpoint-circle',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01423 i18nString(UIStrings.clickToRevealInSourcesPanel),
Wolfgang Beyer1525b1f2021-02-02 14:12:30424 (): Promise<void> => Common.Revealer.reveal(sourceCode),
425 );
426 }
427
Jack Franklind7508302022-05-09 14:22:21428 #maybeRenderNetworkLinkForURL(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32429 if (this.#frame) {
430 const resource = this.#frame.resourceForURL(this.#frame.url);
Wolfgang Beyer1525b1f2021-02-02 14:12:30431 if (resource && resource.request) {
432 const request = resource.request;
Wolfgang Beyerffae99f2021-07-08 08:46:53433 return renderIconLink(
Wolfgang Beyerf64d63e2023-04-04 14:47:38434 'arrow-up-down-circle', i18nString(UIStrings.clickToRevealInNetworkPanel), (): Promise<void> => {
Wolfgang Beyer705d89f2023-02-24 15:12:34435 const headersTab = Root.Runtime.experiments.isEnabled(Root.Runtime.ExperimentName.HEADER_OVERRIDES) ?
436 NetworkForward.UIRequestLocation.UIRequestTabs.HeadersComponent :
437 NetworkForward.UIRequestLocation.UIRequestTabs.Headers;
438 const requestLocation = NetworkForward.UIRequestLocation.UIRequestLocation.tab(request, headersTab);
Sigurd Schneider14d3e9f2021-06-14 08:29:01439 return Common.Revealer.reveal(requestLocation);
440 });
Wolfgang Beyer1525b1f2021-02-02 14:12:30441 }
442 }
443 return LitHtml.nothing;
444 }
445
Tim van der Lippec3f835a2021-12-15 13:28:32446 #uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode|null {
Wolfgang Beyer1525b1f2021-02-02 14:12:30447 for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) {
448 const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project);
449 if (projectTarget && projectTarget === frame.resourceTreeModel().target()) {
450 const uiSourceCode = project.uiSourceCodeForURL(frame.url);
451 if (uiSourceCode) {
452 return uiSourceCode;
453 }
454 }
455 }
456 return null;
457 }
458
Jack Franklind7508302022-05-09 14:22:21459 #maybeRenderUnreachableURL(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32460 if (!this.#frame || !this.#frame.unreachableUrl()) {
Wolfgang Beyer1525b1f2021-02-02 14:12:30461 return LitHtml.nothing;
462 }
463 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36464 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.unreachableUrl)}</${
465 ReportView.ReportView.ReportKey.litTagName}>
466 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30467 <div class="inline-items">
Tim van der Lippec3f835a2021-12-15 13:28:32468 ${this.#renderNetworkLinkForUnreachableURL()}
469 <div class="text-ellipsis" title=${this.#frame.unreachableUrl()}>${this.#frame.unreachableUrl()}</div>
Wolfgang Beyer1525b1f2021-02-02 14:12:30470 </div>
Kriti Sapra74915452021-05-13 11:57:36471 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30472 `;
473 }
474
Jack Franklind7508302022-05-09 14:22:21475 #renderNetworkLinkForUnreachableURL(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32476 if (this.#frame) {
477 const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(this.#frame.unreachableUrl());
Wolfgang Beyer1525b1f2021-02-02 14:12:30478 if (unreachableUrl) {
Wolfgang Beyerffae99f2021-07-08 08:46:53479 return renderIconLink(
Wolfgang Beyerf64d63e2023-04-04 14:47:38480 'arrow-up-down-circle',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01481 i18nString(UIStrings.clickToRevealInNetworkPanelMight),
Wolfgang Beyer1525b1f2021-02-02 14:12:30482 ():
483 void => {
Tim van der Lippe2d9a95c2022-01-04 15:18:03484 void Common.Revealer.reveal(NetworkForward.UIFilter.UIRequestFilter.filters([
Wolfgang Beyer1525b1f2021-02-02 14:12:30485 {
Sigurd Schneider30722582021-06-16 06:54:16486 filterType: NetworkForward.UIFilter.FilterType.Domain,
Wolfgang Beyer1525b1f2021-02-02 14:12:30487 filterValue: unreachableUrl.domain(),
488 },
489 {
490 filterType: null,
491 filterValue: unreachableUrl.path,
492 },
Sigurd Schneider30722582021-06-16 06:54:16493 ]));
Wolfgang Beyer1525b1f2021-02-02 14:12:30494 },
495 );
496 }
497 }
498 return LitHtml.nothing;
499 }
500
Jack Franklind7508302022-05-09 14:22:21501 #maybeRenderOrigin(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32502 if (this.#frame && this.#frame.securityOrigin && this.#frame.securityOrigin !== '://') {
Wolfgang Beyer1525b1f2021-02-02 14:12:30503 return LitHtml.html`
Wolfgang Beyer5e451ff2021-12-08 16:44:35504 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.origin)}</${
Kriti Sapra74915452021-05-13 11:57:36505 ReportView.ReportView.ReportKey.litTagName}>
506 <${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32507 <div class="text-ellipsis" title=${this.#frame.securityOrigin}>${this.#frame.securityOrigin}</div>
Kriti Sapra74915452021-05-13 11:57:36508 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30509 `;
510 }
511 return LitHtml.nothing;
512 }
513
Jack Franklind7508302022-05-09 14:22:21514 async #renderOwnerElement(): Promise<LitHtml.LitTemplate> {
Tim van der Lippec3f835a2021-12-15 13:28:32515 if (this.#frame) {
516 const linkTargetDOMNode = await this.#frame.getOwnerDOMNodeOrDocument();
Wolfgang Beyerf0d985e2021-02-05 12:56:52517 if (linkTargetDOMNode) {
518 // Disabled until https://crbug.com/1079231 is fixed.
519 // clang-format off
Wolfgang Beyerf0d985e2021-02-05 12:56:52520 return LitHtml.html`
Wolfgang Beyerf64d63e2023-04-04 14:47:38521 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.ownerElement)}</${ReportView.ReportView.ReportKey.litTagName}>
Kriti Sapra74915452021-05-13 11:57:36522 <${ReportView.ReportView.ReportValue.litTagName} class="without-min-width">
Wolfgang Beyerf64d63e2023-04-04 14:47:38523 <div class="inline-items">
524 <button class="link" role="link" tabindex=0
525 @mouseenter=${(): Promise<void>|undefined => this.#frame?.highlight()}
526 @mouseleave=${(): void => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()}
527 @click=${(): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode)}
528 title=${i18nString(UIStrings.clickToRevealInElementsPanel)}
529 >
530 <${IconButton.Icon.Icon.litTagName} .data=${{
531 iconName: 'code-circle',
532 color: 'var(--icon-link)',
Kateryna Prokopenkob6c61772023-04-26 12:43:12533 width: '16px',
534 height: '16px',
Wolfgang Beyerf64d63e2023-04-04 14:47:38535 } as IconButton.Icon.IconData}>
536 </${IconButton.Icon.Icon.litTagName}>
537 </button>
538 <button class="link text-link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToRevealInElementsPanel)}
539 @mouseenter=${(): Promise<void>|undefined => this.#frame?.highlight()}
540 @mouseleave=${(): void => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()}
541 @click=${(): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode)}
542 >
543 &lt;${linkTargetDOMNode.nodeName().toLocaleLowerCase()}&gt;
544 </button>
545 </div>
Kriti Sapra74915452021-05-13 11:57:36546 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyerf0d985e2021-02-05 12:56:52547 `;
548 // clang-format on
Wolfgang Beyer1525b1f2021-02-02 14:12:30549 }
550 }
551 return LitHtml.nothing;
552 }
553
Jack Franklind7508302022-05-09 14:22:21554 #maybeRenderCreationStacktrace(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32555 const creationStackTraceData = this.#frame?.getCreationStackTraceData();
Wolfgang Beyera20485a2021-04-21 07:22:19556 if (creationStackTraceData && creationStackTraceData.creationStackTrace) {
Wolfgang Beyera036d0c2021-03-19 09:09:33557 // Disabled until https://crbug.com/1079231 is fixed.
558 // clang-format off
Wolfgang Beyer19093942021-03-15 15:00:34559 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36560 <${ReportView.ReportView.ReportKey.litTagName} title=${i18nString(UIStrings.creationStackTraceExplanation)}>${
561 i18nString(UIStrings.creationStackTrace)}</${ReportView.ReportView.ReportKey.litTagName}>
562 <${ReportView.ReportView.ReportValue.litTagName}>
563 <${StackTrace.litTagName} .data=${{
Tim van der Lippec3f835a2021-12-15 13:28:32564 frame: this.#frame,
Wolfgang Beyera036d0c2021-03-19 09:09:33565 buildStackTraceRows: Components.JSPresentationUtils.buildStackTraceRows,
566 } as StackTraceData}>
Kriti Sapra74915452021-05-13 11:57:36567 </${StackTrace.litTagName}>
568 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer19093942021-03-15 15:00:34569 `;
Wolfgang Beyera036d0c2021-03-19 09:09:33570 // clang-format on
Wolfgang Beyer19093942021-03-15 15:00:34571 }
572 return LitHtml.nothing;
573 }
574
Tim van der Lippec3f835a2021-12-15 13:28:32575 #getAdFrameTypeStrings(type: Protocol.Page.AdFrameType.Child|Protocol.Page.AdFrameType.Root):
Sigurd Schneidercc9a02e2021-06-16 06:20:33576 {value: Platform.UIString.LocalizedString, description: Platform.UIString.LocalizedString} {
577 switch (type) {
578 case Protocol.Page.AdFrameType.Child:
579 return {value: i18nString(UIStrings.child), description: i18nString(UIStrings.childDescription)};
580 case Protocol.Page.AdFrameType.Root:
581 return {value: i18nString(UIStrings.root), description: i18nString(UIStrings.rootDescription)};
Wolfgang Beyer1525b1f2021-02-02 14:12:30582 }
Sigurd Schneidercc9a02e2021-06-16 06:20:33583 }
584
Tim van der Lippec3f835a2021-12-15 13:28:32585 #getAdFrameExplanationString(explanation: Protocol.Page.AdFrameExplanation): Platform.UIString.LocalizedString {
Sigurd Schneidercc9a02e2021-06-16 06:20:33586 switch (explanation) {
587 case Protocol.Page.AdFrameExplanation.CreatedByAdScript:
588 return i18nString(UIStrings.createdByAdScriptExplanation);
589 case Protocol.Page.AdFrameExplanation.MatchedBlockingRule:
590 return i18nString(UIStrings.matchedBlockingRuleExplanation);
591 case Protocol.Page.AdFrameExplanation.ParentIsAd:
592 return i18nString(UIStrings.parentIsAdExplanation);
593 }
594 }
595
Jack Franklind7508302022-05-09 14:22:21596 #maybeRenderAdStatus(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32597 if (!this.#frame) {
Sigurd Schneidercc9a02e2021-06-16 06:20:33598 return LitHtml.nothing;
599 }
Tim van der Lippec3f835a2021-12-15 13:28:32600 const adFrameType = this.#frame.adFrameType();
Sigurd Schneidercc9a02e2021-06-16 06:20:33601 if (adFrameType === Protocol.Page.AdFrameType.None) {
602 return LitHtml.nothing;
603 }
Tim van der Lippec3f835a2021-12-15 13:28:32604 const typeStrings = this.#getAdFrameTypeStrings(adFrameType);
Jack Franklina31102b2021-12-03 15:01:22605 const rows = [LitHtml.html`<div title=${typeStrings.description}>${typeStrings.value}</div>`];
Tim van der Lippec3f835a2021-12-15 13:28:32606 for (const explanation of this.#frame.adFrameStatus()?.explanations || []) {
607 rows.push(LitHtml.html`<div>${this.#getAdFrameExplanationString(explanation)}</div>`);
Sigurd Schneidercc9a02e2021-06-16 06:20:33608 }
Danil Somsikovc48b2b12022-06-24 15:03:03609
Alex Rudenkob8b48602022-10-17 12:59:58610 const adScriptLinkElement = this.#target ? this.#linkifier.linkifyScriptLocation(
611 this.#target, this.#adScriptId?.scriptId || null,
612 Platform.DevToolsPath.EmptyUrlString, undefined, undefined) :
613 null;
Danil Somsikovc48b2b12022-06-24 15:03:03614
615 // Disabled until https://crbug.com/1079231 is fixed.
616 // clang-format off
Sigurd Schneidercc9a02e2021-06-16 06:20:33617 return LitHtml.html`
618 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.adStatus)}</${
619 ReportView.ReportView.ReportKey.litTagName}>
620 <${ReportView.ReportView.ReportValue.litTagName}>
Danil Somsikovc48b2b12022-06-24 15:03:03621 <${ExpandableList.ExpandableList.ExpandableList.litTagName} .data=${
622 {rows} as ExpandableList.ExpandableList.ExpandableListData}></${
Sigurd Schneidercc9a02e2021-06-16 06:20:33623 ExpandableList.ExpandableList.ExpandableList.litTagName}></${ReportView.ReportView.ReportValue.litTagName}>
Danil Somsikovc48b2b12022-06-24 15:03:03624 ${this.#target ? LitHtml.html`
625 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.creatorAdScript)}</${
626 ReportView.ReportView.ReportKey.litTagName}>
627 <${ReportView.ReportView.ReportValue.litTagName} class="ad-script-link">${adScriptLinkElement}</${
628 ReportView.ReportView.ReportValue.litTagName}>
629 ` : LitHtml.nothing}
630 `;
631 // clang-format on
Wolfgang Beyer1525b1f2021-02-02 14:12:30632 }
Wolfgang Beyerabfc8472021-02-04 11:29:50633
Jack Franklind7508302022-05-09 14:22:21634 #renderIsolationSection(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32635 if (!this.#frame) {
Wolfgang Beyerabfc8472021-02-04 11:29:50636 return LitHtml.nothing;
637 }
638 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36639 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.securityIsolation)}</${
640 ReportView.ReportView.ReportSectionHeader.litTagName}>
641 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.secureContext)}</${
642 ReportView.ReportView.ReportKey.litTagName}>
643 <${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32644 ${this.#frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}\xA0${
645 this.#maybeRenderSecureContextExplanation()}
Kriti Sapra74915452021-05-13 11:57:36646 </${ReportView.ReportView.ReportValue.litTagName}>
647 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.crossoriginIsolated)}</${
648 ReportView.ReportView.ReportKey.litTagName}>
649 <${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32650 ${this.#frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
Kriti Sapra74915452021-05-13 11:57:36651 </${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32652 ${LitHtml.Directives.until(this.#maybeRenderCoopCoepStatus(), LitHtml.nothing)}
Kriti Sapra74915452021-05-13 11:57:36653 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
654 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyerabfc8472021-02-04 11:29:50655 `;
656 }
657
Jack Franklind7508302022-05-09 14:22:21658 #maybeRenderSecureContextExplanation(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32659 const explanation = this.#getSecureContextExplanation();
Wolfgang Beyerabfc8472021-02-04 11:29:50660 if (explanation) {
Tim van der Lippe0005b802021-06-03 10:47:59661 return LitHtml.html`<span class="inline-comment">${explanation}</span>`;
Wolfgang Beyerabfc8472021-02-04 11:29:50662 }
663 return LitHtml.nothing;
664 }
665
Tim van der Lippec3f835a2021-12-15 13:28:32666 #getSecureContextExplanation(): Platform.UIString.LocalizedString|null {
667 switch (this.#frame?.getSecureContextType()) {
Wolfgang Beyerabfc8472021-02-04 11:29:50668 case Protocol.Page.SecureContextType.Secure:
669 return null;
670 case Protocol.Page.SecureContextType.SecureLocalhost:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01671 return i18nString(UIStrings.localhostIsAlwaysASecureContext);
Wolfgang Beyerabfc8472021-02-04 11:29:50672 case Protocol.Page.SecureContextType.InsecureAncestor:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01673 return i18nString(UIStrings.aFrameAncestorIsAnInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50674 case Protocol.Page.SecureContextType.InsecureScheme:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01675 return i18nString(UIStrings.theFramesSchemeIsInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50676 }
677 return null;
678 }
679
Jack Franklind7508302022-05-09 14:22:21680 async #maybeRenderCoopCoepStatus(): Promise<LitHtml.LitTemplate> {
Tim van der Lippec3f835a2021-12-15 13:28:32681 if (this.#frame) {
682 const model = this.#frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager);
683 const info = model && await model.getSecurityIsolationStatus(this.#frame.id);
Wolfgang Beyerabfc8472021-02-04 11:29:50684 if (info) {
685 return LitHtml.html`
686 ${
Tim van der Lippec3f835a2021-12-15 13:28:32687 this.#maybeRenderCrossOriginStatus(
Wolfgang Beyerdbf211e2021-11-23 10:23:54688 info.coep, i18n.i18n.lockedString('Cross-Origin Embedder Policy (COEP)'),
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01689 Protocol.Network.CrossOriginEmbedderPolicyValue.None)}
Wolfgang Beyerabfc8472021-02-04 11:29:50690 ${
Tim van der Lippec3f835a2021-12-15 13:28:32691 this.#maybeRenderCrossOriginStatus(
Wolfgang Beyerdbf211e2021-11-23 10:23:54692 info.coop, i18n.i18n.lockedString('Cross-Origin Opener Policy (COOP)'),
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01693 Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)}
Wolfgang Beyerabfc8472021-02-04 11:29:50694 `;
695 }
696 }
697 return LitHtml.nothing;
698 }
699
Tim van der Lippec3f835a2021-12-15 13:28:32700 #maybeRenderCrossOriginStatus(
Wolfgang Beyerabfc8472021-02-04 11:29:50701 info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined,
702 policyName: string,
703 noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue|
Jack Franklind7508302022-05-09 14:22:21704 Protocol.Network.CrossOriginOpenerPolicyValue): LitHtml.LitTemplate {
Wolfgang Beyerabfc8472021-02-04 11:29:50705 if (!info) {
706 return LitHtml.nothing;
707 }
708 const isEnabled = info.value !== noneValue;
709 const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue);
710 const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint;
711 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36712 <${ReportView.ReportView.ReportKey.litTagName}>${policyName}</${ReportView.ReportView.ReportKey.litTagName}>
713 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyerabfc8472021-02-04 11:29:50714 ${isEnabled ? info.value : info.reportOnlyValue}
715 ${isReportOnly ? LitHtml.html`<span class="inline-comment">report-only</span>` : LitHtml.nothing}
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01716 ${
717 endpoint ? LitHtml.html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` :
718 LitHtml.nothing}
Kriti Sapra74915452021-05-13 11:57:36719 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyerabfc8472021-02-04 11:29:50720 `;
721 }
Wolfgang Beyer6a6efe62021-02-04 15:56:21722
Jack Franklind7508302022-05-09 14:22:21723 #renderApiAvailabilitySection(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32724 if (!this.#frame) {
Wolfgang Beyer6a6efe62021-02-04 15:56:21725 return LitHtml.nothing;
726 }
727
728 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36729 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.apiAvailability)}</${
730 ReportView.ReportView.ReportSectionHeader.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21731 <div class="span-cols">
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01732 ${i18nString(UIStrings.availabilityOfCertainApisDepends)}
Wolfgang Beyer4751c1c2021-03-24 15:32:35733 <x-link href="https://web.dev/why-coop-coep/" class="link">${i18nString(UIStrings.learnMore)}</x-link>
Wolfgang Beyer6a6efe62021-02-04 15:56:21734 </div>
Tim van der Lippec3f835a2021-12-15 13:28:32735 ${this.#renderSharedArrayBufferAvailability()}
736 ${this.#renderMeasureMemoryAvailability()}
Kriti Sapra74915452021-05-13 11:57:36737 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
738 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21739 `;
740 }
741
Jack Franklind7508302022-05-09 14:22:21742 #renderSharedArrayBufferAvailability(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32743 if (this.#frame) {
744 const features = this.#frame.getGatedAPIFeatures();
Wolfgang Beyer6a6efe62021-02-04 15:56:21745 if (features) {
746 const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers);
747 const sabTransferAvailable =
748 sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed);
749 const availabilityText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01750 i18nString(UIStrings.availableTransferable) :
751 (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable));
Wolfgang Beyer6a6efe62021-02-04 15:56:21752 const tooltipText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01753 i18nString(UIStrings.sharedarraybufferConstructorIs) :
754 (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : '');
Wolfgang Beyer6a6efe62021-02-04 15:56:21755
Jack Franklind7508302022-05-09 14:22:21756 function renderHint(frame: SDK.ResourceTreeModel.ResourceTreeFrame): LitHtml.LitTemplate {
Sigurd Schneider2a450252021-05-04 07:13:15757 switch (frame.getCrossOriginIsolatedContextType()) {
758 case Protocol.Page.CrossOriginIsolatedContextType.Isolated:
759 return LitHtml.nothing;
760 case Protocol.Page.CrossOriginIsolatedContextType.NotIsolated:
761 if (sabAvailable) {
762 return LitHtml.html`<span class="inline-comment">${
763 i18nString(UIStrings.willRequireCrossoriginIsolated)}</span>`;
764 }
765 return LitHtml.html`<span class="inline-comment">${
766 i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`;
767 case Protocol.Page.CrossOriginIsolatedContextType.NotIsolatedFeatureDisabled:
768 if (!sabTransferAvailable) {
769 return LitHtml.html`<span class="inline-comment">${
770 i18nString(
771 UIStrings
772 .transferRequiresCrossoriginIsolatedPermission)} <code>cross-origin-isolated</code></span>`;
773 }
774 break;
775 }
776 return LitHtml.nothing;
777 }
778
Peter Marshall0e1cd822021-02-24 10:52:42779 // SharedArrayBuffer is an API name, so we don't translate it.
Wolfgang Beyer6a6efe62021-02-04 15:56:21780 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36781 <${ReportView.ReportView.ReportKey.litTagName}>SharedArrayBuffers</${
782 ReportView.ReportView.ReportKey.litTagName}>
783 <${ReportView.ReportView.ReportValue.litTagName} title=${tooltipText}>
Tim van der Lippec3f835a2021-12-15 13:28:32784 ${availabilityText}\xA0${renderHint(this.#frame)}
Kriti Sapra74915452021-05-13 11:57:36785 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21786 `;
Wolfgang Beyer6a6efe62021-02-04 15:56:21787 }
788 }
789 return LitHtml.nothing;
790 }
791
Jack Franklind7508302022-05-09 14:22:21792 #renderMeasureMemoryAvailability(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32793 if (this.#frame) {
794 const measureMemoryAvailable = this.#frame.isCrossOriginIsolated();
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01795 const availabilityText =
796 measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable);
797 const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) :
798 i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory);
Wolfgang Beyer6a6efe62021-02-04 15:56:21799 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36800 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.measureMemory)}</${
801 ReportView.ReportView.ReportKey.litTagName}>
802 <${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippe0005b802021-06-03 10:47:59803 <span title=${tooltipText}>${
804 availabilityText}</span>\xA0<x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/">${
Wolfgang Beyer09b0e8e2021-02-09 13:39:48805 i18nString(UIStrings.learnMore)}</x-link>
Kriti Sapra74915452021-05-13 11:57:36806 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21807 `;
808 }
809 return LitHtml.nothing;
810 }
Wolfgang Beyere5d1a9f2021-02-05 09:42:43811
Danil Somsikov325f2182022-05-16 09:40:39812 #renderPrerenderingSection(): LitHtml.LitTemplate {
Robert Lin48a925e2022-11-02 11:55:56813 if (this.#prerenderedUrl && this.#prerenderedUrl !== '') {
814 const status = Prerender2ReasonDescription['PrerenderingOngoing'].name() + ' ' + this.#prerenderedUrl;
815 return LitHtml.html`
816 <${ReportView.ReportView.ReportSectionHeader.litTagName}>
817 ${i18nString(UIStrings.prerendering)}</${ReportView.ReportView.ReportSectionHeader.litTagName}>
818 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.prerenderingStatus)}</${
819 ReportView.ReportView.ReportKey.litTagName}>
820 <${ReportView.ReportView.ReportValue.litTagName}>
821 <div class="text-ellipsis" title=${status}>${status}</div>
822 </${ReportView.ReportView.ReportValue.litTagName}>
823 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
824 ReportView.ReportView.ReportSectionDivider.litTagName}>`;
825 }
826
Danil Somsikov325f2182022-05-16 09:40:39827 if (!this.#frame || !this.#frame.prerenderFinalStatus) {
828 return LitHtml.nothing;
829 }
Robert Lin48a925e2022-11-02 11:55:56830
Robert Lin449f9332022-07-06 14:05:45831 const finalStatus = Prerender2ReasonDescription[this.#frame.prerenderFinalStatus].name();
Robert Lind77df7d2022-10-03 01:34:49832
833 if (this.#frame.prerenderDisallowedApiMethod) {
834 const detailSection = Prerender2ReasonDescription['DisallowedApiMethod'].name();
835 return LitHtml.html`
836 <${ReportView.ReportView.ReportSectionHeader.litTagName}>
837 ${i18nString(UIStrings.prerendering)}</${ReportView.ReportView.ReportSectionHeader.litTagName}>
838 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.prerenderingStatus)}</${
839 ReportView.ReportView.ReportKey.litTagName}>
840 <${ReportView.ReportView.ReportValue.litTagName}>
841 <div class="text-ellipsis" title=${finalStatus}>${finalStatus}</div>
842 </${ReportView.ReportView.ReportValue.litTagName}>
843 <${ReportView.ReportView.ReportKey.litTagName}>${detailSection}</${ReportView.ReportView.ReportKey.litTagName}>
844 <${ReportView.ReportView.ReportValue.litTagName}>
845 <div class="text-ellipsis" title=${this.#frame.prerenderDisallowedApiMethod}>
846 ${this.#frame.prerenderDisallowedApiMethod}
847 </div>
848 </${ReportView.ReportView.ReportValue.litTagName}>
849 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
850 ReportView.ReportView.ReportSectionDivider.litTagName}>`;
851 }
Danil Somsikov325f2182022-05-16 09:40:39852 return LitHtml.html`
853 <${ReportView.ReportView.ReportSectionHeader.litTagName}>
854 ${i18nString(UIStrings.prerendering)}</${ReportView.ReportView.ReportSectionHeader.litTagName}>
855 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.prerenderingStatus)}</${
856 ReportView.ReportView.ReportKey.litTagName}>
857 <${ReportView.ReportView.ReportValue.litTagName}>
Robert Lin449f9332022-07-06 14:05:45858 <div class="text-ellipsis" title=${finalStatus}>${finalStatus}</div>
Danil Somsikov325f2182022-05-16 09:40:39859 </${ReportView.ReportView.ReportValue.litTagName}>
860 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
861 ReportView.ReportView.ReportSectionDivider.litTagName}>`;
862 }
863
Jack Franklind7508302022-05-09 14:22:21864 #renderAdditionalInfoSection(): LitHtml.LitTemplate {
Tim van der Lippec3f835a2021-12-15 13:28:32865 if (!this.#frame) {
Wolfgang Beyere5d1a9f2021-02-05 09:42:43866 return LitHtml.nothing;
867 }
868
869 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36870 <${ReportView.ReportView.ReportSectionHeader.litTagName}
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01871 title=${i18nString(UIStrings.thisAdditionalDebugging)}
Kriti Sapra74915452021-05-13 11:57:36872 >${i18nString(UIStrings.additionalInformation)}</${ReportView.ReportView.ReportSectionHeader.litTagName}>
873 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.frameId)}</${
874 ReportView.ReportView.ReportKey.litTagName}>
875 <${ReportView.ReportView.ReportValue.litTagName}>
Tim van der Lippec3f835a2021-12-15 13:28:32876 <div class="text-ellipsis" title=${this.#frame.id}>${this.#frame.id}</div>
Kriti Sapra74915452021-05-13 11:57:36877 </${ReportView.ReportView.ReportValue.litTagName}>
878 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
879 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43880 `;
881 }
Wolfgang Beyer92395c92021-02-02 10:43:23882}
883
Kriti Sapra34df98d2021-05-06 10:15:42884ComponentHelpers.CustomElements.defineComponent('devtools-resources-frame-details-view', FrameDetailsReportView);
Wolfgang Beyer92395c92021-02-02 10:43:23885
886declare global {
887 // eslint-disable-next-line @typescript-eslint/no-unused-vars
888 interface HTMLElementTagNameMap {
889 'devtools-resources-frame-details-view': FrameDetailsReportView;
890 }
891}