Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 1 | // 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 Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 5 | import type * as Components from '../ui/components/components.js'; |
| 6 | |
Wolfgang Beyer | 2ed11a4 | 2020-09-30 07:24:54 | [diff] [blame] | 7 | import * as Bindings from '../bindings/bindings.js'; |
Sigurd Schneider | 1e5ad28 | 2020-07-17 11:52:08 | [diff] [blame] | 8 | import * as Common from '../common/common.js'; |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 9 | import * as LitHtml from '../third_party/lit-html/lit-html.js'; |
Sigurd Schneider | fc2bd21 | 2020-08-12 12:58:41 | [diff] [blame] | 10 | import * as Network from '../network/network.js'; |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 11 | import * as Platform from '../platform/platform.js'; |
Wolfgang Beyer | 95951c4d | 2020-10-23 08:00:06 | [diff] [blame] | 12 | import * as Root from '../root/root.js'; |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 13 | import * as SDK from '../sdk/sdk.js'; // eslint-disable-line no-unused-vars |
| 14 | import * as UI from '../ui/ui.js'; |
Sigurd Schneider | 1e5ad28 | 2020-07-17 11:52:08 | [diff] [blame] | 15 | import * as Workspace from '../workspace/workspace.js'; |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 16 | |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 17 | import * as i18n from '../i18n/i18n.js'; |
| 18 | export 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 | }; |
| 195 | const str_ = i18n.i18n.registerUIStrings('resources/FrameDetailsView.ts', UIStrings); |
| 196 | const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); |
Sigurd Schneider | 1e5ad28 | 2020-07-17 11:52:08 | [diff] [blame] | 197 | export class FrameDetailsView extends UI.ThrottledWidget.ThrottledWidget { |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 198 | private readonly reportView = new FrameDetailsReportView(); |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 199 | private readonly frame: SDK.ResourceTreeModel.ResourceTreeFrame; |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 200 | |
Wolfgang Beyer | 309863f | 2021-01-21 09:01:21 | [diff] [blame] | 201 | constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) { |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 202 | super(); |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 203 | this.frame = frame; |
| 204 | this.contentElement.classList.add('overflow-auto'); |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 205 | this.contentElement.appendChild(this.reportView); |
Sigurd Schneider | 1e5ad28 | 2020-07-17 11:52:08 | [diff] [blame] | 206 | this.update(); |
| 207 | } |
| 208 | |
Wolfgang Beyer | 309863f | 2021-01-21 09:01:21 | [diff] [blame] | 209 | async doUpdate(): Promise<void> { |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 210 | this.reportView.data = {frame: this.frame}; |
Sigurd Schneider | eabef96 | 2020-11-05 10:51:49 | [diff] [blame] | 211 | } |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 212 | } |
Wolfgang Beyer | 3b4747f | 2020-08-12 07:30:46 | [diff] [blame] | 213 | |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 214 | export interface FrameDetailsReportViewData { |
| 215 | frame: SDK.ResourceTreeModel.ResourceTreeFrame; |
| 216 | } |
| 217 | |
| 218 | export class FrameDetailsReportView extends HTMLElement { |
| 219 | private readonly shadow = this.attachShadow({mode: 'open'}); |
| 220 | private frame?: SDK.ResourceTreeModel.ResourceTreeFrame; |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 221 | private protocolMonitorExperimentEnabled = false; |
| 222 | |
| 223 | connectedCallback(): void { |
| 224 | this.protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocolMonitor'); |
| 225 | } |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 226 | |
| 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 Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 240 | <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 Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 265 | .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 Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 289 | .inline-items { |
| 290 | display: flex; |
| 291 | } |
| 292 | </style> |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 293 | <devtools-report .data=${{reportTitle: this.frame.displayName()} as Components.ReportView.ReportData}> |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 294 | ${this.renderDocumentSection()} |
| 295 | ${this.renderIsolationSection()} |
| 296 | ${this.renderApiAvailabilitySection()} |
| 297 | ${this.protocolMonitorExperimentEnabled ? this.renderAdditionalInfoSection() : LitHtml.nothing} |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 298 | </devtools-report> |
| 299 | `, this.shadow); |
| 300 | // clang-format on |
| 301 | } |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 302 | |
| 303 | private renderDocumentSection(): LitHtml.TemplateResult|{} { |
| 304 | if (!this.frame) { |
| 305 | return LitHtml.nothing; |
| 306 | } |
| 307 | |
| 308 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 309 | <devtools-report-section-header>${i18nString(UIStrings.document)}</devtools-report-section-header> |
| 310 | <devtools-report-key>${i18nString(UIStrings.url)}</devtools-report-key> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 311 | <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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 333 | i18nString(UIStrings.clickToRevealInSourcesPanel), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 334 | (): 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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 345 | i18nString(UIStrings.clickToRevealInNetworkPanel), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 346 | (): 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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 391 | <devtools-report-key>${i18nString(UIStrings.unreachableUrl)}</devtools-report-key> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 392 | <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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 407 | i18nString(UIStrings.clickToRevealInNetworkPanelMight), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 408 | (): |
| 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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 430 | <devtools-report-key>${i18nString(UIStrings.origin)}</devtools-report-key> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 431 | <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 Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 441 | 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 Beyer | ddf051e | 2021-02-09 08:33:01 | [diff] [blame] | 447 | .button-icon-with-text { |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 448 | vertical-align: sub; |
| 449 | } |
Wolfgang Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame^] | 450 | |
| 451 | .without-min-width { |
| 452 | min-width: auto; |
| 453 | } |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 454 | </style> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 455 | <devtools-report-key>${i18nString(UIStrings.ownerElement)}</devtools-report-key> |
Wolfgang Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame^] | 456 | <devtools-report-value class="without-min-width"> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 457 | <button class="link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToRevealInElementsPanel)} |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 458 | @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 Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame^] | 469 | </button> |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 470 | </devtools-report-value> |
| 471 | `; |
| 472 | // clang-format on |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 473 | } |
| 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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 482 | <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 Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 485 | `; |
| 486 | } |
| 487 | if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Child) { |
| 488 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 489 | <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 Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 492 | `; |
| 493 | } |
| 494 | } |
| 495 | return LitHtml.nothing; |
| 496 | } |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 497 | |
| 498 | private renderIsolationSection(): LitHtml.TemplateResult|{} { |
| 499 | if (!this.frame) { |
| 500 | return LitHtml.nothing; |
| 501 | } |
| 502 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 503 | <devtools-report-section-header>${i18nString(UIStrings.securityIsolation)}</devtools-report-section-header> |
| 504 | <devtools-report-key>${i18nString(UIStrings.secureContext)}</devtools-report-key> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 505 | <devtools-report-value> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 506 | ${this.frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 507 | ${this.maybeRenderSecureContextExplanation()} |
| 508 | </devtools-report-value> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 509 | <devtools-report-key>${i18nString(UIStrings.crossoriginIsolated)}</devtools-report-key> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 510 | <devtools-report-value> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 511 | ${this.frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 512 | </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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 533 | return i18nString(UIStrings.localhostIsAlwaysASecureContext); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 534 | case Protocol.Page.SecureContextType.InsecureAncestor: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 535 | return i18nString(UIStrings.aFrameAncestorIsAnInsecure); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 536 | case Protocol.Page.SecureContextType.InsecureScheme: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 537 | return i18nString(UIStrings.theFramesSchemeIsInsecure); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 538 | } |
| 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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 550 | info.coep, i18nString(UIStrings.crossoriginEmbedderPolicy), |
| 551 | Protocol.Network.CrossOriginEmbedderPolicyValue.None)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 552 | ${ |
| 553 | this.maybeRenderCrossOriginStatus( |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 554 | info.coop, i18nString(UIStrings.crossoriginOpenerPolicy), |
| 555 | Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 556 | `; |
| 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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 578 | ${ |
| 579 | endpoint ? LitHtml.html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` : |
| 580 | LitHtml.nothing} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 581 | </devtools-report-value> |
| 582 | `; |
| 583 | } |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 584 | |
| 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 Franklin | 49a9481 | 2021-02-05 14:20:12 | [diff] [blame] | 595 | line-height: 28px; |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 596 | } |
| 597 | </style> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 598 | <devtools-report-section-header>${i18nString(UIStrings.apiAvailability)}</devtools-report-section-header> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 599 | <div class="span-cols"> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 600 | ${i18nString(UIStrings.availabilityOfCertainApisDepends)} |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 601 | <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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 617 | i18nString(UIStrings.availableTransferable) : |
| 618 | (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable)); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 619 | const tooltipText = sabTransferAvailable ? |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 620 | i18nString(UIStrings.sharedarraybufferConstructorIs) : |
| 621 | (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : ''); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 622 | |
| 623 | // Disabled until https://crbug.com/1079231 is fixed. |
| 624 | // clang-format off |
| 625 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 626 | <devtools-report-key>${i18nString(UIStrings.sharedArrayBuffers)}</devtools-report-key> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 627 | <devtools-report-value title=${tooltipText}> |
| 628 | ${availabilityText} |
| 629 | ${!this.frame.isCrossOriginIsolated() ? |
| 630 | (sabAvailable ? |
| 631 | LitHtml.html`<span class="inline-comment">${ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 632 | i18nString(UIStrings.WillRequireCrossoriginIsolated)}</span>` : |
| 633 | LitHtml.html`<span class="inline-comment">${i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`) : |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 634 | 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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 646 | const availabilityText = |
| 647 | measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable); |
| 648 | const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) : |
| 649 | i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 650 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 651 | <devtools-report-key>${i18nString(UIStrings.measureMemory)}</devtools-report-key> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 652 | <devtools-report-value> |
| 653 | <span title=${tooltipText}>${availabilityText}</span> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 654 | <x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/">${ |
Wolfgang Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame^] | 655 | i18nString(UIStrings.learnMore)}</x-link> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 656 | </devtools-report-value> |
| 657 | `; |
| 658 | } |
| 659 | return LitHtml.nothing; |
| 660 | } |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 661 | |
| 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 Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 669 | title=${i18nString(UIStrings.thisAdditionalDebugging)} |
| 670 | >${i18nString(UIStrings.additionalInformation)}</devtools-report-section-header> |
| 671 | <devtools-report-key>${i18nString(UIStrings.frameId)}</devtools-report-key> |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 672 | <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 Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | customElements.define('devtools-resources-frame-details-view', FrameDetailsReportView); |
| 681 | |
| 682 | declare global { |
| 683 | // eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 684 | interface HTMLElementTagNameMap { |
| 685 | 'devtools-resources-frame-details-view': FrameDetailsReportView; |
| 686 | } |
| 687 | } |