blob: 695145423766a0bfcdbdd3662f59b8254ad48aa2 [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';
Wolfgang Beyer760462e2020-07-13 15:01:3513import * as SDK from '../sdk/sdk.js'; // eslint-disable-line no-unused-vars
14import * 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';
18export const UIStrings = {
19 /**
20 *@description Section header in the Frame Details view
21 */
22 additionalInformation: 'Additional Information',
23 /**
24 *@description Explanation for why the additional information section is being shown
25 */
26 thisAdditionalDebugging:
27 'This additional (debugging) information is shown because the \'Protocol Monitor\' experiment is enabled.',
28 /**
29 *@description Label for subtitle of frame details view
30 */
31 frameId: 'Frame ID',
32 /**
33 *@description Name of a network resource type
34 */
35 document: 'Document',
36 /**
37 *@description Text for web URLs
38 */
39 url: 'URL',
40 /**
41 *@description Title for a link to the Sources panel
42 */
43 clickToRevealInSourcesPanel: 'Click to reveal in Sources panel',
44 /**
45 *@description Title for a link to the Network panel
46 */
47 clickToRevealInNetworkPanel: 'Click to reveal in Network panel',
48 /**
49 *@description Title for unreachable URL field
50 */
51 unreachableUrl: 'Unreachable URL',
52 /**
53 *@description Title for a link that applies a filter to the network panel
54 */
55 clickToRevealInNetworkPanelMight: 'Click to reveal in Network panel (might require page reload)',
56 /**
57 *@description Text for the origin of something
58 */
59 origin: 'Origin',
60 /**
61 *@description Related node label in Timeline UIUtils of the Performance panel
62 */
63 ownerElement: 'Owner Element',
64 /**
65 *@description Title for a link to the Elements panel
66 */
67 clickToRevealInElementsPanel: 'Click to reveal in Elements panel',
68 /**
69 *@description Title for ad frame type field
70 */
71 adStatus: 'Ad Status',
72 /**
73 *@description Description for ad frame type
74 */
75 thisFrameHasBeenIdentifiedAsThe: 'This frame has been identified as the root frame of an ad',
76 /**
77 *@description Value for ad frame type
78 */
79 root: 'root',
80 /**
81 *@description Description for ad frame type
82 */
83 thisFrameHasBeenIdentifiedAsTheA: 'This frame has been identified as the a child frame of an ad',
84 /**
85 *@description Value for ad frame type
86 */
87 child: 'child',
88 /**
89 *@description Section header in the Frame Details view
90 */
91 securityIsolation: 'Security & Isolation',
92 /**
93 *@description Row title for in the Frame Details view
94 */
95 secureContext: 'Secure Context',
96 /**
97 *@description Text in Timeline indicating that input has happened recently
98 */
99 yes: 'Yes',
100 /**
101 *@description Text in Timeline indicating that input has not happened recently
102 */
103 no: 'No',
104 /**
105 *@description Row title for in the Frame Details view
106 */
107 crossoriginIsolated: 'Cross-Origin Isolated',
108 /**
109 *@description Explanatory text in the Frame Details view
110 */
111 localhostIsAlwaysASecureContext: 'Localhost is always a secure context',
112 /**
113 *@description Explanatory text in the Frame Details view
114 */
115 aFrameAncestorIsAnInsecure: 'A frame ancestor is an insecure context',
116 /**
117 *@description Explanatory text in the Frame Details view
118 */
119 theFramesSchemeIsInsecure: 'The frame\'s scheme is insecure',
120 /**
121 *@description Row title in the Frame Details view
122 */
123 crossoriginEmbedderPolicy: 'Cross-Origin Embedder Policy',
124 /**
125 *@description Row title in the Frame Details view
126 */
127 crossoriginOpenerPolicy: 'Cross-Origin Opener Policy',
128 /**
Peter Marshallec861882021-02-16 11:14:21129 *@description This label specifies the server endpoints to which the server is reporting errors
130 *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:01131 */
132 reportingTo: 'reporting to',
133 /**
134 *@description Section header in the Frame Details view
135 */
136 apiAvailability: 'API availability',
137 /**
138 *@description Explanatory text in the Frame Details view for the API availability section
139 */
140 availabilityOfCertainApisDepends: 'Availability of certain APIs depends on the document being cross-origin isolated.',
141 /**
142 *@description Description of the SharedArrayBuffer status
143 */
144 availableTransferable: 'available, transferable',
145 /**
146 *@description Description of the SharedArrayBuffer status
147 */
148 availableNotTransferable: 'available, not transferable',
149 /**
150 *@description Explanation for the SharedArrayBuffer availability status
151 */
152 unavailable: 'unavailable',
153 /**
154 *@description Tooltip for the SharedArrayBuffer availability status
155 */
156 sharedarraybufferConstructorIs:
157 'SharedArrayBuffer constructor is available and SABs can be transferred via postMessage',
158 /**
159 *@description Tooltip for the SharedArrayBuffer availability status
160 */
161 sharedarraybufferConstructorIsAvailable:
162 'SharedArrayBuffer constructor is available but SABs cannot be transferred via postMessage',
163 /**
164 *@description Entry in the API availability section of the frame details view
165 */
166 sharedArrayBuffers: 'Shared Array Buffers',
167 /**
168 *@description Explanation for the SharedArrayBuffer availability status
169 */
170 WillRequireCrossoriginIsolated: '⚠️ will require cross-origin isolated context in the future',
171 /**
172 *@description Explanation for the SharedArrayBuffer availability status
173 */
174 requiresCrossoriginIsolated: 'requires cross-origin isolated context',
175 /**
176 *@description Explanation for the Measure Memory availability status
177 */
178 available: 'available',
179 /**
180 *@description Tooltip for the Measure Memory availability status
181 */
182 thePerformanceAPI: 'The performance.measureUserAgentSpecificMemory() API is available',
183 /**
184 *@description Tooltip for the Measure Memory availability status
185 */
186 thePerformancemeasureuseragentspecificmemory: 'The performance.measureUserAgentSpecificMemory() API is not available',
187 /**
188 *@description Entry in the API availability section of the frame details view
189 */
190 measureMemory: 'Measure Memory',
191 /**
192 *@description Text that is usually a hyperlink to more documentation
193 */
194 learnMore: 'Learn more',
195};
196const str_ = i18n.i18n.registerUIStrings('resources/FrameDetailsView.ts', UIStrings);
197const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
Sigurd Schneider1e5ad282020-07-17 11:52:08198export class FrameDetailsView extends UI.ThrottledWidget.ThrottledWidget {
Wolfgang Beyer92395c92021-02-02 10:43:23199 private readonly reportView = new FrameDetailsReportView();
Wolfgang Beyere5d1a9f2021-02-05 09:42:43200 private readonly frame: SDK.ResourceTreeModel.ResourceTreeFrame;
Wolfgang Beyer92395c92021-02-02 10:43:23201
Wolfgang Beyer309863f2021-01-21 09:01:21202 constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) {
Wolfgang Beyer760462e2020-07-13 15:01:35203 super();
Wolfgang Beyere5d1a9f2021-02-05 09:42:43204 this.frame = frame;
205 this.contentElement.classList.add('overflow-auto');
Wolfgang Beyer92395c92021-02-02 10:43:23206 this.contentElement.appendChild(this.reportView);
Sigurd Schneider1e5ad282020-07-17 11:52:08207 this.update();
208 }
209
Wolfgang Beyer309863f2021-01-21 09:01:21210 async doUpdate(): Promise<void> {
Wolfgang Beyere5d1a9f2021-02-05 09:42:43211 this.reportView.data = {frame: this.frame};
Sigurd Schneidereabef962020-11-05 10:51:49212 }
Wolfgang Beyer760462e2020-07-13 15:01:35213}
Wolfgang Beyer3b4747f2020-08-12 07:30:46214
Wolfgang Beyer92395c92021-02-02 10:43:23215export interface FrameDetailsReportViewData {
216 frame: SDK.ResourceTreeModel.ResourceTreeFrame;
217}
218
219export class FrameDetailsReportView extends HTMLElement {
220 private readonly shadow = this.attachShadow({mode: 'open'});
221 private frame?: SDK.ResourceTreeModel.ResourceTreeFrame;
Wolfgang Beyere5d1a9f2021-02-05 09:42:43222 private protocolMonitorExperimentEnabled = false;
223
224 connectedCallback(): void {
225 this.protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocolMonitor');
226 }
Wolfgang Beyer92395c92021-02-02 10:43:23227
228 set data(data: FrameDetailsReportViewData) {
229 this.frame = data.frame;
230 this.render();
231 }
232
233 private async render(): Promise<void> {
234 if (!this.frame) {
235 return;
236 }
237
238 // Disabled until https://crbug.com/1079231 is fixed.
239 // clang-format off
240 LitHtml.render(LitHtml.html`
Wolfgang Beyer1525b1f2021-02-02 14:12:30241 <style>
242 .text-ellipsis {
243 overflow: hidden;
244 text-overflow: ellipsis;
245 white-space: nowrap;
246 }
247
248 button ~ .text-ellipsis {
249 padding-left: 2px;
250 }
251
252 .link {
253 color: var(--color-link);
254 text-decoration: underline;
255 cursor: pointer;
256 padding: 2px 0; /* adjust focus ring size */
257 }
258
259 button.link {
260 border: none;
261 background: none;
262 font-family: inherit;
263 font-size: inherit;
264 }
265
Wolfgang Beyerabfc8472021-02-04 11:29:50266 .inline-comment {
267 padding-left: 1ex;
268 white-space: pre-line;
269 }
270
271 .inline-comment::before {
272 content: "(";
273 }
274
275 .inline-comment::after {
276 content: ")";
277 }
278
279 .inline-name {
280 color: var(--color-text-secondary);
281 padding-left: 2ex;
282 user-select: none;
283 white-space: pre-line;
284 }
285
286 .inline-name::after {
287 content: ':\u00a0';
288 }
289
Wolfgang Beyer1525b1f2021-02-02 14:12:30290 .inline-items {
291 display: flex;
292 }
293 </style>
Wolfgang Beyer92395c92021-02-02 10:43:23294 <devtools-report .data=${{reportTitle: this.frame.displayName()} as Components.ReportView.ReportData}>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43295 ${this.renderDocumentSection()}
296 ${this.renderIsolationSection()}
297 ${this.renderApiAvailabilitySection()}
298 ${this.protocolMonitorExperimentEnabled ? this.renderAdditionalInfoSection() : LitHtml.nothing}
Wolfgang Beyer92395c92021-02-02 10:43:23299 </devtools-report>
300 `, this.shadow);
301 // clang-format on
302 }
Wolfgang Beyer1525b1f2021-02-02 14:12:30303
304 private renderDocumentSection(): LitHtml.TemplateResult|{} {
305 if (!this.frame) {
306 return LitHtml.nothing;
307 }
308
309 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01310 <devtools-report-section-header>${i18nString(UIStrings.document)}</devtools-report-section-header>
311 <devtools-report-key>${i18nString(UIStrings.url)}</devtools-report-key>
Wolfgang Beyer1525b1f2021-02-02 14:12:30312 <devtools-report-value>
313 <div class="inline-items">
314 ${this.maybeRenderSourcesLinkForURL()}
315 ${this.maybeRenderNetworkLinkForURL()}
316 <div class="text-ellipsis" title=${this.frame.url}>${this.frame.url}</div>
317 </div>
318 </devtools-report-value>
319 ${this.maybeRenderUnreachableURL()}
320 ${this.maybeRenderOrigin()}
321 ${LitHtml.Directives.until(this.renderOwnerElement(), LitHtml.nothing)}
322 ${this.maybeRenderAdStatus()}
323 <devtools-report-divider></devtools-report-divider>
324 `;
325 }
326
327 private maybeRenderSourcesLinkForURL(): LitHtml.TemplateResult|{} {
328 if (!this.frame || this.frame.unreachableUrl()) {
329 return LitHtml.nothing;
330 }
331 const sourceCode = this.uiSourceCodeForFrame(this.frame);
332 return this.renderIconLink(
333 'sources_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01334 i18nString(UIStrings.clickToRevealInSourcesPanel),
Wolfgang Beyer1525b1f2021-02-02 14:12:30335 (): Promise<void> => Common.Revealer.reveal(sourceCode),
336 );
337 }
338
339 private maybeRenderNetworkLinkForURL(): LitHtml.TemplateResult|{} {
340 if (this.frame) {
341 const resource = this.frame.resourceForURL(this.frame.url);
342 if (resource && resource.request) {
343 const request = resource.request;
344 return this.renderIconLink(
345 'network_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01346 i18nString(UIStrings.clickToRevealInNetworkPanel),
Wolfgang Beyer1525b1f2021-02-02 14:12:30347 (): Promise<void> =>
348 Network.NetworkPanel.NetworkPanel.selectAndShowRequest(request, Network.NetworkItemView.Tabs.Headers),
349 );
350 }
351 }
352 return LitHtml.nothing;
353 }
354
355 private renderIconLink(
356 iconName: string, title: Platform.UIString.LocalizedString,
357 clickHandler: (() => void)|(() => Promise<void>)): LitHtml.TemplateResult {
358 // Disabled until https://crbug.com/1079231 is fixed.
359 // clang-format off
360 return LitHtml.html`
361 <button class="link" role="link" tabindex=0 @click=${clickHandler} title=${title}>
362 <devtools-icon .data=${{
363 iconName: iconName,
364 color: 'var(--color-primary)',
365 width: '16px',
366 height: '16px',
367 } as Components.Icon.IconData}>
368 </button>
369 `;
370 // clang-format on
371 }
372
373 private uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode
374 |null {
375 for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) {
376 const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project);
377 if (projectTarget && projectTarget === frame.resourceTreeModel().target()) {
378 const uiSourceCode = project.uiSourceCodeForURL(frame.url);
379 if (uiSourceCode) {
380 return uiSourceCode;
381 }
382 }
383 }
384 return null;
385 }
386
387 private maybeRenderUnreachableURL(): LitHtml.TemplateResult|{} {
388 if (!this.frame || !this.frame.unreachableUrl()) {
389 return LitHtml.nothing;
390 }
391 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01392 <devtools-report-key>${i18nString(UIStrings.unreachableUrl)}</devtools-report-key>
Wolfgang Beyer1525b1f2021-02-02 14:12:30393 <devtools-report-value>
394 <div class="inline-items">
395 ${this.renderNetworkLinkForUnreachableURL()}
396 <div class="text-ellipsis" title=${this.frame.unreachableUrl()}>${this.frame.unreachableUrl()}</div>
397 </div>
398 </devtools-report-value>
399 `;
400 }
401
402 private renderNetworkLinkForUnreachableURL(): LitHtml.TemplateResult|{} {
403 if (this.frame) {
404 const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(this.frame.unreachableUrl());
405 if (unreachableUrl) {
406 return this.renderIconLink(
407 'network_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01408 i18nString(UIStrings.clickToRevealInNetworkPanelMight),
Wolfgang Beyer1525b1f2021-02-02 14:12:30409 ():
410 void => {
411 Network.NetworkPanel.NetworkPanel.revealAndFilter([
412 {
413 filterType: 'domain',
414 filterValue: unreachableUrl.domain(),
415 },
416 {
417 filterType: null,
418 filterValue: unreachableUrl.path,
419 },
420 ]);
421 },
422 );
423 }
424 }
425 return LitHtml.nothing;
426 }
427
428 private maybeRenderOrigin(): LitHtml.TemplateResult|{} {
429 if (this.frame && this.frame.securityOrigin && this.frame.securityOrigin !== '://') {
430 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01431 <devtools-report-key>${i18nString(UIStrings.origin)}</devtools-report-key>
Wolfgang Beyer1525b1f2021-02-02 14:12:30432 <devtools-report-value>
433 <div class="text-ellipsis" title=${this.frame.securityOrigin}>${this.frame.securityOrigin}</div>
434 </devtools-report-value>
435 `;
436 }
437 return LitHtml.nothing;
438 }
439
440 private async renderOwnerElement(): Promise<LitHtml.TemplateResult|{}> {
441 if (this.frame) {
Wolfgang Beyerf0d985e2021-02-05 12:56:52442 const linkTargetDOMNode = await this.frame.getOwnerDOMNodeOrDocument();
443 if (linkTargetDOMNode) {
444 // Disabled until https://crbug.com/1079231 is fixed.
445 // clang-format off
446 return LitHtml.html`
447 <style>
Wolfgang Beyerddf051e2021-02-09 08:33:01448 .button-icon-with-text {
Wolfgang Beyerf0d985e2021-02-05 12:56:52449 vertical-align: sub;
450 }
Wolfgang Beyer09b0e8e2021-02-09 13:39:48451
452 .without-min-width {
453 min-width: auto;
454 }
Wolfgang Beyerf0d985e2021-02-05 12:56:52455 </style>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01456 <devtools-report-key>${i18nString(UIStrings.ownerElement)}</devtools-report-key>
Wolfgang Beyer09b0e8e2021-02-09 13:39:48457 <devtools-report-value class="without-min-width">
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01458 <button class="link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToRevealInElementsPanel)}
Wolfgang Beyerf0d985e2021-02-05 12:56:52459 @mouseenter=${(): Promise<void>|undefined => this.frame?.highlight()}
460 @mouseleave=${(): void => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()}
461 @click=${(): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode)}
462 >
463 <devtools-icon class="button-icon-with-text" .data=${{
464 iconName: 'elements_panel_icon',
465 color: 'var(--color-primary)',
466 width: '16px',
467 height: '16px',
468 } as Components.Icon.IconData}></devtools-icon>
469 <${linkTargetDOMNode.nodeName().toLocaleLowerCase()}>
Wolfgang Beyer09b0e8e2021-02-09 13:39:48470 </button>
Wolfgang Beyerf0d985e2021-02-05 12:56:52471 </devtools-report-value>
472 `;
473 // clang-format on
Wolfgang Beyer1525b1f2021-02-02 14:12:30474 }
475 }
476 return LitHtml.nothing;
477 }
478
479 private maybeRenderAdStatus(): LitHtml.TemplateResult|{} {
480 if (this.frame) {
481 if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Root) {
482 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01483 <devtools-report-key>${i18nString(UIStrings.adStatus)}</devtools-report-key>
484 <devtools-report-value title=${i18nString(UIStrings.thisFrameHasBeenIdentifiedAsThe)}>${
485 i18nString(UIStrings.root)}</devtools-report-value>
Wolfgang Beyer1525b1f2021-02-02 14:12:30486 `;
487 }
488 if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Child) {
489 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01490 <devtools-report-key>${i18nString(UIStrings.adStatus)}</devtools-report-key>
491 <devtools-report-value title=${i18nString(UIStrings.thisFrameHasBeenIdentifiedAsTheA)}>${
492 i18nString(UIStrings.child)}</devtools-report-value>
Wolfgang Beyer1525b1f2021-02-02 14:12:30493 `;
494 }
495 }
496 return LitHtml.nothing;
497 }
Wolfgang Beyerabfc8472021-02-04 11:29:50498
499 private renderIsolationSection(): LitHtml.TemplateResult|{} {
500 if (!this.frame) {
501 return LitHtml.nothing;
502 }
503 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01504 <devtools-report-section-header>${i18nString(UIStrings.securityIsolation)}</devtools-report-section-header>
505 <devtools-report-key>${i18nString(UIStrings.secureContext)}</devtools-report-key>
Wolfgang Beyerabfc8472021-02-04 11:29:50506 <devtools-report-value>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01507 ${this.frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
Wolfgang Beyerabfc8472021-02-04 11:29:50508 ${this.maybeRenderSecureContextExplanation()}
509 </devtools-report-value>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01510 <devtools-report-key>${i18nString(UIStrings.crossoriginIsolated)}</devtools-report-key>
Wolfgang Beyerabfc8472021-02-04 11:29:50511 <devtools-report-value>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01512 ${this.frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
Wolfgang Beyerabfc8472021-02-04 11:29:50513 </devtools-report-value>
514 ${LitHtml.Directives.until(this.maybeRenderCoopCoepStatus(), LitHtml.nothing)}
515 <devtools-report-divider></devtools-report-divider>
516 `;
517 }
518
519 private maybeRenderSecureContextExplanation(): LitHtml.TemplateResult|{} {
520 const explanation = this.getSecureContextExplanation();
521 if (explanation) {
522 return LitHtml.html`
523 <span class="inline-comment">${explanation}</span>
524 `;
525 }
526 return LitHtml.nothing;
527 }
528
529 private getSecureContextExplanation(): Platform.UIString.LocalizedString|null {
530 switch (this.frame?.getSecureContextType()) {
531 case Protocol.Page.SecureContextType.Secure:
532 return null;
533 case Protocol.Page.SecureContextType.SecureLocalhost:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01534 return i18nString(UIStrings.localhostIsAlwaysASecureContext);
Wolfgang Beyerabfc8472021-02-04 11:29:50535 case Protocol.Page.SecureContextType.InsecureAncestor:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01536 return i18nString(UIStrings.aFrameAncestorIsAnInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50537 case Protocol.Page.SecureContextType.InsecureScheme:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01538 return i18nString(UIStrings.theFramesSchemeIsInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50539 }
540 return null;
541 }
542
543 private async maybeRenderCoopCoepStatus(): Promise<LitHtml.TemplateResult|{}> {
544 if (this.frame) {
545 const model = this.frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager);
546 const info = model && await model.getSecurityIsolationStatus(this.frame.id);
547 if (info) {
548 return LitHtml.html`
549 ${
550 this.maybeRenderCrossOriginStatus(
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01551 info.coep, i18nString(UIStrings.crossoriginEmbedderPolicy),
552 Protocol.Network.CrossOriginEmbedderPolicyValue.None)}
Wolfgang Beyerabfc8472021-02-04 11:29:50553 ${
554 this.maybeRenderCrossOriginStatus(
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01555 info.coop, i18nString(UIStrings.crossoriginOpenerPolicy),
556 Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)}
Wolfgang Beyerabfc8472021-02-04 11:29:50557 `;
558 }
559 }
560 return LitHtml.nothing;
561 }
562
563 private maybeRenderCrossOriginStatus(
564 info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined,
565 policyName: string,
566 noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue|
567 Protocol.Network.CrossOriginOpenerPolicyValue): LitHtml.TemplateResult|{} {
568 if (!info) {
569 return LitHtml.nothing;
570 }
571 const isEnabled = info.value !== noneValue;
572 const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue);
573 const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint;
574 return LitHtml.html`
575 <devtools-report-key>${policyName}</devtools-report-key>
576 <devtools-report-value>
577 ${isEnabled ? info.value : info.reportOnlyValue}
578 ${isReportOnly ? LitHtml.html`<span class="inline-comment">report-only</span>` : LitHtml.nothing}
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01579 ${
580 endpoint ? LitHtml.html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` :
581 LitHtml.nothing}
Wolfgang Beyerabfc8472021-02-04 11:29:50582 </devtools-report-value>
583 `;
584 }
Wolfgang Beyer6a6efe62021-02-04 15:56:21585
586 private renderApiAvailabilitySection(): LitHtml.TemplateResult|{} {
587 if (!this.frame) {
588 return LitHtml.nothing;
589 }
590
591 return LitHtml.html`
592 <style>
593 .span-cols {
594 grid-column-start: span 2;
595 margin: 0 0 8px 30px;
Jack Franklin49a94812021-02-05 14:20:12596 line-height: 28px;
Wolfgang Beyer6a6efe62021-02-04 15:56:21597 }
598 </style>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01599 <devtools-report-section-header>${i18nString(UIStrings.apiAvailability)}</devtools-report-section-header>
Wolfgang Beyer6a6efe62021-02-04 15:56:21600 <div class="span-cols">
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01601 ${i18nString(UIStrings.availabilityOfCertainApisDepends)}
Wolfgang Beyer6a6efe62021-02-04 15:56:21602 <x-link href="https://web.dev/why-coop-coep/" class="link">Learn more</x-link>
603 </div>
604 ${this.renderSharedArrayBufferAvailability()}
605 ${this.renderMeasureMemoryAvailability()}
606 <devtools-report-divider></devtools-report-divider>
607 `;
608 }
609
610 private renderSharedArrayBufferAvailability(): LitHtml.TemplateResult|{} {
611 if (this.frame) {
612 const features = this.frame.getGatedAPIFeatures();
613 if (features) {
614 const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers);
615 const sabTransferAvailable =
616 sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed);
617 const availabilityText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01618 i18nString(UIStrings.availableTransferable) :
619 (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable));
Wolfgang Beyer6a6efe62021-02-04 15:56:21620 const tooltipText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01621 i18nString(UIStrings.sharedarraybufferConstructorIs) :
622 (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : '');
Wolfgang Beyer6a6efe62021-02-04 15:56:21623
624 // Disabled until https://crbug.com/1079231 is fixed.
625 // clang-format off
626 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01627 <devtools-report-key>${i18nString(UIStrings.sharedArrayBuffers)}</devtools-report-key>
Wolfgang Beyer6a6efe62021-02-04 15:56:21628 <devtools-report-value title=${tooltipText}>
629 ${availabilityText}
630 ${!this.frame.isCrossOriginIsolated() ?
631 (sabAvailable ?
632 LitHtml.html`<span class="inline-comment">${
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01633 i18nString(UIStrings.WillRequireCrossoriginIsolated)}</span>` :
634 LitHtml.html`<span class="inline-comment">${i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`) :
Wolfgang Beyer6a6efe62021-02-04 15:56:21635 LitHtml.nothing}
636 </devtools-report-value>
637 `;
638 // clang-format on
639 }
640 }
641 return LitHtml.nothing;
642 }
643
644 private renderMeasureMemoryAvailability(): LitHtml.TemplateResult|{} {
645 if (this.frame) {
646 const measureMemoryAvailable = this.frame.isCrossOriginIsolated();
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01647 const availabilityText =
648 measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable);
649 const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) :
650 i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory);
Wolfgang Beyer6a6efe62021-02-04 15:56:21651 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01652 <devtools-report-key>${i18nString(UIStrings.measureMemory)}</devtools-report-key>
Wolfgang Beyer6a6efe62021-02-04 15:56:21653 <devtools-report-value>
654 <span title=${tooltipText}>${availabilityText}</span>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01655 <x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/">${
Wolfgang Beyer09b0e8e2021-02-09 13:39:48656 i18nString(UIStrings.learnMore)}</x-link>
Wolfgang Beyer6a6efe62021-02-04 15:56:21657 </devtools-report-value>
658 `;
659 }
660 return LitHtml.nothing;
661 }
Wolfgang Beyere5d1a9f2021-02-05 09:42:43662
663 private renderAdditionalInfoSection(): LitHtml.TemplateResult|{} {
664 if (!this.frame) {
665 return LitHtml.nothing;
666 }
667
668 return LitHtml.html`
669 <devtools-report-section-header
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01670 title=${i18nString(UIStrings.thisAdditionalDebugging)}
671 >${i18nString(UIStrings.additionalInformation)}</devtools-report-section-header>
672 <devtools-report-key>${i18nString(UIStrings.frameId)}</devtools-report-key>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43673 <devtools-report-value>
674 <div class="text-ellipsis" title=${this.frame.id}>${this.frame.id}</div>
675 </devtools-report-value>
676 <devtools-report-divider></devtools-report-divider>
677 `;
678 }
Wolfgang Beyer92395c92021-02-02 10:43:23679}
680
681customElements.define('devtools-resources-frame-details-view', FrameDetailsReportView);
682
683declare global {
684 // eslint-disable-next-line @typescript-eslint/no-unused-vars
685 interface HTMLElementTagNameMap {
686 'devtools-resources-frame-details-view': FrameDetailsReportView;
687 }
688}