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