blob: c1da7f4975f079ccf995d9cc419228b3e3e44d40 [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
Wolfgang Beyer92395c92021-02-02 10:43:235import type * as Components from '../ui/components/components.js';
6
Wolfgang Beyer2ed11a42020-09-30 07:24:547import * as Bindings from '../bindings/bindings.js';
Sigurd Schneider1e5ad282020-07-17 11:52:088import * as Common from '../common/common.js';
Wolfgang Beyer92395c92021-02-02 10:43:239import * as LitHtml from '../third_party/lit-html/lit-html.js';
Sigurd Schneiderfc2bd212020-08-12 12:58:4110import * as Network from '../network/network.js';
Wolfgang Beyer1525b1f2021-02-02 14:12:3011import * as Platform from '../platform/platform.js';
Wolfgang Beyer95951c4d2020-10-23 08:00:0612import * as Root from '../root/root.js';
Tim van der Lippe5f62c6f2021-02-25 16:39:2613import * as SDK from '../sdk/sdk.js';
Wolfgang Beyer760462e2020-07-13 15:01:3514import * as UI from '../ui/ui.js';
Sigurd Schneider1e5ad282020-07-17 11:52:0815import * as Workspace from '../workspace/workspace.js';
Wolfgang Beyer760462e2020-07-13 15:01:3516
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0117import * as i18n from '../i18n/i18n.js';
Sigurd Schneider173154c2021-02-18 14:18:3818
Simon Zünd697fb0b2021-03-01 10:12:4219const UIStrings = {
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0120 /**
21 *@description Section header in the Frame Details view
22 */
23 additionalInformation: 'Additional Information',
24 /**
25 *@description Explanation for why the additional information section is being shown
26 */
27 thisAdditionalDebugging:
28 'This additional (debugging) information is shown because the \'Protocol Monitor\' experiment is enabled.',
29 /**
30 *@description Label for subtitle of frame details view
31 */
32 frameId: 'Frame ID',
33 /**
34 *@description Name of a network resource type
35 */
36 document: 'Document',
37 /**
38 *@description Text for web URLs
39 */
40 url: 'URL',
41 /**
42 *@description Title for a link to the Sources panel
43 */
44 clickToRevealInSourcesPanel: 'Click to reveal in Sources panel',
45 /**
46 *@description Title for a link to the Network panel
47 */
48 clickToRevealInNetworkPanel: 'Click to reveal in Network panel',
49 /**
50 *@description Title for unreachable URL field
51 */
52 unreachableUrl: 'Unreachable URL',
53 /**
54 *@description Title for a link that applies a filter to the network panel
55 */
56 clickToRevealInNetworkPanelMight: 'Click to reveal in Network panel (might require page reload)',
57 /**
58 *@description Text for the origin of something
59 */
60 origin: 'Origin',
61 /**
62 *@description Related node label in Timeline UIUtils of the Performance panel
63 */
64 ownerElement: 'Owner Element',
65 /**
66 *@description Title for a link to the Elements panel
67 */
68 clickToRevealInElementsPanel: 'Click to reveal in Elements panel',
69 /**
70 *@description Title for ad frame type field
71 */
72 adStatus: 'Ad Status',
73 /**
74 *@description Description for ad frame type
75 */
76 thisFrameHasBeenIdentifiedAsThe: 'This frame has been identified as the root frame of an ad',
77 /**
78 *@description Value for ad frame type
79 */
80 root: 'root',
81 /**
82 *@description Description for ad frame type
83 */
Peter Marshall3d967382021-02-25 06:56:1884 thisFrameHasBeenIdentifiedAsTheA: 'This frame has been identified as a child frame of an ad',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:0185 /**
86 *@description Value for ad frame type
87 */
88 child: 'child',
89 /**
90 *@description Section header in the Frame Details view
91 */
92 securityIsolation: 'Security & Isolation',
93 /**
94 *@description Row title for in the Frame Details view
95 */
96 secureContext: 'Secure Context',
97 /**
98 *@description Text in Timeline indicating that input has happened recently
99 */
100 yes: 'Yes',
101 /**
102 *@description Text in Timeline indicating that input has not happened recently
103 */
104 no: 'No',
105 /**
106 *@description Row title for in the Frame Details view
107 */
108 crossoriginIsolated: 'Cross-Origin Isolated',
109 /**
110 *@description Explanatory text in the Frame Details view
111 */
112 localhostIsAlwaysASecureContext: 'Localhost is always a secure context',
113 /**
114 *@description Explanatory text in the Frame Details view
115 */
116 aFrameAncestorIsAnInsecure: 'A frame ancestor is an insecure context',
117 /**
118 *@description Explanatory text in the Frame Details view
119 */
120 theFramesSchemeIsInsecure: 'The frame\'s scheme is insecure',
121 /**
122 *@description Row title in the Frame Details view
123 */
124 crossoriginEmbedderPolicy: 'Cross-Origin Embedder Policy',
125 /**
126 *@description Row title in the Frame Details view
127 */
128 crossoriginOpenerPolicy: 'Cross-Origin Opener Policy',
129 /**
Peter Marshallec861882021-02-16 11:14:21130 *@description This label specifies the server endpoints to which the server is reporting errors
131 *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:01132 */
133 reportingTo: 'reporting to',
134 /**
135 *@description Section header in the Frame Details view
136 */
137 apiAvailability: 'API availability',
138 /**
139 *@description Explanatory text in the Frame Details view for the API availability section
140 */
141 availabilityOfCertainApisDepends: 'Availability of certain APIs depends on the document being cross-origin isolated.',
142 /**
143 *@description Description of the SharedArrayBuffer status
144 */
145 availableTransferable: 'available, transferable',
146 /**
147 *@description Description of the SharedArrayBuffer status
148 */
149 availableNotTransferable: 'available, not transferable',
150 /**
151 *@description Explanation for the SharedArrayBuffer availability status
152 */
153 unavailable: 'unavailable',
154 /**
155 *@description Tooltip for the SharedArrayBuffer availability status
156 */
157 sharedarraybufferConstructorIs:
158 'SharedArrayBuffer constructor is available and SABs can be transferred via postMessage',
159 /**
160 *@description Tooltip for the SharedArrayBuffer availability status
161 */
162 sharedarraybufferConstructorIsAvailable:
163 'SharedArrayBuffer constructor is available but SABs cannot be transferred via postMessage',
164 /**
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01165 *@description Explanation for the SharedArrayBuffer availability status
166 */
167 WillRequireCrossoriginIsolated: '⚠️ will require cross-origin isolated context in the future',
168 /**
169 *@description Explanation for the SharedArrayBuffer availability status
170 */
171 requiresCrossoriginIsolated: 'requires cross-origin isolated context',
172 /**
173 *@description Explanation for the Measure Memory availability status
174 */
175 available: 'available',
176 /**
177 *@description Tooltip for the Measure Memory availability status
178 */
179 thePerformanceAPI: 'The performance.measureUserAgentSpecificMemory() API is available',
180 /**
181 *@description Tooltip for the Measure Memory availability status
182 */
183 thePerformancemeasureuseragentspecificmemory: 'The performance.measureUserAgentSpecificMemory() API is not available',
184 /**
185 *@description Entry in the API availability section of the frame details view
186 */
187 measureMemory: 'Measure Memory',
188 /**
189 *@description Text that is usually a hyperlink to more documentation
190 */
191 learnMore: 'Learn more',
192};
193const str_ = i18n.i18n.registerUIStrings('resources/FrameDetailsView.ts', UIStrings);
194const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
Sigurd Schneider1e5ad282020-07-17 11:52:08195export class FrameDetailsView extends UI.ThrottledWidget.ThrottledWidget {
Wolfgang Beyer92395c92021-02-02 10:43:23196 private readonly reportView = new FrameDetailsReportView();
Wolfgang Beyere5d1a9f2021-02-05 09:42:43197 private readonly frame: SDK.ResourceTreeModel.ResourceTreeFrame;
Wolfgang Beyer92395c92021-02-02 10:43:23198
Wolfgang Beyer309863f2021-01-21 09:01:21199 constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) {
Wolfgang Beyer760462e2020-07-13 15:01:35200 super();
Wolfgang Beyere5d1a9f2021-02-05 09:42:43201 this.frame = frame;
202 this.contentElement.classList.add('overflow-auto');
Wolfgang Beyer92395c92021-02-02 10:43:23203 this.contentElement.appendChild(this.reportView);
Sigurd Schneider1e5ad282020-07-17 11:52:08204 this.update();
205 }
206
Wolfgang Beyer309863f2021-01-21 09:01:21207 async doUpdate(): Promise<void> {
Wolfgang Beyere5d1a9f2021-02-05 09:42:43208 this.reportView.data = {frame: this.frame};
Sigurd Schneidereabef962020-11-05 10:51:49209 }
Wolfgang Beyer760462e2020-07-13 15:01:35210}
Wolfgang Beyer3b4747f2020-08-12 07:30:46211
Wolfgang Beyer92395c92021-02-02 10:43:23212export interface FrameDetailsReportViewData {
213 frame: SDK.ResourceTreeModel.ResourceTreeFrame;
214}
215
216export class FrameDetailsReportView extends HTMLElement {
217 private readonly shadow = this.attachShadow({mode: 'open'});
218 private frame?: SDK.ResourceTreeModel.ResourceTreeFrame;
Wolfgang Beyere5d1a9f2021-02-05 09:42:43219 private protocolMonitorExperimentEnabled = false;
220
221 connectedCallback(): void {
222 this.protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocolMonitor');
223 }
Wolfgang Beyer92395c92021-02-02 10:43:23224
225 set data(data: FrameDetailsReportViewData) {
226 this.frame = data.frame;
227 this.render();
228 }
229
230 private async render(): Promise<void> {
231 if (!this.frame) {
232 return;
233 }
234
235 // Disabled until https://crbug.com/1079231 is fixed.
236 // clang-format off
237 LitHtml.render(LitHtml.html`
Wolfgang Beyer1525b1f2021-02-02 14:12:30238 <style>
239 .text-ellipsis {
240 overflow: hidden;
241 text-overflow: ellipsis;
242 white-space: nowrap;
243 }
244
245 button ~ .text-ellipsis {
246 padding-left: 2px;
247 }
248
249 .link {
250 color: var(--color-link);
251 text-decoration: underline;
252 cursor: pointer;
253 padding: 2px 0; /* adjust focus ring size */
254 }
255
256 button.link {
257 border: none;
258 background: none;
259 font-family: inherit;
260 font-size: inherit;
261 }
262
Wolfgang Beyerabfc8472021-02-04 11:29:50263 .inline-comment {
264 padding-left: 1ex;
265 white-space: pre-line;
266 }
267
268 .inline-comment::before {
269 content: "(";
270 }
271
272 .inline-comment::after {
273 content: ")";
274 }
275
276 .inline-name {
277 color: var(--color-text-secondary);
278 padding-left: 2ex;
279 user-select: none;
280 white-space: pre-line;
281 }
282
283 .inline-name::after {
284 content: ':\u00a0';
285 }
286
Wolfgang Beyer1525b1f2021-02-02 14:12:30287 .inline-items {
288 display: flex;
289 }
290 </style>
Wolfgang Beyer92395c92021-02-02 10:43:23291 <devtools-report .data=${{reportTitle: this.frame.displayName()} as Components.ReportView.ReportData}>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43292 ${this.renderDocumentSection()}
293 ${this.renderIsolationSection()}
294 ${this.renderApiAvailabilitySection()}
Sigurd Schneider173154c2021-02-18 14:18:38295 ${LitHtml.Directives.until(this.renderPermissionPolicy(), LitHtml.nothing)}
Wolfgang Beyere5d1a9f2021-02-05 09:42:43296 ${this.protocolMonitorExperimentEnabled ? this.renderAdditionalInfoSection() : LitHtml.nothing}
Wolfgang Beyer92395c92021-02-02 10:43:23297 </devtools-report>
298 `, this.shadow);
299 // clang-format on
300 }
Wolfgang Beyer1525b1f2021-02-02 14:12:30301
Sigurd Schneider173154c2021-02-18 14:18:38302 private async renderPermissionPolicy(): Promise<LitHtml.TemplateResult|{}> {
303 const stats = await (this.frame && this.frame.getPermissionsPolicyState());
304 if (!stats) {
305 return LitHtml.nothing;
306 }
307 const allowed = stats.filter(s => s.allowed).map(s => s.feature).sort();
308 const disallowed = stats.filter(s => !s.allowed).map(s => s.feature).sort();
309 return LitHtml.html`<devtools-report-section-header>Permissions Policy</devtools-report-section-header>
310 ${
311 allowed.length ? LitHtml.html`<devtools-report-key>Allowed Features</devtools-report-key>
312 <devtools-report-value>${allowed.join(', ')}</devtools-report-value>` :
313 LitHtml.nothing}
314 ${
315 disallowed.length ? LitHtml.html`<devtools-report-key>Disallowed Features</devtools-report-key>
316 <devtools-report-value>${disallowed.join(', ')}</devtools-report-value>` :
317 LitHtml.nothing}
318 `;
319 }
320
Wolfgang Beyer1525b1f2021-02-02 14:12:30321 private renderDocumentSection(): LitHtml.TemplateResult|{} {
322 if (!this.frame) {
323 return LitHtml.nothing;
324 }
325
326 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01327 <devtools-report-section-header>${i18nString(UIStrings.document)}</devtools-report-section-header>
328 <devtools-report-key>${i18nString(UIStrings.url)}</devtools-report-key>
Wolfgang Beyer1525b1f2021-02-02 14:12:30329 <devtools-report-value>
330 <div class="inline-items">
331 ${this.maybeRenderSourcesLinkForURL()}
332 ${this.maybeRenderNetworkLinkForURL()}
333 <div class="text-ellipsis" title=${this.frame.url}>${this.frame.url}</div>
334 </div>
335 </devtools-report-value>
336 ${this.maybeRenderUnreachableURL()}
337 ${this.maybeRenderOrigin()}
338 ${LitHtml.Directives.until(this.renderOwnerElement(), LitHtml.nothing)}
339 ${this.maybeRenderAdStatus()}
340 <devtools-report-divider></devtools-report-divider>
341 `;
342 }
343
344 private maybeRenderSourcesLinkForURL(): LitHtml.TemplateResult|{} {
345 if (!this.frame || this.frame.unreachableUrl()) {
346 return LitHtml.nothing;
347 }
348 const sourceCode = this.uiSourceCodeForFrame(this.frame);
349 return this.renderIconLink(
350 'sources_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01351 i18nString(UIStrings.clickToRevealInSourcesPanel),
Wolfgang Beyer1525b1f2021-02-02 14:12:30352 (): Promise<void> => Common.Revealer.reveal(sourceCode),
353 );
354 }
355
356 private maybeRenderNetworkLinkForURL(): LitHtml.TemplateResult|{} {
357 if (this.frame) {
358 const resource = this.frame.resourceForURL(this.frame.url);
359 if (resource && resource.request) {
360 const request = resource.request;
361 return this.renderIconLink(
362 'network_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01363 i18nString(UIStrings.clickToRevealInNetworkPanel),
Wolfgang Beyer1525b1f2021-02-02 14:12:30364 (): Promise<void> =>
365 Network.NetworkPanel.NetworkPanel.selectAndShowRequest(request, Network.NetworkItemView.Tabs.Headers),
366 );
367 }
368 }
369 return LitHtml.nothing;
370 }
371
372 private renderIconLink(
373 iconName: string, title: Platform.UIString.LocalizedString,
374 clickHandler: (() => void)|(() => Promise<void>)): LitHtml.TemplateResult {
375 // Disabled until https://crbug.com/1079231 is fixed.
376 // clang-format off
377 return LitHtml.html`
378 <button class="link" role="link" tabindex=0 @click=${clickHandler} title=${title}>
379 <devtools-icon .data=${{
380 iconName: iconName,
381 color: 'var(--color-primary)',
382 width: '16px',
383 height: '16px',
384 } as Components.Icon.IconData}>
385 </button>
386 `;
387 // clang-format on
388 }
389
390 private uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode
391 |null {
392 for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) {
393 const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project);
394 if (projectTarget && projectTarget === frame.resourceTreeModel().target()) {
395 const uiSourceCode = project.uiSourceCodeForURL(frame.url);
396 if (uiSourceCode) {
397 return uiSourceCode;
398 }
399 }
400 }
401 return null;
402 }
403
404 private maybeRenderUnreachableURL(): LitHtml.TemplateResult|{} {
405 if (!this.frame || !this.frame.unreachableUrl()) {
406 return LitHtml.nothing;
407 }
408 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01409 <devtools-report-key>${i18nString(UIStrings.unreachableUrl)}</devtools-report-key>
Wolfgang Beyer1525b1f2021-02-02 14:12:30410 <devtools-report-value>
411 <div class="inline-items">
412 ${this.renderNetworkLinkForUnreachableURL()}
413 <div class="text-ellipsis" title=${this.frame.unreachableUrl()}>${this.frame.unreachableUrl()}</div>
414 </div>
415 </devtools-report-value>
416 `;
417 }
418
419 private renderNetworkLinkForUnreachableURL(): LitHtml.TemplateResult|{} {
420 if (this.frame) {
421 const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(this.frame.unreachableUrl());
422 if (unreachableUrl) {
423 return this.renderIconLink(
424 'network_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01425 i18nString(UIStrings.clickToRevealInNetworkPanelMight),
Wolfgang Beyer1525b1f2021-02-02 14:12:30426 ():
427 void => {
428 Network.NetworkPanel.NetworkPanel.revealAndFilter([
429 {
Jan Schefflerd6c1d402021-02-26 16:56:38430 // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration)
431 // @ts-expect-error
Wolfgang Beyer1525b1f2021-02-02 14:12:30432 filterType: 'domain',
433 filterValue: unreachableUrl.domain(),
434 },
435 {
436 filterType: null,
437 filterValue: unreachableUrl.path,
438 },
439 ]);
440 },
441 );
442 }
443 }
444 return LitHtml.nothing;
445 }
446
447 private maybeRenderOrigin(): LitHtml.TemplateResult|{} {
448 if (this.frame && this.frame.securityOrigin && this.frame.securityOrigin !== '://') {
449 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01450 <devtools-report-key>${i18nString(UIStrings.origin)}</devtools-report-key>
Wolfgang Beyer1525b1f2021-02-02 14:12:30451 <devtools-report-value>
452 <div class="text-ellipsis" title=${this.frame.securityOrigin}>${this.frame.securityOrigin}</div>
453 </devtools-report-value>
454 `;
455 }
456 return LitHtml.nothing;
457 }
458
459 private async renderOwnerElement(): Promise<LitHtml.TemplateResult|{}> {
460 if (this.frame) {
Wolfgang Beyerf0d985e2021-02-05 12:56:52461 const linkTargetDOMNode = await this.frame.getOwnerDOMNodeOrDocument();
462 if (linkTargetDOMNode) {
463 // Disabled until https://crbug.com/1079231 is fixed.
464 // clang-format off
465 return LitHtml.html`
466 <style>
Wolfgang Beyerddf051e2021-02-09 08:33:01467 .button-icon-with-text {
Wolfgang Beyerf0d985e2021-02-05 12:56:52468 vertical-align: sub;
469 }
Wolfgang Beyer09b0e8e2021-02-09 13:39:48470
471 .without-min-width {
472 min-width: auto;
473 }
Wolfgang Beyerf0d985e2021-02-05 12:56:52474 </style>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01475 <devtools-report-key>${i18nString(UIStrings.ownerElement)}</devtools-report-key>
Wolfgang Beyer09b0e8e2021-02-09 13:39:48476 <devtools-report-value class="without-min-width">
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01477 <button class="link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToRevealInElementsPanel)}
Wolfgang Beyerf0d985e2021-02-05 12:56:52478 @mouseenter=${(): Promise<void>|undefined => this.frame?.highlight()}
479 @mouseleave=${(): void => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()}
480 @click=${(): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode)}
481 >
482 <devtools-icon class="button-icon-with-text" .data=${{
483 iconName: 'elements_panel_icon',
484 color: 'var(--color-primary)',
485 width: '16px',
486 height: '16px',
487 } as Components.Icon.IconData}></devtools-icon>
488 <${linkTargetDOMNode.nodeName().toLocaleLowerCase()}>
Wolfgang Beyer09b0e8e2021-02-09 13:39:48489 </button>
Wolfgang Beyerf0d985e2021-02-05 12:56:52490 </devtools-report-value>
491 `;
492 // clang-format on
Wolfgang Beyer1525b1f2021-02-02 14:12:30493 }
494 }
495 return LitHtml.nothing;
496 }
497
498 private maybeRenderAdStatus(): LitHtml.TemplateResult|{} {
499 if (this.frame) {
500 if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Root) {
501 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01502 <devtools-report-key>${i18nString(UIStrings.adStatus)}</devtools-report-key>
503 <devtools-report-value title=${i18nString(UIStrings.thisFrameHasBeenIdentifiedAsThe)}>${
504 i18nString(UIStrings.root)}</devtools-report-value>
Wolfgang Beyer1525b1f2021-02-02 14:12:30505 `;
506 }
507 if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Child) {
508 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01509 <devtools-report-key>${i18nString(UIStrings.adStatus)}</devtools-report-key>
510 <devtools-report-value title=${i18nString(UIStrings.thisFrameHasBeenIdentifiedAsTheA)}>${
511 i18nString(UIStrings.child)}</devtools-report-value>
Wolfgang Beyer1525b1f2021-02-02 14:12:30512 `;
513 }
514 }
515 return LitHtml.nothing;
516 }
Wolfgang Beyerabfc8472021-02-04 11:29:50517
518 private renderIsolationSection(): LitHtml.TemplateResult|{} {
519 if (!this.frame) {
520 return LitHtml.nothing;
521 }
522 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01523 <devtools-report-section-header>${i18nString(UIStrings.securityIsolation)}</devtools-report-section-header>
524 <devtools-report-key>${i18nString(UIStrings.secureContext)}</devtools-report-key>
Wolfgang Beyerabfc8472021-02-04 11:29:50525 <devtools-report-value>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01526 ${this.frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
Wolfgang Beyerabfc8472021-02-04 11:29:50527 ${this.maybeRenderSecureContextExplanation()}
528 </devtools-report-value>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01529 <devtools-report-key>${i18nString(UIStrings.crossoriginIsolated)}</devtools-report-key>
Wolfgang Beyerabfc8472021-02-04 11:29:50530 <devtools-report-value>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01531 ${this.frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
Wolfgang Beyerabfc8472021-02-04 11:29:50532 </devtools-report-value>
533 ${LitHtml.Directives.until(this.maybeRenderCoopCoepStatus(), LitHtml.nothing)}
534 <devtools-report-divider></devtools-report-divider>
535 `;
536 }
537
538 private maybeRenderSecureContextExplanation(): LitHtml.TemplateResult|{} {
539 const explanation = this.getSecureContextExplanation();
540 if (explanation) {
541 return LitHtml.html`
542 <span class="inline-comment">${explanation}</span>
543 `;
544 }
545 return LitHtml.nothing;
546 }
547
548 private getSecureContextExplanation(): Platform.UIString.LocalizedString|null {
549 switch (this.frame?.getSecureContextType()) {
550 case Protocol.Page.SecureContextType.Secure:
551 return null;
552 case Protocol.Page.SecureContextType.SecureLocalhost:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01553 return i18nString(UIStrings.localhostIsAlwaysASecureContext);
Wolfgang Beyerabfc8472021-02-04 11:29:50554 case Protocol.Page.SecureContextType.InsecureAncestor:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01555 return i18nString(UIStrings.aFrameAncestorIsAnInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50556 case Protocol.Page.SecureContextType.InsecureScheme:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01557 return i18nString(UIStrings.theFramesSchemeIsInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50558 }
559 return null;
560 }
561
562 private async maybeRenderCoopCoepStatus(): Promise<LitHtml.TemplateResult|{}> {
563 if (this.frame) {
564 const model = this.frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager);
565 const info = model && await model.getSecurityIsolationStatus(this.frame.id);
566 if (info) {
567 return LitHtml.html`
568 ${
569 this.maybeRenderCrossOriginStatus(
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01570 info.coep, i18nString(UIStrings.crossoriginEmbedderPolicy),
571 Protocol.Network.CrossOriginEmbedderPolicyValue.None)}
Wolfgang Beyerabfc8472021-02-04 11:29:50572 ${
573 this.maybeRenderCrossOriginStatus(
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01574 info.coop, i18nString(UIStrings.crossoriginOpenerPolicy),
575 Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)}
Wolfgang Beyerabfc8472021-02-04 11:29:50576 `;
577 }
578 }
579 return LitHtml.nothing;
580 }
581
582 private maybeRenderCrossOriginStatus(
583 info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined,
584 policyName: string,
585 noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue|
586 Protocol.Network.CrossOriginOpenerPolicyValue): LitHtml.TemplateResult|{} {
587 if (!info) {
588 return LitHtml.nothing;
589 }
590 const isEnabled = info.value !== noneValue;
591 const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue);
592 const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint;
593 return LitHtml.html`
594 <devtools-report-key>${policyName}</devtools-report-key>
595 <devtools-report-value>
596 ${isEnabled ? info.value : info.reportOnlyValue}
597 ${isReportOnly ? LitHtml.html`<span class="inline-comment">report-only</span>` : LitHtml.nothing}
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01598 ${
599 endpoint ? LitHtml.html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` :
600 LitHtml.nothing}
Wolfgang Beyerabfc8472021-02-04 11:29:50601 </devtools-report-value>
602 `;
603 }
Wolfgang Beyer6a6efe62021-02-04 15:56:21604
605 private renderApiAvailabilitySection(): LitHtml.TemplateResult|{} {
606 if (!this.frame) {
607 return LitHtml.nothing;
608 }
609
610 return LitHtml.html`
611 <style>
612 .span-cols {
613 grid-column-start: span 2;
614 margin: 0 0 8px 30px;
Jack Franklin49a94812021-02-05 14:20:12615 line-height: 28px;
Wolfgang Beyer6a6efe62021-02-04 15:56:21616 }
617 </style>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01618 <devtools-report-section-header>${i18nString(UIStrings.apiAvailability)}</devtools-report-section-header>
Wolfgang Beyer6a6efe62021-02-04 15:56:21619 <div class="span-cols">
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01620 ${i18nString(UIStrings.availabilityOfCertainApisDepends)}
Wolfgang Beyer6a6efe62021-02-04 15:56:21621 <x-link href="https://web.dev/why-coop-coep/" class="link">Learn more</x-link>
622 </div>
623 ${this.renderSharedArrayBufferAvailability()}
624 ${this.renderMeasureMemoryAvailability()}
625 <devtools-report-divider></devtools-report-divider>
626 `;
627 }
628
629 private renderSharedArrayBufferAvailability(): LitHtml.TemplateResult|{} {
630 if (this.frame) {
631 const features = this.frame.getGatedAPIFeatures();
632 if (features) {
633 const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers);
634 const sabTransferAvailable =
635 sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed);
636 const availabilityText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01637 i18nString(UIStrings.availableTransferable) :
638 (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable));
Wolfgang Beyer6a6efe62021-02-04 15:56:21639 const tooltipText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01640 i18nString(UIStrings.sharedarraybufferConstructorIs) :
641 (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : '');
Wolfgang Beyer6a6efe62021-02-04 15:56:21642
Peter Marshall0e1cd822021-02-24 10:52:42643 // SharedArrayBuffer is an API name, so we don't translate it.
Wolfgang Beyer6a6efe62021-02-04 15:56:21644 // Disabled until https://crbug.com/1079231 is fixed.
645 // clang-format off
646 return LitHtml.html`
Peter Marshall0e1cd822021-02-24 10:52:42647 <devtools-report-key>SharedArrayBuffers</devtools-report-key>
Wolfgang Beyer6a6efe62021-02-04 15:56:21648 <devtools-report-value title=${tooltipText}>
649 ${availabilityText}
650 ${!this.frame.isCrossOriginIsolated() ?
651 (sabAvailable ?
652 LitHtml.html`<span class="inline-comment">${
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01653 i18nString(UIStrings.WillRequireCrossoriginIsolated)}</span>` :
654 LitHtml.html`<span class="inline-comment">${i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`) :
Wolfgang Beyer6a6efe62021-02-04 15:56:21655 LitHtml.nothing}
656 </devtools-report-value>
657 `;
658 // clang-format on
659 }
660 }
661 return LitHtml.nothing;
662 }
663
664 private renderMeasureMemoryAvailability(): LitHtml.TemplateResult|{} {
665 if (this.frame) {
666 const measureMemoryAvailable = this.frame.isCrossOriginIsolated();
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01667 const availabilityText =
668 measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable);
669 const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) :
670 i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory);
Wolfgang Beyer6a6efe62021-02-04 15:56:21671 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01672 <devtools-report-key>${i18nString(UIStrings.measureMemory)}</devtools-report-key>
Wolfgang Beyer6a6efe62021-02-04 15:56:21673 <devtools-report-value>
674 <span title=${tooltipText}>${availabilityText}</span>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01675 <x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/">${
Wolfgang Beyer09b0e8e2021-02-09 13:39:48676 i18nString(UIStrings.learnMore)}</x-link>
Wolfgang Beyer6a6efe62021-02-04 15:56:21677 </devtools-report-value>
678 `;
679 }
680 return LitHtml.nothing;
681 }
Wolfgang Beyere5d1a9f2021-02-05 09:42:43682
683 private renderAdditionalInfoSection(): LitHtml.TemplateResult|{} {
684 if (!this.frame) {
685 return LitHtml.nothing;
686 }
687
688 return LitHtml.html`
689 <devtools-report-section-header
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01690 title=${i18nString(UIStrings.thisAdditionalDebugging)}
691 >${i18nString(UIStrings.additionalInformation)}</devtools-report-section-header>
692 <devtools-report-key>${i18nString(UIStrings.frameId)}</devtools-report-key>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43693 <devtools-report-value>
694 <div class="text-ellipsis" title=${this.frame.id}>${this.frame.id}</div>
695 </devtools-report-value>
696 <devtools-report-divider></devtools-report-divider>
697 `;
698 }
Wolfgang Beyer92395c92021-02-02 10:43:23699}
700
701customElements.define('devtools-resources-frame-details-view', FrameDetailsReportView);
702
703declare global {
704 // eslint-disable-next-line @typescript-eslint/no-unused-vars
705 interface HTMLElementTagNameMap {
706 'devtools-resources-frame-details-view': FrameDetailsReportView;
707 }
708}