blob: abc4feddcfab617693e95d74009c96f82113b849 [file] [log] [blame]
Wolfgang Beyer760462e2020-07-13 15:01:351// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Kriti Sapra74915452021-05-13 11:57:365/* eslint-disable rulesdir/components_import */
Tim van der Lippefeb2a1e2021-04-14 11:39:546
Wolfgang Beyer19093942021-03-15 15:00:347import type {StackTraceData} from './StackTrace.js';
Kriti Sapra74915452021-05-13 11:57:368import {StackTrace} from './StackTrace.js';
Tim van der Lippe1bd5e212021-05-06 10:54:299import * as Bindings from '../../../models/bindings/bindings.js';
10import * as Common from '../../../core/common/common.js';
11import * as i18n from '../../../core/i18n/i18n.js';
12import * as Network from '../../network/network.js';
Jack Franklina75ae7c2021-05-11 13:22:5413import type * as Platform from '../../../core/platform/platform.js';
Tim van der Lippe1bd5e212021-05-06 10:54:2914import * as Root from '../../../core/root/root.js';
15import * as SDK from '../../../core/sdk/sdk.js'; // eslint-disable-line no-unused-vars
Paul Lewis01f49392021-05-10 13:54:2016import * as LitHtml from '../../../ui/lit-html/lit-html.js';
Kriti Sapra74915452021-05-13 11:57:3617import * as ReportView from '../../../ui/components/report_view/report_view.js';
18import * as IconButton from '../../../ui/components/icon_button/icon_button.js';
Tim van der Lippe1bd5e212021-05-06 10:54:2919import * as ComponentHelpers from '../../../ui/components/helpers/helpers.js';
20import * as UI from '../../../ui/legacy/legacy.js';
21import * as Workspace from '../../../models/workspace/workspace.js';
22import * as Components from '../../../ui/legacy/components/utils/utils.js';
Wolfgang Beyer760462e2020-07-13 15:01:3523
Simon Zünd697fb0b2021-03-01 10:12:4224const UIStrings = {
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0125 /**
26 *@description Section header in the Frame Details view
27 */
28 additionalInformation: 'Additional Information',
29 /**
30 *@description Explanation for why the additional information section is being shown
31 */
32 thisAdditionalDebugging:
33 'This additional (debugging) information is shown because the \'Protocol Monitor\' experiment is enabled.',
34 /**
35 *@description Label for subtitle of frame details view
36 */
37 frameId: 'Frame ID',
38 /**
39 *@description Name of a network resource type
40 */
41 document: 'Document',
42 /**
43 *@description Text for web URLs
44 */
45 url: 'URL',
46 /**
47 *@description Title for a link to the Sources panel
48 */
49 clickToRevealInSourcesPanel: 'Click to reveal in Sources panel',
50 /**
51 *@description Title for a link to the Network panel
52 */
53 clickToRevealInNetworkPanel: 'Click to reveal in Network panel',
54 /**
55 *@description Title for unreachable URL field
56 */
57 unreachableUrl: 'Unreachable URL',
58 /**
59 *@description Title for a link that applies a filter to the network panel
60 */
61 clickToRevealInNetworkPanelMight: 'Click to reveal in Network panel (might require page reload)',
62 /**
63 *@description Text for the origin of something
64 */
65 origin: 'Origin',
66 /**
67 *@description Related node label in Timeline UIUtils of the Performance panel
68 */
69 ownerElement: 'Owner Element',
70 /**
71 *@description Title for a link to the Elements panel
72 */
73 clickToRevealInElementsPanel: 'Click to reveal in Elements panel',
74 /**
75 *@description Title for ad frame type field
76 */
77 adStatus: 'Ad Status',
78 /**
79 *@description Description for ad frame type
80 */
81 thisFrameHasBeenIdentifiedAsThe: 'This frame has been identified as the root frame of an ad',
82 /**
83 *@description Value for ad frame type
84 */
85 root: 'root',
86 /**
87 *@description Description for ad frame type
88 */
Peter Marshall3d967382021-02-25 06:56:1889 thisFrameHasBeenIdentifiedAsTheA: 'This frame has been identified as a child frame of an ad',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0190 /**
91 *@description Value for ad frame type
92 */
93 child: 'child',
94 /**
95 *@description Section header in the Frame Details view
96 */
97 securityIsolation: 'Security & Isolation',
98 /**
99 *@description Row title for in the Frame Details view
100 */
101 secureContext: 'Secure Context',
102 /**
103 *@description Text in Timeline indicating that input has happened recently
104 */
105 yes: 'Yes',
106 /**
107 *@description Text in Timeline indicating that input has not happened recently
108 */
109 no: 'No',
110 /**
111 *@description Row title for in the Frame Details view
112 */
113 crossoriginIsolated: 'Cross-Origin Isolated',
114 /**
115 *@description Explanatory text in the Frame Details view
116 */
117 localhostIsAlwaysASecureContext: 'Localhost is always a secure context',
118 /**
119 *@description Explanatory text in the Frame Details view
120 */
121 aFrameAncestorIsAnInsecure: 'A frame ancestor is an insecure context',
122 /**
123 *@description Explanatory text in the Frame Details view
124 */
125 theFramesSchemeIsInsecure: 'The frame\'s scheme is insecure',
126 /**
127 *@description Row title in the Frame Details view
128 */
129 crossoriginEmbedderPolicy: 'Cross-Origin Embedder Policy',
130 /**
131 *@description Row title in the Frame Details view
132 */
133 crossoriginOpenerPolicy: 'Cross-Origin Opener Policy',
134 /**
Peter Marshallec861882021-02-16 11:14:21135 *@description This label specifies the server endpoints to which the server is reporting errors
136 *and warnings through the Report-to API. Following this label will be the URL of the server.
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01137 */
138 reportingTo: 'reporting to',
139 /**
140 *@description Section header in the Frame Details view
141 */
142 apiAvailability: 'API availability',
143 /**
144 *@description Explanatory text in the Frame Details view for the API availability section
145 */
146 availabilityOfCertainApisDepends: 'Availability of certain APIs depends on the document being cross-origin isolated.',
147 /**
148 *@description Description of the SharedArrayBuffer status
149 */
150 availableTransferable: 'available, transferable',
151 /**
152 *@description Description of the SharedArrayBuffer status
153 */
154 availableNotTransferable: 'available, not transferable',
155 /**
156 *@description Explanation for the SharedArrayBuffer availability status
157 */
158 unavailable: 'unavailable',
159 /**
160 *@description Tooltip for the SharedArrayBuffer availability status
161 */
162 sharedarraybufferConstructorIs:
163 'SharedArrayBuffer constructor is available and SABs can be transferred via postMessage',
164 /**
165 *@description Tooltip for the SharedArrayBuffer availability status
166 */
167 sharedarraybufferConstructorIsAvailable:
168 'SharedArrayBuffer constructor is available but SABs cannot be transferred via postMessage',
169 /**
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01170 *@description Explanation for the SharedArrayBuffer availability status
171 */
Sigurd Schneider2a450252021-05-04 07:13:15172 willRequireCrossoriginIsolated: '⚠️ will require cross-origin isolated context in the future',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01173 /**
174 *@description Explanation for the SharedArrayBuffer availability status
175 */
176 requiresCrossoriginIsolated: 'requires cross-origin isolated context',
177 /**
Sigurd Schneider2a450252021-05-04 07:13:15178 *@description Explanation for the SharedArrayBuffer availability status
179 */
180 transferRequiresCrossoriginIsolatedPermission: 'transfer requires permission policy:',
181 /**
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01182 *@description Explanation for the Measure Memory availability status
183 */
184 available: 'available',
185 /**
186 *@description Tooltip for the Measure Memory availability status
187 */
188 thePerformanceAPI: 'The performance.measureUserAgentSpecificMemory() API is available',
189 /**
190 *@description Tooltip for the Measure Memory availability status
191 */
192 thePerformancemeasureuseragentspecificmemory: 'The performance.measureUserAgentSpecificMemory() API is not available',
193 /**
194 *@description Entry in the API availability section of the frame details view
195 */
196 measureMemory: 'Measure Memory',
197 /**
198 *@description Text that is usually a hyperlink to more documentation
199 */
200 learnMore: 'Learn more',
Wolfgang Beyer19093942021-03-15 15:00:34201 /**
Wolfgang Beyer40834922021-05-10 08:34:22202 *@description Label for a stack trace. If a frame is created programmatically (i.e. via JavaScript), there is a
203 * stack trace for the line of code which caused the creation of the iframe. This is the stack trace we are showing here.
Wolfgang Beyer19093942021-03-15 15:00:34204 */
205 creationStackTrace: 'Frame Creation Stack Trace',
206 /**
207 *@description Tooltip for 'Frame Creation Stack Trace' explaining that the stack
208 *trace shows where in the code the frame has been created programmatically
209 */
210 creationStackTraceExplanation: 'This frame was created programmatically. The stack trace shows where this happened.',
Wolfgang Beyer4751c1c2021-03-24 15:32:35211 /**
212 *@description Label for a button. When clicked more details (for the content this button refers to) will be shown.
213 */
214 showDetails: 'Show details',
215 /**
216 *@description Label for a button. When clicked some details (for the content this button refers to) will be hidden.
217 */
218 hideDetails: 'Hide details',
219 /**
Wolfgang Beyer4751c1c2021-03-24 15:32:35220 *@description Label for a list of features which are allowed according to the current Permissions policy
221 *(a mechanism that allows developers to enable/disable browser features and APIs (e.g. camera, geolocation, autoplay))
222 */
223 allowedFeatures: 'Allowed Features',
224 /**
225 *@description Label for a list of features which are disabled according to the current Permissions policy
226 *(a mechanism that allows developers to enable/disable browser features and APIs (e.g. camera, geolocation, autoplay))
227 */
228 disabledFeatures: 'Disabled Features',
229 /**
230 *@description Tooltip text for a link to a specific request's headers in the Network panel.
231 */
232 clickToShowHeader: 'Click to reveal the request whose "`Permissions-Policy`" HTTP header disables this feature.',
233 /**
Wolfgang Beyer40834922021-05-10 08:34:22234 *@description Tooltip text for a link to a specific iframe in the Elements panel (Iframes can be nested, the link goes
235 * to the outer-most iframe which blocks a certain feature).
Wolfgang Beyer4751c1c2021-03-24 15:32:35236 */
237 clickToShowIframe: 'Click to reveal the top-most iframe which does not allow this feature in the elements panel.',
238 /**
239 *@description Text describing that a specific feature is blocked by not being included in the iframe's "allow" attribute.
240 */
241 disabledByIframe: 'missing in iframe "`allow`" attribute',
242 /**
243 *@description Text describing that a specific feature is blocked by a Permissions Policy specified in a request header.
244 */
245 disabledByHeader: 'disabled by "`Permissions-Policy`" header',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01246};
Tim van der Lippe1bd5e212021-05-06 10:54:29247const str_ = i18n.i18n.registerUIStrings('panels/application/components/FrameDetailsView.ts', UIStrings);
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01248const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
Sigurd Schneider1e5ad282020-07-17 11:52:08249export class FrameDetailsView extends UI.ThrottledWidget.ThrottledWidget {
Wolfgang Beyer92395c92021-02-02 10:43:23250 private readonly reportView = new FrameDetailsReportView();
Wolfgang Beyere5d1a9f2021-02-05 09:42:43251 private readonly frame: SDK.ResourceTreeModel.ResourceTreeFrame;
Wolfgang Beyer92395c92021-02-02 10:43:23252
Wolfgang Beyer309863f2021-01-21 09:01:21253 constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) {
Wolfgang Beyer760462e2020-07-13 15:01:35254 super();
Wolfgang Beyere5d1a9f2021-02-05 09:42:43255 this.frame = frame;
256 this.contentElement.classList.add('overflow-auto');
Wolfgang Beyer92395c92021-02-02 10:43:23257 this.contentElement.appendChild(this.reportView);
Sigurd Schneider1e5ad282020-07-17 11:52:08258 this.update();
259 }
260
Wolfgang Beyer309863f2021-01-21 09:01:21261 async doUpdate(): Promise<void> {
Wolfgang Beyere5d1a9f2021-02-05 09:42:43262 this.reportView.data = {frame: this.frame};
Sigurd Schneidereabef962020-11-05 10:51:49263 }
Wolfgang Beyer760462e2020-07-13 15:01:35264}
Wolfgang Beyer3b4747f2020-08-12 07:30:46265
Wolfgang Beyer92395c92021-02-02 10:43:23266export interface FrameDetailsReportViewData {
267 frame: SDK.ResourceTreeModel.ResourceTreeFrame;
268}
269
270export class FrameDetailsReportView extends HTMLElement {
271 private readonly shadow = this.attachShadow({mode: 'open'});
272 private frame?: SDK.ResourceTreeModel.ResourceTreeFrame;
Wolfgang Beyere5d1a9f2021-02-05 09:42:43273 private protocolMonitorExperimentEnabled = false;
Wolfgang Beyer4751c1c2021-03-24 15:32:35274 private showPermissionsDisallowedDetails = false;
Wolfgang Beyere5d1a9f2021-02-05 09:42:43275
276 connectedCallback(): void {
277 this.protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocolMonitor');
278 }
Wolfgang Beyer92395c92021-02-02 10:43:23279
280 set data(data: FrameDetailsReportViewData) {
281 this.frame = data.frame;
282 this.render();
283 }
284
285 private async render(): Promise<void> {
286 if (!this.frame) {
287 return;
288 }
289
290 // Disabled until https://crbug.com/1079231 is fixed.
291 // clang-format off
Wolfgang Beyer92395c92021-02-02 10:43:23292 LitHtml.render(LitHtml.html`
Wolfgang Beyer1525b1f2021-02-02 14:12:30293 <style>
294 .text-ellipsis {
295 overflow: hidden;
296 text-overflow: ellipsis;
297 white-space: nowrap;
298 }
299
300 button ~ .text-ellipsis {
301 padding-left: 2px;
302 }
303
Wolfgang Beyer19093942021-03-15 15:00:34304 .link,
305 .devtools-link {
Wolfgang Beyer1525b1f2021-02-02 14:12:30306 color: var(--color-link);
307 text-decoration: underline;
308 cursor: pointer;
309 padding: 2px 0; /* adjust focus ring size */
310 }
311
312 button.link {
313 border: none;
314 background: none;
315 font-family: inherit;
316 font-size: inherit;
317 }
318
Wolfgang Beyerabfc8472021-02-04 11:29:50319 .inline-comment {
320 padding-left: 1ex;
321 white-space: pre-line;
322 }
323
324 .inline-comment::before {
325 content: "(";
326 }
327
328 .inline-comment::after {
329 content: ")";
330 }
331
332 .inline-name {
333 color: var(--color-text-secondary);
334 padding-left: 2ex;
335 user-select: none;
336 white-space: pre-line;
337 }
338
339 .inline-name::after {
340 content: ':\u00a0';
341 }
342
Wolfgang Beyer1525b1f2021-02-02 14:12:30343 .inline-items {
344 display: flex;
345 }
Wolfgang Beyer4751c1c2021-03-24 15:32:35346
347 .span-cols {
348 grid-column-start: span 2;
349 margin: 0 0 8px 30px;
350 line-height: 28px;
351 }
352
353 .policies-list {
354 padding-top: 3px;
355 }
Wolfgang Beyer1525b1f2021-02-02 14:12:30356 </style>
Kriti Sapra74915452021-05-13 11:57:36357 <${ReportView.ReportView.Report.litTagName} .data=${{reportTitle: this.frame.displayName()} as ReportView.ReportView.ReportData}>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43358 ${this.renderDocumentSection()}
359 ${this.renderIsolationSection()}
360 ${this.renderApiAvailabilitySection()}
Sigurd Schneider173154c2021-02-18 14:18:38361 ${LitHtml.Directives.until(this.renderPermissionPolicy(), LitHtml.nothing)}
Wolfgang Beyere5d1a9f2021-02-05 09:42:43362 ${this.protocolMonitorExperimentEnabled ? this.renderAdditionalInfoSection() : LitHtml.nothing}
Kriti Sapra74915452021-05-13 11:57:36363 </${ReportView.ReportView.Report.litTagName}>
Wolfgang Beyer92395c92021-02-02 10:43:23364 `, this.shadow);
365 // clang-format on
366 }
Wolfgang Beyer1525b1f2021-02-02 14:12:30367
Sigurd Schneider173154c2021-02-18 14:18:38368 private async renderPermissionPolicy(): Promise<LitHtml.TemplateResult|{}> {
Wolfgang Beyer4751c1c2021-03-24 15:32:35369 const policies = await (this.frame && this.frame.getPermissionsPolicyState());
370 if (!policies) {
Sigurd Schneider173154c2021-02-18 14:18:38371 return LitHtml.nothing;
372 }
Wolfgang Beyer4751c1c2021-03-24 15:32:35373
374 const toggleShowPermissionsDisallowedDetails = (): void => {
375 this.showPermissionsDisallowedDetails = !this.showPermissionsDisallowedDetails;
376 this.render();
377 };
378
379 const renderAllowed = (): LitHtml.TemplateResult|{} => {
380 const allowed = policies.filter(p => p.allowed).map(p => p.feature).sort();
381 if (!allowed.length) {
382 return LitHtml.nothing;
383 }
Wolfgang Beyer4751c1c2021-03-24 15:32:35384 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36385 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.allowedFeatures)}</${
386 ReportView.ReportView.ReportKey.litTagName}>
387 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer4751c1c2021-03-24 15:32:35388 ${allowed.join(', ')}
Kriti Sapra74915452021-05-13 11:57:36389 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer4751c1c2021-03-24 15:32:35390 `;
391 };
392
393 const renderDisallowed = async(): Promise<LitHtml.TemplateResult|{}> => {
394 const disallowed = policies.filter(p => !p.allowed).sort((a, b) => a.feature.localeCompare(b.feature));
395 if (!disallowed.length) {
396 return LitHtml.nothing;
397 }
398 if (!this.showPermissionsDisallowedDetails) {
Wolfgang Beyer4751c1c2021-03-24 15:32:35399 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36400 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.disabledFeatures)}</${
401 ReportView.ReportView.ReportKey.litTagName}>
402 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer4751c1c2021-03-24 15:32:35403 ${disallowed.map(p => p.feature).join(', ')}
404 <button class="link" @click=${(): void => toggleShowPermissionsDisallowedDetails()}>
405 ${i18nString(UIStrings.showDetails)}
406 </button>
Kriti Sapra74915452021-05-13 11:57:36407 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer4751c1c2021-03-24 15:32:35408 `;
409 }
410
411 const frameManager = SDK.FrameManager.FrameManager.instance();
412 const featureRows = await Promise.all(disallowed.map(async policy => {
413 const frame = policy.locator ? frameManager.getFrame(policy.locator.frameId) : null;
414 const blockReason = policy.locator?.blockReason;
415 const linkTargetDOMNode = await (
416 blockReason === Protocol.Page.PermissionsPolicyBlockReason.IframeAttribute && frame &&
417 frame.getOwnerDOMNodeOrDocument());
418 const resource = frame && frame.resourceForURL(frame.url);
419 const linkTargetRequest =
420 blockReason === Protocol.Page.PermissionsPolicyBlockReason.Header && resource && resource.request;
421 const blockReasonText = blockReason === Protocol.Page.PermissionsPolicyBlockReason.IframeAttribute ?
422 i18nString(UIStrings.disabledByIframe) :
423 blockReason === Protocol.Page.PermissionsPolicyBlockReason.Header ? i18nString(UIStrings.disabledByHeader) :
424 '';
Wolfgang Beyer89cc8732021-04-07 13:45:56425 const revealHeader = async(): Promise<void> => {
426 if (!linkTargetRequest) {
427 return;
428 }
429 const headerName =
430 linkTargetRequest.responseHeaderValue('permissions-policy') ? 'permissions-policy' : 'feature-policy';
431 const requestLocation = Network.NetworkSearchScope.UIRequestLocation.responseHeaderMatch(
432 linkTargetRequest,
433 {name: headerName, value: ''},
434 );
435 // TODO(crbug.com/1196676) Refactor to use Common.Revealer
436 await Network.NetworkPanel.RequestLocationRevealer.instance().reveal(requestLocation);
437 };
438
Wolfgang Beyer4751c1c2021-03-24 15:32:35439 return LitHtml.html`
440 <div class="permissions-row">
441 <div>
Kriti Sapra74915452021-05-13 11:57:36442 <${IconButton.Icon.Icon.litTagName} class="allowed-icon"
Tim van der Lippe151b7972021-04-13 10:53:42443 .data=${{color: '', iconName: 'error_icon', width: '14px'} as IconButton.Icon.IconData}>
Kriti Sapra74915452021-05-13 11:57:36444 </${IconButton.Icon.Icon.litTagName}>
Wolfgang Beyer4751c1c2021-03-24 15:32:35445 </div>
446 <div class="feature-name text-ellipsis">
447 ${policy.feature}
448 </div>
449 <div class="block-reason">${blockReasonText}</div>
450 <div>
451 ${
452 linkTargetDOMNode ? this.renderIconLink(
453 'elements_panel_icon',
454 i18nString(UIStrings.clickToShowIframe),
455 (): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode),
456 ) :
457 LitHtml.nothing}
Wolfgang Beyer89cc8732021-04-07 13:45:56458 ${
Wolfgang Beyer4751c1c2021-03-24 15:32:35459 linkTargetRequest ? this.renderIconLink(
460 'network_panel_icon',
461 i18nString(UIStrings.clickToShowHeader),
Wolfgang Beyer89cc8732021-04-07 13:45:56462 revealHeader,
Wolfgang Beyer4751c1c2021-03-24 15:32:35463 ) :
464 LitHtml.nothing}
465 </div>
466 </div>
467 `;
468 }));
469
Wolfgang Beyer4751c1c2021-03-24 15:32:35470 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36471 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.disabledFeatures)}</${
472 ReportView.ReportView.ReportKey.litTagName}>
473 <${ReportView.ReportView.ReportValue.litTagName} class="policies-list">
Wolfgang Beyer4751c1c2021-03-24 15:32:35474 <style>
475 .permissions-row {
476 display: flex;
477 line-height: 22px;
478 }
479
480 .permissions-row div {
481 padding-right: 5px;
482 }
483
484 .feature-name {
485 width: 135px;
486 }
487
488 .allowed-icon {
489 padding: 2.5px 0;
490 }
491
492 .block-reason {
493 width: 215px;
494 }
495 </style>
496 ${featureRows}
497 <div class="permissions-row">
498 <button class="link" @click=${(): void => toggleShowPermissionsDisallowedDetails()}>
499 ${i18nString(UIStrings.hideDetails)}
500 </button>
501 </div>
Kriti Sapra74915452021-05-13 11:57:36502 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer4751c1c2021-03-24 15:32:35503 `;
504 };
505
Wolfgang Beyer4751c1c2021-03-24 15:32:35506 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36507 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18n.i18n.lockedString('Permissions Policy')}</${
508 ReportView.ReportView.ReportSectionHeader.litTagName}>
Wolfgang Beyer4751c1c2021-03-24 15:32:35509 ${renderAllowed()}
510 ${LitHtml.Directives.until(renderDisallowed(), LitHtml.nothing)}
Kriti Sapra74915452021-05-13 11:57:36511 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
512 ReportView.ReportView.ReportSectionDivider.litTagName}>
Sigurd Schneider173154c2021-02-18 14:18:38513 `;
514 }
515
Wolfgang Beyer1525b1f2021-02-02 14:12:30516 private renderDocumentSection(): LitHtml.TemplateResult|{} {
517 if (!this.frame) {
518 return LitHtml.nothing;
519 }
520
Wolfgang Beyer1525b1f2021-02-02 14:12:30521 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36522 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.document)}</${
523 ReportView.ReportView.ReportSectionHeader.litTagName}>
524 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.url)}</${
525 ReportView.ReportView.ReportKey.litTagName}>
526 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30527 <div class="inline-items">
528 ${this.maybeRenderSourcesLinkForURL()}
529 ${this.maybeRenderNetworkLinkForURL()}
530 <div class="text-ellipsis" title=${this.frame.url}>${this.frame.url}</div>
531 </div>
Kriti Sapra74915452021-05-13 11:57:36532 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30533 ${this.maybeRenderUnreachableURL()}
534 ${this.maybeRenderOrigin()}
535 ${LitHtml.Directives.until(this.renderOwnerElement(), LitHtml.nothing)}
Wolfgang Beyer19093942021-03-15 15:00:34536 ${this.maybeRenderCreationStacktrace()}
Wolfgang Beyer1525b1f2021-02-02 14:12:30537 ${this.maybeRenderAdStatus()}
Kriti Sapra74915452021-05-13 11:57:36538 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
539 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30540 `;
541 }
542
543 private maybeRenderSourcesLinkForURL(): LitHtml.TemplateResult|{} {
544 if (!this.frame || this.frame.unreachableUrl()) {
545 return LitHtml.nothing;
546 }
547 const sourceCode = this.uiSourceCodeForFrame(this.frame);
548 return this.renderIconLink(
549 'sources_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01550 i18nString(UIStrings.clickToRevealInSourcesPanel),
Wolfgang Beyer1525b1f2021-02-02 14:12:30551 (): Promise<void> => Common.Revealer.reveal(sourceCode),
552 );
553 }
554
555 private maybeRenderNetworkLinkForURL(): LitHtml.TemplateResult|{} {
556 if (this.frame) {
557 const resource = this.frame.resourceForURL(this.frame.url);
558 if (resource && resource.request) {
559 const request = resource.request;
560 return this.renderIconLink(
561 'network_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01562 i18nString(UIStrings.clickToRevealInNetworkPanel),
Wolfgang Beyer1525b1f2021-02-02 14:12:30563 (): Promise<void> =>
564 Network.NetworkPanel.NetworkPanel.selectAndShowRequest(request, Network.NetworkItemView.Tabs.Headers),
565 );
566 }
567 }
568 return LitHtml.nothing;
569 }
570
571 private renderIconLink(
572 iconName: string, title: Platform.UIString.LocalizedString,
573 clickHandler: (() => void)|(() => Promise<void>)): LitHtml.TemplateResult {
574 // Disabled until https://crbug.com/1079231 is fixed.
575 // clang-format off
Wolfgang Beyer1525b1f2021-02-02 14:12:30576 return LitHtml.html`
577 <button class="link" role="link" tabindex=0 @click=${clickHandler} title=${title}>
Kriti Sapra74915452021-05-13 11:57:36578 <${IconButton.Icon.Icon.litTagName} .data=${{
Wolfgang Beyer1525b1f2021-02-02 14:12:30579 iconName: iconName,
580 color: 'var(--color-primary)',
581 width: '16px',
582 height: '16px',
Tim van der Lippe151b7972021-04-13 10:53:42583 } as IconButton.Icon.IconData}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30584 </button>
585 `;
586 // clang-format on
587 }
588
589 private uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode
590 |null {
591 for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) {
592 const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project);
593 if (projectTarget && projectTarget === frame.resourceTreeModel().target()) {
594 const uiSourceCode = project.uiSourceCodeForURL(frame.url);
595 if (uiSourceCode) {
596 return uiSourceCode;
597 }
598 }
599 }
600 return null;
601 }
602
603 private maybeRenderUnreachableURL(): LitHtml.TemplateResult|{} {
604 if (!this.frame || !this.frame.unreachableUrl()) {
605 return LitHtml.nothing;
606 }
Wolfgang Beyer1525b1f2021-02-02 14:12:30607 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36608 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.unreachableUrl)}</${
609 ReportView.ReportView.ReportKey.litTagName}>
610 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30611 <div class="inline-items">
612 ${this.renderNetworkLinkForUnreachableURL()}
613 <div class="text-ellipsis" title=${this.frame.unreachableUrl()}>${this.frame.unreachableUrl()}</div>
614 </div>
Kriti Sapra74915452021-05-13 11:57:36615 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30616 `;
617 }
618
619 private renderNetworkLinkForUnreachableURL(): LitHtml.TemplateResult|{} {
620 if (this.frame) {
621 const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(this.frame.unreachableUrl());
622 if (unreachableUrl) {
623 return this.renderIconLink(
624 'network_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01625 i18nString(UIStrings.clickToRevealInNetworkPanelMight),
Wolfgang Beyer1525b1f2021-02-02 14:12:30626 ():
627 void => {
628 Network.NetworkPanel.NetworkPanel.revealAndFilter([
629 {
Jan Schefflerd6c1d402021-02-26 16:56:38630 // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration)
631 // @ts-expect-error
Wolfgang Beyer1525b1f2021-02-02 14:12:30632 filterType: 'domain',
633 filterValue: unreachableUrl.domain(),
634 },
635 {
636 filterType: null,
637 filterValue: unreachableUrl.path,
638 },
639 ]);
640 },
641 );
642 }
643 }
644 return LitHtml.nothing;
645 }
646
647 private maybeRenderOrigin(): LitHtml.TemplateResult|{} {
648 if (this.frame && this.frame.securityOrigin && this.frame.securityOrigin !== '://') {
Wolfgang Beyer1525b1f2021-02-02 14:12:30649 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36650 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.origin)}</${
651 ReportView.ReportView.ReportKey.litTagName}>
652 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30653 <div class="text-ellipsis" title=${this.frame.securityOrigin}>${this.frame.securityOrigin}</div>
Kriti Sapra74915452021-05-13 11:57:36654 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30655 `;
656 }
657 return LitHtml.nothing;
658 }
659
660 private async renderOwnerElement(): Promise<LitHtml.TemplateResult|{}> {
661 if (this.frame) {
Wolfgang Beyerf0d985e2021-02-05 12:56:52662 const linkTargetDOMNode = await this.frame.getOwnerDOMNodeOrDocument();
663 if (linkTargetDOMNode) {
664 // Disabled until https://crbug.com/1079231 is fixed.
665 // clang-format off
Wolfgang Beyerf0d985e2021-02-05 12:56:52666 return LitHtml.html`
667 <style>
Wolfgang Beyerddf051e2021-02-09 08:33:01668 .button-icon-with-text {
Wolfgang Beyerf0d985e2021-02-05 12:56:52669 vertical-align: sub;
670 }
Wolfgang Beyer09b0e8e2021-02-09 13:39:48671
672 .without-min-width {
673 min-width: auto;
674 }
Wolfgang Beyerf0d985e2021-02-05 12:56:52675 </style>
Kriti Sapra74915452021-05-13 11:57:36676 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.ownerElement)}</${ReportView.ReportView.ReportKey.litTagName}>
677 <${ReportView.ReportView.ReportValue.litTagName} class="without-min-width">
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01678 <button class="link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToRevealInElementsPanel)}
Wolfgang Beyerf0d985e2021-02-05 12:56:52679 @mouseenter=${(): Promise<void>|undefined => this.frame?.highlight()}
680 @mouseleave=${(): void => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()}
681 @click=${(): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode)}
682 >
Kriti Sapra74915452021-05-13 11:57:36683 <${IconButton.Icon.Icon.litTagName} class="button-icon-with-text" .data=${{
Wolfgang Beyerf0d985e2021-02-05 12:56:52684 iconName: 'elements_panel_icon',
685 color: 'var(--color-primary)',
686 width: '16px',
687 height: '16px',
Kriti Sapra74915452021-05-13 11:57:36688 } as IconButton.Icon.IconData}></${IconButton.Icon.Icon.litTagName}>
Jack Franklin5ba6ec62021-04-30 07:36:20689 &lt;${linkTargetDOMNode.nodeName().toLocaleLowerCase()}&gt;
Wolfgang Beyer09b0e8e2021-02-09 13:39:48690 </button>
Kriti Sapra74915452021-05-13 11:57:36691 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyerf0d985e2021-02-05 12:56:52692 `;
693 // clang-format on
Wolfgang Beyer1525b1f2021-02-02 14:12:30694 }
695 }
696 return LitHtml.nothing;
697 }
698
Wolfgang Beyer19093942021-03-15 15:00:34699 private maybeRenderCreationStacktrace(): LitHtml.TemplateResult|{} {
Wolfgang Beyera20485a2021-04-21 07:22:19700 const creationStackTraceData = this.frame?.getCreationStackTraceData();
701 if (creationStackTraceData && creationStackTraceData.creationStackTrace) {
Wolfgang Beyera036d0c2021-03-19 09:09:33702 // Disabled until https://crbug.com/1079231 is fixed.
703 // clang-format off
Wolfgang Beyer19093942021-03-15 15:00:34704 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36705 <${ReportView.ReportView.ReportKey.litTagName} title=${i18nString(UIStrings.creationStackTraceExplanation)}>${
706 i18nString(UIStrings.creationStackTrace)}</${ReportView.ReportView.ReportKey.litTagName}>
707 <${ReportView.ReportView.ReportValue.litTagName}>
708 <${StackTrace.litTagName} .data=${{
Wolfgang Beyera036d0c2021-03-19 09:09:33709 frame: this.frame,
710 buildStackTraceRows: Components.JSPresentationUtils.buildStackTraceRows,
711 } as StackTraceData}>
Kriti Sapra74915452021-05-13 11:57:36712 </${StackTrace.litTagName}>
713 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer19093942021-03-15 15:00:34714 `;
Wolfgang Beyera036d0c2021-03-19 09:09:33715 // clang-format on
Wolfgang Beyer19093942021-03-15 15:00:34716 }
717 return LitHtml.nothing;
718 }
719
Wolfgang Beyer1525b1f2021-02-02 14:12:30720 private maybeRenderAdStatus(): LitHtml.TemplateResult|{} {
721 if (this.frame) {
722 if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Root) {
Wolfgang Beyer1525b1f2021-02-02 14:12:30723 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36724 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.adStatus)}</${
725 ReportView.ReportView.ReportKey.litTagName}>
726 <${ReportView.ReportView.ReportValue.litTagName} title=${
727 i18nString(UIStrings.thisFrameHasBeenIdentifiedAsThe)}>${i18nString(UIStrings.root)}</${
728 ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30729 `;
730 }
731 if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Child) {
Wolfgang Beyer1525b1f2021-02-02 14:12:30732 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36733 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.adStatus)}</${
734 ReportView.ReportView.ReportKey.litTagName}>
735 <${ReportView.ReportView.ReportValue.litTagName} title=${
736 i18nString(UIStrings.thisFrameHasBeenIdentifiedAsTheA)}>${i18nString(UIStrings.child)}</${
737 ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer1525b1f2021-02-02 14:12:30738 `;
739 }
740 }
741 return LitHtml.nothing;
742 }
Wolfgang Beyerabfc8472021-02-04 11:29:50743
744 private renderIsolationSection(): LitHtml.TemplateResult|{} {
745 if (!this.frame) {
746 return LitHtml.nothing;
747 }
Wolfgang Beyerabfc8472021-02-04 11:29:50748 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36749 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.securityIsolation)}</${
750 ReportView.ReportView.ReportSectionHeader.litTagName}>
751 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.secureContext)}</${
752 ReportView.ReportView.ReportKey.litTagName}>
753 <${ReportView.ReportView.ReportValue.litTagName}>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01754 ${this.frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
Wolfgang Beyerabfc8472021-02-04 11:29:50755 ${this.maybeRenderSecureContextExplanation()}
Kriti Sapra74915452021-05-13 11:57:36756 </${ReportView.ReportView.ReportValue.litTagName}>
757 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.crossoriginIsolated)}</${
758 ReportView.ReportView.ReportKey.litTagName}>
759 <${ReportView.ReportView.ReportValue.litTagName}>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01760 ${this.frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
Kriti Sapra74915452021-05-13 11:57:36761 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyerabfc8472021-02-04 11:29:50762 ${LitHtml.Directives.until(this.maybeRenderCoopCoepStatus(), LitHtml.nothing)}
Kriti Sapra74915452021-05-13 11:57:36763 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
764 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyerabfc8472021-02-04 11:29:50765 `;
766 }
767
768 private maybeRenderSecureContextExplanation(): LitHtml.TemplateResult|{} {
769 const explanation = this.getSecureContextExplanation();
770 if (explanation) {
771 return LitHtml.html`
772 <span class="inline-comment">${explanation}</span>
773 `;
774 }
775 return LitHtml.nothing;
776 }
777
778 private getSecureContextExplanation(): Platform.UIString.LocalizedString|null {
779 switch (this.frame?.getSecureContextType()) {
780 case Protocol.Page.SecureContextType.Secure:
781 return null;
782 case Protocol.Page.SecureContextType.SecureLocalhost:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01783 return i18nString(UIStrings.localhostIsAlwaysASecureContext);
Wolfgang Beyerabfc8472021-02-04 11:29:50784 case Protocol.Page.SecureContextType.InsecureAncestor:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01785 return i18nString(UIStrings.aFrameAncestorIsAnInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50786 case Protocol.Page.SecureContextType.InsecureScheme:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01787 return i18nString(UIStrings.theFramesSchemeIsInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50788 }
789 return null;
790 }
791
792 private async maybeRenderCoopCoepStatus(): Promise<LitHtml.TemplateResult|{}> {
793 if (this.frame) {
794 const model = this.frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager);
795 const info = model && await model.getSecurityIsolationStatus(this.frame.id);
796 if (info) {
797 return LitHtml.html`
798 ${
799 this.maybeRenderCrossOriginStatus(
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01800 info.coep, i18nString(UIStrings.crossoriginEmbedderPolicy),
801 Protocol.Network.CrossOriginEmbedderPolicyValue.None)}
Wolfgang Beyerabfc8472021-02-04 11:29:50802 ${
803 this.maybeRenderCrossOriginStatus(
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01804 info.coop, i18nString(UIStrings.crossoriginOpenerPolicy),
805 Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)}
Wolfgang Beyerabfc8472021-02-04 11:29:50806 `;
807 }
808 }
809 return LitHtml.nothing;
810 }
811
812 private maybeRenderCrossOriginStatus(
813 info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined,
814 policyName: string,
815 noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue|
816 Protocol.Network.CrossOriginOpenerPolicyValue): LitHtml.TemplateResult|{} {
817 if (!info) {
818 return LitHtml.nothing;
819 }
820 const isEnabled = info.value !== noneValue;
821 const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue);
822 const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint;
Wolfgang Beyerabfc8472021-02-04 11:29:50823 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36824 <${ReportView.ReportView.ReportKey.litTagName}>${policyName}</${ReportView.ReportView.ReportKey.litTagName}>
825 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyerabfc8472021-02-04 11:29:50826 ${isEnabled ? info.value : info.reportOnlyValue}
827 ${isReportOnly ? LitHtml.html`<span class="inline-comment">report-only</span>` : LitHtml.nothing}
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01828 ${
829 endpoint ? LitHtml.html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` :
830 LitHtml.nothing}
Kriti Sapra74915452021-05-13 11:57:36831 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyerabfc8472021-02-04 11:29:50832 `;
833 }
Wolfgang Beyer6a6efe62021-02-04 15:56:21834
835 private renderApiAvailabilitySection(): LitHtml.TemplateResult|{} {
836 if (!this.frame) {
837 return LitHtml.nothing;
838 }
839
Wolfgang Beyer6a6efe62021-02-04 15:56:21840 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36841 <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.apiAvailability)}</${
842 ReportView.ReportView.ReportSectionHeader.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21843 <div class="span-cols">
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01844 ${i18nString(UIStrings.availabilityOfCertainApisDepends)}
Wolfgang Beyer4751c1c2021-03-24 15:32:35845 <x-link href="https://web.dev/why-coop-coep/" class="link">${i18nString(UIStrings.learnMore)}</x-link>
Wolfgang Beyer6a6efe62021-02-04 15:56:21846 </div>
847 ${this.renderSharedArrayBufferAvailability()}
848 ${this.renderMeasureMemoryAvailability()}
Kriti Sapra74915452021-05-13 11:57:36849 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
850 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21851 `;
852 }
853
854 private renderSharedArrayBufferAvailability(): LitHtml.TemplateResult|{} {
855 if (this.frame) {
856 const features = this.frame.getGatedAPIFeatures();
857 if (features) {
858 const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers);
859 const sabTransferAvailable =
860 sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed);
861 const availabilityText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01862 i18nString(UIStrings.availableTransferable) :
863 (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable));
Wolfgang Beyer6a6efe62021-02-04 15:56:21864 const tooltipText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01865 i18nString(UIStrings.sharedarraybufferConstructorIs) :
866 (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : '');
Wolfgang Beyer6a6efe62021-02-04 15:56:21867
Sigurd Schneider2a450252021-05-04 07:13:15868 function renderHint(frame: SDK.ResourceTreeModel.ResourceTreeFrame): LitHtml.TemplateResult|{} {
869 switch (frame.getCrossOriginIsolatedContextType()) {
870 case Protocol.Page.CrossOriginIsolatedContextType.Isolated:
871 return LitHtml.nothing;
872 case Protocol.Page.CrossOriginIsolatedContextType.NotIsolated:
873 if (sabAvailable) {
874 return LitHtml.html`<span class="inline-comment">${
875 i18nString(UIStrings.willRequireCrossoriginIsolated)}</span>`;
876 }
877 return LitHtml.html`<span class="inline-comment">${
878 i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`;
879 case Protocol.Page.CrossOriginIsolatedContextType.NotIsolatedFeatureDisabled:
880 if (!sabTransferAvailable) {
881 return LitHtml.html`<span class="inline-comment">${
882 i18nString(
883 UIStrings
884 .transferRequiresCrossoriginIsolatedPermission)} <code>cross-origin-isolated</code></span>`;
885 }
886 break;
887 }
888 return LitHtml.nothing;
889 }
890
Peter Marshall0e1cd822021-02-24 10:52:42891 // SharedArrayBuffer is an API name, so we don't translate it.
Wolfgang Beyer6a6efe62021-02-04 15:56:21892 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36893 <${ReportView.ReportView.ReportKey.litTagName}>SharedArrayBuffers</${
894 ReportView.ReportView.ReportKey.litTagName}>
895 <${ReportView.ReportView.ReportValue.litTagName} title=${tooltipText}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21896 ${availabilityText}
Sigurd Schneider2a450252021-05-04 07:13:15897 ${renderHint(this.frame)}
Kriti Sapra74915452021-05-13 11:57:36898 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21899 `;
Wolfgang Beyer6a6efe62021-02-04 15:56:21900 }
901 }
902 return LitHtml.nothing;
903 }
904
905 private renderMeasureMemoryAvailability(): LitHtml.TemplateResult|{} {
906 if (this.frame) {
907 const measureMemoryAvailable = this.frame.isCrossOriginIsolated();
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01908 const availabilityText =
909 measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable);
910 const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) :
911 i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory);
Wolfgang Beyer6a6efe62021-02-04 15:56:21912 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36913 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.measureMemory)}</${
914 ReportView.ReportView.ReportKey.litTagName}>
915 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21916 <span title=${tooltipText}>${availabilityText}</span>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01917 <x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/">${
Wolfgang Beyer09b0e8e2021-02-09 13:39:48918 i18nString(UIStrings.learnMore)}</x-link>
Kriti Sapra74915452021-05-13 11:57:36919 </${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyer6a6efe62021-02-04 15:56:21920 `;
921 }
922 return LitHtml.nothing;
923 }
Wolfgang Beyere5d1a9f2021-02-05 09:42:43924
925 private renderAdditionalInfoSection(): LitHtml.TemplateResult|{} {
926 if (!this.frame) {
927 return LitHtml.nothing;
928 }
929
Wolfgang Beyere5d1a9f2021-02-05 09:42:43930 return LitHtml.html`
Kriti Sapra74915452021-05-13 11:57:36931 <${ReportView.ReportView.ReportSectionHeader.litTagName}
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01932 title=${i18nString(UIStrings.thisAdditionalDebugging)}
Kriti Sapra74915452021-05-13 11:57:36933 >${i18nString(UIStrings.additionalInformation)}</${ReportView.ReportView.ReportSectionHeader.litTagName}>
934 <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.frameId)}</${
935 ReportView.ReportView.ReportKey.litTagName}>
936 <${ReportView.ReportView.ReportValue.litTagName}>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43937 <div class="text-ellipsis" title=${this.frame.id}>${this.frame.id}</div>
Kriti Sapra74915452021-05-13 11:57:36938 </${ReportView.ReportView.ReportValue.litTagName}>
939 <${ReportView.ReportView.ReportSectionDivider.litTagName}></${
940 ReportView.ReportView.ReportSectionDivider.litTagName}>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43941 `;
942 }
Wolfgang Beyer92395c92021-02-02 10:43:23943}
944
Kriti Sapra34df98d2021-05-06 10:15:42945ComponentHelpers.CustomElements.defineComponent('devtools-resources-frame-details-view', FrameDetailsReportView);
Wolfgang Beyer92395c92021-02-02 10:43:23946
947declare global {
948 // eslint-disable-next-line @typescript-eslint/no-unused-vars
949 interface HTMLElementTagNameMap {
950 'devtools-resources-frame-details-view': FrameDetailsReportView;
951 }
952}