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 | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 5 | import type {StackTraceData} from './StackTrace.js'; |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 6 | import {StackTrace} from './StackTrace.js'; |
Tim van der Lippe | 1bd5e21 | 2021-05-06 10:54:29 | [diff] [blame] | 7 | import * as Bindings from '../../../models/bindings/bindings.js'; |
| 8 | import * as Common from '../../../core/common/common.js'; |
| 9 | import * as i18n from '../../../core/i18n/i18n.js'; |
| 10 | import * as Network from '../../network/network.js'; |
Jack Franklin | a75ae7c | 2021-05-11 13:22:54 | [diff] [blame] | 11 | import type * as Platform from '../../../core/platform/platform.js'; |
Tim van der Lippe | 1bd5e21 | 2021-05-06 10:54:29 | [diff] [blame] | 12 | import * as Root from '../../../core/root/root.js'; |
| 13 | import * as SDK from '../../../core/sdk/sdk.js'; // eslint-disable-line no-unused-vars |
Paul Lewis | 01f4939 | 2021-05-10 13:54:20 | [diff] [blame] | 14 | import * as LitHtml from '../../../ui/lit-html/lit-html.js'; |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 15 | import * as ReportView from '../../../ui/components/report_view/report_view.js'; |
| 16 | import * as IconButton from '../../../ui/components/icon_button/icon_button.js'; |
Tim van der Lippe | 1bd5e21 | 2021-05-06 10:54:29 | [diff] [blame] | 17 | import * as ComponentHelpers from '../../../ui/components/helpers/helpers.js'; |
| 18 | import * as UI from '../../../ui/legacy/legacy.js'; |
| 19 | import * as Workspace from '../../../models/workspace/workspace.js'; |
| 20 | import * as Components from '../../../ui/legacy/components/utils/utils.js'; |
Tim van der Lippe | 229a54f | 2021-05-14 16:59:05 | [diff] [blame] | 21 | import * as Protocol from '../../../generated/protocol.js'; |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 22 | |
Simon Zünd | 697fb0b | 2021-03-01 10:12:42 | [diff] [blame] | 23 | const UIStrings = { |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 24 | /** |
| 25 | *@description Section header in the Frame Details view |
| 26 | */ |
| 27 | additionalInformation: 'Additional Information', |
| 28 | /** |
| 29 | *@description Explanation for why the additional information section is being shown |
| 30 | */ |
| 31 | thisAdditionalDebugging: |
| 32 | 'This additional (debugging) information is shown because the \'Protocol Monitor\' experiment is enabled.', |
| 33 | /** |
| 34 | *@description Label for subtitle of frame details view |
| 35 | */ |
| 36 | frameId: 'Frame ID', |
| 37 | /** |
| 38 | *@description Name of a network resource type |
| 39 | */ |
| 40 | document: 'Document', |
| 41 | /** |
| 42 | *@description Text for web URLs |
| 43 | */ |
| 44 | url: 'URL', |
| 45 | /** |
| 46 | *@description Title for a link to the Sources panel |
| 47 | */ |
| 48 | clickToRevealInSourcesPanel: 'Click to reveal in Sources panel', |
| 49 | /** |
| 50 | *@description Title for a link to the Network panel |
| 51 | */ |
| 52 | clickToRevealInNetworkPanel: 'Click to reveal in Network panel', |
| 53 | /** |
| 54 | *@description Title for unreachable URL field |
| 55 | */ |
| 56 | unreachableUrl: 'Unreachable URL', |
| 57 | /** |
| 58 | *@description Title for a link that applies a filter to the network panel |
| 59 | */ |
| 60 | clickToRevealInNetworkPanelMight: 'Click to reveal in Network panel (might require page reload)', |
| 61 | /** |
| 62 | *@description Text for the origin of something |
| 63 | */ |
| 64 | origin: 'Origin', |
| 65 | /** |
| 66 | *@description Related node label in Timeline UIUtils of the Performance panel |
| 67 | */ |
| 68 | ownerElement: 'Owner Element', |
| 69 | /** |
| 70 | *@description Title for a link to the Elements panel |
| 71 | */ |
| 72 | clickToRevealInElementsPanel: 'Click to reveal in Elements panel', |
| 73 | /** |
| 74 | *@description Title for ad frame type field |
| 75 | */ |
| 76 | adStatus: 'Ad Status', |
| 77 | /** |
| 78 | *@description Description for ad frame type |
| 79 | */ |
| 80 | thisFrameHasBeenIdentifiedAsThe: 'This frame has been identified as the root frame of an ad', |
| 81 | /** |
| 82 | *@description Value for ad frame type |
| 83 | */ |
| 84 | root: 'root', |
| 85 | /** |
| 86 | *@description Description for ad frame type |
| 87 | */ |
Peter Marshall | 3d96738 | 2021-02-25 06:56:18 | [diff] [blame] | 88 | 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] | 89 | /** |
| 90 | *@description Value for ad frame type |
| 91 | */ |
| 92 | child: 'child', |
| 93 | /** |
| 94 | *@description Section header in the Frame Details view |
| 95 | */ |
| 96 | securityIsolation: 'Security & Isolation', |
| 97 | /** |
| 98 | *@description Row title for in the Frame Details view |
| 99 | */ |
| 100 | secureContext: 'Secure Context', |
| 101 | /** |
| 102 | *@description Text in Timeline indicating that input has happened recently |
| 103 | */ |
| 104 | yes: 'Yes', |
| 105 | /** |
| 106 | *@description Text in Timeline indicating that input has not happened recently |
| 107 | */ |
| 108 | no: 'No', |
| 109 | /** |
| 110 | *@description Row title for in the Frame Details view |
| 111 | */ |
| 112 | crossoriginIsolated: 'Cross-Origin Isolated', |
| 113 | /** |
| 114 | *@description Explanatory text in the Frame Details view |
| 115 | */ |
| 116 | localhostIsAlwaysASecureContext: 'Localhost is always a secure context', |
| 117 | /** |
| 118 | *@description Explanatory text in the Frame Details view |
| 119 | */ |
| 120 | aFrameAncestorIsAnInsecure: 'A frame ancestor is an insecure context', |
| 121 | /** |
| 122 | *@description Explanatory text in the Frame Details view |
| 123 | */ |
| 124 | theFramesSchemeIsInsecure: 'The frame\'s scheme is insecure', |
| 125 | /** |
| 126 | *@description Row title in the Frame Details view |
| 127 | */ |
| 128 | crossoriginEmbedderPolicy: 'Cross-Origin Embedder Policy', |
| 129 | /** |
| 130 | *@description Row title in the Frame Details view |
| 131 | */ |
| 132 | crossoriginOpenerPolicy: 'Cross-Origin Opener Policy', |
| 133 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 134 | *@description This label specifies the server endpoints to which the server is reporting errors |
| 135 | *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] | 136 | */ |
| 137 | reportingTo: 'reporting to', |
| 138 | /** |
| 139 | *@description Section header in the Frame Details view |
| 140 | */ |
| 141 | apiAvailability: 'API availability', |
| 142 | /** |
| 143 | *@description Explanatory text in the Frame Details view for the API availability section |
| 144 | */ |
| 145 | availabilityOfCertainApisDepends: 'Availability of certain APIs depends on the document being cross-origin isolated.', |
| 146 | /** |
| 147 | *@description Description of the SharedArrayBuffer status |
| 148 | */ |
| 149 | availableTransferable: 'available, transferable', |
| 150 | /** |
| 151 | *@description Description of the SharedArrayBuffer status |
| 152 | */ |
| 153 | availableNotTransferable: 'available, not transferable', |
| 154 | /** |
| 155 | *@description Explanation for the SharedArrayBuffer availability status |
| 156 | */ |
| 157 | unavailable: 'unavailable', |
| 158 | /** |
| 159 | *@description Tooltip for the SharedArrayBuffer availability status |
| 160 | */ |
| 161 | sharedarraybufferConstructorIs: |
| 162 | 'SharedArrayBuffer constructor is available and SABs can be transferred via postMessage', |
| 163 | /** |
| 164 | *@description Tooltip for the SharedArrayBuffer availability status |
| 165 | */ |
| 166 | sharedarraybufferConstructorIsAvailable: |
| 167 | 'SharedArrayBuffer constructor is available but SABs cannot be transferred via postMessage', |
| 168 | /** |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 169 | *@description Explanation for the SharedArrayBuffer availability status |
| 170 | */ |
Sigurd Schneider | 2a45025 | 2021-05-04 07:13:15 | [diff] [blame] | 171 | willRequireCrossoriginIsolated: '⚠️ will require cross-origin isolated context in the future', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 172 | /** |
| 173 | *@description Explanation for the SharedArrayBuffer availability status |
| 174 | */ |
| 175 | requiresCrossoriginIsolated: 'requires cross-origin isolated context', |
| 176 | /** |
Sigurd Schneider | f7e58be | 2021-05-14 14:41:52 | [diff] [blame] | 177 | *@description Explanation for the SharedArrayBuffer availability status in case the transfer of a SAB requires the |
| 178 | * permission policy `cross-origin-isolated` to be enabled (e.g. because the message refers to the situation in an iframe). |
| 179 | */ |
| 180 | transferRequiresCrossoriginIsolatedPermission: |
| 181 | '`SharedArrayBuffer` transfer requires enabling the permission policy:', |
Sigurd Schneider | 2a45025 | 2021-05-04 07:13:15 | [diff] [blame] | 182 | /** |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 183 | *@description Explanation for the Measure Memory availability status |
| 184 | */ |
| 185 | available: 'available', |
| 186 | /** |
| 187 | *@description Tooltip for the Measure Memory availability status |
| 188 | */ |
| 189 | thePerformanceAPI: 'The performance.measureUserAgentSpecificMemory() API is available', |
| 190 | /** |
| 191 | *@description Tooltip for the Measure Memory availability status |
| 192 | */ |
| 193 | thePerformancemeasureuseragentspecificmemory: 'The performance.measureUserAgentSpecificMemory() API is not available', |
| 194 | /** |
| 195 | *@description Entry in the API availability section of the frame details view |
| 196 | */ |
| 197 | measureMemory: 'Measure Memory', |
| 198 | /** |
| 199 | *@description Text that is usually a hyperlink to more documentation |
| 200 | */ |
| 201 | learnMore: 'Learn more', |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 202 | /** |
Wolfgang Beyer | 4083492 | 2021-05-10 08:34:22 | [diff] [blame] | 203 | *@description Label for a stack trace. If a frame is created programmatically (i.e. via JavaScript), there is a |
| 204 | * stack trace for the line of code which caused the creation of the iframe. This is the stack trace we are showing here. |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 205 | */ |
| 206 | creationStackTrace: 'Frame Creation Stack Trace', |
| 207 | /** |
| 208 | *@description Tooltip for 'Frame Creation Stack Trace' explaining that the stack |
| 209 | *trace shows where in the code the frame has been created programmatically |
| 210 | */ |
| 211 | creationStackTraceExplanation: 'This frame was created programmatically. The stack trace shows where this happened.', |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 212 | /** |
| 213 | *@description Label for a button. When clicked more details (for the content this button refers to) will be shown. |
| 214 | */ |
| 215 | showDetails: 'Show details', |
| 216 | /** |
| 217 | *@description Label for a button. When clicked some details (for the content this button refers to) will be hidden. |
| 218 | */ |
| 219 | hideDetails: 'Hide details', |
| 220 | /** |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 221 | *@description Label for a list of features which are allowed according to the current Permissions policy |
| 222 | *(a mechanism that allows developers to enable/disable browser features and APIs (e.g. camera, geolocation, autoplay)) |
| 223 | */ |
| 224 | allowedFeatures: 'Allowed Features', |
| 225 | /** |
| 226 | *@description Label for a list of features which are disabled according to the current Permissions policy |
| 227 | *(a mechanism that allows developers to enable/disable browser features and APIs (e.g. camera, geolocation, autoplay)) |
| 228 | */ |
| 229 | disabledFeatures: 'Disabled Features', |
| 230 | /** |
| 231 | *@description Tooltip text for a link to a specific request's headers in the Network panel. |
| 232 | */ |
| 233 | clickToShowHeader: 'Click to reveal the request whose "`Permissions-Policy`" HTTP header disables this feature.', |
| 234 | /** |
Wolfgang Beyer | 4083492 | 2021-05-10 08:34:22 | [diff] [blame] | 235 | *@description Tooltip text for a link to a specific iframe in the Elements panel (Iframes can be nested, the link goes |
| 236 | * to the outer-most iframe which blocks a certain feature). |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 237 | */ |
| 238 | clickToShowIframe: 'Click to reveal the top-most iframe which does not allow this feature in the elements panel.', |
| 239 | /** |
| 240 | *@description Text describing that a specific feature is blocked by not being included in the iframe's "allow" attribute. |
| 241 | */ |
| 242 | disabledByIframe: 'missing in iframe "`allow`" attribute', |
| 243 | /** |
| 244 | *@description Text describing that a specific feature is blocked by a Permissions Policy specified in a request header. |
| 245 | */ |
| 246 | disabledByHeader: 'disabled by "`Permissions-Policy`" header', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 247 | }; |
Tim van der Lippe | 1bd5e21 | 2021-05-06 10:54:29 | [diff] [blame] | 248 | const str_ = i18n.i18n.registerUIStrings('panels/application/components/FrameDetailsView.ts', UIStrings); |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 249 | const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); |
Sigurd Schneider | 1e5ad28 | 2020-07-17 11:52:08 | [diff] [blame] | 250 | export class FrameDetailsView extends UI.ThrottledWidget.ThrottledWidget { |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 251 | private readonly reportView = new FrameDetailsReportView(); |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 252 | private readonly frame: SDK.ResourceTreeModel.ResourceTreeFrame; |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 253 | |
Wolfgang Beyer | 309863f | 2021-01-21 09:01:21 | [diff] [blame] | 254 | constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) { |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 255 | super(); |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 256 | this.frame = frame; |
| 257 | this.contentElement.classList.add('overflow-auto'); |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 258 | this.contentElement.appendChild(this.reportView); |
Sigurd Schneider | 1e5ad28 | 2020-07-17 11:52:08 | [diff] [blame] | 259 | this.update(); |
| 260 | } |
| 261 | |
Wolfgang Beyer | 309863f | 2021-01-21 09:01:21 | [diff] [blame] | 262 | async doUpdate(): Promise<void> { |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 263 | this.reportView.data = {frame: this.frame}; |
Sigurd Schneider | eabef96 | 2020-11-05 10:51:49 | [diff] [blame] | 264 | } |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 265 | } |
Wolfgang Beyer | 3b4747f | 2020-08-12 07:30:46 | [diff] [blame] | 266 | |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 267 | export interface FrameDetailsReportViewData { |
| 268 | frame: SDK.ResourceTreeModel.ResourceTreeFrame; |
| 269 | } |
| 270 | |
| 271 | export class FrameDetailsReportView extends HTMLElement { |
| 272 | private readonly shadow = this.attachShadow({mode: 'open'}); |
| 273 | private frame?: SDK.ResourceTreeModel.ResourceTreeFrame; |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 274 | private protocolMonitorExperimentEnabled = false; |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 275 | private showPermissionsDisallowedDetails = false; |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 276 | |
| 277 | connectedCallback(): void { |
| 278 | this.protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocolMonitor'); |
| 279 | } |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 280 | |
| 281 | set data(data: FrameDetailsReportViewData) { |
| 282 | this.frame = data.frame; |
| 283 | this.render(); |
| 284 | } |
| 285 | |
| 286 | private async render(): Promise<void> { |
| 287 | if (!this.frame) { |
| 288 | return; |
| 289 | } |
| 290 | |
| 291 | // Disabled until https://crbug.com/1079231 is fixed. |
| 292 | // clang-format off |
| 293 | LitHtml.render(LitHtml.html` |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 294 | <style> |
| 295 | .text-ellipsis { |
| 296 | overflow: hidden; |
| 297 | text-overflow: ellipsis; |
| 298 | white-space: nowrap; |
| 299 | } |
| 300 | |
| 301 | button ~ .text-ellipsis { |
| 302 | padding-left: 2px; |
| 303 | } |
| 304 | |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 305 | .link, |
| 306 | .devtools-link { |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 307 | color: var(--color-link); |
| 308 | text-decoration: underline; |
| 309 | cursor: pointer; |
| 310 | padding: 2px 0; /* adjust focus ring size */ |
| 311 | } |
| 312 | |
| 313 | button.link { |
| 314 | border: none; |
| 315 | background: none; |
| 316 | font-family: inherit; |
| 317 | font-size: inherit; |
| 318 | } |
| 319 | |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 320 | .inline-comment { |
| 321 | padding-left: 1ex; |
| 322 | white-space: pre-line; |
| 323 | } |
| 324 | |
| 325 | .inline-comment::before { |
| 326 | content: "("; |
| 327 | } |
| 328 | |
| 329 | .inline-comment::after { |
| 330 | content: ")"; |
| 331 | } |
| 332 | |
| 333 | .inline-name { |
| 334 | color: var(--color-text-secondary); |
| 335 | padding-left: 2ex; |
| 336 | user-select: none; |
| 337 | white-space: pre-line; |
| 338 | } |
| 339 | |
| 340 | .inline-name::after { |
| 341 | content: ':\u00a0'; |
| 342 | } |
| 343 | |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 344 | .inline-items { |
| 345 | display: flex; |
| 346 | } |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 347 | |
| 348 | .span-cols { |
| 349 | grid-column-start: span 2; |
| 350 | margin: 0 0 8px 30px; |
| 351 | line-height: 28px; |
| 352 | } |
| 353 | |
| 354 | .policies-list { |
| 355 | padding-top: 3px; |
| 356 | } |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 357 | </style> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 358 | <${ReportView.ReportView.Report.litTagName} .data=${{reportTitle: this.frame.displayName()} as ReportView.ReportView.ReportData}> |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 359 | ${this.renderDocumentSection()} |
| 360 | ${this.renderIsolationSection()} |
| 361 | ${this.renderApiAvailabilitySection()} |
Sigurd Schneider | 173154c | 2021-02-18 14:18:38 | [diff] [blame] | 362 | ${LitHtml.Directives.until(this.renderPermissionPolicy(), LitHtml.nothing)} |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 363 | ${this.protocolMonitorExperimentEnabled ? this.renderAdditionalInfoSection() : LitHtml.nothing} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 364 | </${ReportView.ReportView.Report.litTagName}> |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 365 | `, this.shadow); |
| 366 | // clang-format on |
| 367 | } |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 368 | |
Sigurd Schneider | 173154c | 2021-02-18 14:18:38 | [diff] [blame] | 369 | private async renderPermissionPolicy(): Promise<LitHtml.TemplateResult|{}> { |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 370 | const policies = await (this.frame && this.frame.getPermissionsPolicyState()); |
| 371 | if (!policies) { |
Sigurd Schneider | 173154c | 2021-02-18 14:18:38 | [diff] [blame] | 372 | return LitHtml.nothing; |
| 373 | } |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 374 | |
| 375 | const toggleShowPermissionsDisallowedDetails = (): void => { |
| 376 | this.showPermissionsDisallowedDetails = !this.showPermissionsDisallowedDetails; |
| 377 | this.render(); |
| 378 | }; |
| 379 | |
| 380 | const renderAllowed = (): LitHtml.TemplateResult|{} => { |
| 381 | const allowed = policies.filter(p => p.allowed).map(p => p.feature).sort(); |
| 382 | if (!allowed.length) { |
| 383 | return LitHtml.nothing; |
| 384 | } |
| 385 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 386 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.allowedFeatures)}</${ |
| 387 | ReportView.ReportView.ReportKey.litTagName}> |
| 388 | <${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 389 | ${allowed.join(', ')} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 390 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 391 | `; |
| 392 | }; |
| 393 | |
| 394 | const renderDisallowed = async(): Promise<LitHtml.TemplateResult|{}> => { |
| 395 | const disallowed = policies.filter(p => !p.allowed).sort((a, b) => a.feature.localeCompare(b.feature)); |
| 396 | if (!disallowed.length) { |
| 397 | return LitHtml.nothing; |
| 398 | } |
| 399 | if (!this.showPermissionsDisallowedDetails) { |
| 400 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 401 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.disabledFeatures)}</${ |
| 402 | ReportView.ReportView.ReportKey.litTagName}> |
| 403 | <${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 404 | ${disallowed.map(p => p.feature).join(', ')} |
| 405 | <button class="link" @click=${(): void => toggleShowPermissionsDisallowedDetails()}> |
| 406 | ${i18nString(UIStrings.showDetails)} |
| 407 | </button> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 408 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 409 | `; |
| 410 | } |
| 411 | |
| 412 | const frameManager = SDK.FrameManager.FrameManager.instance(); |
| 413 | const featureRows = await Promise.all(disallowed.map(async policy => { |
| 414 | const frame = policy.locator ? frameManager.getFrame(policy.locator.frameId) : null; |
| 415 | const blockReason = policy.locator?.blockReason; |
| 416 | const linkTargetDOMNode = await ( |
| 417 | blockReason === Protocol.Page.PermissionsPolicyBlockReason.IframeAttribute && frame && |
| 418 | frame.getOwnerDOMNodeOrDocument()); |
| 419 | const resource = frame && frame.resourceForURL(frame.url); |
| 420 | const linkTargetRequest = |
| 421 | blockReason === Protocol.Page.PermissionsPolicyBlockReason.Header && resource && resource.request; |
| 422 | const blockReasonText = blockReason === Protocol.Page.PermissionsPolicyBlockReason.IframeAttribute ? |
| 423 | i18nString(UIStrings.disabledByIframe) : |
| 424 | blockReason === Protocol.Page.PermissionsPolicyBlockReason.Header ? i18nString(UIStrings.disabledByHeader) : |
| 425 | ''; |
Wolfgang Beyer | 89cc873 | 2021-04-07 13:45:56 | [diff] [blame] | 426 | const revealHeader = async(): Promise<void> => { |
| 427 | if (!linkTargetRequest) { |
| 428 | return; |
| 429 | } |
| 430 | const headerName = |
| 431 | linkTargetRequest.responseHeaderValue('permissions-policy') ? 'permissions-policy' : 'feature-policy'; |
| 432 | const requestLocation = Network.NetworkSearchScope.UIRequestLocation.responseHeaderMatch( |
| 433 | linkTargetRequest, |
| 434 | {name: headerName, value: ''}, |
| 435 | ); |
| 436 | // TODO(crbug.com/1196676) Refactor to use Common.Revealer |
| 437 | await Network.NetworkPanel.RequestLocationRevealer.instance().reveal(requestLocation); |
| 438 | }; |
| 439 | |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 440 | return LitHtml.html` |
| 441 | <div class="permissions-row"> |
| 442 | <div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 443 | <${IconButton.Icon.Icon.litTagName} class="allowed-icon" |
Tim van der Lippe | 151b797 | 2021-04-13 10:53:42 | [diff] [blame] | 444 | .data=${{color: '', iconName: 'error_icon', width: '14px'} as IconButton.Icon.IconData}> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 445 | </${IconButton.Icon.Icon.litTagName}> |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 446 | </div> |
| 447 | <div class="feature-name text-ellipsis"> |
| 448 | ${policy.feature} |
| 449 | </div> |
| 450 | <div class="block-reason">${blockReasonText}</div> |
| 451 | <div> |
| 452 | ${ |
| 453 | linkTargetDOMNode ? this.renderIconLink( |
| 454 | 'elements_panel_icon', |
| 455 | i18nString(UIStrings.clickToShowIframe), |
| 456 | (): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode), |
| 457 | ) : |
| 458 | LitHtml.nothing} |
Wolfgang Beyer | 89cc873 | 2021-04-07 13:45:56 | [diff] [blame] | 459 | ${ |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 460 | linkTargetRequest ? this.renderIconLink( |
| 461 | 'network_panel_icon', |
| 462 | i18nString(UIStrings.clickToShowHeader), |
Wolfgang Beyer | 89cc873 | 2021-04-07 13:45:56 | [diff] [blame] | 463 | revealHeader, |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 464 | ) : |
| 465 | LitHtml.nothing} |
| 466 | </div> |
| 467 | </div> |
| 468 | `; |
| 469 | })); |
| 470 | |
| 471 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 472 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.disabledFeatures)}</${ |
| 473 | ReportView.ReportView.ReportKey.litTagName}> |
| 474 | <${ReportView.ReportView.ReportValue.litTagName} class="policies-list"> |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 475 | <style> |
| 476 | .permissions-row { |
| 477 | display: flex; |
| 478 | line-height: 22px; |
| 479 | } |
| 480 | |
| 481 | .permissions-row div { |
| 482 | padding-right: 5px; |
| 483 | } |
| 484 | |
| 485 | .feature-name { |
| 486 | width: 135px; |
| 487 | } |
| 488 | |
| 489 | .allowed-icon { |
| 490 | padding: 2.5px 0; |
| 491 | } |
| 492 | |
| 493 | .block-reason { |
| 494 | width: 215px; |
| 495 | } |
| 496 | </style> |
| 497 | ${featureRows} |
| 498 | <div class="permissions-row"> |
| 499 | <button class="link" @click=${(): void => toggleShowPermissionsDisallowedDetails()}> |
| 500 | ${i18nString(UIStrings.hideDetails)} |
| 501 | </button> |
| 502 | </div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 503 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 504 | `; |
| 505 | }; |
| 506 | |
| 507 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 508 | <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18n.i18n.lockedString('Permissions Policy')}</${ |
| 509 | ReportView.ReportView.ReportSectionHeader.litTagName}> |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 510 | ${renderAllowed()} |
| 511 | ${LitHtml.Directives.until(renderDisallowed(), LitHtml.nothing)} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 512 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ |
| 513 | ReportView.ReportView.ReportSectionDivider.litTagName}> |
Sigurd Schneider | 173154c | 2021-02-18 14:18:38 | [diff] [blame] | 514 | `; |
| 515 | } |
| 516 | |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 517 | private renderDocumentSection(): LitHtml.TemplateResult|{} { |
| 518 | if (!this.frame) { |
| 519 | return LitHtml.nothing; |
| 520 | } |
| 521 | |
| 522 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 523 | <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.document)}</${ |
| 524 | ReportView.ReportView.ReportSectionHeader.litTagName}> |
| 525 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.url)}</${ |
| 526 | ReportView.ReportView.ReportKey.litTagName}> |
| 527 | <${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 528 | <div class="inline-items"> |
| 529 | ${this.maybeRenderSourcesLinkForURL()} |
| 530 | ${this.maybeRenderNetworkLinkForURL()} |
| 531 | <div class="text-ellipsis" title=${this.frame.url}>${this.frame.url}</div> |
| 532 | </div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 533 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 534 | ${this.maybeRenderUnreachableURL()} |
| 535 | ${this.maybeRenderOrigin()} |
| 536 | ${LitHtml.Directives.until(this.renderOwnerElement(), LitHtml.nothing)} |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 537 | ${this.maybeRenderCreationStacktrace()} |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 538 | ${this.maybeRenderAdStatus()} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 539 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ |
| 540 | ReportView.ReportView.ReportSectionDivider.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 541 | `; |
| 542 | } |
| 543 | |
| 544 | private maybeRenderSourcesLinkForURL(): LitHtml.TemplateResult|{} { |
| 545 | if (!this.frame || this.frame.unreachableUrl()) { |
| 546 | return LitHtml.nothing; |
| 547 | } |
| 548 | const sourceCode = this.uiSourceCodeForFrame(this.frame); |
| 549 | return this.renderIconLink( |
| 550 | 'sources_panel_icon', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 551 | i18nString(UIStrings.clickToRevealInSourcesPanel), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 552 | (): Promise<void> => Common.Revealer.reveal(sourceCode), |
| 553 | ); |
| 554 | } |
| 555 | |
| 556 | private maybeRenderNetworkLinkForURL(): LitHtml.TemplateResult|{} { |
| 557 | if (this.frame) { |
| 558 | const resource = this.frame.resourceForURL(this.frame.url); |
| 559 | if (resource && resource.request) { |
| 560 | const request = resource.request; |
| 561 | return this.renderIconLink( |
| 562 | 'network_panel_icon', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 563 | i18nString(UIStrings.clickToRevealInNetworkPanel), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 564 | (): Promise<void> => |
| 565 | Network.NetworkPanel.NetworkPanel.selectAndShowRequest(request, Network.NetworkItemView.Tabs.Headers), |
| 566 | ); |
| 567 | } |
| 568 | } |
| 569 | return LitHtml.nothing; |
| 570 | } |
| 571 | |
| 572 | private renderIconLink( |
| 573 | iconName: string, title: Platform.UIString.LocalizedString, |
| 574 | clickHandler: (() => void)|(() => Promise<void>)): LitHtml.TemplateResult { |
| 575 | // Disabled until https://crbug.com/1079231 is fixed. |
| 576 | // clang-format off |
| 577 | return LitHtml.html` |
| 578 | <button class="link" role="link" tabindex=0 @click=${clickHandler} title=${title}> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 579 | <${IconButton.Icon.Icon.litTagName} .data=${{ |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 580 | iconName: iconName, |
| 581 | color: 'var(--color-primary)', |
| 582 | width: '16px', |
| 583 | height: '16px', |
Tim van der Lippe | 151b797 | 2021-04-13 10:53:42 | [diff] [blame] | 584 | } as IconButton.Icon.IconData}> |
Tim van der Lippe | 0005b80 | 2021-06-03 10:47:59 | [diff] [blame^] | 585 | </${IconButton.Icon.Icon.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 586 | </button> |
| 587 | `; |
| 588 | // clang-format on |
| 589 | } |
| 590 | |
| 591 | private uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode |
| 592 | |null { |
| 593 | for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) { |
| 594 | const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project); |
| 595 | if (projectTarget && projectTarget === frame.resourceTreeModel().target()) { |
| 596 | const uiSourceCode = project.uiSourceCodeForURL(frame.url); |
| 597 | if (uiSourceCode) { |
| 598 | return uiSourceCode; |
| 599 | } |
| 600 | } |
| 601 | } |
| 602 | return null; |
| 603 | } |
| 604 | |
| 605 | private maybeRenderUnreachableURL(): LitHtml.TemplateResult|{} { |
| 606 | if (!this.frame || !this.frame.unreachableUrl()) { |
| 607 | return LitHtml.nothing; |
| 608 | } |
| 609 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 610 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.unreachableUrl)}</${ |
| 611 | ReportView.ReportView.ReportKey.litTagName}> |
| 612 | <${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 613 | <div class="inline-items"> |
| 614 | ${this.renderNetworkLinkForUnreachableURL()} |
| 615 | <div class="text-ellipsis" title=${this.frame.unreachableUrl()}>${this.frame.unreachableUrl()}</div> |
| 616 | </div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 617 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 618 | `; |
| 619 | } |
| 620 | |
| 621 | private renderNetworkLinkForUnreachableURL(): LitHtml.TemplateResult|{} { |
| 622 | if (this.frame) { |
| 623 | const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(this.frame.unreachableUrl()); |
| 624 | if (unreachableUrl) { |
| 625 | return this.renderIconLink( |
| 626 | 'network_panel_icon', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 627 | i18nString(UIStrings.clickToRevealInNetworkPanelMight), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 628 | (): |
| 629 | void => { |
| 630 | Network.NetworkPanel.NetworkPanel.revealAndFilter([ |
| 631 | { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 632 | // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration) |
| 633 | // @ts-expect-error |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 634 | filterType: 'domain', |
| 635 | filterValue: unreachableUrl.domain(), |
| 636 | }, |
| 637 | { |
| 638 | filterType: null, |
| 639 | filterValue: unreachableUrl.path, |
| 640 | }, |
| 641 | ]); |
| 642 | }, |
| 643 | ); |
| 644 | } |
| 645 | } |
| 646 | return LitHtml.nothing; |
| 647 | } |
| 648 | |
| 649 | private maybeRenderOrigin(): LitHtml.TemplateResult|{} { |
| 650 | if (this.frame && this.frame.securityOrigin && this.frame.securityOrigin !== '://') { |
| 651 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 652 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.origin)}</${ |
| 653 | ReportView.ReportView.ReportKey.litTagName}> |
| 654 | <${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 655 | <div class="text-ellipsis" title=${this.frame.securityOrigin}>${this.frame.securityOrigin}</div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 656 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 657 | `; |
| 658 | } |
| 659 | return LitHtml.nothing; |
| 660 | } |
| 661 | |
| 662 | private async renderOwnerElement(): Promise<LitHtml.TemplateResult|{}> { |
| 663 | if (this.frame) { |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 664 | const linkTargetDOMNode = await this.frame.getOwnerDOMNodeOrDocument(); |
| 665 | if (linkTargetDOMNode) { |
| 666 | // Disabled until https://crbug.com/1079231 is fixed. |
| 667 | // clang-format off |
| 668 | return LitHtml.html` |
| 669 | <style> |
Wolfgang Beyer | ddf051e | 2021-02-09 08:33:01 | [diff] [blame] | 670 | .button-icon-with-text { |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 671 | vertical-align: sub; |
| 672 | } |
Wolfgang Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame] | 673 | |
| 674 | .without-min-width { |
| 675 | min-width: auto; |
| 676 | } |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 677 | </style> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 678 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.ownerElement)}</${ReportView.ReportView.ReportKey.litTagName}> |
| 679 | <${ReportView.ReportView.ReportValue.litTagName} class="without-min-width"> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 680 | <button class="link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToRevealInElementsPanel)} |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 681 | @mouseenter=${(): Promise<void>|undefined => this.frame?.highlight()} |
| 682 | @mouseleave=${(): void => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()} |
| 683 | @click=${(): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode)} |
| 684 | > |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 685 | <${IconButton.Icon.Icon.litTagName} class="button-icon-with-text" .data=${{ |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 686 | iconName: 'elements_panel_icon', |
| 687 | color: 'var(--color-primary)', |
| 688 | width: '16px', |
| 689 | height: '16px', |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 690 | } as IconButton.Icon.IconData}></${IconButton.Icon.Icon.litTagName}> |
Jack Franklin | 5ba6ec6 | 2021-04-30 07:36:20 | [diff] [blame] | 691 | <${linkTargetDOMNode.nodeName().toLocaleLowerCase()}> |
Wolfgang Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame] | 692 | </button> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 693 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 694 | `; |
| 695 | // clang-format on |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 696 | } |
| 697 | } |
| 698 | return LitHtml.nothing; |
| 699 | } |
| 700 | |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 701 | private maybeRenderCreationStacktrace(): LitHtml.TemplateResult|{} { |
Wolfgang Beyer | a20485a | 2021-04-21 07:22:19 | [diff] [blame] | 702 | const creationStackTraceData = this.frame?.getCreationStackTraceData(); |
| 703 | if (creationStackTraceData && creationStackTraceData.creationStackTrace) { |
Wolfgang Beyer | a036d0c | 2021-03-19 09:09:33 | [diff] [blame] | 704 | // Disabled until https://crbug.com/1079231 is fixed. |
| 705 | // clang-format off |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 706 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 707 | <${ReportView.ReportView.ReportKey.litTagName} title=${i18nString(UIStrings.creationStackTraceExplanation)}>${ |
| 708 | i18nString(UIStrings.creationStackTrace)}</${ReportView.ReportView.ReportKey.litTagName}> |
| 709 | <${ReportView.ReportView.ReportValue.litTagName}> |
| 710 | <${StackTrace.litTagName} .data=${{ |
Wolfgang Beyer | a036d0c | 2021-03-19 09:09:33 | [diff] [blame] | 711 | frame: this.frame, |
| 712 | buildStackTraceRows: Components.JSPresentationUtils.buildStackTraceRows, |
| 713 | } as StackTraceData}> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 714 | </${StackTrace.litTagName}> |
| 715 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 716 | `; |
Wolfgang Beyer | a036d0c | 2021-03-19 09:09:33 | [diff] [blame] | 717 | // clang-format on |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 718 | } |
| 719 | return LitHtml.nothing; |
| 720 | } |
| 721 | |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 722 | private maybeRenderAdStatus(): LitHtml.TemplateResult|{} { |
| 723 | if (this.frame) { |
| 724 | if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Root) { |
| 725 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 726 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.adStatus)}</${ |
| 727 | ReportView.ReportView.ReportKey.litTagName}> |
| 728 | <${ReportView.ReportView.ReportValue.litTagName} title=${ |
| 729 | i18nString(UIStrings.thisFrameHasBeenIdentifiedAsThe)}>${i18nString(UIStrings.root)}</${ |
| 730 | ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 731 | `; |
| 732 | } |
| 733 | if (this.frame.adFrameType() === Protocol.Page.AdFrameType.Child) { |
| 734 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 735 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.adStatus)}</${ |
| 736 | ReportView.ReportView.ReportKey.litTagName}> |
| 737 | <${ReportView.ReportView.ReportValue.litTagName} title=${ |
| 738 | i18nString(UIStrings.thisFrameHasBeenIdentifiedAsTheA)}>${i18nString(UIStrings.child)}</${ |
| 739 | ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 740 | `; |
| 741 | } |
| 742 | } |
| 743 | return LitHtml.nothing; |
| 744 | } |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 745 | |
| 746 | private renderIsolationSection(): LitHtml.TemplateResult|{} { |
| 747 | if (!this.frame) { |
| 748 | return LitHtml.nothing; |
| 749 | } |
| 750 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 751 | <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.securityIsolation)}</${ |
| 752 | ReportView.ReportView.ReportSectionHeader.litTagName}> |
| 753 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.secureContext)}</${ |
| 754 | ReportView.ReportView.ReportKey.litTagName}> |
| 755 | <${ReportView.ReportView.ReportValue.litTagName}> |
Tim van der Lippe | 0005b80 | 2021-06-03 10:47:59 | [diff] [blame^] | 756 | ${this.frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}\xA0${ |
| 757 | this.maybeRenderSecureContextExplanation()} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 758 | </${ReportView.ReportView.ReportValue.litTagName}> |
| 759 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.crossoriginIsolated)}</${ |
| 760 | ReportView.ReportView.ReportKey.litTagName}> |
| 761 | <${ReportView.ReportView.ReportValue.litTagName}> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 762 | ${this.frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 763 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 764 | ${LitHtml.Directives.until(this.maybeRenderCoopCoepStatus(), LitHtml.nothing)} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 765 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ |
| 766 | ReportView.ReportView.ReportSectionDivider.litTagName}> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 767 | `; |
| 768 | } |
| 769 | |
| 770 | private maybeRenderSecureContextExplanation(): LitHtml.TemplateResult|{} { |
| 771 | const explanation = this.getSecureContextExplanation(); |
| 772 | if (explanation) { |
Tim van der Lippe | 0005b80 | 2021-06-03 10:47:59 | [diff] [blame^] | 773 | return LitHtml.html`<span class="inline-comment">${explanation}</span>`; |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 774 | } |
| 775 | return LitHtml.nothing; |
| 776 | } |
| 777 | |
| 778 | private getSecureContextExplanation(): Platform.UIString.LocalizedString|null { |
| 779 | switch (this.frame?.getSecureContextType()) { |
| 780 | case Protocol.Page.SecureContextType.Secure: |
| 781 | return null; |
| 782 | case Protocol.Page.SecureContextType.SecureLocalhost: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 783 | return i18nString(UIStrings.localhostIsAlwaysASecureContext); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 784 | case Protocol.Page.SecureContextType.InsecureAncestor: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 785 | return i18nString(UIStrings.aFrameAncestorIsAnInsecure); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 786 | case Protocol.Page.SecureContextType.InsecureScheme: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 787 | return i18nString(UIStrings.theFramesSchemeIsInsecure); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 788 | } |
| 789 | return null; |
| 790 | } |
| 791 | |
| 792 | private async maybeRenderCoopCoepStatus(): Promise<LitHtml.TemplateResult|{}> { |
| 793 | if (this.frame) { |
| 794 | const model = this.frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager); |
| 795 | const info = model && await model.getSecurityIsolationStatus(this.frame.id); |
| 796 | if (info) { |
| 797 | return LitHtml.html` |
| 798 | ${ |
| 799 | this.maybeRenderCrossOriginStatus( |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 800 | info.coep, i18nString(UIStrings.crossoriginEmbedderPolicy), |
| 801 | Protocol.Network.CrossOriginEmbedderPolicyValue.None)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 802 | ${ |
| 803 | this.maybeRenderCrossOriginStatus( |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 804 | info.coop, i18nString(UIStrings.crossoriginOpenerPolicy), |
| 805 | Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 806 | `; |
| 807 | } |
| 808 | } |
| 809 | return LitHtml.nothing; |
| 810 | } |
| 811 | |
| 812 | private maybeRenderCrossOriginStatus( |
| 813 | info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined, |
| 814 | policyName: string, |
| 815 | noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue| |
| 816 | Protocol.Network.CrossOriginOpenerPolicyValue): LitHtml.TemplateResult|{} { |
| 817 | if (!info) { |
| 818 | return LitHtml.nothing; |
| 819 | } |
| 820 | const isEnabled = info.value !== noneValue; |
| 821 | const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue); |
| 822 | const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint; |
| 823 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 824 | <${ReportView.ReportView.ReportKey.litTagName}>${policyName}</${ReportView.ReportView.ReportKey.litTagName}> |
| 825 | <${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 826 | ${isEnabled ? info.value : info.reportOnlyValue} |
| 827 | ${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] | 828 | ${ |
| 829 | endpoint ? LitHtml.html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` : |
| 830 | LitHtml.nothing} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 831 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 832 | `; |
| 833 | } |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 834 | |
| 835 | private renderApiAvailabilitySection(): LitHtml.TemplateResult|{} { |
| 836 | if (!this.frame) { |
| 837 | return LitHtml.nothing; |
| 838 | } |
| 839 | |
| 840 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 841 | <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.apiAvailability)}</${ |
| 842 | ReportView.ReportView.ReportSectionHeader.litTagName}> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 843 | <div class="span-cols"> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 844 | ${i18nString(UIStrings.availabilityOfCertainApisDepends)} |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 845 | <x-link href="https://web.dev/why-coop-coep/" class="link">${i18nString(UIStrings.learnMore)}</x-link> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 846 | </div> |
| 847 | ${this.renderSharedArrayBufferAvailability()} |
| 848 | ${this.renderMeasureMemoryAvailability()} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 849 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ |
| 850 | ReportView.ReportView.ReportSectionDivider.litTagName}> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 851 | `; |
| 852 | } |
| 853 | |
| 854 | private renderSharedArrayBufferAvailability(): LitHtml.TemplateResult|{} { |
| 855 | if (this.frame) { |
| 856 | const features = this.frame.getGatedAPIFeatures(); |
| 857 | if (features) { |
| 858 | const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers); |
| 859 | const sabTransferAvailable = |
| 860 | sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed); |
| 861 | const availabilityText = sabTransferAvailable ? |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 862 | i18nString(UIStrings.availableTransferable) : |
| 863 | (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable)); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 864 | const tooltipText = sabTransferAvailable ? |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 865 | i18nString(UIStrings.sharedarraybufferConstructorIs) : |
| 866 | (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : ''); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 867 | |
Sigurd Schneider | 2a45025 | 2021-05-04 07:13:15 | [diff] [blame] | 868 | function renderHint(frame: SDK.ResourceTreeModel.ResourceTreeFrame): LitHtml.TemplateResult|{} { |
| 869 | switch (frame.getCrossOriginIsolatedContextType()) { |
| 870 | case Protocol.Page.CrossOriginIsolatedContextType.Isolated: |
| 871 | return LitHtml.nothing; |
| 872 | case Protocol.Page.CrossOriginIsolatedContextType.NotIsolated: |
| 873 | if (sabAvailable) { |
| 874 | return LitHtml.html`<span class="inline-comment">${ |
| 875 | i18nString(UIStrings.willRequireCrossoriginIsolated)}</span>`; |
| 876 | } |
| 877 | return LitHtml.html`<span class="inline-comment">${ |
| 878 | i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`; |
| 879 | case Protocol.Page.CrossOriginIsolatedContextType.NotIsolatedFeatureDisabled: |
| 880 | if (!sabTransferAvailable) { |
| 881 | return LitHtml.html`<span class="inline-comment">${ |
| 882 | i18nString( |
| 883 | UIStrings |
| 884 | .transferRequiresCrossoriginIsolatedPermission)} <code>cross-origin-isolated</code></span>`; |
| 885 | } |
| 886 | break; |
| 887 | } |
| 888 | return LitHtml.nothing; |
| 889 | } |
| 890 | |
Peter Marshall | 0e1cd82 | 2021-02-24 10:52:42 | [diff] [blame] | 891 | // SharedArrayBuffer is an API name, so we don't translate it. |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 892 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 893 | <${ReportView.ReportView.ReportKey.litTagName}>SharedArrayBuffers</${ |
| 894 | ReportView.ReportView.ReportKey.litTagName}> |
| 895 | <${ReportView.ReportView.ReportValue.litTagName} title=${tooltipText}> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 896 | ${availabilityText} |
Sigurd Schneider | 2a45025 | 2021-05-04 07:13:15 | [diff] [blame] | 897 | ${renderHint(this.frame)} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 898 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 899 | `; |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 900 | } |
| 901 | } |
| 902 | return LitHtml.nothing; |
| 903 | } |
| 904 | |
| 905 | private renderMeasureMemoryAvailability(): LitHtml.TemplateResult|{} { |
| 906 | if (this.frame) { |
| 907 | const measureMemoryAvailable = this.frame.isCrossOriginIsolated(); |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 908 | const availabilityText = |
| 909 | measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable); |
| 910 | const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) : |
| 911 | i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 912 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 913 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.measureMemory)}</${ |
| 914 | ReportView.ReportView.ReportKey.litTagName}> |
| 915 | <${ReportView.ReportView.ReportValue.litTagName}> |
Tim van der Lippe | 0005b80 | 2021-06-03 10:47:59 | [diff] [blame^] | 916 | <span title=${tooltipText}>${ |
| 917 | availabilityText}</span>\xA0<x-link class="link" href="https://web.dev/monitor-total-page-memory-usage/">${ |
Wolfgang Beyer | 09b0e8e | 2021-02-09 13:39:48 | [diff] [blame] | 918 | i18nString(UIStrings.learnMore)}</x-link> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 919 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 920 | `; |
| 921 | } |
| 922 | return LitHtml.nothing; |
| 923 | } |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 924 | |
| 925 | private renderAdditionalInfoSection(): LitHtml.TemplateResult|{} { |
| 926 | if (!this.frame) { |
| 927 | return LitHtml.nothing; |
| 928 | } |
| 929 | |
| 930 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 931 | <${ReportView.ReportView.ReportSectionHeader.litTagName} |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 932 | title=${i18nString(UIStrings.thisAdditionalDebugging)} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 933 | >${i18nString(UIStrings.additionalInformation)}</${ReportView.ReportView.ReportSectionHeader.litTagName}> |
| 934 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.frameId)}</${ |
| 935 | ReportView.ReportView.ReportKey.litTagName}> |
| 936 | <${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 937 | <div class="text-ellipsis" title=${this.frame.id}>${this.frame.id}</div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 938 | </${ReportView.ReportView.ReportValue.litTagName}> |
| 939 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ |
| 940 | ReportView.ReportView.ReportSectionDivider.litTagName}> |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 941 | `; |
| 942 | } |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 943 | } |
| 944 | |
Kriti Sapra | 34df98d | 2021-05-06 10:15:42 | [diff] [blame] | 945 | ComponentHelpers.CustomElements.defineComponent('devtools-resources-frame-details-view', FrameDetailsReportView); |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 946 | |
| 947 | declare global { |
| 948 | // eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 949 | interface HTMLElementTagNameMap { |
| 950 | 'devtools-resources-frame-details-view': FrameDetailsReportView; |
| 951 | } |
| 952 | } |