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