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'; |
Tim van der Lippe | 5f62c6f | 2021-02-25 16:39:26 | [diff] [blame] | 13 | import * as SDK from '../sdk/sdk.js'; |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 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'; |
Sigurd Schneider | 173154c | 2021-02-18 14:18:38 | [diff] [blame] | 18 | |
Simon Zünd | 697fb0b | 2021-03-01 10:12:42 | [diff] [blame^] | 19 | const UIStrings = { |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 20 | /** |
| 21 | *@description Section header in the Frame Details view |
| 22 | */ |
| 23 | additionalInformation: 'Additional Information', |
| 24 | /** |
| 25 | *@description Explanation for why the additional information section is being shown |
| 26 | */ |
| 27 | thisAdditionalDebugging: |
| 28 | 'This additional (debugging) information is shown because the \'Protocol Monitor\' experiment is enabled.', |
| 29 | /** |
| 30 | *@description Label for subtitle of frame details view |
| 31 | */ |
| 32 | frameId: 'Frame ID', |
| 33 | /** |
| 34 | *@description Name of a network resource type |
| 35 | */ |
| 36 | document: 'Document', |
| 37 | /** |
| 38 | *@description Text for web URLs |
| 39 | */ |
| 40 | url: 'URL', |
| 41 | /** |
| 42 | *@description Title for a link to the Sources panel |
| 43 | */ |
| 44 | clickToRevealInSourcesPanel: 'Click to reveal in Sources panel', |
| 45 | /** |
| 46 | *@description Title for a link to the Network panel |
| 47 | */ |
| 48 | clickToRevealInNetworkPanel: 'Click to reveal in Network panel', |
| 49 | /** |
| 50 | *@description Title for unreachable URL field |
| 51 | */ |
| 52 | unreachableUrl: 'Unreachable URL', |
| 53 | /** |
| 54 | *@description Title for a link that applies a filter to the network panel |
| 55 | */ |
| 56 | clickToRevealInNetworkPanelMight: 'Click to reveal in Network panel (might require page reload)', |
| 57 | /** |
| 58 | *@description Text for the origin of something |
| 59 | */ |
| 60 | origin: 'Origin', |
| 61 | /** |
| 62 | *@description Related node label in Timeline UIUtils of the Performance panel |
| 63 | */ |
| 64 | ownerElement: 'Owner Element', |
| 65 | /** |
| 66 | *@description Title for a link to the Elements panel |
| 67 | */ |
| 68 | clickToRevealInElementsPanel: 'Click to reveal in Elements panel', |
| 69 | /** |
| 70 | *@description Title for ad frame type field |
| 71 | */ |
| 72 | adStatus: 'Ad Status', |
| 73 | /** |
| 74 | *@description Description for ad frame type |
| 75 | */ |
| 76 | thisFrameHasBeenIdentifiedAsThe: 'This frame has been identified as the root frame of an ad', |
| 77 | /** |
| 78 | *@description Value for ad frame type |
| 79 | */ |
| 80 | root: 'root', |
| 81 | /** |
| 82 | *@description Description for ad frame type |
| 83 | */ |
Peter Marshall | 3d96738 | 2021-02-25 06:56:18 | [diff] [blame] | 84 | thisFrameHasBeenIdentifiedAsTheA: 'This frame has been identified as a child frame of an ad', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 85 | /** |
| 86 | *@description Value for ad frame type |
| 87 | */ |
| 88 | child: 'child', |
| 89 | /** |
| 90 | *@description Section header in the Frame Details view |
| 91 | */ |
| 92 | securityIsolation: 'Security & Isolation', |
| 93 | /** |
| 94 | *@description Row title for in the Frame Details view |
| 95 | */ |
| 96 | secureContext: 'Secure Context', |
| 97 | /** |
| 98 | *@description Text in Timeline indicating that input has happened recently |
| 99 | */ |
| 100 | yes: 'Yes', |
| 101 | /** |
| 102 | *@description Text in Timeline indicating that input has not happened recently |
| 103 | */ |
| 104 | no: 'No', |
| 105 | /** |
| 106 | *@description Row title for in the Frame Details view |
| 107 | */ |
| 108 | crossoriginIsolated: 'Cross-Origin Isolated', |
| 109 | /** |
| 110 | *@description Explanatory text in the Frame Details view |
| 111 | */ |
| 112 | localhostIsAlwaysASecureContext: 'Localhost is always a secure context', |
| 113 | /** |
| 114 | *@description Explanatory text in the Frame Details view |
| 115 | */ |
| 116 | aFrameAncestorIsAnInsecure: 'A frame ancestor is an insecure context', |
| 117 | /** |
| 118 | *@description Explanatory text in the Frame Details view |
| 119 | */ |
| 120 | theFramesSchemeIsInsecure: 'The frame\'s scheme is insecure', |
| 121 | /** |
| 122 | *@description Row title in the Frame Details view |
| 123 | */ |
| 124 | crossoriginEmbedderPolicy: 'Cross-Origin Embedder Policy', |
| 125 | /** |
| 126 | *@description Row title in the Frame Details view |
| 127 | */ |
| 128 | crossoriginOpenerPolicy: 'Cross-Origin Opener Policy', |
| 129 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 130 | *@description This label specifies the server endpoints to which the server is reporting errors |
| 131 | *and warnings through the Report-to API. Following this label will be the URL of the server. |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 132 | */ |
| 133 | reportingTo: 'reporting to', |
| 134 | /** |
| 135 | *@description Section header in the Frame Details view |
| 136 | */ |
| 137 | apiAvailability: 'API availability', |
| 138 | /** |
| 139 | *@description Explanatory text in the Frame Details view for the API availability section |
| 140 | */ |
| 141 | availabilityOfCertainApisDepends: 'Availability of certain APIs depends on the document being cross-origin isolated.', |
| 142 | /** |
| 143 | *@description Description of the SharedArrayBuffer status |
| 144 | */ |
| 145 | availableTransferable: 'available, transferable', |
| 146 | /** |
| 147 | *@description Description of the SharedArrayBuffer status |
| 148 | */ |
| 149 | availableNotTransferable: 'available, not transferable', |
| 150 | /** |
| 151 | *@description Explanation for the SharedArrayBuffer availability status |
| 152 | */ |
| 153 | unavailable: 'unavailable', |
| 154 | /** |
| 155 | *@description Tooltip for the SharedArrayBuffer availability status |
| 156 | */ |
| 157 | sharedarraybufferConstructorIs: |
| 158 | 'SharedArrayBuffer constructor is available and SABs can be transferred via postMessage', |
| 159 | /** |
| 160 | *@description Tooltip for the SharedArrayBuffer availability status |
| 161 | */ |
| 162 | sharedarraybufferConstructorIsAvailable: |
| 163 | 'SharedArrayBuffer constructor is available but SABs cannot be transferred via postMessage', |
| 164 | /** |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 165 | *@description Explanation for the SharedArrayBuffer availability status |
| 166 | */ |
| 167 | WillRequireCrossoriginIsolated: '⚠️ will require cross-origin isolated context in the future', |
| 168 | /** |
| 169 | *@description Explanation for the SharedArrayBuffer availability status |
| 170 | */ |
| 171 | requiresCrossoriginIsolated: 'requires cross-origin isolated context', |
| 172 | /** |
| 173 | *@description Explanation for the Measure Memory availability status |
| 174 | */ |
| 175 | available: 'available', |
| 176 | /** |
| 177 | *@description Tooltip for the Measure Memory availability status |
| 178 | */ |
| 179 | thePerformanceAPI: 'The performance.measureUserAgentSpecificMemory() API is available', |
| 180 | /** |
| 181 | *@description Tooltip for the Measure Memory availability status |
| 182 | */ |
| 183 | thePerformancemeasureuseragentspecificmemory: 'The performance.measureUserAgentSpecificMemory() API is not available', |
| 184 | /** |
| 185 | *@description Entry in the API availability section of the frame details view |
| 186 | */ |
| 187 | measureMemory: 'Measure Memory', |
| 188 | /** |
| 189 | *@description Text that is usually a hyperlink to more documentation |
| 190 | */ |
| 191 | learnMore: 'Learn more', |
| 192 | }; |
| 193 | const str_ = i18n.i18n.registerUIStrings('resources/FrameDetailsView.ts', UIStrings); |
| 194 | const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); |
Sigurd Schneider | 1e5ad28 | 2020-07-17 11:52:08 | [diff] [blame] | 195 | export class FrameDetailsView extends UI.ThrottledWidget.ThrottledWidget { |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 196 | private readonly reportView = new FrameDetailsReportView(); |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 197 | private readonly frame: SDK.ResourceTreeModel.ResourceTreeFrame; |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 198 | |
Wolfgang Beyer | 309863f | 2021-01-21 09:01:21 | [diff] [blame] | 199 | constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) { |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 200 | super(); |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 201 | this.frame = frame; |
| 202 | this.contentElement.classList.add('overflow-auto'); |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 203 | this.contentElement.appendChild(this.reportView); |
Sigurd Schneider | 1e5ad28 | 2020-07-17 11:52:08 | [diff] [blame] | 204 | this.update(); |
| 205 | } |
| 206 | |
Wolfgang Beyer | 309863f | 2021-01-21 09:01:21 | [diff] [blame] | 207 | async doUpdate(): Promise<void> { |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 208 | this.reportView.data = {frame: this.frame}; |
Sigurd Schneider | eabef96 | 2020-11-05 10:51:49 | [diff] [blame] | 209 | } |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 210 | } |
Wolfgang Beyer | 3b4747f | 2020-08-12 07:30:46 | [diff] [blame] | 211 | |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 212 | export interface FrameDetailsReportViewData { |
| 213 | frame: SDK.ResourceTreeModel.ResourceTreeFrame; |
| 214 | } |
| 215 | |
| 216 | export class FrameDetailsReportView extends HTMLElement { |
| 217 | private readonly shadow = this.attachShadow({mode: 'open'}); |
| 218 | private frame?: SDK.ResourceTreeModel.ResourceTreeFrame; |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 219 | private protocolMonitorExperimentEnabled = false; |
| 220 | |
| 221 | connectedCallback(): void { |
| 222 | this.protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocolMonitor'); |
| 223 | } |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 224 | |
| 225 | set data(data: FrameDetailsReportViewData) { |
| 226 | this.frame = data.frame; |
| 227 | this.render(); |
| 228 | } |
| 229 | |
| 230 | private async render(): Promise<void> { |
| 231 | if (!this.frame) { |
| 232 | return; |
| 233 | } |
| 234 | |
| 235 | // Disabled until https://crbug.com/1079231 is fixed. |
| 236 | // clang-format off |
| 237 | LitHtml.render(LitHtml.html` |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 238 | <style> |
| 239 | .text-ellipsis { |
| 240 | overflow: hidden; |
| 241 | text-overflow: ellipsis; |
| 242 | white-space: nowrap; |
| 243 | } |
| 244 | |
| 245 | button ~ .text-ellipsis { |
| 246 | padding-left: 2px; |
| 247 | } |
| 248 | |
| 249 | .link { |
| 250 | color: var(--color-link); |
| 251 | text-decoration: underline; |
| 252 | cursor: pointer; |
| 253 | padding: 2px 0; /* adjust focus ring size */ |
| 254 | } |
| 255 | |
| 256 | button.link { |
| 257 | border: none; |
| 258 | background: none; |
| 259 | font-family: inherit; |
| 260 | font-size: inherit; |
| 261 | } |
| 262 | |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 263 | .inline-comment { |
| 264 | padding-left: 1ex; |
| 265 | white-space: pre-line; |
| 266 | } |
| 267 | |
| 268 | .inline-comment::before { |
| 269 | content: "("; |
| 270 | } |
| 271 | |
| 272 | .inline-comment::after { |
| 273 | content: ")"; |
| 274 | } |
| 275 | |
| 276 | .inline-name { |
| 277 | color: var(--color-text-secondary); |
| 278 | padding-left: 2ex; |
| 279 | user-select: none; |
| 280 | white-space: pre-line; |
| 281 | } |
| 282 | |
| 283 | .inline-name::after { |
| 284 | content: ':\u00a0'; |
| 285 | } |
| 286 | |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 287 | .inline-items { |
| 288 | display: flex; |
| 289 | } |
| 290 | </style> |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 291 | <devtools-report .data=${{reportTitle: this.frame.displayName()} as Components.ReportView.ReportData}> |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 292 | ${this.renderDocumentSection()} |
| 293 | ${this.renderIsolationSection()} |
| 294 | ${this.renderApiAvailabilitySection()} |
Sigurd Schneider | 173154c | 2021-02-18 14:18:38 | [diff] [blame] | 295 | ${LitHtml.Directives.until(this.renderPermissionPolicy(), LitHtml.nothing)} |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 296 | ${this.protocolMonitorExperimentEnabled ? this.renderAdditionalInfoSection() : LitHtml.nothing} |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 297 | </devtools-report> |
| 298 | `, this.shadow); |
| 299 | // clang-format on |
| 300 | } |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 301 | |
Sigurd Schneider | 173154c | 2021-02-18 14:18:38 | [diff] [blame] | 302 | private async renderPermissionPolicy(): Promise<LitHtml.TemplateResult|{}> { |
| 303 | const stats = await (this.frame && this.frame.getPermissionsPolicyState()); |
| 304 | if (!stats) { |
| 305 | return LitHtml.nothing; |
| 306 | } |
| 307 | const allowed = stats.filter(s => s.allowed).map(s => s.feature).sort(); |
| 308 | const disallowed = stats.filter(s => !s.allowed).map(s => s.feature).sort(); |
| 309 | return LitHtml.html`<devtools-report-section-header>Permissions Policy</devtools-report-section-header> |
| 310 | ${ |
| 311 | allowed.length ? LitHtml.html`<devtools-report-key>Allowed Features</devtools-report-key> |
| 312 | <devtools-report-value>${allowed.join(', ')}</devtools-report-value>` : |
| 313 | LitHtml.nothing} |
| 314 | ${ |
| 315 | disallowed.length ? LitHtml.html`<devtools-report-key>Disallowed Features</devtools-report-key> |
| 316 | <devtools-report-value>${disallowed.join(', ')}</devtools-report-value>` : |
| 317 | LitHtml.nothing} |
| 318 | `; |
| 319 | } |
| 320 | |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 321 | private renderDocumentSection(): LitHtml.TemplateResult|{} { |
| 322 | if (!this.frame) { |
| 323 | return LitHtml.nothing; |
| 324 | } |
| 325 | |
| 326 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 327 | <devtools-report-section-header>${i18nString(UIStrings.document)}</devtools-report-section-header> |
| 328 | <devtools-report-key>${i18nString(UIStrings.url)}</devtools-report-key> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 329 | <devtools-report-value> |
| 330 | <div class="inline-items"> |
| 331 | ${this.maybeRenderSourcesLinkForURL()} |
| 332 | ${this.maybeRenderNetworkLinkForURL()} |
| 333 | <div class="text-ellipsis" title=${this.frame.url}>${this.frame.url}</div> |
| 334 | </div> |
| 335 | </devtools-report-value> |
| 336 | ${this.maybeRenderUnreachableURL()} |
| 337 | ${this.maybeRenderOrigin()} |
| 338 | ${LitHtml.Directives.until(this.renderOwnerElement(), LitHtml.nothing)} |
| 339 | ${this.maybeRenderAdStatus()} |
| 340 | <devtools-report-divider></devtools-report-divider> |
| 341 | `; |
| 342 | } |
| 343 | |
| 344 | private maybeRenderSourcesLinkForURL(): LitHtml.TemplateResult|{} { |
| 345 | if (!this.frame || this.frame.unreachableUrl()) { |
| 346 | return LitHtml.nothing; |
| 347 | } |
| 348 | const sourceCode = this.uiSourceCodeForFrame(this.frame); |
| 349 | return this.renderIconLink( |
| 350 | 'sources_panel_icon', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 351 | i18nString(UIStrings.clickToRevealInSourcesPanel), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 352 | (): Promise<void> => Common.Revealer.reveal(sourceCode), |
| 353 | ); |
| 354 | } |
| 355 | |
| 356 | private maybeRenderNetworkLinkForURL(): LitHtml.TemplateResult|{} { |
| 357 | if (this.frame) { |
| 358 | const resource = this.frame.resourceForURL(this.frame.url); |
| 359 | if (resource && resource.request) { |
| 360 | const request = resource.request; |
| 361 | return this.renderIconLink( |
| 362 | 'network_panel_icon', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 363 | i18nString(UIStrings.clickToRevealInNetworkPanel), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 364 | (): Promise<void> => |
| 365 | Network.NetworkPanel.NetworkPanel.selectAndShowRequest(request, Network.NetworkItemView.Tabs.Headers), |
| 366 | ); |
| 367 | } |
| 368 | } |
| 369 | return LitHtml.nothing; |
| 370 | } |
| 371 | |
| 372 | private renderIconLink( |
| 373 | iconName: string, title: Platform.UIString.LocalizedString, |
| 374 | clickHandler: (() => void)|(() => Promise<void>)): LitHtml.TemplateResult { |
| 375 | // Disabled until https://crbug.com/1079231 is fixed. |
| 376 | // clang-format off |
| 377 | return LitHtml.html` |
| 378 | <button class="link" role="link" tabindex=0 @click=${clickHandler} title=${title}> |
| 379 | <devtools-icon .data=${{ |
| 380 | iconName: iconName, |
| 381 | color: 'var(--color-primary)', |
| 382 | width: '16px', |
| 383 | height: '16px', |
| 384 | } as Components.Icon.IconData}> |
| 385 | </button> |
| 386 | `; |
| 387 | // clang-format on |
| 388 | } |
| 389 | |
| 390 | private uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode |
| 391 | |null { |
| 392 | for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) { |
| 393 | const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project); |
| 394 | if (projectTarget && projectTarget === frame.resourceTreeModel().target()) { |
| 395 | const uiSourceCode = project.uiSourceCodeForURL(frame.url); |
| 396 | if (uiSourceCode) { |
| 397 | return uiSourceCode; |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | return null; |
| 402 | } |
| 403 | |
| 404 | private maybeRenderUnreachableURL(): LitHtml.TemplateResult|{} { |
| 405 | if (!this.frame || !this.frame.unreachableUrl()) { |
| 406 | return LitHtml.nothing; |
| 407 | } |
| 408 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 409 | <devtools-report-key>${i18nString(UIStrings.unreachableUrl)}</devtools-report-key> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 410 | <devtools-report-value> |
| 411 | <div class="inline-items"> |
| 412 | ${this.renderNetworkLinkForUnreachableURL()} |
| 413 | <div class="text-ellipsis" title=${this.frame.unreachableUrl()}>${this.frame.unreachableUrl()}</div> |
| 414 | </div> |
| 415 | </devtools-report-value> |
| 416 | `; |
| 417 | } |
| 418 | |
| 419 | private renderNetworkLinkForUnreachableURL(): LitHtml.TemplateResult|{} { |
| 420 | if (this.frame) { |
| 421 | const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(this.frame.unreachableUrl()); |
| 422 | if (unreachableUrl) { |
| 423 | return this.renderIconLink( |
| 424 | 'network_panel_icon', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 425 | i18nString(UIStrings.clickToRevealInNetworkPanelMight), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 426 | (): |
| 427 | void => { |
| 428 | Network.NetworkPanel.NetworkPanel.revealAndFilter([ |
| 429 | { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 430 | // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration) |
| 431 | // @ts-expect-error |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 432 | filterType: 'domain', |
| 433 | filterValue: unreachableUrl.domain(), |
| 434 | }, |
| 435 | { |
| 436 | filterType: null, |
| 437 | filterValue: unreachableUrl.path, |
| 438 | }, |
| 439 | ]); |
| 440 | }, |
| 441 | ); |
| 442 | } |
| 443 | } |
| 444 | return LitHtml.nothing; |
| 445 | } |
| 446 | |
| 447 | private maybeRenderOrigin(): LitHtml.TemplateResult|{} { |
| 448 | if (this.frame && this.frame.securityOrigin && this.frame.securityOrigin !== '://') { |
| 449 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 450 | <devtools-report-key>${i18nString(UIStrings.origin)}</devtools-report-key> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 451 | <devtools-report-value> |
| 452 | <div class="text-ellipsis" title=${this.frame.securityOrigin}>${this.frame.securityOrigin}</div> |
| 453 | </devtools-report-value> |
| 454 | `; |
| 455 | } |
| 456 | return LitHtml.nothing; |
| 457 | } |
| 458 | |
| 459 | private async renderOwnerElement(): Promise<LitHtml.TemplateResult|{}> { |
| 460 | if (this.frame) { |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 461 | const linkTargetDOMNode = await this.frame.getOwnerDOMNodeOrDocument(); |
| 462 | if (linkTargetDOMNode) { |
| 463 | // Disabled until https://crbug.com/1079231 is fixed. |
| 464 | // clang-format off |
| 465 | return LitHtml.html` |
| 466 | <style> |
Wolfgang Beyer | ddf051e | 2021-02-09 08:33:01 | [diff] [blame] | 467 | .button-icon-with-text { |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 468 | vertical-align: sub; |
| 469 | } |
Wolfgang Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame] | 470 | |
| 471 | .without-min-width { |
| 472 | min-width: auto; |
| 473 | } |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 474 | </style> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 475 | <devtools-report-key>${i18nString(UIStrings.ownerElement)}</devtools-report-key> |
Wolfgang Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame] | 476 | <devtools-report-value class="without-min-width"> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 477 | <button class="link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToRevealInElementsPanel)} |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 478 | @mouseenter=${(): Promise<void>|undefined => this.frame?.highlight()} |
| 479 | @mouseleave=${(): void => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()} |
| 480 | @click=${(): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode)} |
| 481 | > |
| 482 | <devtools-icon class="button-icon-with-text" .data=${{ |
| 483 | iconName: 'elements_panel_icon', |
| 484 | color: 'var(--color-primary)', |
| 485 | width: '16px', |
| 486 | height: '16px', |
| 487 | } as Components.Icon.IconData}></devtools-icon> |
| 488 | <${linkTargetDOMNode.nodeName().toLocaleLowerCase()}> |
Wolfgang Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame] | 489 | </button> |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 490 | </devtools-report-value> |
| 491 | `; |
| 492 | // clang-format on |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 493 | } |
| 494 | } |
| 495 | return LitHtml.nothing; |
| 496 | } |
| 497 | |
| 498 | private maybeRenderAdStatus(): LitHtml.TemplateResult|{} { |
| 499 | if (this.frame) { |
| 500 | if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Root) { |
| 501 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 502 | <devtools-report-key>${i18nString(UIStrings.adStatus)}</devtools-report-key> |
| 503 | <devtools-report-value title=${i18nString(UIStrings.thisFrameHasBeenIdentifiedAsThe)}>${ |
| 504 | i18nString(UIStrings.root)}</devtools-report-value> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 505 | `; |
| 506 | } |
| 507 | if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Child) { |
| 508 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 509 | <devtools-report-key>${i18nString(UIStrings.adStatus)}</devtools-report-key> |
| 510 | <devtools-report-value title=${i18nString(UIStrings.thisFrameHasBeenIdentifiedAsTheA)}>${ |
| 511 | i18nString(UIStrings.child)}</devtools-report-value> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 512 | `; |
| 513 | } |
| 514 | } |
| 515 | return LitHtml.nothing; |
| 516 | } |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 517 | |
| 518 | private renderIsolationSection(): LitHtml.TemplateResult|{} { |
| 519 | if (!this.frame) { |
| 520 | return LitHtml.nothing; |
| 521 | } |
| 522 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 523 | <devtools-report-section-header>${i18nString(UIStrings.securityIsolation)}</devtools-report-section-header> |
| 524 | <devtools-report-key>${i18nString(UIStrings.secureContext)}</devtools-report-key> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 525 | <devtools-report-value> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 526 | ${this.frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 527 | ${this.maybeRenderSecureContextExplanation()} |
| 528 | </devtools-report-value> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 529 | <devtools-report-key>${i18nString(UIStrings.crossoriginIsolated)}</devtools-report-key> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 530 | <devtools-report-value> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 531 | ${this.frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 532 | </devtools-report-value> |
| 533 | ${LitHtml.Directives.until(this.maybeRenderCoopCoepStatus(), LitHtml.nothing)} |
| 534 | <devtools-report-divider></devtools-report-divider> |
| 535 | `; |
| 536 | } |
| 537 | |
| 538 | private maybeRenderSecureContextExplanation(): LitHtml.TemplateResult|{} { |
| 539 | const explanation = this.getSecureContextExplanation(); |
| 540 | if (explanation) { |
| 541 | return LitHtml.html` |
| 542 | <span class="inline-comment">${explanation}</span> |
| 543 | `; |
| 544 | } |
| 545 | return LitHtml.nothing; |
| 546 | } |
| 547 | |
| 548 | private getSecureContextExplanation(): Platform.UIString.LocalizedString|null { |
| 549 | switch (this.frame?.getSecureContextType()) { |
| 550 | case Protocol.Page.SecureContextType.Secure: |
| 551 | return null; |
| 552 | case Protocol.Page.SecureContextType.SecureLocalhost: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 553 | return i18nString(UIStrings.localhostIsAlwaysASecureContext); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 554 | case Protocol.Page.SecureContextType.InsecureAncestor: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 555 | return i18nString(UIStrings.aFrameAncestorIsAnInsecure); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 556 | case Protocol.Page.SecureContextType.InsecureScheme: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 557 | return i18nString(UIStrings.theFramesSchemeIsInsecure); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 558 | } |
| 559 | return null; |
| 560 | } |
| 561 | |
| 562 | private async maybeRenderCoopCoepStatus(): Promise<LitHtml.TemplateResult|{}> { |
| 563 | if (this.frame) { |
| 564 | const model = this.frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager); |
| 565 | const info = model && await model.getSecurityIsolationStatus(this.frame.id); |
| 566 | if (info) { |
| 567 | return LitHtml.html` |
| 568 | ${ |
| 569 | this.maybeRenderCrossOriginStatus( |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 570 | info.coep, i18nString(UIStrings.crossoriginEmbedderPolicy), |
| 571 | Protocol.Network.CrossOriginEmbedderPolicyValue.None)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 572 | ${ |
| 573 | this.maybeRenderCrossOriginStatus( |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 574 | info.coop, i18nString(UIStrings.crossoriginOpenerPolicy), |
| 575 | Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 576 | `; |
| 577 | } |
| 578 | } |
| 579 | return LitHtml.nothing; |
| 580 | } |
| 581 | |
| 582 | private maybeRenderCrossOriginStatus( |
| 583 | info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined, |
| 584 | policyName: string, |
| 585 | noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue| |
| 586 | Protocol.Network.CrossOriginOpenerPolicyValue): LitHtml.TemplateResult|{} { |
| 587 | if (!info) { |
| 588 | return LitHtml.nothing; |
| 589 | } |
| 590 | const isEnabled = info.value !== noneValue; |
| 591 | const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue); |
| 592 | const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint; |
| 593 | return LitHtml.html` |
| 594 | <devtools-report-key>${policyName}</devtools-report-key> |
| 595 | <devtools-report-value> |
| 596 | ${isEnabled ? info.value : info.reportOnlyValue} |
| 597 | ${isReportOnly ? LitHtml.html`<span class="inline-comment">report-only</span>` : LitHtml.nothing} |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 598 | ${ |
| 599 | endpoint ? LitHtml.html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` : |
| 600 | LitHtml.nothing} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 601 | </devtools-report-value> |
| 602 | `; |
| 603 | } |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 604 | |
| 605 | private renderApiAvailabilitySection(): LitHtml.TemplateResult|{} { |
| 606 | if (!this.frame) { |
| 607 | return LitHtml.nothing; |
| 608 | } |
| 609 | |
| 610 | return LitHtml.html` |
| 611 | <style> |
| 612 | .span-cols { |
| 613 | grid-column-start: span 2; |
| 614 | margin: 0 0 8px 30px; |
Jack Franklin | 49a9481 | 2021-02-05 14:20:12 | [diff] [blame] | 615 | line-height: 28px; |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 616 | } |
| 617 | </style> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 618 | <devtools-report-section-header>${i18nString(UIStrings.apiAvailability)}</devtools-report-section-header> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 619 | <div class="span-cols"> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 620 | ${i18nString(UIStrings.availabilityOfCertainApisDepends)} |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 621 | <x-link href="https://web.dev/why-coop-coep/" class="link">Learn more</x-link> |
| 622 | </div> |
| 623 | ${this.renderSharedArrayBufferAvailability()} |
| 624 | ${this.renderMeasureMemoryAvailability()} |
| 625 | <devtools-report-divider></devtools-report-divider> |
| 626 | `; |
| 627 | } |
| 628 | |
| 629 | private renderSharedArrayBufferAvailability(): LitHtml.TemplateResult|{} { |
| 630 | if (this.frame) { |
| 631 | const features = this.frame.getGatedAPIFeatures(); |
| 632 | if (features) { |
| 633 | const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers); |
| 634 | const sabTransferAvailable = |
| 635 | sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed); |
| 636 | const availabilityText = sabTransferAvailable ? |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 637 | i18nString(UIStrings.availableTransferable) : |
| 638 | (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable)); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 639 | const tooltipText = sabTransferAvailable ? |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 640 | i18nString(UIStrings.sharedarraybufferConstructorIs) : |
| 641 | (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : ''); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 642 | |
Peter Marshall | 0e1cd82 | 2021-02-24 10:52:42 | [diff] [blame] | 643 | // SharedArrayBuffer is an API name, so we don't translate it. |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 644 | // Disabled until https://crbug.com/1079231 is fixed. |
| 645 | // clang-format off |
| 646 | return LitHtml.html` |
Peter Marshall | 0e1cd82 | 2021-02-24 10:52:42 | [diff] [blame] | 647 | <devtools-report-key>SharedArrayBuffers</devtools-report-key> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 648 | <devtools-report-value title=${tooltipText}> |
| 649 | ${availabilityText} |
| 650 | ${!this.frame.isCrossOriginIsolated() ? |
| 651 | (sabAvailable ? |
| 652 | LitHtml.html`<span class="inline-comment">${ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 653 | i18nString(UIStrings.WillRequireCrossoriginIsolated)}</span>` : |
| 654 | LitHtml.html`<span class="inline-comment">${i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`) : |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 655 | LitHtml.nothing} |
| 656 | </devtools-report-value> |
| 657 | `; |
| 658 | // clang-format on |
| 659 | } |
| 660 | } |
| 661 | return LitHtml.nothing; |
| 662 | } |
| 663 | |
| 664 | private renderMeasureMemoryAvailability(): LitHtml.TemplateResult|{} { |
| 665 | if (this.frame) { |
| 666 | const measureMemoryAvailable = this.frame.isCrossOriginIsolated(); |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 667 | const availabilityText = |
| 668 | measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable); |
| 669 | const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) : |
| 670 | i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 671 | return LitHtml.html` |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 672 | <devtools-report-key>${i18nString(UIStrings.measureMemory)}</devtools-report-key> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 673 | <devtools-report-value> |
| 674 | <span title=${tooltipText}>${availabilityText}</span> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 675 | <x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/">${ |
Wolfgang Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame] | 676 | i18nString(UIStrings.learnMore)}</x-link> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 677 | </devtools-report-value> |
| 678 | `; |
| 679 | } |
| 680 | return LitHtml.nothing; |
| 681 | } |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 682 | |
| 683 | private renderAdditionalInfoSection(): LitHtml.TemplateResult|{} { |
| 684 | if (!this.frame) { |
| 685 | return LitHtml.nothing; |
| 686 | } |
| 687 | |
| 688 | return LitHtml.html` |
| 689 | <devtools-report-section-header |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 690 | title=${i18nString(UIStrings.thisAdditionalDebugging)} |
| 691 | >${i18nString(UIStrings.additionalInformation)}</devtools-report-section-header> |
| 692 | <devtools-report-key>${i18nString(UIStrings.frameId)}</devtools-report-key> |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 693 | <devtools-report-value> |
| 694 | <div class="text-ellipsis" title=${this.frame.id}>${this.frame.id}</div> |
| 695 | </devtools-report-value> |
| 696 | <devtools-report-divider></devtools-report-divider> |
| 697 | `; |
| 698 | } |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | customElements.define('devtools-resources-frame-details-view', FrameDetailsReportView); |
| 702 | |
| 703 | declare global { |
| 704 | // eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 705 | interface HTMLElementTagNameMap { |
| 706 | 'devtools-resources-frame-details-view': FrameDetailsReportView; |
| 707 | } |
| 708 | } |