Danil Somsikov | 4ba8f35 | 2021-06-09 12:27:22 | [diff] [blame] | 1 | // Copyright 2021 The Chromium Authors. All rights reserved. |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Tim van der Lippe | 1bd5e21 | 2021-05-06 10:54:29 | [diff] [blame] | 5 | import * as Common from '../../../core/common/common.js'; |
| 6 | import * as i18n from '../../../core/i18n/i18n.js'; |
Danil Somsikov | c48b2b1 | 2022-06-24 15:03:03 | [diff] [blame] | 7 | import * as Platform from '../../../core/platform/platform.js'; |
Tim van der Lippe | 1bd5e21 | 2021-05-06 10:54:29 | [diff] [blame] | 8 | import * as Root from '../../../core/root/root.js'; |
Tim van der Lippe | c2cbf32 | 2021-07-26 14:35:33 | [diff] [blame] | 9 | import * as SDK from '../../../core/sdk/sdk.js'; |
Tim van der Lippe | 229a54f | 2021-05-14 16:59:05 | [diff] [blame] | 10 | import * as Protocol from '../../../generated/protocol.js'; |
Wolfgang Beyer | 61baf65 | 2023-10-16 16:18:19 | [diff] [blame] | 11 | import * as Bindings from '../../../models/bindings/bindings.js'; |
| 12 | import * as Workspace from '../../../models/workspace/workspace.js'; |
| 13 | import * as NetworkForward from '../../../panels/network/forward/forward.js'; |
| 14 | import * as CspEvaluator from '../../../third_party/csp_evaluator/csp_evaluator.js'; |
| 15 | import * as ExpandableList from '../../../ui/components/expandable_list/expandable_list.js'; |
| 16 | import * as ComponentHelpers from '../../../ui/components/helpers/helpers.js'; |
| 17 | import * as IconButton from '../../../ui/components/icon_button/icon_button.js'; |
| 18 | import * as LegacyWrapper from '../../../ui/components/legacy_wrapper/legacy_wrapper.js'; |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 19 | import * as Coordinator from '../../../ui/components/render_coordinator/render_coordinator.js'; |
Wolfgang Beyer | 61baf65 | 2023-10-16 16:18:19 | [diff] [blame] | 20 | import * as ReportView from '../../../ui/components/report_view/report_view.js'; |
| 21 | import * as Components from '../../../ui/legacy/components/utils/utils.js'; |
| 22 | import * as LitHtml from '../../../ui/lit-html/lit-html.js'; |
Wolfgang Beyer | 760462e | 2020-07-13 15:01:35 | [diff] [blame] | 23 | |
Kriti Sapra | 9db87f5 | 2021-07-14 12:51:12 | [diff] [blame] | 24 | import frameDetailsReportViewStyles from './frameDetailsReportView.css.js'; |
Benedikt Meurer | 5eb9e24 | 2023-12-27 13:40:52 | [diff] [blame^] | 25 | import {OriginTrialTreeView} from './OriginTrialTreeView.js'; |
Wolfgang Beyer | 61baf65 | 2023-10-16 16:18:19 | [diff] [blame] | 26 | import { |
| 27 | PermissionsPolicySection, |
| 28 | type PermissionsPolicySectionData, |
| 29 | renderIconLink, |
| 30 | } from './PermissionsPolicySection.js'; |
| 31 | import {StackTrace, type StackTraceData} from './StackTrace.js'; |
Kriti Sapra | 9db87f5 | 2021-07-14 12:51:12 | [diff] [blame] | 32 | |
Simon Zünd | 697fb0b | 2021-03-01 10:12:42 | [diff] [blame] | 33 | const UIStrings = { |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 34 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 35 | *@description Section header in the Frame Details view |
| 36 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 37 | additionalInformation: 'Additional Information', |
| 38 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 39 | *@description Explanation for why the additional information section is being shown |
| 40 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 41 | thisAdditionalDebugging: |
| 42 | 'This additional (debugging) information is shown because the \'Protocol Monitor\' experiment is enabled.', |
| 43 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 44 | *@description Label for subtitle of frame details view |
| 45 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 46 | frameId: 'Frame ID', |
| 47 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 48 | *@description Name of a network resource type |
| 49 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 50 | document: 'Document', |
| 51 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 52 | *@description A web URL (for a lot of languages this does not need to be translated, please translate only where necessary) |
| 53 | */ |
Wolfgang Beyer | 5e451ff | 2021-12-08 16:44:35 | [diff] [blame] | 54 | url: 'URL', |
| 55 | /** |
| 56 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 57 | *@description Title for a link to the Sources panel |
| 58 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 59 | clickToRevealInSourcesPanel: 'Click to reveal in Sources panel', |
| 60 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 61 | *@description Title for a link to the Network panel |
| 62 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 63 | clickToRevealInNetworkPanel: 'Click to reveal in Network panel', |
| 64 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 65 | *@description Title for unreachable URL field |
| 66 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 67 | unreachableUrl: 'Unreachable URL', |
| 68 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 69 | *@description Title for a link that applies a filter to the network panel |
| 70 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 71 | clickToRevealInNetworkPanelMight: 'Click to reveal in Network panel (might require page reload)', |
| 72 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 73 | *@description The origin of a URL (https://web.dev/same-site-same-origin/#origin) |
| 74 | *(for a lot of languages this does not need to be translated, please translate only where necessary) |
| 75 | */ |
Wolfgang Beyer | 5e451ff | 2021-12-08 16:44:35 | [diff] [blame] | 76 | origin: 'Origin', |
| 77 | /** |
| 78 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 79 | *@description Related node label in Timeline UIUtils of the Performance panel |
| 80 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 81 | ownerElement: 'Owner Element', |
| 82 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 83 | *@description Title for a link to the Elements panel |
| 84 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 85 | clickToRevealInElementsPanel: 'Click to reveal in Elements panel', |
| 86 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 87 | *@description Title for ad frame type field |
| 88 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 89 | adStatus: 'Ad Status', |
| 90 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 91 | *@description Description for ad frame type |
| 92 | */ |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 93 | rootDescription: 'This frame has been identified as the root frame of an ad', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 94 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 95 | *@description Value for ad frame type |
| 96 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 97 | root: 'root', |
| 98 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 99 | *@description Description for ad frame type |
| 100 | */ |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 101 | childDescription: '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] | 102 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 103 | *@description Value for ad frame type |
| 104 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 105 | child: 'child', |
| 106 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 107 | *@description Section header in the Frame Details view |
| 108 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 109 | securityIsolation: 'Security & Isolation', |
| 110 | /** |
Wolfgang Beyer | 61baf65 | 2023-10-16 16:18:19 | [diff] [blame] | 111 | *@description Section header in the Frame Details view |
| 112 | */ |
| 113 | contentSecurityPolicy: 'Content Security Policy (CSP)', |
| 114 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 115 | *@description Row title for in the Frame Details view |
| 116 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 117 | secureContext: 'Secure Context', |
| 118 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 119 | *@description Text in Timeline indicating that input has happened recently |
| 120 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 121 | yes: 'Yes', |
| 122 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 123 | *@description Text in Timeline indicating that input has not happened recently |
| 124 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 125 | no: 'No', |
| 126 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 127 | *@description Label for whether a frame is cross-origin isolated |
| 128 | *(https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/) |
| 129 | *(for a lot of languages this does not need to be translated, please translate only where necessary) |
| 130 | */ |
Wolfgang Beyer | 5e451ff | 2021-12-08 16:44:35 | [diff] [blame] | 131 | crossoriginIsolated: 'Cross-Origin Isolated', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 132 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 133 | *@description Explanatory text in the Frame Details view |
| 134 | */ |
Wolfgang Beyer | dbf211e | 2021-11-23 10:23:54 | [diff] [blame] | 135 | localhostIsAlwaysASecureContext: '`Localhost` is always a secure context', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 136 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 137 | *@description Explanatory text in the Frame Details view |
| 138 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 139 | aFrameAncestorIsAnInsecure: 'A frame ancestor is an insecure context', |
| 140 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 141 | *@description Explanatory text in the Frame Details view |
| 142 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 143 | theFramesSchemeIsInsecure: 'The frame\'s scheme is insecure', |
| 144 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 145 | *@description This label specifies the server endpoints to which the server is reporting errors |
| 146 | *and warnings through the Report-to API. Following this label will be the URL of the server. |
| 147 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 148 | reportingTo: 'reporting to', |
| 149 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 150 | *@description Section header in the Frame Details view |
| 151 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 152 | apiAvailability: 'API availability', |
| 153 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 154 | *@description Explanation of why cross-origin isolation is important |
| 155 | *(https://web.dev/why-coop-coep/) |
| 156 | *(for a lot of languages 'cross-origin isolation' does not need to be translated, please translate only where necessary) |
| 157 | */ |
Wolfgang Beyer | 5e451ff | 2021-12-08 16:44:35 | [diff] [blame] | 158 | availabilityOfCertainApisDepends: 'Availability of certain APIs depends on the document being cross-origin isolated.', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 159 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 160 | *@description Description of the SharedArrayBuffer status |
| 161 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 162 | availableTransferable: 'available, transferable', |
| 163 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 164 | *@description Description of the SharedArrayBuffer status |
| 165 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 166 | availableNotTransferable: 'available, not transferable', |
| 167 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 168 | *@description Explanation for the SharedArrayBuffer availability status |
| 169 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 170 | unavailable: 'unavailable', |
| 171 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 172 | *@description Tooltip for the SharedArrayBuffer availability status |
| 173 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 174 | sharedarraybufferConstructorIs: |
Wolfgang Beyer | dbf211e | 2021-11-23 10:23:54 | [diff] [blame] | 175 | '`SharedArrayBuffer` constructor is available and `SABs` can be transferred via `postMessage`', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 176 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 177 | *@description Tooltip for the SharedArrayBuffer availability status |
| 178 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 179 | sharedarraybufferConstructorIsAvailable: |
Wolfgang Beyer | dbf211e | 2021-11-23 10:23:54 | [diff] [blame] | 180 | '`SharedArrayBuffer` constructor is available but `SABs` cannot be transferred via `postMessage`', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 181 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 182 | *@description Explanation why SharedArrayBuffer will not be available in the future |
| 183 | *(https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/) |
| 184 | *(for a lot of languages 'cross-origin isolation' does not need to be translated, please translate only where necessary) |
| 185 | */ |
Wolfgang Beyer | 5e451ff | 2021-12-08 16:44:35 | [diff] [blame] | 186 | willRequireCrossoriginIsolated: '⚠️ will require cross-origin isolated context in the future', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 187 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 188 | *@description Explanation why SharedArrayBuffer is not available |
| 189 | *(https://developer.chrome.com/docs/extensions/mv3/cross-origin-isolation/) |
| 190 | *(for a lot of languages 'cross-origin isolation' does not need to be translated, please translate only where necessary). |
| 191 | */ |
Wolfgang Beyer | 5e451ff | 2021-12-08 16:44:35 | [diff] [blame] | 192 | requiresCrossoriginIsolated: 'requires cross-origin isolated context', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 193 | /** |
Sigurd Schneider | f7e58be | 2021-05-14 14:41:52 | [diff] [blame] | 194 | *@description Explanation for the SharedArrayBuffer availability status in case the transfer of a SAB requires the |
| 195 | * permission policy `cross-origin-isolated` to be enabled (e.g. because the message refers to the situation in an iframe). |
| 196 | */ |
| 197 | transferRequiresCrossoriginIsolatedPermission: |
| 198 | '`SharedArrayBuffer` transfer requires enabling the permission policy:', |
Sigurd Schneider | 2a45025 | 2021-05-04 07:13:15 | [diff] [blame] | 199 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 200 | *@description Explanation for the Measure Memory availability status |
| 201 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 202 | available: 'available', |
| 203 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 204 | *@description Tooltip for the Measure Memory availability status |
| 205 | */ |
Wolfgang Beyer | dbf211e | 2021-11-23 10:23:54 | [diff] [blame] | 206 | thePerformanceAPI: 'The `performance.measureUserAgentSpecificMemory()` API is available', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 207 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 208 | *@description Tooltip for the Measure Memory availability status |
| 209 | */ |
Wolfgang Beyer | dbf211e | 2021-11-23 10:23:54 | [diff] [blame] | 210 | thePerformancemeasureuseragentspecificmemory: |
| 211 | 'The `performance.measureUserAgentSpecificMemory()` API is not available', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 212 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 213 | *@description Entry in the API availability section of the frame details view |
| 214 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 215 | measureMemory: 'Measure Memory', |
| 216 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 217 | *@description Text that is usually a hyperlink to more documentation |
| 218 | */ |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 219 | learnMore: 'Learn more', |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 220 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 221 | *@description Label for a stack trace. If a frame is created programmatically (i.e. via JavaScript), there is a |
| 222 | * stack trace for the line of code which caused the creation of the iframe. This is the stack trace we are showing here. |
| 223 | */ |
Wolfgang Beyer | dbf211e | 2021-11-23 10:23:54 | [diff] [blame] | 224 | creationStackTrace: 'Frame Creation `Stack Trace`', |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 225 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 226 | *@description Tooltip for 'Frame Creation Stack Trace' explaining that the stack |
| 227 | *trace shows where in the code the frame has been created programmatically |
| 228 | */ |
Wolfgang Beyer | dbf211e | 2021-11-23 10:23:54 | [diff] [blame] | 229 | creationStackTraceExplanation: |
| 230 | 'This frame was created programmatically. The `stack trace` shows where this happened.', |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 231 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 232 | *@description Text descripting why a frame has been indentified as an advertisement. |
| 233 | */ |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 234 | parentIsAdExplanation: 'This frame is considered an ad frame because its parent frame is an ad frame.', |
| 235 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 236 | *@description Text descripting why a frame has been indentified as an advertisement. |
| 237 | */ |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 238 | matchedBlockingRuleExplanation: |
| 239 | 'This frame is considered an ad frame because its current (or previous) main document is an ad resource.', |
| 240 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 241 | *@description Text descripting why a frame has been indentified as an advertisement. |
| 242 | */ |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 243 | createdByAdScriptExplanation: |
Wolfgang Beyer | dbf211e | 2021-11-23 10:23:54 | [diff] [blame] | 244 | 'There was an ad script in the `(async) stack` when this frame was created. Examining the creation `stack trace` of this frame might provide more insight.', |
Wolfgang Beyer | 1a432c4 | 2022-01-20 09:30:14 | [diff] [blame] | 245 | /** |
Jack Franklin | fd72c07 | 2022-12-21 11:45:01 | [diff] [blame] | 246 | *@description Label for a link to an ad script, which created the current iframe. |
| 247 | */ |
Danil Somsikov | c48b2b1 | 2022-06-24 15:03:03 | [diff] [blame] | 248 | creatorAdScript: 'Creator Ad Script', |
Wolfgang Beyer | 61baf65 | 2023-10-16 16:18:19 | [diff] [blame] | 249 | /** |
| 250 | *@description Text describing the absence of a value. |
| 251 | */ |
| 252 | none: 'None', |
Benedikt Meurer | 5eb9e24 | 2023-12-27 13:40:52 | [diff] [blame^] | 253 | /** |
| 254 | *@description Explanation of what origin trials are |
| 255 | *(https://developer.chrome.com/docs/web-platform/origin-trials/) |
| 256 | *(please don't translate 'origin trials'). |
| 257 | */ |
| 258 | originTrialsExplanation: 'Origin trials give you access to a new or experimental feature.', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 259 | }; |
Tim van der Lippe | 1bd5e21 | 2021-05-06 10:54:29 | [diff] [blame] | 260 | const str_ = i18n.i18n.registerUIStrings('panels/application/components/FrameDetailsView.ts', UIStrings); |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 261 | const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); |
Wolfgang Beyer | 3b4747f | 2020-08-12 07:30:46 | [diff] [blame] | 262 | |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 263 | const coordinator = Coordinator.RenderCoordinator.RenderCoordinator.instance(); |
| 264 | |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 265 | export interface FrameDetailsReportViewData { |
| 266 | frame: SDK.ResourceTreeModel.ResourceTreeFrame; |
Danil Somsikov | c48b2b1 | 2022-06-24 15:03:03 | [diff] [blame] | 267 | target?: SDK.Target.Target; |
Alex Rudenko | b8b4860 | 2022-10-17 12:59:58 | [diff] [blame] | 268 | adScriptId: Protocol.Page.AdScriptId|null; |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 269 | } |
| 270 | |
Danil Somsikov | 091da10 | 2023-06-09 21:56:03 | [diff] [blame] | 271 | export class FrameDetailsReportView extends LegacyWrapper.LegacyWrapper.WrappableComponent { |
Jack Franklin | af799b3 | 2021-07-01 08:37:18 | [diff] [blame] | 272 | static readonly litTagName = LitHtml.literal`devtools-resources-frame-details-view`; |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 273 | readonly #shadow = this.attachShadow({mode: 'open'}); |
| 274 | #frame?: SDK.ResourceTreeModel.ResourceTreeFrame; |
Danil Somsikov | c48b2b1 | 2022-06-24 15:03:03 | [diff] [blame] | 275 | #target?: SDK.Target.Target; |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 276 | #protocolMonitorExperimentEnabled = false; |
| 277 | #permissionsPolicies: Promise<Protocol.Page.PermissionsPolicyFeatureState[]|null>|null = null; |
| 278 | #permissionsPolicySectionData: PermissionsPolicySectionData = {policies: [], showDetails: false}; |
| 279 | #originTrialTreeView: OriginTrialTreeView = new OriginTrialTreeView(); |
Danil Somsikov | c48b2b1 | 2022-06-24 15:03:03 | [diff] [blame] | 280 | #linkifier = new Components.Linkifier.Linkifier(); |
Alex Rudenko | b8b4860 | 2022-10-17 12:59:58 | [diff] [blame] | 281 | #adScriptId: Protocol.Page.AdScriptId|null = null; |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 282 | |
Danil Somsikov | 5875b3b | 2023-05-17 21:41:36 | [diff] [blame] | 283 | constructor(frame: SDK.ResourceTreeModel.ResourceTreeFrame) { |
| 284 | super(); |
| 285 | this.#frame = frame; |
Danil Somsikov | 091da10 | 2023-06-09 21:56:03 | [diff] [blame] | 286 | void this.render(); |
Danil Somsikov | 5875b3b | 2023-05-17 21:41:36 | [diff] [blame] | 287 | } |
| 288 | |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 289 | connectedCallback(): void { |
Danil Somsikov | 2d619e1 | 2023-07-10 10:13:52 | [diff] [blame] | 290 | this.parentElement?.classList.add('overflow-auto'); |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 291 | this.#protocolMonitorExperimentEnabled = Root.Runtime.experiments.isEnabled('protocolMonitor'); |
| 292 | this.#shadow.adoptedStyleSheets = [frameDetailsReportViewStyles]; |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 293 | } |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 294 | |
Danil Somsikov | 5875b3b | 2023-05-17 21:41:36 | [diff] [blame] | 295 | override async render(): Promise<void> { |
| 296 | this.#adScriptId = (await this.#frame?.parentFrame()?.getAdScriptId(this.#frame?.id)) || null; |
| 297 | const debuggerModel = this.#adScriptId?.debuggerId ? |
| 298 | await SDK.DebuggerModel.DebuggerModel.modelForDebuggerId(this.#adScriptId?.debuggerId) : |
| 299 | null; |
| 300 | this.#target = debuggerModel?.target(); |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 301 | if (!this.#permissionsPolicies && this.#frame) { |
| 302 | this.#permissionsPolicies = this.#frame.getPermissionsPolicyState(); |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 303 | } |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 304 | await coordinator.write('FrameDetailsView render', () => { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 305 | if (!this.#frame) { |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 306 | return; |
| 307 | } |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 308 | |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 309 | // Disabled until https://crbug.com/1079231 is fixed. |
| 310 | // clang-format off |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 311 | LitHtml.render(LitHtml.html` |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 312 | <${ReportView.ReportView.Report.litTagName} .data=${{reportTitle: this.#frame.displayName()} as ReportView.ReportView.ReportData}> |
| 313 | ${this.#renderDocumentSection()} |
| 314 | ${this.#renderIsolationSection()} |
| 315 | ${this.#renderApiAvailabilitySection()} |
| 316 | ${this.#renderOriginTrial()} |
| 317 | ${LitHtml.Directives.until(this.#permissionsPolicies?.then(policies => { |
| 318 | this.#permissionsPolicySectionData.policies = policies || []; |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 319 | return LitHtml.html` |
| 320 | <${PermissionsPolicySection.litTagName} |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 321 | .data=${this.#permissionsPolicySectionData as PermissionsPolicySectionData} |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 322 | > |
| 323 | </${PermissionsPolicySection.litTagName}> |
| 324 | `; |
| 325 | }), LitHtml.nothing)} |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 326 | ${this.#protocolMonitorExperimentEnabled ? this.#renderAdditionalInfoSection() : LitHtml.nothing} |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 327 | </${ReportView.ReportView.Report.litTagName}> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 328 | `, this.#shadow, {host: this}); |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 329 | // clang-format on |
| 330 | }); |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 331 | } |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 332 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 333 | #renderOriginTrial(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 334 | if (!this.#frame) { |
Charlie Hu | 2086be5 | 2021-07-02 16:12:12 | [diff] [blame] | 335 | return LitHtml.nothing; |
| 336 | } |
Charlie Hu | 6c295cf | 2021-08-10 15:38:48 | [diff] [blame] | 337 | |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 338 | this.#originTrialTreeView.classList.add('span-cols'); |
Charlie Hu | 6c295cf | 2021-08-10 15:38:48 | [diff] [blame] | 339 | |
Benedikt Meurer | 5eb9e24 | 2023-12-27 13:40:52 | [diff] [blame^] | 340 | void this.#frame.getOriginTrials().then(trials => { |
| 341 | this.#originTrialTreeView.data = {trials}; |
| 342 | }); |
Charlie Hu | 6c295cf | 2021-08-10 15:38:48 | [diff] [blame] | 343 | |
Benedikt Meurer | 5eb9e24 | 2023-12-27 13:40:52 | [diff] [blame^] | 344 | // clang-format off |
Charlie Hu | 2086be5 | 2021-07-02 16:12:12 | [diff] [blame] | 345 | return LitHtml.html` |
Benedikt Meurer | 5eb9e24 | 2023-12-27 13:40:52 | [diff] [blame^] | 346 | <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18n.i18n.lockedString('Origin trials')}</${ReportView.ReportView.ReportSectionHeader.litTagName}> |
| 347 | <div class="span-cols"> |
| 348 | ${i18nString(UIStrings.originTrialsExplanation)} |
| 349 | <x-link href="https://developer.chrome.com/docs/web-platform/origin-trials/" class="link">${i18nString(UIStrings.learnMore)}</x-link> |
| 350 | </div> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 351 | ${this.#originTrialTreeView} |
Benedikt Meurer | 5eb9e24 | 2023-12-27 13:40:52 | [diff] [blame^] | 352 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ReportView.ReportView.ReportSectionDivider.litTagName}> |
Charlie Hu | 2086be5 | 2021-07-02 16:12:12 | [diff] [blame] | 353 | `; |
Benedikt Meurer | 5eb9e24 | 2023-12-27 13:40:52 | [diff] [blame^] | 354 | // clang-format on |
Charlie Hu | 2086be5 | 2021-07-02 16:12:12 | [diff] [blame] | 355 | } |
| 356 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 357 | #renderDocumentSection(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 358 | if (!this.#frame) { |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 359 | return LitHtml.nothing; |
| 360 | } |
| 361 | |
| 362 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 363 | <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.document)}</${ |
| 364 | ReportView.ReportView.ReportSectionHeader.litTagName}> |
Wolfgang Beyer | 5e451ff | 2021-12-08 16:44:35 | [diff] [blame] | 365 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.url)}</${ |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 366 | ReportView.ReportView.ReportKey.litTagName}> |
| 367 | <${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 368 | <div class="inline-items"> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 369 | ${this.#maybeRenderSourcesLinkForURL()} |
| 370 | ${this.#maybeRenderNetworkLinkForURL()} |
| 371 | <div class="text-ellipsis" title=${this.#frame.url}>${this.#frame.url}</div> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 372 | </div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 373 | </${ReportView.ReportView.ReportValue.litTagName}> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 374 | ${this.#maybeRenderUnreachableURL()} |
| 375 | ${this.#maybeRenderOrigin()} |
| 376 | ${LitHtml.Directives.until(this.#renderOwnerElement(), LitHtml.nothing)} |
| 377 | ${this.#maybeRenderCreationStacktrace()} |
| 378 | ${this.#maybeRenderAdStatus()} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 379 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ |
| 380 | ReportView.ReportView.ReportSectionDivider.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 381 | `; |
| 382 | } |
| 383 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 384 | #maybeRenderSourcesLinkForURL(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 385 | if (!this.#frame || this.#frame.unreachableUrl()) { |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 386 | return LitHtml.nothing; |
| 387 | } |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 388 | const sourceCode = this.#uiSourceCodeForFrame(this.#frame); |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 389 | return renderIconLink( |
Wolfgang Beyer | f64d63e | 2023-04-04 14:47:38 | [diff] [blame] | 390 | 'breakpoint-circle', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 391 | i18nString(UIStrings.clickToRevealInSourcesPanel), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 392 | (): Promise<void> => Common.Revealer.reveal(sourceCode), |
| 393 | ); |
| 394 | } |
| 395 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 396 | #maybeRenderNetworkLinkForURL(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 397 | if (this.#frame) { |
| 398 | const resource = this.#frame.resourceForURL(this.#frame.url); |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 399 | if (resource && resource.request) { |
| 400 | const request = resource.request; |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 401 | return renderIconLink( |
Wolfgang Beyer | f64d63e | 2023-04-04 14:47:38 | [diff] [blame] | 402 | 'arrow-up-down-circle', i18nString(UIStrings.clickToRevealInNetworkPanel), (): Promise<void> => { |
Wolfgang Beyer | 650e957 | 2023-11-29 12:45:08 | [diff] [blame] | 403 | const requestLocation = NetworkForward.UIRequestLocation.UIRequestLocation.tab( |
| 404 | request, NetworkForward.UIRequestLocation.UIRequestTabs.HeadersComponent); |
Sigurd Schneider | 14d3e9f | 2021-06-14 08:29:01 | [diff] [blame] | 405 | return Common.Revealer.reveal(requestLocation); |
| 406 | }); |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 407 | } |
| 408 | } |
| 409 | return LitHtml.nothing; |
| 410 | } |
| 411 | |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 412 | #uiSourceCodeForFrame(frame: SDK.ResourceTreeModel.ResourceTreeFrame): Workspace.UISourceCode.UISourceCode|null { |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 413 | for (const project of Workspace.Workspace.WorkspaceImpl.instance().projects()) { |
| 414 | const projectTarget = Bindings.NetworkProject.NetworkProject.getTargetForProject(project); |
| 415 | if (projectTarget && projectTarget === frame.resourceTreeModel().target()) { |
| 416 | const uiSourceCode = project.uiSourceCodeForURL(frame.url); |
| 417 | if (uiSourceCode) { |
| 418 | return uiSourceCode; |
| 419 | } |
| 420 | } |
| 421 | } |
| 422 | return null; |
| 423 | } |
| 424 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 425 | #maybeRenderUnreachableURL(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 426 | if (!this.#frame || !this.#frame.unreachableUrl()) { |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 427 | return LitHtml.nothing; |
| 428 | } |
| 429 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 430 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.unreachableUrl)}</${ |
| 431 | ReportView.ReportView.ReportKey.litTagName}> |
| 432 | <${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 433 | <div class="inline-items"> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 434 | ${this.#renderNetworkLinkForUnreachableURL()} |
| 435 | <div class="text-ellipsis" title=${this.#frame.unreachableUrl()}>${this.#frame.unreachableUrl()}</div> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 436 | </div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 437 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 438 | `; |
| 439 | } |
| 440 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 441 | #renderNetworkLinkForUnreachableURL(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 442 | if (this.#frame) { |
| 443 | const unreachableUrl = Common.ParsedURL.ParsedURL.fromString(this.#frame.unreachableUrl()); |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 444 | if (unreachableUrl) { |
Wolfgang Beyer | ffae99f | 2021-07-08 08:46:53 | [diff] [blame] | 445 | return renderIconLink( |
Wolfgang Beyer | f64d63e | 2023-04-04 14:47:38 | [diff] [blame] | 446 | 'arrow-up-down-circle', |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 447 | i18nString(UIStrings.clickToRevealInNetworkPanelMight), |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 448 | (): |
| 449 | void => { |
Tim van der Lippe | 2d9a95c | 2022-01-04 15:18:03 | [diff] [blame] | 450 | void Common.Revealer.reveal(NetworkForward.UIFilter.UIRequestFilter.filters([ |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 451 | { |
Sigurd Schneider | 3072258 | 2021-06-16 06:54:16 | [diff] [blame] | 452 | filterType: NetworkForward.UIFilter.FilterType.Domain, |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 453 | filterValue: unreachableUrl.domain(), |
| 454 | }, |
| 455 | { |
| 456 | filterType: null, |
| 457 | filterValue: unreachableUrl.path, |
| 458 | }, |
Sigurd Schneider | 3072258 | 2021-06-16 06:54:16 | [diff] [blame] | 459 | ])); |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 460 | }, |
| 461 | ); |
| 462 | } |
| 463 | } |
| 464 | return LitHtml.nothing; |
| 465 | } |
| 466 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 467 | #maybeRenderOrigin(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 468 | if (this.#frame && this.#frame.securityOrigin && this.#frame.securityOrigin !== '://') { |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 469 | return LitHtml.html` |
Wolfgang Beyer | 5e451ff | 2021-12-08 16:44:35 | [diff] [blame] | 470 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.origin)}</${ |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 471 | ReportView.ReportView.ReportKey.litTagName}> |
| 472 | <${ReportView.ReportView.ReportValue.litTagName}> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 473 | <div class="text-ellipsis" title=${this.#frame.securityOrigin}>${this.#frame.securityOrigin}</div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 474 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 475 | `; |
| 476 | } |
| 477 | return LitHtml.nothing; |
| 478 | } |
| 479 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 480 | async #renderOwnerElement(): Promise<LitHtml.LitTemplate> { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 481 | if (this.#frame) { |
| 482 | const linkTargetDOMNode = await this.#frame.getOwnerDOMNodeOrDocument(); |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 483 | if (linkTargetDOMNode) { |
| 484 | // Disabled until https://crbug.com/1079231 is fixed. |
| 485 | // clang-format off |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 486 | return LitHtml.html` |
Wolfgang Beyer | f64d63e | 2023-04-04 14:47:38 | [diff] [blame] | 487 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.ownerElement)}</${ReportView.ReportView.ReportKey.litTagName}> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 488 | <${ReportView.ReportView.ReportValue.litTagName} class="without-min-width"> |
Wolfgang Beyer | f64d63e | 2023-04-04 14:47:38 | [diff] [blame] | 489 | <div class="inline-items"> |
| 490 | <button class="link" role="link" tabindex=0 |
| 491 | @mouseenter=${(): Promise<void>|undefined => this.#frame?.highlight()} |
| 492 | @mouseleave=${(): void => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()} |
| 493 | @click=${(): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode)} |
| 494 | title=${i18nString(UIStrings.clickToRevealInElementsPanel)} |
| 495 | > |
| 496 | <${IconButton.Icon.Icon.litTagName} .data=${{ |
| 497 | iconName: 'code-circle', |
| 498 | color: 'var(--icon-link)', |
Kateryna Prokopenko | b6c6177 | 2023-04-26 12:43:12 | [diff] [blame] | 499 | width: '16px', |
| 500 | height: '16px', |
Wolfgang Beyer | f64d63e | 2023-04-04 14:47:38 | [diff] [blame] | 501 | } as IconButton.Icon.IconData}> |
| 502 | </${IconButton.Icon.Icon.litTagName}> |
| 503 | </button> |
| 504 | <button class="link text-link" role="link" tabindex=0 title=${i18nString(UIStrings.clickToRevealInElementsPanel)} |
| 505 | @mouseenter=${(): Promise<void>|undefined => this.#frame?.highlight()} |
| 506 | @mouseleave=${(): void => SDK.OverlayModel.OverlayModel.hideDOMNodeHighlight()} |
| 507 | @click=${(): Promise<void> => Common.Revealer.reveal(linkTargetDOMNode)} |
| 508 | > |
| 509 | <${linkTargetDOMNode.nodeName().toLocaleLowerCase()}> |
| 510 | </button> |
| 511 | </div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 512 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | f0d985e | 2021-02-05 12:56:52 | [diff] [blame] | 513 | `; |
| 514 | // clang-format on |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 515 | } |
| 516 | } |
| 517 | return LitHtml.nothing; |
| 518 | } |
| 519 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 520 | #maybeRenderCreationStacktrace(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 521 | const creationStackTraceData = this.#frame?.getCreationStackTraceData(); |
Wolfgang Beyer | a20485a | 2021-04-21 07:22:19 | [diff] [blame] | 522 | if (creationStackTraceData && creationStackTraceData.creationStackTrace) { |
Wolfgang Beyer | a036d0c | 2021-03-19 09:09:33 | [diff] [blame] | 523 | // Disabled until https://crbug.com/1079231 is fixed. |
| 524 | // clang-format off |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 525 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 526 | <${ReportView.ReportView.ReportKey.litTagName} title=${i18nString(UIStrings.creationStackTraceExplanation)}>${ |
| 527 | i18nString(UIStrings.creationStackTrace)}</${ReportView.ReportView.ReportKey.litTagName}> |
| 528 | <${ReportView.ReportView.ReportValue.litTagName}> |
| 529 | <${StackTrace.litTagName} .data=${{ |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 530 | frame: this.#frame, |
Wolfgang Beyer | a036d0c | 2021-03-19 09:09:33 | [diff] [blame] | 531 | buildStackTraceRows: Components.JSPresentationUtils.buildStackTraceRows, |
| 532 | } as StackTraceData}> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 533 | </${StackTrace.litTagName}> |
| 534 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 535 | `; |
Wolfgang Beyer | a036d0c | 2021-03-19 09:09:33 | [diff] [blame] | 536 | // clang-format on |
Wolfgang Beyer | 1909394 | 2021-03-15 15:00:34 | [diff] [blame] | 537 | } |
| 538 | return LitHtml.nothing; |
| 539 | } |
| 540 | |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 541 | #getAdFrameTypeStrings(type: Protocol.Page.AdFrameType.Child|Protocol.Page.AdFrameType.Root): |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 542 | {value: Platform.UIString.LocalizedString, description: Platform.UIString.LocalizedString} { |
| 543 | switch (type) { |
| 544 | case Protocol.Page.AdFrameType.Child: |
| 545 | return {value: i18nString(UIStrings.child), description: i18nString(UIStrings.childDescription)}; |
| 546 | case Protocol.Page.AdFrameType.Root: |
| 547 | return {value: i18nString(UIStrings.root), description: i18nString(UIStrings.rootDescription)}; |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 548 | } |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 549 | } |
| 550 | |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 551 | #getAdFrameExplanationString(explanation: Protocol.Page.AdFrameExplanation): Platform.UIString.LocalizedString { |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 552 | switch (explanation) { |
| 553 | case Protocol.Page.AdFrameExplanation.CreatedByAdScript: |
| 554 | return i18nString(UIStrings.createdByAdScriptExplanation); |
| 555 | case Protocol.Page.AdFrameExplanation.MatchedBlockingRule: |
| 556 | return i18nString(UIStrings.matchedBlockingRuleExplanation); |
| 557 | case Protocol.Page.AdFrameExplanation.ParentIsAd: |
| 558 | return i18nString(UIStrings.parentIsAdExplanation); |
| 559 | } |
| 560 | } |
| 561 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 562 | #maybeRenderAdStatus(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 563 | if (!this.#frame) { |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 564 | return LitHtml.nothing; |
| 565 | } |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 566 | const adFrameType = this.#frame.adFrameType(); |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 567 | if (adFrameType === Protocol.Page.AdFrameType.None) { |
| 568 | return LitHtml.nothing; |
| 569 | } |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 570 | const typeStrings = this.#getAdFrameTypeStrings(adFrameType); |
Jack Franklin | a31102b | 2021-12-03 15:01:22 | [diff] [blame] | 571 | const rows = [LitHtml.html`<div title=${typeStrings.description}>${typeStrings.value}</div>`]; |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 572 | for (const explanation of this.#frame.adFrameStatus()?.explanations || []) { |
| 573 | rows.push(LitHtml.html`<div>${this.#getAdFrameExplanationString(explanation)}</div>`); |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 574 | } |
Danil Somsikov | c48b2b1 | 2022-06-24 15:03:03 | [diff] [blame] | 575 | |
Alex Rudenko | b8b4860 | 2022-10-17 12:59:58 | [diff] [blame] | 576 | const adScriptLinkElement = this.#target ? this.#linkifier.linkifyScriptLocation( |
| 577 | this.#target, this.#adScriptId?.scriptId || null, |
| 578 | Platform.DevToolsPath.EmptyUrlString, undefined, undefined) : |
| 579 | null; |
Danil Somsikov | c48b2b1 | 2022-06-24 15:03:03 | [diff] [blame] | 580 | |
| 581 | // Disabled until https://crbug.com/1079231 is fixed. |
| 582 | // clang-format off |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 583 | return LitHtml.html` |
| 584 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.adStatus)}</${ |
| 585 | ReportView.ReportView.ReportKey.litTagName}> |
| 586 | <${ReportView.ReportView.ReportValue.litTagName}> |
Danil Somsikov | c48b2b1 | 2022-06-24 15:03:03 | [diff] [blame] | 587 | <${ExpandableList.ExpandableList.ExpandableList.litTagName} .data=${ |
| 588 | {rows} as ExpandableList.ExpandableList.ExpandableListData}></${ |
Sigurd Schneider | cc9a02e | 2021-06-16 06:20:33 | [diff] [blame] | 589 | ExpandableList.ExpandableList.ExpandableList.litTagName}></${ReportView.ReportView.ReportValue.litTagName}> |
Danil Somsikov | c48b2b1 | 2022-06-24 15:03:03 | [diff] [blame] | 590 | ${this.#target ? LitHtml.html` |
| 591 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.creatorAdScript)}</${ |
| 592 | ReportView.ReportView.ReportKey.litTagName}> |
| 593 | <${ReportView.ReportView.ReportValue.litTagName} class="ad-script-link">${adScriptLinkElement}</${ |
| 594 | ReportView.ReportView.ReportValue.litTagName}> |
| 595 | ` : LitHtml.nothing} |
| 596 | `; |
| 597 | // clang-format on |
Wolfgang Beyer | 1525b1f | 2021-02-02 14:12:30 | [diff] [blame] | 598 | } |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 599 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 600 | #renderIsolationSection(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 601 | if (!this.#frame) { |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 602 | return LitHtml.nothing; |
| 603 | } |
| 604 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 605 | <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.securityIsolation)}</${ |
| 606 | ReportView.ReportView.ReportSectionHeader.litTagName}> |
| 607 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.secureContext)}</${ |
| 608 | ReportView.ReportView.ReportKey.litTagName}> |
| 609 | <${ReportView.ReportView.ReportValue.litTagName}> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 610 | ${this.#frame.isSecureContext() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)}\xA0${ |
| 611 | this.#maybeRenderSecureContextExplanation()} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 612 | </${ReportView.ReportView.ReportValue.litTagName}> |
| 613 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.crossoriginIsolated)}</${ |
| 614 | ReportView.ReportView.ReportKey.litTagName}> |
| 615 | <${ReportView.ReportView.ReportValue.litTagName}> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 616 | ${this.#frame.isCrossOriginIsolated() ? i18nString(UIStrings.yes) : i18nString(UIStrings.no)} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 617 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 61baf65 | 2023-10-16 16:18:19 | [diff] [blame] | 618 | ${LitHtml.Directives.until(this.#maybeRenderCoopCoepCSPStatus(), LitHtml.nothing)} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 619 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ |
| 620 | ReportView.ReportView.ReportSectionDivider.litTagName}> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 621 | `; |
| 622 | } |
| 623 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 624 | #maybeRenderSecureContextExplanation(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 625 | const explanation = this.#getSecureContextExplanation(); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 626 | if (explanation) { |
Tim van der Lippe | 0005b80 | 2021-06-03 10:47:59 | [diff] [blame] | 627 | return LitHtml.html`<span class="inline-comment">${explanation}</span>`; |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 628 | } |
| 629 | return LitHtml.nothing; |
| 630 | } |
| 631 | |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 632 | #getSecureContextExplanation(): Platform.UIString.LocalizedString|null { |
| 633 | switch (this.#frame?.getSecureContextType()) { |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 634 | case Protocol.Page.SecureContextType.Secure: |
| 635 | return null; |
| 636 | case Protocol.Page.SecureContextType.SecureLocalhost: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 637 | return i18nString(UIStrings.localhostIsAlwaysASecureContext); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 638 | case Protocol.Page.SecureContextType.InsecureAncestor: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 639 | return i18nString(UIStrings.aFrameAncestorIsAnInsecure); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 640 | case Protocol.Page.SecureContextType.InsecureScheme: |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 641 | return i18nString(UIStrings.theFramesSchemeIsInsecure); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 642 | } |
| 643 | return null; |
| 644 | } |
| 645 | |
Wolfgang Beyer | 61baf65 | 2023-10-16 16:18:19 | [diff] [blame] | 646 | async #maybeRenderCoopCoepCSPStatus(): Promise<LitHtml.LitTemplate> { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 647 | if (this.#frame) { |
| 648 | const model = this.#frame.resourceTreeModel().target().model(SDK.NetworkManager.NetworkManager); |
| 649 | const info = model && await model.getSecurityIsolationStatus(this.#frame.id); |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 650 | if (info) { |
| 651 | return LitHtml.html` |
| 652 | ${ |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 653 | this.#maybeRenderCrossOriginStatus( |
Wolfgang Beyer | dbf211e | 2021-11-23 10:23:54 | [diff] [blame] | 654 | info.coep, i18n.i18n.lockedString('Cross-Origin Embedder Policy (COEP)'), |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 655 | Protocol.Network.CrossOriginEmbedderPolicyValue.None)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 656 | ${ |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 657 | this.#maybeRenderCrossOriginStatus( |
Wolfgang Beyer | dbf211e | 2021-11-23 10:23:54 | [diff] [blame] | 658 | info.coop, i18n.i18n.lockedString('Cross-Origin Opener Policy (COOP)'), |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 659 | Protocol.Network.CrossOriginOpenerPolicyValue.UnsafeNone)} |
Wolfgang Beyer | 61baf65 | 2023-10-16 16:18:19 | [diff] [blame] | 660 | ${this.#renderCSPSection(info.csp)} |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 661 | `; |
| 662 | } |
| 663 | } |
| 664 | return LitHtml.nothing; |
| 665 | } |
| 666 | |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 667 | #maybeRenderCrossOriginStatus( |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 668 | info: Protocol.Network.CrossOriginEmbedderPolicyStatus|Protocol.Network.CrossOriginOpenerPolicyStatus|undefined, |
| 669 | policyName: string, |
| 670 | noneValue: Protocol.Network.CrossOriginEmbedderPolicyValue| |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 671 | Protocol.Network.CrossOriginOpenerPolicyValue): LitHtml.LitTemplate { |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 672 | if (!info) { |
| 673 | return LitHtml.nothing; |
| 674 | } |
| 675 | const isEnabled = info.value !== noneValue; |
| 676 | const isReportOnly = (!isEnabled && info.reportOnlyValue !== noneValue); |
| 677 | const endpoint = isEnabled ? info.reportingEndpoint : info.reportOnlyReportingEndpoint; |
| 678 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 679 | <${ReportView.ReportView.ReportKey.litTagName}>${policyName}</${ReportView.ReportView.ReportKey.litTagName}> |
| 680 | <${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 681 | ${isEnabled ? info.value : info.reportOnlyValue} |
| 682 | ${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] | 683 | ${ |
| 684 | endpoint ? LitHtml.html`<span class="inline-name">${i18nString(UIStrings.reportingTo)}</span>${endpoint}` : |
| 685 | LitHtml.nothing} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 686 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | abfc847 | 2021-02-04 11:29:50 | [diff] [blame] | 687 | `; |
| 688 | } |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 689 | |
Wolfgang Beyer | 61baf65 | 2023-10-16 16:18:19 | [diff] [blame] | 690 | #renderEffectiveDirectives(directives: string): LitHtml.LitTemplate[] { |
| 691 | const parsedDirectives = new CspEvaluator.CspParser.CspParser(directives).csp.directives; |
| 692 | const result = []; |
| 693 | for (const directive in parsedDirectives) { |
| 694 | result.push(LitHtml.html`<div><span class="bold">${directive}</span>${ |
| 695 | ': ' + parsedDirectives[directive]?.join(', ')}</div>`); |
| 696 | } |
| 697 | return result; |
| 698 | } |
| 699 | |
| 700 | #renderSingleCSP(cspInfo: Protocol.Network.ContentSecurityPolicyStatus): LitHtml.LitTemplate { |
| 701 | // Disabled until https://crbug.com/1079231 is fixed. |
| 702 | // clang-format off |
| 703 | return LitHtml.html` |
| 704 | <${ReportView.ReportView.ReportKey.litTagName}>${ |
| 705 | cspInfo.isEnforced ? i18n.i18n.lockedString('Content-Security-Policy') : |
| 706 | LitHtml.html`${ |
| 707 | i18n.i18n.lockedString('Content-Security-Policy-Report-Only') |
| 708 | }<x-link |
| 709 | class="link" |
| 710 | href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only" |
| 711 | ><${ |
| 712 | IconButton.Icon.Icon.litTagName} .data=${{ |
| 713 | iconName: 'help', |
| 714 | color: 'var(--icon-link)', |
| 715 | width: '16px', |
| 716 | height: '16px', |
| 717 | } as IconButton.Icon.IconData}> |
| 718 | </${IconButton.Icon.Icon.litTagName |
| 719 | }></x-link>` |
| 720 | } |
| 721 | </${ReportView.ReportView.ReportKey.litTagName}> |
| 722 | <${ReportView.ReportView.ReportValue.litTagName}> |
| 723 | <${IconButton.Icon.Icon.litTagName} class="inline-icon" .data=${{ |
| 724 | iconName: 'code', |
| 725 | color: 'var(--icon-default)', |
| 726 | width: '18px', |
| 727 | height: '18px', |
| 728 | } as IconButton.Icon.IconData}> |
| 729 | </${IconButton.Icon.Icon.litTagName}> |
| 730 | ${cspInfo.source === Protocol.Network.ContentSecurityPolicySource.HTTP ? i18n.i18n.lockedString('HTTP header') : i18n.i18n.lockedString('Meta tag')} |
| 731 | ${this.#renderEffectiveDirectives(cspInfo.effectiveDirectives)} |
| 732 | </${ReportView.ReportView.ReportValue.litTagName}> |
| 733 | `; |
| 734 | // clang-format on |
| 735 | } |
| 736 | |
| 737 | #renderCSPSection(cspInfos: Protocol.Network.ContentSecurityPolicyStatus[]|undefined): LitHtml.LitTemplate { |
| 738 | // Disabled until https://crbug.com/1079231 is fixed. |
| 739 | // clang-format off |
| 740 | return LitHtml.html` |
| 741 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ReportView.ReportView.ReportSectionDivider.litTagName}> |
| 742 | <${ReportView.ReportView.ReportSectionHeader.litTagName}> |
| 743 | ${i18nString(UIStrings.contentSecurityPolicy)} |
| 744 | </${ReportView.ReportView.ReportSectionHeader.litTagName}> |
| 745 | ${(cspInfos && cspInfos.length) ? cspInfos.map(cspInfo => this.#renderSingleCSP(cspInfo)) : LitHtml.html` |
| 746 | <${ReportView.ReportView.ReportKey.litTagName}>${ |
| 747 | i18n.i18n.lockedString('Content-Security-Policy')}</${ |
| 748 | ReportView.ReportView.ReportKey.litTagName}> |
| 749 | <${ReportView.ReportView.ReportValue.litTagName}> |
| 750 | ${i18nString(UIStrings.none)} |
| 751 | </${ReportView.ReportView.ReportValue.litTagName}> |
| 752 | `} |
| 753 | `; |
| 754 | // clang-format on |
| 755 | } |
| 756 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 757 | #renderApiAvailabilitySection(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 758 | if (!this.#frame) { |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 759 | return LitHtml.nothing; |
| 760 | } |
| 761 | |
| 762 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 763 | <${ReportView.ReportView.ReportSectionHeader.litTagName}>${i18nString(UIStrings.apiAvailability)}</${ |
| 764 | ReportView.ReportView.ReportSectionHeader.litTagName}> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 765 | <div class="span-cols"> |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 766 | ${i18nString(UIStrings.availabilityOfCertainApisDepends)} |
Wolfgang Beyer | 4751c1c | 2021-03-24 15:32:35 | [diff] [blame] | 767 | <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] | 768 | </div> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 769 | ${this.#renderSharedArrayBufferAvailability()} |
| 770 | ${this.#renderMeasureMemoryAvailability()} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 771 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ |
| 772 | ReportView.ReportView.ReportSectionDivider.litTagName}> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 773 | `; |
| 774 | } |
| 775 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 776 | #renderSharedArrayBufferAvailability(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 777 | if (this.#frame) { |
| 778 | const features = this.#frame.getGatedAPIFeatures(); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 779 | if (features) { |
| 780 | const sabAvailable = features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffers); |
| 781 | const sabTransferAvailable = |
| 782 | sabAvailable && features.includes(Protocol.Page.GatedAPIFeatures.SharedArrayBuffersTransferAllowed); |
| 783 | const availabilityText = sabTransferAvailable ? |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 784 | i18nString(UIStrings.availableTransferable) : |
| 785 | (sabAvailable ? i18nString(UIStrings.availableNotTransferable) : i18nString(UIStrings.unavailable)); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 786 | const tooltipText = sabTransferAvailable ? |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 787 | i18nString(UIStrings.sharedarraybufferConstructorIs) : |
| 788 | (sabAvailable ? i18nString(UIStrings.sharedarraybufferConstructorIsAvailable) : ''); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 789 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 790 | function renderHint(frame: SDK.ResourceTreeModel.ResourceTreeFrame): LitHtml.LitTemplate { |
Sigurd Schneider | 2a45025 | 2021-05-04 07:13:15 | [diff] [blame] | 791 | switch (frame.getCrossOriginIsolatedContextType()) { |
| 792 | case Protocol.Page.CrossOriginIsolatedContextType.Isolated: |
| 793 | return LitHtml.nothing; |
| 794 | case Protocol.Page.CrossOriginIsolatedContextType.NotIsolated: |
| 795 | if (sabAvailable) { |
| 796 | return LitHtml.html`<span class="inline-comment">${ |
| 797 | i18nString(UIStrings.willRequireCrossoriginIsolated)}</span>`; |
| 798 | } |
| 799 | return LitHtml.html`<span class="inline-comment">${ |
| 800 | i18nString(UIStrings.requiresCrossoriginIsolated)}</span>`; |
| 801 | case Protocol.Page.CrossOriginIsolatedContextType.NotIsolatedFeatureDisabled: |
| 802 | if (!sabTransferAvailable) { |
| 803 | return LitHtml.html`<span class="inline-comment">${ |
| 804 | i18nString( |
| 805 | UIStrings |
| 806 | .transferRequiresCrossoriginIsolatedPermission)} <code>cross-origin-isolated</code></span>`; |
| 807 | } |
| 808 | break; |
| 809 | } |
| 810 | return LitHtml.nothing; |
| 811 | } |
| 812 | |
Peter Marshall | 0e1cd82 | 2021-02-24 10:52:42 | [diff] [blame] | 813 | // SharedArrayBuffer is an API name, so we don't translate it. |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 814 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 815 | <${ReportView.ReportView.ReportKey.litTagName}>SharedArrayBuffers</${ |
| 816 | ReportView.ReportView.ReportKey.litTagName}> |
| 817 | <${ReportView.ReportView.ReportValue.litTagName} title=${tooltipText}> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 818 | ${availabilityText}\xA0${renderHint(this.#frame)} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 819 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 820 | `; |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 821 | } |
| 822 | } |
| 823 | return LitHtml.nothing; |
| 824 | } |
| 825 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 826 | #renderMeasureMemoryAvailability(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 827 | if (this.#frame) { |
| 828 | const measureMemoryAvailable = this.#frame.isCrossOriginIsolated(); |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 829 | const availabilityText = |
| 830 | measureMemoryAvailable ? i18nString(UIStrings.available) : i18nString(UIStrings.unavailable); |
| 831 | const tooltipText = measureMemoryAvailable ? i18nString(UIStrings.thePerformanceAPI) : |
| 832 | i18nString(UIStrings.thePerformancemeasureuseragentspecificmemory); |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 833 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 834 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.measureMemory)}</${ |
| 835 | ReportView.ReportView.ReportKey.litTagName}> |
| 836 | <${ReportView.ReportView.ReportValue.litTagName}> |
Tim van der Lippe | 0005b80 | 2021-06-03 10:47:59 | [diff] [blame] | 837 | <span title=${tooltipText}>${ |
| 838 | 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] | 839 | i18nString(UIStrings.learnMore)}</x-link> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 840 | </${ReportView.ReportView.ReportValue.litTagName}> |
Wolfgang Beyer | 6a6efe6 | 2021-02-04 15:56:21 | [diff] [blame] | 841 | `; |
| 842 | } |
| 843 | return LitHtml.nothing; |
| 844 | } |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 845 | |
Jack Franklin | d750830 | 2022-05-09 14:22:21 | [diff] [blame] | 846 | #renderAdditionalInfoSection(): LitHtml.LitTemplate { |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 847 | if (!this.#frame) { |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 848 | return LitHtml.nothing; |
| 849 | } |
| 850 | |
| 851 | return LitHtml.html` |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 852 | <${ReportView.ReportView.ReportSectionHeader.litTagName} |
Vidal Guillermo Diazleal Ortega | 0a997bb | 2021-02-09 04:33:01 | [diff] [blame] | 853 | title=${i18nString(UIStrings.thisAdditionalDebugging)} |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 854 | >${i18nString(UIStrings.additionalInformation)}</${ReportView.ReportView.ReportSectionHeader.litTagName}> |
| 855 | <${ReportView.ReportView.ReportKey.litTagName}>${i18nString(UIStrings.frameId)}</${ |
| 856 | ReportView.ReportView.ReportKey.litTagName}> |
| 857 | <${ReportView.ReportView.ReportValue.litTagName}> |
Tim van der Lippe | c3f835a | 2021-12-15 13:28:32 | [diff] [blame] | 858 | <div class="text-ellipsis" title=${this.#frame.id}>${this.#frame.id}</div> |
Kriti Sapra | 7491545 | 2021-05-13 11:57:36 | [diff] [blame] | 859 | </${ReportView.ReportView.ReportValue.litTagName}> |
| 860 | <${ReportView.ReportView.ReportSectionDivider.litTagName}></${ |
| 861 | ReportView.ReportView.ReportSectionDivider.litTagName}> |
Wolfgang Beyer | e5d1a9f | 2021-02-05 09:42:43 | [diff] [blame] | 862 | `; |
| 863 | } |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 864 | } |
| 865 | |
Kriti Sapra | 34df98d | 2021-05-06 10:15:42 | [diff] [blame] | 866 | ComponentHelpers.CustomElements.defineComponent('devtools-resources-frame-details-view', FrameDetailsReportView); |
Wolfgang Beyer | 92395c9 | 2021-02-02 10:43:23 | [diff] [blame] | 867 | |
| 868 | declare global { |
| 869 | // eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 870 | interface HTMLElementTagNameMap { |
| 871 | 'devtools-resources-frame-details-view': FrameDetailsReportView; |
| 872 | } |
| 873 | } |