blob: ad8f0f1703565fe75c00f034f09ae8474fd5f8a3 [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 /**
129 *@description This label specifies the server endpoints to which the server is reporting errors and warnings through the Report-to API
130 */
131 reportingTo: 'reporting to',
132 /**
133 *@description Section header in the Frame Details view
134 */
135 apiAvailability: 'API availability',
136 /**
137 *@description Explanatory text in the Frame Details view for the API availability section
138 */
139 availabilityOfCertainApisDepends: 'Availability of certain APIs depends on the document being cross-origin isolated.',
140 /**
141 *@description Description of the SharedArrayBuffer status
142 */
143 availableTransferable: 'available, transferable',
144 /**
145 *@description Description of the SharedArrayBuffer status
146 */
147 availableNotTransferable: 'available, not transferable',
148 /**
149 *@description Explanation for the SharedArrayBuffer availability status
150 */
151 unavailable: 'unavailable',
152 /**
153 *@description Tooltip for the SharedArrayBuffer availability status
154 */
155 sharedarraybufferConstructorIs:
156 'SharedArrayBuffer constructor is available and SABs can be transferred via postMessage',
157 /**
158 *@description Tooltip for the SharedArrayBuffer availability status
159 */
160 sharedarraybufferConstructorIsAvailable:
161 'SharedArrayBuffer constructor is available but SABs cannot be transferred via postMessage',
162 /**
163 *@description Entry in the API availability section of the frame details view
164 */
165 sharedArrayBuffers: 'Shared Array Buffers',
166 /**
167 *@description Explanation for the SharedArrayBuffer availability status
168 */
169 WillRequireCrossoriginIsolated: '⚠️ will require cross-origin isolated context in the future',
170 /**
171 *@description Explanation for the SharedArrayBuffer availability status
172 */
173 requiresCrossoriginIsolated: 'requires cross-origin isolated context',
174 /**
175 *@description Explanation for the Measure Memory availability status
176 */
177 available: 'available',
178 /**
179 *@description Tooltip for the Measure Memory availability status
180 */
181 thePerformanceAPI: 'The performance.measureUserAgentSpecificMemory() API is available',
182 /**
183 *@description Tooltip for the Measure Memory availability status
184 */
185 thePerformancemeasureuseragentspecificmemory: 'The performance.measureUserAgentSpecificMemory() API is not available',
186 /**
187 *@description Entry in the API availability section of the frame details view
188 */
189 measureMemory: 'Measure Memory',
190 /**
191 *@description Text that is usually a hyperlink to more documentation
192 */
193 learnMore: 'Learn more',
194};
195const str_ = i18n.i18n.registerUIStrings('resources/FrameDetailsView.ts', UIStrings);
196const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
Sigurd Schneider1e5ad282020-07-17 11:52:08197export class FrameDetailsView extends UI.ThrottledWidget.ThrottledWidget {
Wolfgang Beyer92395c92021-02-02 10:43:23198 private readonly reportView = new FrameDetailsReportView();
Wolfgang Beyere5d1a9f2021-02-05 09:42:43199 private readonly frame: SDK.ResourceTreeModel.ResourceTreeFrame;
Wolfgang Beyer92395c92021-02-02 10:43:23200
Wolfgang Beyer309863f2021-01-21 09:01:21201 constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) {
Wolfgang Beyer760462e2020-07-13 15:01:35202 super();
Wolfgang Beyere5d1a9f2021-02-05 09:42:43203 this.frame = frame;
204 this.contentElement.classList.add('overflow-auto');
Wolfgang Beyer92395c92021-02-02 10:43:23205 this.contentElement.appendChild(this.reportView);
Sigurd Schneider1e5ad282020-07-17 11:52:08206 this.update();
207 }
208
Wolfgang Beyer309863f2021-01-21 09:01:21209 async doUpdate(): Promise<void> {
Wolfgang Beyere5d1a9f2021-02-05 09:42:43210 this.reportView.data = {frame: this.frame};
Sigurd Schneidereabef962020-11-05 10:51:49211 }
Wolfgang Beyer760462e2020-07-13 15:01:35212}
Wolfgang Beyer3b4747f2020-08-12 07:30:46213
Wolfgang Beyer92395c92021-02-02 10:43:23214export interface FrameDetailsReportViewData {
215 frame: SDK.ResourceTreeModel.ResourceTreeFrame;
216}
217
218export class FrameDetailsReportView extends HTMLElement {
219 private readonly shadow = this.attachShadow({mode: 'open'});
220 private frame?: SDK.ResourceTreeModel.ResourceTreeFrame;
Wolfgang Beyere5d1a9f2021-02-05 09:42:43221 private protocolMonitorExperimentEnabled = false;
222
223 connectedCallback(): void {
224 this.protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocolMonitor');
225 }
Wolfgang Beyer92395c92021-02-02 10:43:23226
227 set data(data: FrameDetailsReportViewData) {
228 this.frame = data.frame;
229 this.render();
230 }
231
232 private async render(): Promise<void> {
233 if (!this.frame) {
234 return;
235 }
236
237 // Disabled until https://crbug.com/1079231 is fixed.
238 // clang-format off
239 LitHtml.render(LitHtml.html`
Wolfgang Beyer1525b1f2021-02-02 14:12:30240 <style>
241 .text-ellipsis {
242 overflow: hidden;
243 text-overflow: ellipsis;
244 white-space: nowrap;
245 }
246
247 button ~ .text-ellipsis {
248 padding-left: 2px;
249 }
250
251 .link {
252 color: var(--color-link);
253 text-decoration: underline;
254 cursor: pointer;
255 padding: 2px 0; /* adjust focus ring size */
256 }
257
258 button.link {
259 border: none;
260 background: none;
261 font-family: inherit;
262 font-size: inherit;
263 }
264
Wolfgang Beyerabfc8472021-02-04 11:29:50265 .inline-comment {
266 padding-left: 1ex;
267 white-space: pre-line;
268 }
269
270 .inline-comment::before {
271 content: "(";
272 }
273
274 .inline-comment::after {
275 content: ")";
276 }
277
278 .inline-name {
279 color: var(--color-text-secondary);
280 padding-left: 2ex;
281 user-select: none;
282 white-space: pre-line;
283 }
284
285 .inline-name::after {
286 content: ':\u00a0';
287 }
288
Wolfgang Beyer1525b1f2021-02-02 14:12:30289 .inline-items {
290 display: flex;
291 }
292 </style>
Wolfgang Beyer92395c92021-02-02 10:43:23293 <devtools-report .data=${{reportTitle: this.frame.displayName()} as Components.ReportView.ReportData}>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43294 ${this.renderDocumentSection()}
295 ${this.renderIsolationSection()}
296 ${this.renderApiAvailabilitySection()}
297 ${this.protocolMonitorExperimentEnabled ? this.renderAdditionalInfoSection() : LitHtml.nothing}
Wolfgang Beyer92395c92021-02-02 10:43:23298 </devtools-report>
299 `, this.shadow);
300 // clang-format on
301 }
Wolfgang Beyer1525b1f2021-02-02 14:12:30302
303 private renderDocumentSection(): LitHtml.TemplateResult|{} {
304 if (!this.frame) {
305 return LitHtml.nothing;
306 }
307
308 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01309 <devtools-report-section-header>${i18nString(UIStrings.document)}</devtools-report-section-header>
310 <devtools-report-key>${i18nString(UIStrings.url)}</devtools-report-key>
Wolfgang Beyer1525b1f2021-02-02 14:12:30311 <devtools-report-value>
312 <div class="inline-items">
313 ${this.maybeRenderSourcesLinkForURL()}
314 ${this.maybeRenderNetworkLinkForURL()}
315 <div class="text-ellipsis" title=${this.frame.url}>${this.frame.url}</div>
316 </div>
317 </devtools-report-value>
318 ${this.maybeRenderUnreachableURL()}
319 ${this.maybeRenderOrigin()}
320 ${LitHtml.Directives.until(this.renderOwnerElement(), LitHtml.nothing)}
321 ${this.maybeRenderAdStatus()}
322 <devtools-report-divider></devtools-report-divider>
323 `;
324 }
325
326 private maybeRenderSourcesLinkForURL(): LitHtml.TemplateResult|{} {
327 if (!this.frame || this.frame.unreachableUrl()) {
328 return LitHtml.nothing;
329 }
330 const sourceCode = this.uiSourceCodeForFrame(this.frame);
331 return this.renderIconLink(
332 'sources_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01333 i18nString(UIStrings.clickToRevealInSourcesPanel),
Wolfgang Beyer1525b1f2021-02-02 14:12:30334 (): Promise<void> => Common.Revealer.reveal(sourceCode),
335 );
336 }
337
338 private maybeRenderNetworkLinkForURL(): LitHtml.TemplateResult|{} {
339 if (this.frame) {
340 const resource = this.frame.resourceForURL(this.frame.url);
341 if (resource && resource.request) {
342 const request = resource.request;
343 return this.renderIconLink(
344 'network_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01345 i18nString(UIStrings.clickToRevealInNetworkPanel),
Wolfgang Beyer1525b1f2021-02-02 14:12:30346 (): Promise<void> =>
347 Network.NetworkPanel.NetworkPanel.selectAndShowRequest(request, Network.NetworkItemView.Tabs.Headers),
348 );
349 }
350 }
351 return LitHtml.nothing;
352 }
353
354 private renderIconLink(
355 iconName: string, title: Platform.UIString.LocalizedString,
356 clickHandler: (() => void)|(() => Promise<void>)): LitHtml.TemplateResult {
357 // Disabled until https://crbug.com/1079231 is fixed.
358 // clang-format off
359 return LitHtml.html`
360 <button class="link" role="link" tabindex=0 @click=${clickHandler} title=${title}>
361 <devtools-icon .data=${{
362 iconName: iconName,
363 color: 'var(--color-primary)',
364 width: '16px',
365 height: '16px',
366 } as Components.Icon.IconData}>
367 </button>
368 `;
369 // clang-format on
370 }
371
372 private uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode
373 |null {
374 for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) {
375 const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project);
376 if (projectTarget && projectTarget === frame.resourceTreeModel().target()) {
377 const uiSourceCode = project.uiSourceCodeForURL(frame.url);
378 if (uiSourceCode) {
379 return uiSourceCode;
380 }
381 }
382 }
383 return null;
384 }
385
386 private maybeRenderUnreachableURL(): LitHtml.TemplateResult|{} {
387 if (!this.frame || !this.frame.unreachableUrl()) {
388 return LitHtml.nothing;
389 }
390 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01391 <devtools-report-key>${i18nString(UIStrings.unreachableUrl)}</devtools-report-key>
Wolfgang Beyer1525b1f2021-02-02 14:12:30392 <devtools-report-value>
393 <div class="inline-items">
394 ${this.renderNetworkLinkForUnreachableURL()}
395 <div class="text-ellipsis" title=${this.frame.unreachableUrl()}>${this.frame.unreachableUrl()}</div>
396 </div>
397 </devtools-report-value>
398 `;
399 }
400
401 private renderNetworkLinkForUnreachableURL(): LitHtml.TemplateResult|{} {
402 if (this.frame) {
403 const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(this.frame.unreachableUrl());
404 if (unreachableUrl) {
405 return this.renderIconLink(
406 'network_panel_icon',
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01407 i18nString(UIStrings.clickToRevealInNetworkPanelMight),
Wolfgang Beyer1525b1f2021-02-02 14:12:30408 ():
409 void => {
410 Network.NetworkPanel.NetworkPanel.revealAndFilter([
411 {
412 filterType: 'domain',
413 filterValue: unreachableUrl.domain(),
414 },
415 {
416 filterType: null,
417 filterValue: unreachableUrl.path,
418 },
419 ]);
420 },
421 );
422 }
423 }
424 return LitHtml.nothing;
425 }
426
427 private maybeRenderOrigin(): LitHtml.TemplateResult|{} {
428 if (this.frame && this.frame.securityOrigin && this.frame.securityOrigin !== '://') {
429 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01430 <devtools-report-key>${i18nString(UIStrings.origin)}</devtools-report-key>
Wolfgang Beyer1525b1f2021-02-02 14:12:30431 <devtools-report-value>
432 <div class="text-ellipsis" title=${this.frame.securityOrigin}>${this.frame.securityOrigin}</div>
433 </devtools-report-value>
434 `;
435 }
436 return LitHtml.nothing;
437 }
438
439 private async renderOwnerElement(): Promise<LitHtml.TemplateResult|{}> {
440 if (this.frame) {
Wolfgang Beyerf0d985e2021-02-05 12:56:52441 const linkTargetDOMNode = await this.frame.getOwnerDOMNodeOrDocument();
442 if (linkTargetDOMNode) {
443 // Disabled until https://crbug.com/1079231 is fixed.
444 // clang-format off
445 return LitHtml.html`
446 <style>
Wolfgang Beyerddf051e2021-02-09 08:33:01447 .button-icon-with-text {
Wolfgang Beyerf0d985e2021-02-05 12:56:52448 vertical-align: sub;
449 }
Wolfgang Beyer09b0e8e2021-02-09 13:39:48450
451 .without-min-width {
452 min-width: auto;
453 }
Wolfgang Beyerf0d985e2021-02-05 12:56:52454 </style>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01455 <devtools-report-key>${i18nString(UIStrings.ownerElement)}</devtools-report-key>
Wolfgang Beyer09b0e8e2021-02-09 13:39:48456 <devtools-report-value class="without-min-width">
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01457 <button class="link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToRevealInElementsPanel)}
Wolfgang Beyerf0d985e2021-02-05 12:56:52458 @mouseenter=${(): Promise<void>|undefined => this.frame?.highlight()}
459 @mouseleave=${(): void => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()}
460 @click=${(): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode)}
461 >
462 <devtools-icon class="button-icon-with-text" .data=${{
463 iconName: 'elements_panel_icon',
464 color: 'var(--color-primary)',
465 width: '16px',
466 height: '16px',
467 } as Components.Icon.IconData}></devtools-icon>
468 <${linkTargetDOMNode.nodeName().toLocaleLowerCase()}>
Wolfgang Beyer09b0e8e2021-02-09 13:39:48469 </button>
Wolfgang Beyerf0d985e2021-02-05 12:56:52470 </devtools-report-value>
471 `;
472 // clang-format on
Wolfgang Beyer1525b1f2021-02-02 14:12:30473 }
474 }
475 return LitHtml.nothing;
476 }
477
478 private maybeRenderAdStatus(): LitHtml.TemplateResult|{} {
479 if (this.frame) {
480 if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Root) {
481 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01482 <devtools-report-key>${i18nString(UIStrings.adStatus)}</devtools-report-key>
483 <devtools-report-value title=${i18nString(UIStrings.thisFrameHasBeenIdentifiedAsThe)}>${
484 i18nString(UIStrings.root)}</devtools-report-value>
Wolfgang Beyer1525b1f2021-02-02 14:12:30485 `;
486 }
487 if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Child) {
488 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01489 <devtools-report-key>${i18nString(UIStrings.adStatus)}</devtools-report-key>
490 <devtools-report-value title=${i18nString(UIStrings.thisFrameHasBeenIdentifiedAsTheA)}>${
491 i18nString(UIStrings.child)}</devtools-report-value>
Wolfgang Beyer1525b1f2021-02-02 14:12:30492 `;
493 }
494 }
495 return LitHtml.nothing;
496 }
Wolfgang Beyerabfc8472021-02-04 11:29:50497
498 private renderIsolationSection(): LitHtml.TemplateResult|{} {
499 if (!this.frame) {
500 return LitHtml.nothing;
501 }
502 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01503 <devtools-report-section-header>${i18nString(UIStrings.securityIsolation)}</devtools-report-section-header>
504 <devtools-report-key>${i18nString(UIStrings.secureContext)}</devtools-report-key>
Wolfgang Beyerabfc8472021-02-04 11:29:50505 <devtools-report-value>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01506 ${this.frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
Wolfgang Beyerabfc8472021-02-04 11:29:50507 ${this.maybeRenderSecureContextExplanation()}
508 </devtools-report-value>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01509 <devtools-report-key>${i18nString(UIStrings.crossoriginIsolated)}</devtools-report-key>
Wolfgang Beyerabfc8472021-02-04 11:29:50510 <devtools-report-value>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01511 ${this.frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}
Wolfgang Beyerabfc8472021-02-04 11:29:50512 </devtools-report-value>
513 ${LitHtml.Directives.until(this.maybeRenderCoopCoepStatus(), LitHtml.nothing)}
514 <devtools-report-divider></devtools-report-divider>
515 `;
516 }
517
518 private maybeRenderSecureContextExplanation(): LitHtml.TemplateResult|{} {
519 const explanation = this.getSecureContextExplanation();
520 if (explanation) {
521 return LitHtml.html`
522 <span class="inline-comment">${explanation}</span>
523 `;
524 }
525 return LitHtml.nothing;
526 }
527
528 private getSecureContextExplanation(): Platform.UIString.LocalizedString|null {
529 switch (this.frame?.getSecureContextType()) {
530 case Protocol.Page.SecureContextType.Secure:
531 return null;
532 case Protocol.Page.SecureContextType.SecureLocalhost:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01533 return i18nString(UIStrings.localhostIsAlwaysASecureContext);
Wolfgang Beyerabfc8472021-02-04 11:29:50534 case Protocol.Page.SecureContextType.InsecureAncestor:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01535 return i18nString(UIStrings.aFrameAncestorIsAnInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50536 case Protocol.Page.SecureContextType.InsecureScheme:
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01537 return i18nString(UIStrings.theFramesSchemeIsInsecure);
Wolfgang Beyerabfc8472021-02-04 11:29:50538 }
539 return null;
540 }
541
542 private async maybeRenderCoopCoepStatus(): Promise<LitHtml.TemplateResult|{}> {
543 if (this.frame) {
544 const model = this.frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager);
545 const info = model && await model.getSecurityIsolationStatus(this.frame.id);
546 if (info) {
547 return LitHtml.html`
548 ${
549 this.maybeRenderCrossOriginStatus(
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01550 info.coep, i18nString(UIStrings.crossoriginEmbedderPolicy),
551 Protocol.Network.CrossOriginEmbedderPolicyValue.None)}
Wolfgang Beyerabfc8472021-02-04 11:29:50552 ${
553 this.maybeRenderCrossOriginStatus(
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01554 info.coop, i18nString(UIStrings.crossoriginOpenerPolicy),
555 Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)}
Wolfgang Beyerabfc8472021-02-04 11:29:50556 `;
557 }
558 }
559 return LitHtml.nothing;
560 }
561
562 private maybeRenderCrossOriginStatus(
563 info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined,
564 policyName: string,
565 noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue|
566 Protocol.Network.CrossOriginOpenerPolicyValue): LitHtml.TemplateResult|{} {
567 if (!info) {
568 return LitHtml.nothing;
569 }
570 const isEnabled = info.value !== noneValue;
571 const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue);
572 const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint;
573 return LitHtml.html`
574 <devtools-report-key>${policyName}</devtools-report-key>
575 <devtools-report-value>
576 ${isEnabled ? info.value : info.reportOnlyValue}
577 ${isReportOnly ? LitHtml.html`<span class="inline-comment">report-only</span>` : LitHtml.nothing}
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01578 ${
579 endpoint ? LitHtml.html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` :
580 LitHtml.nothing}
Wolfgang Beyerabfc8472021-02-04 11:29:50581 </devtools-report-value>
582 `;
583 }
Wolfgang Beyer6a6efe62021-02-04 15:56:21584
585 private renderApiAvailabilitySection(): LitHtml.TemplateResult|{} {
586 if (!this.frame) {
587 return LitHtml.nothing;
588 }
589
590 return LitHtml.html`
591 <style>
592 .span-cols {
593 grid-column-start: span 2;
594 margin: 0 0 8px 30px;
Jack Franklin49a94812021-02-05 14:20:12595 line-height: 28px;
Wolfgang Beyer6a6efe62021-02-04 15:56:21596 }
597 </style>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01598 <devtools-report-section-header>${i18nString(UIStrings.apiAvailability)}</devtools-report-section-header>
Wolfgang Beyer6a6efe62021-02-04 15:56:21599 <div class="span-cols">
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01600 ${i18nString(UIStrings.availabilityOfCertainApisDepends)}
Wolfgang Beyer6a6efe62021-02-04 15:56:21601 <x-link href="https://web.dev/why-coop-coep/" class="link">Learn more</x-link>
602 </div>
603 ${this.renderSharedArrayBufferAvailability()}
604 ${this.renderMeasureMemoryAvailability()}
605 <devtools-report-divider></devtools-report-divider>
606 `;
607 }
608
609 private renderSharedArrayBufferAvailability(): LitHtml.TemplateResult|{} {
610 if (this.frame) {
611 const features = this.frame.getGatedAPIFeatures();
612 if (features) {
613 const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers);
614 const sabTransferAvailable =
615 sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed);
616 const availabilityText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01617 i18nString(UIStrings.availableTransferable) :
618 (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable));
Wolfgang Beyer6a6efe62021-02-04 15:56:21619 const tooltipText = sabTransferAvailable ?
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01620 i18nString(UIStrings.sharedarraybufferConstructorIs) :
621 (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : '');
Wolfgang Beyer6a6efe62021-02-04 15:56:21622
623 // Disabled until https://crbug.com/1079231 is fixed.
624 // clang-format off
625 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01626 <devtools-report-key>${i18nString(UIStrings.sharedArrayBuffers)}</devtools-report-key>
Wolfgang Beyer6a6efe62021-02-04 15:56:21627 <devtools-report-value title=${tooltipText}>
628 ${availabilityText}
629 ${!this.frame.isCrossOriginIsolated() ?
630 (sabAvailable ?
631 LitHtml.html`<span class="inline-comment">${
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01632 i18nString(UIStrings.WillRequireCrossoriginIsolated)}</span>` :
633 LitHtml.html`<span class="inline-comment">${i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`) :
Wolfgang Beyer6a6efe62021-02-04 15:56:21634 LitHtml.nothing}
635 </devtools-report-value>
636 `;
637 // clang-format on
638 }
639 }
640 return LitHtml.nothing;
641 }
642
643 private renderMeasureMemoryAvailability(): LitHtml.TemplateResult|{} {
644 if (this.frame) {
645 const measureMemoryAvailable = this.frame.isCrossOriginIsolated();
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01646 const availabilityText =
647 measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable);
648 const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) :
649 i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory);
Wolfgang Beyer6a6efe62021-02-04 15:56:21650 return LitHtml.html`
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01651 <devtools-report-key>${i18nString(UIStrings.measureMemory)}</devtools-report-key>
Wolfgang Beyer6a6efe62021-02-04 15:56:21652 <devtools-report-value>
653 <span title=${tooltipText}>${availabilityText}</span>
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01654 <x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/">${
Wolfgang Beyer09b0e8e2021-02-09 13:39:48655 i18nString(UIStrings.learnMore)}</x-link>
Wolfgang Beyer6a6efe62021-02-04 15:56:21656 </devtools-report-value>
657 `;
658 }
659 return LitHtml.nothing;
660 }
Wolfgang Beyere5d1a9f2021-02-05 09:42:43661
662 private renderAdditionalInfoSection(): LitHtml.TemplateResult|{} {
663 if (!this.frame) {
664 return LitHtml.nothing;
665 }
666
667 return LitHtml.html`
668 <devtools-report-section-header
Vidal Guillermo Diazleal Ortega0a997bb2021-02-09 04:33:01669 title=${i18nString(UIStrings.thisAdditionalDebugging)}
670 >${i18nString(UIStrings.additionalInformation)}</devtools-report-section-header>
671 <devtools-report-key>${i18nString(UIStrings.frameId)}</devtools-report-key>
Wolfgang Beyere5d1a9f2021-02-05 09:42:43672 <devtools-report-value>
673 <div class="text-ellipsis" title=${this.frame.id}>${this.frame.id}</div>
674 </devtools-report-value>
675 <devtools-report-divider></devtools-report-divider>
676 `;
677 }
Wolfgang Beyer92395c92021-02-02 10:43:23678}
679
680customElements.define('devtools-resources-frame-details-view', FrameDetailsReportView);
681
682declare global {
683 // eslint-disable-next-line @typescript-eslint/no-unused-vars
684 interface HTMLElementTagNameMap {
685 'devtools-resources-frame-details-view': FrameDetailsReportView;
686 }
687}