Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1 | // Copyright 2021 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 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 5 | /* |
| 6 | * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 7 | * Copyright (C) 2008, 2009 Anthony Ricaud <[email protected]> |
| 8 | * Copyright (C) 2011 Google Inc. All rights reserved. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in the |
| 18 | * documentation and/or other materials provided with the distribution. |
| 19 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
| 20 | * its contributors may be used to endorse or promote products derived |
| 21 | * from this software without specific prior written permission. |
| 22 | * |
| 23 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 24 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 26 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 27 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 30 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | */ |
| 34 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 35 | /* eslint-disable rulesdir/no_underscored_properties */ |
| 36 | |
Tim van der Lippe | f596ca0 | 2021-03-31 10:02:47 | [diff] [blame] | 37 | import * as Components from '../../components/components.js'; |
Tim van der Lippe | 7696157 | 2021-04-06 10:48:07 | [diff] [blame] | 38 | import * as Common from '../../core/common/common.js'; |
Tim van der Lippe | e024731 | 2021-04-01 14:25:30 | [diff] [blame] | 39 | import * as Host from '../../core/host/host.js'; |
Tim van der Lippe | bb352e6 | 2021-04-01 17:57:28 | [diff] [blame] | 40 | import * as i18n from '../../core/i18n/i18n.js'; |
Tim van der Lippe | aa1ed7a | 2021-03-31 14:38:27 | [diff] [blame] | 41 | import * as Platform from '../../core/platform/platform.js'; |
Tim van der Lippe | e00b92f | 2021-03-31 16:52:17 | [diff] [blame] | 42 | import * as SDK from '../../core/sdk/sdk.js'; |
Tim van der Lippe | f596ca0 | 2021-03-31 10:02:47 | [diff] [blame] | 43 | import * as HARImporter from '../../har_importer/har_importer.js'; |
Tim van der Lippe | 959b6f0 | 2021-04-07 09:07:59 | [diff] [blame] | 44 | import * as Bindings from '../../models/bindings/bindings.js'; |
Sigurd Schneider | 055e2e3 | 2021-04-12 11:10:42 | [diff] [blame] | 45 | import * as IssuesManager from '../../models/issues_manager/issues_manager.js'; |
Tim van der Lippe | fca98ed | 2021-04-08 14:10:14 | [diff] [blame] | 46 | import * as TextUtils from '../../models/text_utils/text_utils.js'; |
Tim van der Lippe | f596ca0 | 2021-03-31 10:02:47 | [diff] [blame] | 47 | import * as ThemeSupport from '../../theme_support/theme_support.js'; |
Tim van der Lippe | 8499fe2 | 2021-04-12 16:42:47 | [diff] [blame] | 48 | import * as DataGrid from '../../ui/legacy/components/data_grid/data_grid.js'; |
Tim van der Lippe | 3167ffe | 2021-04-12 16:45:14 | [diff] [blame] | 49 | import * as PerfUI from '../../ui/legacy/components/perf_ui/perf_ui.js'; |
Tim van der Lippe | aa61faf | 2021-04-07 15:32:07 | [diff] [blame] | 50 | import * as UI from '../../ui/legacy/legacy.js'; |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 51 | |
Tim van der Lippe | 119690c | 2020-01-13 12:31:30 | [diff] [blame] | 52 | import {HARWriter} from './HARWriter.js'; |
| 53 | import {Events, NetworkGroupNode, NetworkLogViewInterface, NetworkNode, NetworkRequestNode} from './NetworkDataGridNode.js'; // eslint-disable-line no-unused-vars |
| 54 | import {NetworkFrameGrouper} from './NetworkFrameGrouper.js'; |
| 55 | import {NetworkLogViewColumns} from './NetworkLogViewColumns.js'; |
chait pinnamaneni | 6bc1c12 | 2020-10-30 17:30:52 | [diff] [blame] | 56 | import {FilterOptions} from './NetworkPanel.js'; // eslint-disable-line no-unused-vars |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 57 | import {NetworkTimeBoundary, NetworkTimeCalculator, NetworkTransferDurationCalculator, NetworkTransferTimeCalculator} from './NetworkTimeCalculator.js'; // eslint-disable-line no-unused-vars |
Tim van der Lippe | 119690c | 2020-01-13 12:31:30 | [diff] [blame] | 58 | |
Simon Zünd | 3449069 | 2021-03-01 08:25:18 | [diff] [blame] | 59 | const UIStrings = { |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 60 | /** |
| 61 | *@description Text in Network Log View of the Network panel |
| 62 | */ |
| 63 | hideDataUrls: 'Hide data URLs', |
| 64 | /** |
| 65 | *@description Data urlfilter ui element title in Network Log View of the Network panel |
| 66 | */ |
| 67 | hidesDataAndBlobUrls: 'Hides data: and blob: URLs', |
| 68 | /** |
| 69 | *@description Aria accessible name in Network Log View of the Network panel |
| 70 | */ |
| 71 | resourceTypesToInclude: 'Resource types to include', |
| 72 | /** |
| 73 | *@description Label for a filter in the Network panel |
| 74 | */ |
| 75 | hasBlockedCookies: 'Has blocked cookies', |
| 76 | /** |
Simon Zünd | 562d32c | 2021-02-17 09:22:54 | [diff] [blame] | 77 | *@description Tooltip for a checkbox in the Network panel. The response to a network request may include a |
| 78 | * cookie (https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies). Such response cookies can |
| 79 | * be malformed or otherwise invalid and the browser may choose to ignore or not accept invalid cookies. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 80 | */ |
| 81 | onlyShowRequestsWithBlocked: 'Only show requests with blocked response cookies', |
| 82 | /** |
| 83 | *@description Label for a filter in the Network panel |
| 84 | */ |
| 85 | blockedRequests: 'Blocked Requests', |
| 86 | /** |
| 87 | *@description Tooltip for a filter in the Network panel |
| 88 | */ |
| 89 | onlyShowBlockedRequests: 'Only show blocked requests', |
| 90 | /** |
| 91 | *@description Text that appears when user drag and drop something (for example, a file) in Network Log View of the Network panel |
| 92 | */ |
| 93 | dropHarFilesHere: 'Drop HAR files here', |
| 94 | /** |
| 95 | *@description Recording text text content in Network Log View of the Network panel |
| 96 | */ |
| 97 | recordingNetworkActivity: 'Recording network activity…', |
| 98 | /** |
| 99 | *@description Text in Network Log View of the Network panel |
| 100 | *@example {Ctrl + R} PH1 |
| 101 | */ |
| 102 | performARequestOrHitSToRecordThe: 'Perform a request or hit {PH1} to record the reload.', |
| 103 | /** |
Peter Marshall | 266ab2e | 2021-02-16 17:30:49 | [diff] [blame] | 104 | *@description Shown in the Network Log View of the Network panel when the user has not yet |
| 105 | * recorded any network activity. This is an instruction to the user to start recording in order to |
| 106 | * show network activity in the current UI. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 107 | *@example {Ctrl + E} PH1 |
| 108 | */ |
| 109 | recordSToDisplayNetworkActivity: 'Record ({PH1}) to display network activity.', |
| 110 | /** |
| 111 | *@description Text that is usually a hyperlink to more documentation |
| 112 | */ |
| 113 | learnMore: 'Learn more', |
| 114 | /** |
| 115 | *@description Text to announce to screen readers that network data is available. |
| 116 | */ |
| 117 | networkDataAvailable: 'Network Data Available', |
| 118 | /** |
| 119 | *@description Text in Network Log View of the Network panel |
| 120 | *@example {3} PH1 |
| 121 | *@example {5} PH2 |
| 122 | */ |
| 123 | sSRequests: '{PH1} / {PH2} requests', |
| 124 | /** |
Andres Olivares | 7fbed14 | 2021-03-01 16:22:23 | [diff] [blame] | 125 | *@description Message in the summary toolbar at the bottom of the Network log that shows the compressed size of the |
| 126 | * resources transferred during a selected time frame over the compressed size of all resources transferred during |
| 127 | * the whole network log. |
| 128 | *@example {5 B} PH1 |
| 129 | *@example {10 B} PH2 |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 130 | */ |
| 131 | sSTransferred: '{PH1} / {PH2} transferred', |
| 132 | /** |
Andres Olivares | 7fbed14 | 2021-03-01 16:22:23 | [diff] [blame] | 133 | *@description Message in a tooltip that shows the compressed size of the resources transferred during a selected |
| 134 | * time frame over the compressed size of all resources transferred during the whole network log. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 135 | *@example {10} PH1 |
| 136 | *@example {15} PH2 |
| 137 | */ |
| 138 | sBSBTransferredOverNetwork: '{PH1} B / {PH2} B transferred over network', |
| 139 | /** |
Peter Marshall | 2c3fb30 | 2021-02-19 12:47:04 | [diff] [blame] | 140 | * @description Text in Network Log View of the Network panel. Appears when a particular network |
| 141 | * resource is selected by the user. Shows how large the selected resource was (PH1) out of the |
| 142 | * total size (PH2). |
| 143 | * @example {40MB} PH1 |
| 144 | * @example {50MB} PH2 |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 145 | */ |
| 146 | sSResources: '{PH1} / {PH2} resources', |
| 147 | /** |
| 148 | *@description Text in Network Log View of the Network panel |
| 149 | *@example {40} PH1 |
| 150 | *@example {50} PH2 |
| 151 | */ |
| 152 | sBSBResourcesLoadedByThePage: '{PH1} B / {PH2} B resources loaded by the page', |
| 153 | /** |
| 154 | *@description Text in Network Log View of the Network panel |
| 155 | *@example {6} PH1 |
| 156 | */ |
| 157 | sRequests: '{PH1} requests', |
| 158 | /** |
Andres Olivares | 0a863ab | 2021-02-19 15:21:23 | [diff] [blame] | 159 | *@description Message in the summary toolbar at the bottom of the Network log that shows the compressed size of |
| 160 | * all resources transferred over network during a network activity log. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 161 | *@example {4 B} PH1 |
| 162 | */ |
| 163 | sTransferred: '{PH1} transferred', |
| 164 | /** |
Andres Olivares | 0a863ab | 2021-02-19 15:21:23 | [diff] [blame] | 165 | *@description Message in a tooltip that shows the compressed size of all resources transferred over network during |
| 166 | * a network activity log. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 167 | *@example {4} PH1 |
| 168 | */ |
| 169 | sBTransferredOverNetwork: '{PH1} B transferred over network', |
| 170 | /** |
| 171 | *@description Text in Network Log View of the Network panel |
| 172 | *@example {4} PH1 |
| 173 | */ |
| 174 | sResources: '{PH1} resources', |
| 175 | /** |
| 176 | *@description Text in Network Log View of the Network panel |
| 177 | *@example {10} PH1 |
| 178 | */ |
| 179 | sBResourcesLoadedByThePage: '{PH1} B resources loaded by the page', |
| 180 | /** |
| 181 | *@description Text in Network Log View of the Network panel |
| 182 | *@example {120ms} PH1 |
| 183 | */ |
| 184 | finishS: 'Finish: {PH1}', |
| 185 | /** |
| 186 | *@description Text in Network Log View of the Network panel |
| 187 | *@example {3000ms} PH1 |
| 188 | */ |
| 189 | domcontentloadedS: 'DOMContentLoaded: {PH1}', |
| 190 | /** |
| 191 | *@description Text in Network Log View of the Network panel |
| 192 | *@example {40ms} PH1 |
| 193 | */ |
| 194 | loadS: 'Load: {PH1}', |
| 195 | /** |
| 196 | *@description Text for copying |
| 197 | */ |
| 198 | copy: 'Copy', |
| 199 | /** |
| 200 | *@description Text in Network Log View of the Network panel |
| 201 | */ |
| 202 | copyRequestHeaders: 'Copy request headers', |
| 203 | /** |
| 204 | *@description Text in Network Log View of the Network panel |
| 205 | */ |
| 206 | copyResponseHeaders: 'Copy response headers', |
| 207 | /** |
| 208 | *@description Text in Network Log View of the Network panel |
| 209 | */ |
| 210 | copyResponse: 'Copy response', |
| 211 | /** |
| 212 | *@description Text in Network Log View of the Network panel |
| 213 | */ |
Peter Marshall | f625dc8 | 2021-03-02 08:10:57 | [diff] [blame] | 214 | copyStacktrace: 'Copy stack trace', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 215 | /** |
Peter Marshall | 3ec813d | 2021-03-01 19:40:25 | [diff] [blame] | 216 | * @description A context menu command in the Network panel, for copying to the clipboard. |
| 217 | * PowerShell refers to the format the data will be copied as. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 218 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 219 | copyAsPowershell: 'Copy as `PowerShell`', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 220 | /** |
Peter Marshall | 3ec813d | 2021-03-01 19:40:25 | [diff] [blame] | 221 | *@description A context menu command in the Network panel, for copying to the clipboard. 'fetch' |
| 222 | * refers to the format the data will be copied as, which is compatible with the fetch web API. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 223 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 224 | copyAsFetch: 'Copy as `fetch`', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 225 | /** |
Peter Marshall | 3ec813d | 2021-03-01 19:40:25 | [diff] [blame] | 226 | * @description Text in Network Log View of the Network panel. An action that copies a command to |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 227 | * the developer's clipboard. The command allows the developer to replay this specific network |
| 228 | * request in Node.js, a desktop application/framework. 'Node.js fetch' is a noun phrase for the |
| 229 | * type of request that will be copied. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 230 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 231 | copyAsNodejsFetch: 'Copy as `Node.js` `fetch`', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 232 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 233 | *@description Text in Network Log View of the Network panel. An action that copies a command to |
| 234 | *the clipboard. It will copy the command in the format compatible with cURL (a program, not |
| 235 | *translatable). |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 236 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 237 | copyAsCurlCmd: 'Copy as `cURL` (`cmd`)', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 238 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 239 | *@description Text in Network Log View of the Network panel. An action that copies a command to |
| 240 | *the clipboard. It will copy the command in the format compatible with a Bash script. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 241 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 242 | copyAsCurlBash: 'Copy as `cURL` (`bash`)', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 243 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 244 | *@description Text in Network Log View of the Network panel. An action that copies a command to |
| 245 | *the clipboard. It will copy the command in the format compatible with a PowerShell script. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 246 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 247 | copyAllAsPowershell: 'Copy all as `PowerShell`', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 248 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 249 | *@description Text in Network Log View of the Network panel. An action that copies a command to |
| 250 | *the clipboard. It will copy the command in the format compatible with a 'fetch' command (fetch |
| 251 | *should not be translated). |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 252 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 253 | copyAllAsFetch: 'Copy all as `fetch`', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 254 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 255 | *@description Text in Network Log View of the Network panel. An action that copies a command to |
| 256 | *the clipboard. It will copy the command in the format compatible with a Node.js 'fetch' command |
| 257 | *(fetch and Node.js should not be translated). |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 258 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 259 | copyAllAsNodejsFetch: 'Copy all as `Node.js` `fetch`', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 260 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 261 | *@description Text in Network Log View of the Network panel. An action that copies a command to |
| 262 | *the clipboard. It will copy the command in the format compatible with cURL (a program, not |
| 263 | *translatable). |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 264 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 265 | copyAllAsCurlCmd: 'Copy all as `cURL` (`cmd`)', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 266 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 267 | *@description Text in Network Log View of the Network panel. An action that copies a command to |
| 268 | *the clipboard. It will copy the command in the format compatible with a Bash script. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 269 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 270 | copyAllAsCurlBash: 'Copy all as `cURL` (`bash`)', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 271 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 272 | *@description Text in Network Log View of the Network panel. An action that copies a command to |
| 273 | *the clipboard. It will copy the command in the format compatible with cURL (a program, not |
| 274 | *translatable). |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 275 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 276 | copyAsCurl: 'Copy as `cURL`', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 277 | /** |
Peter Marshall | ec86188 | 2021-02-16 11:14:21 | [diff] [blame] | 278 | *@description Text in Network Log View of the Network panel. An action that copies a command to |
| 279 | *the clipboard. It will copy the command in the format compatible with cURL (a program, not |
| 280 | *translatable). |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 281 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 282 | copyAllAsCurl: 'Copy all as `cURL`', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 283 | /** |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 284 | * @description Text in Network Log View of the Network panel. An action that copies data to the |
| 285 | * clipboard. It will copy the data in the HAR (not translatable) format. 'all' refers to every |
| 286 | * network request that is currently shown. |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 287 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 288 | copyAllAsHar: 'Copy all as `HAR`', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 289 | /** |
| 290 | *@description A context menu item in the Network Log View of the Network panel |
| 291 | */ |
Peter Marshall | b8bd00f | 2021-02-24 08:25:18 | [diff] [blame] | 292 | saveAllAsHarWithContent: 'Save all as `HAR` with content', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 293 | /** |
| 294 | *@description A context menu item in the Network Log View of the Network panel |
| 295 | */ |
| 296 | clearBrowserCache: 'Clear browser cache', |
| 297 | /** |
| 298 | *@description A context menu item in the Network Log View of the Network panel |
| 299 | */ |
| 300 | clearBrowserCookies: 'Clear browser cookies', |
| 301 | /** |
| 302 | *@description A context menu item in the Network Log View of the Network panel |
| 303 | */ |
| 304 | blockRequestUrl: 'Block request URL', |
| 305 | /** |
| 306 | *@description A context menu item in the Network Log View of the Network panel |
| 307 | *@example {example.com} PH1 |
| 308 | */ |
| 309 | unblockS: 'Unblock {PH1}', |
| 310 | /** |
| 311 | *@description A context menu item in the Network Log View of the Network panel |
| 312 | */ |
| 313 | blockRequestDomain: 'Block request domain', |
| 314 | /** |
| 315 | *@description Text to replay an XHR request |
| 316 | */ |
| 317 | replayXhr: 'Replay XHR', |
| 318 | /** |
| 319 | *@description Text in Network Log View of the Network panel |
| 320 | */ |
| 321 | areYouSureYouWantToClearBrowser: 'Are you sure you want to clear browser cache?', |
| 322 | /** |
| 323 | *@description Text in Network Log View of the Network panel |
| 324 | */ |
| 325 | areYouSureYouWantToClearBrowserCookies: 'Are you sure you want to clear browser cookies?', |
| 326 | }; |
Tim van der Lippe | f596ca0 | 2021-03-31 10:02:47 | [diff] [blame] | 327 | const str_ = i18n.i18n.registerUIStrings('panels/network/NetworkLogView.ts', UIStrings); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 328 | const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 329 | export class NetworkLogView extends UI.Widget.VBox implements |
| 330 | SDK.SDKModel.SDKModelObserver<SDK.NetworkManager.NetworkManager>, NetworkLogViewInterface { |
| 331 | _networkHideDataURLSetting: Common.Settings.Setting<boolean>; |
| 332 | _networkShowIssuesOnlySetting: Common.Settings.Setting<boolean>; |
| 333 | _networkOnlyBlockedRequestsSetting: Common.Settings.Setting<boolean>; |
| 334 | // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration) |
| 335 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 336 | _networkResourceTypeFiltersSetting: Common.Settings.Setting<any>; |
| 337 | _rawRowHeight: number; |
| 338 | _progressBarContainer: Element; |
| 339 | _networkLogLargeRowsSetting: Common.Settings.Setting<boolean>; |
| 340 | _rowHeight: number; |
| 341 | _timeCalculator: NetworkTransferTimeCalculator; |
| 342 | _durationCalculator: NetworkTransferDurationCalculator; |
| 343 | _calculator: NetworkTransferTimeCalculator; |
| 344 | _columns: NetworkLogViewColumns; |
| 345 | _staleRequests: Set<SDK.NetworkRequest.NetworkRequest>; |
| 346 | _mainRequestLoadTime: number; |
| 347 | _mainRequestDOMContentLoadedTime: number; |
| 348 | // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration) |
| 349 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 350 | _highlightedSubstringChanges: any; |
| 351 | _filters: Filter[]; |
| 352 | _timeFilter: Filter|null; |
| 353 | _hoveredNode: NetworkNode|null; |
| 354 | _recordingHint: Element|null; |
| 355 | _refreshRequestId: number|null; |
| 356 | _highlightedNode: NetworkRequestNode|null; |
| 357 | _linkifier: Components.Linkifier.Linkifier; |
| 358 | _recording: boolean; |
| 359 | _needsRefresh: boolean; |
| 360 | _headerHeight: number; |
| 361 | _groupLookups: Map<string, GroupLookupInterface>; |
| 362 | _activeGroupLookup: GroupLookupInterface|null; |
| 363 | _textFilterUI: UI.FilterBar.TextFilterUI; |
| 364 | _dataURLFilterUI: UI.FilterBar.CheckboxFilterUI; |
| 365 | _resourceCategoryFilterUI: UI.FilterBar.NamedBitSetFilterUI; |
| 366 | _onlyIssuesFilterUI: UI.FilterBar.CheckboxFilterUI; |
| 367 | _onlyBlockedRequestsUI: UI.FilterBar.CheckboxFilterUI; |
| 368 | _filterParser: TextUtils.TextUtils.FilterParser; |
| 369 | _suggestionBuilder: UI.FilterSuggestionBuilder.FilterSuggestionBuilder; |
| 370 | _dataGrid: DataGrid.SortableDataGrid.SortableDataGrid<NetworkNode>; |
| 371 | _summaryToolbar: UI.Toolbar.Toolbar; |
| 372 | _filterBar: UI.FilterBar.FilterBar; |
| 373 | _textFilterSetting: Common.Settings.Setting<string>; |
| 374 | |
| 375 | constructor( |
| 376 | filterBar: UI.FilterBar.FilterBar, progressBarContainer: Element, |
| 377 | networkLogLargeRowsSetting: Common.Settings.Setting<boolean>) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 378 | super(); |
| 379 | this.setMinimumSize(50, 64); |
Tim van der Lippe | f596ca0 | 2021-03-31 10:02:47 | [diff] [blame] | 380 | this.registerRequiredCSS('panels/network/networkLogView.css', {enableLegacyPatching: true}); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 381 | |
| 382 | this.element.id = 'network-container'; |
Brandon Goddard | 88d885a | 2019-10-31 16:11:05 | [diff] [blame] | 383 | this.element.classList.add('no-node-selected'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 384 | |
Paul Lewis | 2d7d65c | 2020-03-16 17:26:30 | [diff] [blame] | 385 | this._networkHideDataURLSetting = Common.Settings.Settings.instance().createSetting('networkHideDataURL', false); |
| 386 | this._networkShowIssuesOnlySetting = |
| 387 | Common.Settings.Settings.instance().createSetting('networkShowIssuesOnly', false); |
| 388 | this._networkOnlyBlockedRequestsSetting = |
| 389 | Common.Settings.Settings.instance().createSetting('networkOnlyBlockedRequests', false); |
| 390 | this._networkResourceTypeFiltersSetting = |
| 391 | Common.Settings.Settings.instance().createSetting('networkResourceTypeFilters', {}); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 392 | |
| 393 | this._rawRowHeight = 0; |
| 394 | this._progressBarContainer = progressBarContainer; |
| 395 | this._networkLogLargeRowsSetting = networkLogLargeRowsSetting; |
| 396 | this._networkLogLargeRowsSetting.addChangeListener(updateRowHeight.bind(this), this); |
| 397 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 398 | function updateRowHeight(this: NetworkLogView): void { |
Tim van der Lippe | d7cfd14 | 2021-01-07 12:17:24 | [diff] [blame] | 399 | this._rawRowHeight = Boolean(this._networkLogLargeRowsSetting.get()) ? 41 : 21; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 400 | this._rowHeight = this._computeRowHeight(); |
| 401 | } |
| 402 | this._rawRowHeight = 0; |
| 403 | this._rowHeight = 0; |
| 404 | updateRowHeight.call(this); |
| 405 | |
Tim van der Lippe | 119690c | 2020-01-13 12:31:30 | [diff] [blame] | 406 | this._timeCalculator = new NetworkTransferTimeCalculator(); |
Tim van der Lippe | 119690c | 2020-01-13 12:31:30 | [diff] [blame] | 407 | this._durationCalculator = new NetworkTransferDurationCalculator(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 408 | this._calculator = this._timeCalculator; |
| 409 | |
Tim van der Lippe | 119690c | 2020-01-13 12:31:30 | [diff] [blame] | 410 | this._columns = |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 411 | // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration |
| 412 | // @ts-expect-error |
Tim van der Lippe | 119690c | 2020-01-13 12:31:30 | [diff] [blame] | 413 | new NetworkLogViewColumns(this, this._timeCalculator, this._durationCalculator, networkLogLargeRowsSetting); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 414 | this._columns.show(this.element); |
| 415 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 416 | this._staleRequests = new Set(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 417 | this._mainRequestLoadTime = -1; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 418 | this._mainRequestDOMContentLoadedTime = -1; |
| 419 | this._highlightedSubstringChanges = []; |
| 420 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 421 | this._filters = []; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 422 | this._timeFilter = null; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 423 | this._hoveredNode = null; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 424 | this._recordingHint = null; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 425 | this._refreshRequestId = null; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 426 | this._highlightedNode = null; |
| 427 | |
Simon Zünd | cdd72c9 | 2020-10-07 11:48:13 | [diff] [blame] | 428 | this._linkifier = new Components.Linkifier.Linkifier(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 429 | |
| 430 | this._recording = false; |
| 431 | this._needsRefresh = false; |
| 432 | |
| 433 | this._headerHeight = 0; |
| 434 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 435 | this._groupLookups = new Map(); |
Tim van der Lippe | 119690c | 2020-01-13 12:31:30 | [diff] [blame] | 436 | this._groupLookups.set('Frame', new NetworkFrameGrouper(this)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 437 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 438 | this._activeGroupLookup = null; |
| 439 | |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 440 | this._textFilterUI = new UI.FilterBar.TextFilterUI(); |
| 441 | this._textFilterUI.addEventListener(UI.FilterBar.FilterUI.Events.FilterChanged, this._filterChanged, this); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 442 | filterBar.addFilter(this._textFilterUI); |
| 443 | |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 444 | this._dataURLFilterUI = new UI.FilterBar.CheckboxFilterUI( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 445 | 'hide-data-url', i18nString(UIStrings.hideDataUrls), true, this._networkHideDataURLSetting); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 446 | this._dataURLFilterUI.addEventListener( |
| 447 | UI.FilterBar.FilterUI.Events.FilterChanged, this._filterChanged.bind(this), this); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 448 | UI.Tooltip.Tooltip.install(this._dataURLFilterUI.element(), i18nString(UIStrings.hidesDataAndBlobUrls)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 449 | filterBar.addFilter(this._dataURLFilterUI); |
| 450 | |
| 451 | const filterItems = |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 452 | Object.values(Common.ResourceType.resourceCategories) |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 453 | .map( |
| 454 | category => |
| 455 | ({name: category.title(), label: (): string => category.shortTitle(), title: category.title()})); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 456 | this._resourceCategoryFilterUI = |
| 457 | new UI.FilterBar.NamedBitSetFilterUI(filterItems, this._networkResourceTypeFiltersSetting); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 458 | UI.ARIAUtils.setAccessibleName( |
| 459 | this._resourceCategoryFilterUI.element(), i18nString(UIStrings.resourceTypesToInclude)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 460 | this._resourceCategoryFilterUI.addEventListener( |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 461 | UI.FilterBar.FilterUI.Events.FilterChanged, this._filterChanged.bind(this), this); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 462 | filterBar.addFilter(this._resourceCategoryFilterUI); |
| 463 | |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 464 | this._onlyIssuesFilterUI = new UI.FilterBar.CheckboxFilterUI( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 465 | 'only-show-issues', i18nString(UIStrings.hasBlockedCookies), true, this._networkShowIssuesOnlySetting); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 466 | this._onlyIssuesFilterUI.addEventListener( |
| 467 | UI.FilterBar.FilterUI.Events.FilterChanged, this._filterChanged.bind(this), this); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 468 | UI.Tooltip.Tooltip.install(this._onlyIssuesFilterUI.element(), i18nString(UIStrings.onlyShowRequestsWithBlocked)); |
Jan Scheffler | 1ae7c9e | 2019-12-03 15:48:37 | [diff] [blame] | 469 | filterBar.addFilter(this._onlyIssuesFilterUI); |
| 470 | |
Sigurd Schneider | a2afe0b | 2020-03-03 15:27:13 | [diff] [blame] | 471 | this._onlyBlockedRequestsUI = new UI.FilterBar.CheckboxFilterUI( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 472 | 'only-show-blocked-requests', i18nString(UIStrings.blockedRequests), true, |
| 473 | this._networkOnlyBlockedRequestsSetting); |
Sigurd Schneider | a2afe0b | 2020-03-03 15:27:13 | [diff] [blame] | 474 | this._onlyBlockedRequestsUI.addEventListener( |
| 475 | UI.FilterBar.FilterUI.Events.FilterChanged, this._filterChanged.bind(this), this); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 476 | UI.Tooltip.Tooltip.install(this._onlyBlockedRequestsUI.element(), i18nString(UIStrings.onlyShowBlockedRequests)); |
Sigurd Schneider | a2afe0b | 2020-03-03 15:27:13 | [diff] [blame] | 477 | filterBar.addFilter(this._onlyBlockedRequestsUI); |
| 478 | |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 479 | this._filterParser = new TextUtils.TextUtils.FilterParser(_searchKeys); |
| 480 | this._suggestionBuilder = |
| 481 | new UI.FilterSuggestionBuilder.FilterSuggestionBuilder(_searchKeys, NetworkLogView._sortSearchValues); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 482 | this._resetSuggestionBuilder(); |
| 483 | |
| 484 | this._dataGrid = this._columns.dataGrid(); |
| 485 | this._setupDataGrid(); |
| 486 | this._columns.sortByCurrentColumn(); |
Erik Luo | 0187a02 | 2018-05-31 18:35:49 | [diff] [blame] | 487 | filterBar.filterButton().addEventListener( |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 488 | UI.Toolbar.ToolbarButton.Events.Click, |
| 489 | this._dataGrid.scheduleUpdate.bind(this._dataGrid, true /* isFromUser */)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 490 | |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 491 | this._summaryToolbar = new UI.Toolbar.Toolbar('network-summary-bar', this.element); |
chait pinnamaneni | 83f4b6b | 2021-04-08 16:27:05 | [diff] [blame] | 492 | this._summaryToolbar.element.setAttribute('role', 'status'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 493 | |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 494 | new UI.DropTarget.DropTarget( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 495 | this.element, [UI.DropTarget.Type.File], i18nString(UIStrings.dropHarFilesHere), this._handleDrop.bind(this)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 496 | |
Paul Lewis | 2d7d65c | 2020-03-16 17:26:30 | [diff] [blame] | 497 | Common.Settings.Settings.instance() |
| 498 | .moduleSetting('networkColorCodeResourceTypes') |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 499 | .addChangeListener(this._invalidateAllItems.bind(this, false), this); |
| 500 | |
Paul Lewis | daac106 | 2020-03-05 14:37:10 | [diff] [blame] | 501 | SDK.SDKModel.TargetManager.instance().observeModels(SDK.NetworkManager.NetworkManager, this); |
Wolfgang Beyer | d81fad6 | 2020-05-27 12:30:27 | [diff] [blame] | 502 | SDK.NetworkLog.NetworkLog.instance().addEventListener( |
| 503 | SDK.NetworkLog.Events.RequestAdded, this._onRequestUpdated, this); |
| 504 | SDK.NetworkLog.NetworkLog.instance().addEventListener( |
| 505 | SDK.NetworkLog.Events.RequestUpdated, this._onRequestUpdated, this); |
| 506 | SDK.NetworkLog.NetworkLog.instance().addEventListener(SDK.NetworkLog.Events.Reset, this._reset, this); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 507 | |
| 508 | this._updateGroupByFrame(); |
Paul Lewis | 2d7d65c | 2020-03-16 17:26:30 | [diff] [blame] | 509 | Common.Settings.Settings.instance() |
| 510 | .moduleSetting('network.group-by-frame') |
| 511 | .addChangeListener(() => this._updateGroupByFrame()); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 512 | |
| 513 | this._filterBar = filterBar; |
Jack Franklin | e3cb280 | 2020-09-07 09:58:03 | [diff] [blame] | 514 | |
| 515 | this._textFilterSetting = Common.Settings.Settings.instance().createSetting('networkTextFilter', ''); |
| 516 | if (this._textFilterSetting.get()) { |
Jack Franklin | ec06441 | 2020-12-08 13:02:24 | [diff] [blame] | 517 | this._textFilterUI.setValue(this._textFilterSetting.get()); |
Jack Franklin | e3cb280 | 2020-09-07 09:58:03 | [diff] [blame] | 518 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 519 | } |
| 520 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 521 | _updateGroupByFrame(): void { |
Paul Lewis | 2d7d65c | 2020-03-16 17:26:30 | [diff] [blame] | 522 | const value = Common.Settings.Settings.instance().moduleSetting('network.group-by-frame').get(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 523 | this._setGrouping(value ? 'Frame' : null); |
| 524 | } |
| 525 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 526 | static _sortSearchValues(key: string, values: string[]): void { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 527 | if (key === FilterType.Priority) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 528 | values.sort((a, b) => { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 529 | const aPriority = (PerfUI.NetworkPriorities.uiLabelToNetworkPriority(a) as Protocol.Network.ResourcePriority); |
| 530 | const bPriority = (PerfUI.NetworkPriorities.uiLabelToNetworkPriority(b) as Protocol.Network.ResourcePriority); |
Tim van der Lippe | ded23fb | 2020-02-13 13:33:50 | [diff] [blame] | 531 | return PerfUI.NetworkPriorities.networkPriorityWeight(aPriority) - |
| 532 | PerfUI.NetworkPriorities.networkPriorityWeight(bPriority); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 533 | }); |
| 534 | } else { |
| 535 | values.sort(); |
| 536 | } |
| 537 | } |
| 538 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 539 | static _negativeFilter(filter: Filter, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 540 | return !filter(request); |
| 541 | } |
| 542 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 543 | static _requestPathFilter(regex: RegExp|null, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 544 | if (!regex) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 545 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 546 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 547 | |
| 548 | return regex.test(request.path() + '/' + request.name()); |
| 549 | } |
| 550 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 551 | static _subdomains(domain: string): string[] { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 552 | const result = [domain]; |
| 553 | let indexOfPeriod = domain.indexOf('.'); |
| 554 | while (indexOfPeriod !== -1) { |
| 555 | result.push('*' + domain.substring(indexOfPeriod)); |
| 556 | indexOfPeriod = domain.indexOf('.', indexOfPeriod + 1); |
| 557 | } |
| 558 | return result; |
| 559 | } |
| 560 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 561 | static _createRequestDomainFilter(value: string): Filter { |
Tim van der Lippe | bafa3bd | 2021-01-20 12:19:17 | [diff] [blame] | 562 | const escapedPattern = value.split('*').map(Platform.StringUtilities.escapeForRegExp).join('.*'); |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 563 | return NetworkLogView._requestDomainFilter.bind(null, new RegExp('^' + escapedPattern + '$', 'i')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 564 | } |
| 565 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 566 | static _requestDomainFilter(regex: RegExp, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 567 | return regex.test(request.domain); |
| 568 | } |
| 569 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 570 | static _runningRequestFilter(request: SDK.NetworkRequest.NetworkRequest): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 571 | return !request.finished; |
| 572 | } |
| 573 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 574 | static _fromCacheRequestFilter(request: SDK.NetworkRequest.NetworkRequest): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 575 | return request.cached(); |
| 576 | } |
| 577 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 578 | static _interceptedByServiceWorkerFilter(request: SDK.NetworkRequest.NetworkRequest): boolean { |
Joey Arhar | d183e7e | 2019-02-28 03:37:05 | [diff] [blame] | 579 | return request.fetchedViaServiceWorker; |
| 580 | } |
| 581 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 582 | static _initiatedByServiceWorkerFilter(request: SDK.NetworkRequest.NetworkRequest): boolean { |
Joey Arhar | d183e7e | 2019-02-28 03:37:05 | [diff] [blame] | 583 | return request.initiatedByServiceWorker(); |
| 584 | } |
| 585 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 586 | static _requestResponseHeaderFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 587 | return request.responseHeaderValue(value) !== undefined; |
| 588 | } |
| 589 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 590 | static _requestMethodFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 591 | return request.requestMethod === value; |
| 592 | } |
| 593 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 594 | static _requestPriorityFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 595 | return request.priority() === value; |
| 596 | } |
| 597 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 598 | static _requestMimeTypeFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 599 | return request.mimeType === value; |
| 600 | } |
| 601 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 602 | static _requestMixedContentFilter(value: MixedContentFilterValues, request: SDK.NetworkRequest.NetworkRequest): |
| 603 | boolean { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 604 | if (value === MixedContentFilterValues.Displayed) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 605 | return request.mixedContentType === Protocol.Security.MixedContentType.OptionallyBlockable; |
Mathias Bynens | f06e8c0 | 2020-02-28 13:58:28 | [diff] [blame] | 606 | } |
| 607 | if (value === MixedContentFilterValues.Blocked) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 608 | return request.mixedContentType === Protocol.Security.MixedContentType.Blockable && request.wasBlocked(); |
Mathias Bynens | f06e8c0 | 2020-02-28 13:58:28 | [diff] [blame] | 609 | } |
| 610 | if (value === MixedContentFilterValues.BlockOverridden) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 611 | return request.mixedContentType === Protocol.Security.MixedContentType.Blockable && !request.wasBlocked(); |
Mathias Bynens | f06e8c0 | 2020-02-28 13:58:28 | [diff] [blame] | 612 | } |
| 613 | if (value === MixedContentFilterValues.All) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 614 | return request.mixedContentType !== Protocol.Security.MixedContentType.None; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 615 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 616 | |
| 617 | return false; |
| 618 | } |
| 619 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 620 | static _requestSchemeFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 621 | return request.scheme === value; |
| 622 | } |
| 623 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 624 | static _requestCookieDomainFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 625 | return request.allCookiesIncludingBlockedOnes().some(cookie => cookie.domain() === value); |
| 626 | } |
| 627 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 628 | static _requestCookieNameFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 629 | return request.allCookiesIncludingBlockedOnes().some(cookie => cookie.name() === value); |
| 630 | } |
| 631 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 632 | static _requestCookiePathFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Simon Zünd | c975910 | 2020-03-25 11:24:54 | [diff] [blame] | 633 | return request.allCookiesIncludingBlockedOnes().some(cookie => cookie.path() === value); |
| 634 | } |
| 635 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 636 | static _requestCookieValueFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 637 | return request.allCookiesIncludingBlockedOnes().some(cookie => cookie.value() === value); |
| 638 | } |
| 639 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 640 | static _requestSetCookieDomainFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 641 | return request.responseCookies.some(cookie => cookie.domain() === value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 642 | } |
| 643 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 644 | static _requestSetCookieNameFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 645 | return request.responseCookies.some(cookie => cookie.name() === value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 646 | } |
| 647 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 648 | static _requestSetCookieValueFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 649 | return request.responseCookies.some(cookie => cookie.value() === value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 650 | } |
| 651 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 652 | static _requestSizeLargerThanFilter(value: number, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 653 | return request.transferSize >= value; |
| 654 | } |
| 655 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 656 | static _statusCodeFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Tim van der Lippe | d7cfd14 | 2021-01-07 12:17:24 | [diff] [blame] | 657 | return (String(request.statusCode)) === value; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 658 | } |
| 659 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 660 | // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration) |
| 661 | // eslint-disable-next-line @typescript-eslint/naming-convention |
| 662 | static HTTPRequestsFilter(request: SDK.NetworkRequest.NetworkRequest): boolean { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 663 | return request.parsedURL.isValid && (request.scheme in HTTPSchemas); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 664 | } |
| 665 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 666 | static _resourceTypeFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Sigurd Schneider | 464838b | 2020-08-24 13:53:03 | [diff] [blame] | 667 | return request.resourceType().name() === value; |
| 668 | } |
| 669 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 670 | static _requestUrlFilter(value: string, request: SDK.NetworkRequest.NetworkRequest): boolean { |
Tim van der Lippe | bafa3bd | 2021-01-20 12:19:17 | [diff] [blame] | 671 | const regex = new RegExp(Platform.StringUtilities.escapeForRegExp(value), 'i'); |
Julian Geppert | f8ce40c | 2020-09-01 18:02:03 | [diff] [blame] | 672 | return regex.test(request.url()); |
| 673 | } |
| 674 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 675 | static _requestTimeFilter(windowStart: number, windowEnd: number, request: SDK.NetworkRequest.NetworkRequest): |
| 676 | boolean { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 677 | if (request.issueTime() > windowEnd) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 678 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 679 | } |
| 680 | if (request.endTime !== -1 && request.endTime < windowStart) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 681 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 682 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 683 | return true; |
| 684 | } |
| 685 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 686 | static _copyRequestHeaders(request: SDK.NetworkRequest.NetworkRequest): void { |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 687 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(request.requestHeadersText()); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 688 | } |
| 689 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 690 | static _copyResponseHeaders(request: SDK.NetworkRequest.NetworkRequest): void { |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 691 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(request.responseHeadersText); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 692 | } |
| 693 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 694 | static async _copyResponse(request: SDK.NetworkRequest.NetworkRequest): Promise<void> { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 695 | const contentData = await request.contentData(); |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 696 | let content: (string|null)|string = contentData.content || ''; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 697 | if (!request.contentType().isTextType()) { |
Tim van der Lippe | 18f0489 | 2020-03-17 11:39:40 | [diff] [blame] | 698 | content = TextUtils.ContentProvider.contentAsDataURL(content, request.mimeType, contentData.encoded); |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 699 | } else if (contentData.encoded && content) { |
Ingvar Stepanyan | 1c77184 | 2018-10-10 14:35:08 | [diff] [blame] | 700 | content = window.atob(content); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 701 | } |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 702 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(content); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 703 | } |
| 704 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 705 | _handleDrop(dataTransfer: DataTransfer): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 706 | const items = dataTransfer.items; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 707 | if (!items.length) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 708 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 709 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 710 | const entry = items[0].webkitGetAsEntry(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 711 | if (entry.isDirectory) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 712 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 713 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 714 | |
Joey Arhar | 0e1093c | 2019-05-21 00:34:22 | [diff] [blame] | 715 | entry.file(this.onLoadFromFile.bind(this)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 716 | } |
| 717 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 718 | async onLoadFromFile(file: File): Promise<void> { |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 719 | const outputStream = new Common.StringOutputStream.StringOutputStream(); |
| 720 | const reader = new Bindings.FileUtils.ChunkedFileReader(file, /* chunkSize */ 10000000); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 721 | const success = await reader.read(outputStream); |
| 722 | if (!success) { |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 723 | const error = reader.error(); |
| 724 | if (error) { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 725 | // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration) |
| 726 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 727 | this._harLoadFailed((error as any).message); |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 728 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 729 | return; |
| 730 | } |
| 731 | let harRoot; |
| 732 | try { |
| 733 | // HARRoot and JSON.parse might throw. |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 734 | harRoot = new HARImporter.HARFormat.HARRoot(JSON.parse(outputStream.data())); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 735 | } catch (e) { |
| 736 | this._harLoadFailed(e); |
| 737 | return; |
| 738 | } |
Wolfgang Beyer | d81fad6 | 2020-05-27 12:30:27 | [diff] [blame] | 739 | SDK.NetworkLog.NetworkLog.instance().importRequests( |
| 740 | HARImporter.HARImporter.Importer.requestsFromHARLog(harRoot.log)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 741 | } |
| 742 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 743 | _harLoadFailed(message: string): void { |
Paul Lewis | a83ea61 | 2020-03-04 13:01:36 | [diff] [blame] | 744 | Common.Console.Console.instance().error('Failed to load HAR file with following error: ' + message); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 745 | } |
| 746 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 747 | _setGrouping(groupKey: string|null): void { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 748 | if (this._activeGroupLookup) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 749 | this._activeGroupLookup.reset(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 750 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 751 | const groupLookup = groupKey ? this._groupLookups.get(groupKey) || null : null; |
| 752 | this._activeGroupLookup = groupLookup; |
| 753 | this._invalidateAllItems(); |
| 754 | } |
| 755 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 756 | _computeRowHeight(): number { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 757 | return Math.round(this._rawRowHeight * window.devicePixelRatio) / window.devicePixelRatio; |
| 758 | } |
| 759 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 760 | nodeForRequest(request: SDK.NetworkRequest.NetworkRequest): NetworkRequestNode|null { |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 761 | return networkRequestToNode.get(request) || null; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 762 | } |
| 763 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 764 | headerHeight(): number { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 765 | return this._headerHeight; |
| 766 | } |
| 767 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 768 | setRecording(recording: boolean): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 769 | this._recording = recording; |
| 770 | this._updateSummaryBar(); |
| 771 | } |
| 772 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 773 | modelAdded(networkManager: SDK.NetworkManager.NetworkManager): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 774 | // TODO(allada) Remove dependency on networkManager and instead use NetworkLog and PageLoad for needed data. |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 775 | if (networkManager.target().parentTarget()) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 776 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 777 | } |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 778 | const resourceTreeModel = networkManager.target().model(SDK.ResourceTreeModel.ResourceTreeModel); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 779 | if (resourceTreeModel) { |
| 780 | resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.Load, this._loadEventFired, this); |
| 781 | resourceTreeModel.addEventListener( |
| 782 | SDK.ResourceTreeModel.Events.DOMContentLoaded, this._domContentLoadedEventFired, this); |
| 783 | } |
| 784 | } |
| 785 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 786 | modelRemoved(networkManager: SDK.NetworkManager.NetworkManager): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 787 | if (!networkManager.target().parentTarget()) { |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 788 | const resourceTreeModel = networkManager.target().model(SDK.ResourceTreeModel.ResourceTreeModel); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 789 | if (resourceTreeModel) { |
| 790 | resourceTreeModel.removeEventListener(SDK.ResourceTreeModel.Events.Load, this._loadEventFired, this); |
| 791 | resourceTreeModel.removeEventListener( |
| 792 | SDK.ResourceTreeModel.Events.DOMContentLoaded, this._domContentLoadedEventFired, this); |
| 793 | } |
| 794 | } |
| 795 | } |
| 796 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 797 | linkifier(): Components.Linkifier.Linkifier { |
Simon Zünd | cdd72c9 | 2020-10-07 11:48:13 | [diff] [blame] | 798 | return this._linkifier; |
| 799 | } |
| 800 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 801 | setWindow(start: number, end: number): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 802 | if (!start && !end) { |
| 803 | this._timeFilter = null; |
| 804 | this._timeCalculator.setWindow(null); |
| 805 | } else { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 806 | this._timeFilter = NetworkLogView._requestTimeFilter.bind(null, start, end); |
Tim van der Lippe | 119690c | 2020-01-13 12:31:30 | [diff] [blame] | 807 | this._timeCalculator.setWindow(new NetworkTimeBoundary(start, end)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 808 | } |
| 809 | this._filterRequests(); |
| 810 | } |
| 811 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 812 | resetFocus(): void { |
Brandon Goddard | 88d885a | 2019-10-31 16:11:05 | [diff] [blame] | 813 | this._dataGrid.element.focus(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 814 | } |
| 815 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 816 | _resetSuggestionBuilder(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 817 | this._suggestionBuilder.clear(); |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 818 | this._suggestionBuilder.addItem(FilterType.Is, IsFilterType.Running); |
| 819 | this._suggestionBuilder.addItem(FilterType.Is, IsFilterType.FromCache); |
| 820 | this._suggestionBuilder.addItem(FilterType.Is, IsFilterType.ServiceWorkerIntercepted); |
| 821 | this._suggestionBuilder.addItem(FilterType.Is, IsFilterType.ServiceWorkerInitiated); |
| 822 | this._suggestionBuilder.addItem(FilterType.LargerThan, '100'); |
| 823 | this._suggestionBuilder.addItem(FilterType.LargerThan, '10k'); |
| 824 | this._suggestionBuilder.addItem(FilterType.LargerThan, '1M'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 825 | this._textFilterUI.setSuggestionProvider(this._suggestionBuilder.completions.bind(this._suggestionBuilder)); |
| 826 | } |
| 827 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 828 | _filterChanged(_event: Common.EventTarget.EventTargetEvent): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 829 | this.removeAllNodeHighlights(); |
| 830 | this._parseFilterQuery(this._textFilterUI.value()); |
| 831 | this._filterRequests(); |
Jack Franklin | e3cb280 | 2020-09-07 09:58:03 | [diff] [blame] | 832 | this._textFilterSetting.set(this._textFilterUI.value()); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 833 | } |
| 834 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 835 | async resetFilter(): Promise<void> { |
Rajasekar Murugan | 3ad369e | 2020-02-19 18:20:12 | [diff] [blame] | 836 | this._textFilterUI.clear(); |
| 837 | } |
| 838 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 839 | _showRecordingHint(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 840 | this._hideRecordingHint(); |
| 841 | this._recordingHint = this.element.createChild('div', 'network-status-pane fill'); |
| 842 | const hintText = this._recordingHint.createChild('div', 'recording-hint'); |
Joey Arhar | 0585e6f | 2018-10-30 23:11:18 | [diff] [blame] | 843 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 844 | if (this._recording) { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 845 | let reloadShortcutNode: Element|null = null; |
Wolfgang Beyer | 5c385b9 | 2020-11-09 15:20:04 | [diff] [blame] | 846 | const reloadShortcut = |
| 847 | UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutsForAction('inspector_main.reload')[0]; |
| 848 | if (reloadShortcut) { |
| 849 | reloadShortcutNode = this._recordingHint.createChild('b'); |
| 850 | reloadShortcutNode.textContent = reloadShortcut.title(); |
| 851 | } |
| 852 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 853 | const recordingText = hintText.createChild('span'); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 854 | recordingText.textContent = i18nString(UIStrings.recordingNetworkActivity); |
Joey Arhar | 0585e6f | 2018-10-30 23:11:18 | [diff] [blame] | 855 | if (reloadShortcutNode) { |
| 856 | hintText.createChild('br'); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 857 | hintText.appendChild(i18n.i18n.getFormatLocalizedString( |
| 858 | str_, UIStrings.performARequestOrHitSToRecordThe, {PH1: reloadShortcutNode})); |
Joey Arhar | 0585e6f | 2018-10-30 23:11:18 | [diff] [blame] | 859 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 860 | } else { |
| 861 | const recordNode = hintText.createChild('b'); |
Tim van der Lippe | 9c9fb12 | 2020-09-08 15:06:17 | [diff] [blame] | 862 | recordNode.textContent = |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 863 | UI.ShortcutRegistry.ShortcutRegistry.instance().shortcutTitleForAction('network.toggle-recording') || ''; |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 864 | hintText.appendChild( |
| 865 | i18n.i18n.getFormatLocalizedString(str_, UIStrings.recordSToDisplayNetworkActivity, {PH1: recordNode})); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 866 | } |
Kayce Basques | 5444c1b | 2019-02-15 20:32:53 | [diff] [blame] | 867 | hintText.createChild('br'); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 868 | hintText.appendChild(UI.XLink.XLink.create( |
Jecelyn | 90c0416 | 2021-04-07 08:41:35 | [diff] [blame] | 869 | 'https://developer.chrome.com/docs/devtools/network/?utm_source=devtools&utm_campaign=2019Q1', |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 870 | i18nString(UIStrings.learnMore))); |
Amanda Baker | 6761aae | 2019-11-05 18:59:11 | [diff] [blame] | 871 | |
| 872 | this._setHidden(true); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 873 | } |
| 874 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 875 | _hideRecordingHint(): void { |
Amanda Baker | 6761aae | 2019-11-05 18:59:11 | [diff] [blame] | 876 | this._setHidden(false); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 877 | if (this._recordingHint) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 878 | this._recordingHint.remove(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 879 | } |
Michael Liao | 7322dee | 2021-04-07 18:33:30 | [diff] [blame] | 880 | UI.ARIAUtils.alert(i18nString(UIStrings.networkDataAvailable)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 881 | this._recordingHint = null; |
| 882 | } |
| 883 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 884 | _setHidden(value: boolean): void { |
Amanda Baker | 6761aae | 2019-11-05 18:59:11 | [diff] [blame] | 885 | this._columns.setHidden(value); |
| 886 | UI.ARIAUtils.setHidden(this._summaryToolbar.element, value); |
| 887 | } |
| 888 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 889 | elementsToRestoreScrollPositionsFor(): Element[] { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 890 | if (!this._dataGrid) // Not initialized yet. |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 891 | { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 892 | return []; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 893 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 894 | return [this._dataGrid.scrollContainer]; |
| 895 | } |
| 896 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 897 | columnExtensionResolved(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 898 | this._invalidateAllItems(true); |
| 899 | } |
| 900 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 901 | _setupDataGrid(): DataGrid.SortableDataGrid.SortableDataGrid<NetworkNode> { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 902 | this._dataGrid.setRowContextMenuCallback((contextMenu, node) => { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 903 | const request = (node as NetworkNode).request(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 904 | if (request) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 905 | this.handleContextMenuForRequest(contextMenu, request); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 906 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 907 | }); |
| 908 | this._dataGrid.setStickToBottom(true); |
| 909 | this._dataGrid.setName('networkLog'); |
| 910 | this._dataGrid.setResizeMethod(DataGrid.DataGrid.ResizeMethod.Last); |
| 911 | this._dataGrid.element.classList.add('network-log-grid'); |
| 912 | this._dataGrid.element.addEventListener('mousedown', this._dataGridMouseDown.bind(this), true); |
| 913 | this._dataGrid.element.addEventListener('mousemove', this._dataGridMouseMove.bind(this), true); |
| 914 | this._dataGrid.element.addEventListener('mouseleave', () => this._setHoveredNode(null), true); |
Brandon Goddard | 88d885a | 2019-10-31 16:11:05 | [diff] [blame] | 915 | this._dataGrid.element.addEventListener('keydown', event => { |
| 916 | if (isEnterOrSpaceKey(event)) { |
Jack Lynch | 29cc4f3 | 2020-07-22 21:52:05 | [diff] [blame] | 917 | this.dispatchEventToListeners(Events.RequestActivated, {showPanel: true, takeFocus: true}); |
Brandon Goddard | 88d885a | 2019-10-31 16:11:05 | [diff] [blame] | 918 | event.consume(true); |
| 919 | } |
| 920 | }); |
Brandon Goddard | 4493490 | 2020-03-25 16:03:18 | [diff] [blame] | 921 | this._dataGrid.element.addEventListener('focus', this._onDataGridFocus.bind(this), true); |
| 922 | this._dataGrid.element.addEventListener('blur', this._onDataGridBlur.bind(this), true); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 923 | return this._dataGrid; |
| 924 | } |
| 925 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 926 | _dataGridMouseMove(event: Event): void { |
| 927 | const mouseEvent = (event as MouseEvent); |
| 928 | const node = (this._dataGrid.dataGridNodeFromNode((mouseEvent.target as Node))); |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 929 | const highlightInitiatorChain = mouseEvent.shiftKey; |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 930 | this._setHoveredNode(node as NetworkNode, highlightInitiatorChain); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 931 | } |
| 932 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 933 | hoveredNode(): NetworkNode|null { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 934 | return this._hoveredNode; |
| 935 | } |
| 936 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 937 | _setHoveredNode(node: NetworkNode|null, highlightInitiatorChain?: boolean): void { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 938 | if (this._hoveredNode) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 939 | this._hoveredNode.setHovered(false, false); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 940 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 941 | this._hoveredNode = node; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 942 | if (this._hoveredNode) { |
Tim van der Lippe | d7cfd14 | 2021-01-07 12:17:24 | [diff] [blame] | 943 | this._hoveredNode.setHovered(true, Boolean(highlightInitiatorChain)); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 944 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 945 | } |
| 946 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 947 | _dataGridMouseDown(event: Event): void { |
| 948 | const mouseEvent = (event as MouseEvent); |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 949 | if (!this._dataGrid.selectedNode && mouseEvent.button) { |
| 950 | mouseEvent.consume(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 951 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 952 | } |
| 953 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 954 | _updateSummaryBar(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 955 | this._hideRecordingHint(); |
| 956 | |
| 957 | let transferSize = 0; |
Dan Beam | 87466b5 | 2018-12-01 18:41:20 | [diff] [blame] | 958 | let resourceSize = 0; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 959 | let selectedNodeNumber = 0; |
| 960 | let selectedTransferSize = 0; |
Dan Beam | 87466b5 | 2018-12-01 18:41:20 | [diff] [blame] | 961 | let selectedResourceSize = 0; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 962 | let baseTime = -1; |
| 963 | let maxTime = -1; |
| 964 | |
| 965 | let nodeCount = 0; |
Wolfgang Beyer | d81fad6 | 2020-05-27 12:30:27 | [diff] [blame] | 966 | for (const request of SDK.NetworkLog.NetworkLog.instance().requests()) { |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 967 | const node = networkRequestToNode.get(request); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 968 | if (!node) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 969 | continue; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 970 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 971 | nodeCount++; |
| 972 | const requestTransferSize = request.transferSize; |
| 973 | transferSize += requestTransferSize; |
Dan Beam | 87466b5 | 2018-12-01 18:41:20 | [diff] [blame] | 974 | const requestResourceSize = request.resourceSize; |
| 975 | resourceSize += requestResourceSize; |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 976 | if (!filteredNetworkRequests.has(node)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 977 | selectedNodeNumber++; |
| 978 | selectedTransferSize += requestTransferSize; |
Dan Beam | 87466b5 | 2018-12-01 18:41:20 | [diff] [blame] | 979 | selectedResourceSize += requestResourceSize; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 980 | } |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 981 | const networkManager = SDK.NetworkManager.NetworkManager.forRequest(request); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 982 | // TODO(allada) inspectedURL should be stored in PageLoad used instead of target so HAR requests can have an |
| 983 | // inspected url. |
| 984 | if (networkManager && request.url() === networkManager.target().inspectedURL() && |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 985 | request.resourceType() === Common.ResourceType.resourceTypes.Document && |
| 986 | !networkManager.target().parentTarget()) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 987 | baseTime = request.startTime; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 988 | } |
| 989 | if (request.endTime > maxTime) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 990 | maxTime = request.endTime; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 991 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 992 | } |
| 993 | |
| 994 | if (!nodeCount) { |
| 995 | this._showRecordingHint(); |
| 996 | return; |
| 997 | } |
| 998 | |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 999 | this._summaryToolbar.removeToolbarItems(); |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1000 | const appendChunk = (chunk: string, title?: string): HTMLDivElement => { |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1001 | const toolbarText = new UI.Toolbar.ToolbarText(chunk); |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 1002 | toolbarText.setTitle(title ? title : chunk); |
| 1003 | this._summaryToolbar.appendToolbarItem(toolbarText); |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1004 | return toolbarText.element as HTMLDivElement; |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 1005 | }; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1006 | |
| 1007 | if (selectedNodeNumber !== nodeCount) { |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1008 | appendChunk(i18nString(UIStrings.sSRequests, {PH1: selectedNodeNumber, PH2: nodeCount})); |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 1009 | this._summaryToolbar.appendSeparator(); |
| 1010 | appendChunk( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1011 | i18nString(UIStrings.sSTransferred, { |
| 1012 | PH1: Platform.NumberUtilities.bytesToString(selectedTransferSize), |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1013 | PH2: Platform.NumberUtilities.bytesToString(transferSize), |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1014 | }), |
| 1015 | i18nString(UIStrings.sBSBTransferredOverNetwork, {PH1: selectedTransferSize, PH2: transferSize})); |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 1016 | this._summaryToolbar.appendSeparator(); |
| 1017 | appendChunk( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1018 | i18nString(UIStrings.sSResources, { |
| 1019 | PH1: Platform.NumberUtilities.bytesToString(selectedResourceSize), |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1020 | PH2: Platform.NumberUtilities.bytesToString(resourceSize), |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1021 | }), |
| 1022 | i18nString(UIStrings.sBSBResourcesLoadedByThePage, {PH1: selectedResourceSize, PH2: resourceSize})); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1023 | } else { |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1024 | appendChunk(i18nString(UIStrings.sRequests, {PH1: nodeCount})); |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 1025 | this._summaryToolbar.appendSeparator(); |
Changhao Han | 9ec3f6e | 2019-11-12 18:43:25 | [diff] [blame] | 1026 | appendChunk( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1027 | i18nString(UIStrings.sTransferred, {PH1: Platform.NumberUtilities.bytesToString(transferSize)}), |
| 1028 | i18nString(UIStrings.sBTransferredOverNetwork, {PH1: transferSize})); |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 1029 | this._summaryToolbar.appendSeparator(); |
Changhao Han | 9ec3f6e | 2019-11-12 18:43:25 | [diff] [blame] | 1030 | appendChunk( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1031 | i18nString(UIStrings.sResources, {PH1: Platform.NumberUtilities.bytesToString(resourceSize)}), |
| 1032 | i18nString(UIStrings.sBResourcesLoadedByThePage, {PH1: resourceSize})); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1033 | } |
Dan Beam | 87466b5 | 2018-12-01 18:41:20 | [diff] [blame] | 1034 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1035 | if (baseTime !== -1 && maxTime !== -1) { |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 1036 | this._summaryToolbar.appendSeparator(); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1037 | appendChunk(i18nString(UIStrings.finishS, {PH1: Number.secondsToString(maxTime - baseTime)})); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1038 | if (this._mainRequestDOMContentLoadedTime !== -1 && this._mainRequestDOMContentLoadedTime > baseTime) { |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 1039 | this._summaryToolbar.appendSeparator(); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1040 | const domContentLoadedText = i18nString( |
| 1041 | UIStrings.domcontentloadedS, |
| 1042 | {PH1: Number.secondsToString(this._mainRequestDOMContentLoadedTime - baseTime)}); |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1043 | appendChunk(domContentLoadedText).style.color = NetworkLogView.getDCLEventColor(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1044 | } |
| 1045 | if (this._mainRequestLoadTime !== -1) { |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 1046 | this._summaryToolbar.appendSeparator(); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1047 | const loadText = |
| 1048 | i18nString(UIStrings.loadS, {PH1: Number.secondsToString(this._mainRequestLoadTime - baseTime)}); |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1049 | appendChunk(loadText).style.color = NetworkLogView.getLoadEventColor(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1050 | } |
| 1051 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1052 | } |
| 1053 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1054 | scheduleRefresh(): void { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1055 | if (this._needsRefresh) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1056 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1057 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1058 | |
| 1059 | this._needsRefresh = true; |
| 1060 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1061 | if (this.isShowing() && !this._refreshRequestId) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1062 | this._refreshRequestId = this.element.window().requestAnimationFrame(this._refresh.bind(this)); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1063 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1064 | } |
| 1065 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1066 | addFilmStripFrames(times: number[]): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1067 | this._columns.addEventDividers(times, 'network-frame-divider'); |
| 1068 | } |
| 1069 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1070 | selectFilmStripFrame(time: number): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1071 | this._columns.selectFilmStripFrame(time); |
| 1072 | } |
| 1073 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1074 | clearFilmStripFrame(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1075 | this._columns.clearFilmStripFrame(); |
| 1076 | } |
| 1077 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1078 | _refreshIfNeeded(): void { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1079 | if (this._needsRefresh) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1080 | this._refresh(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1081 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1082 | } |
| 1083 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1084 | _invalidateAllItems(deferUpdate?: boolean): void { |
Wolfgang Beyer | d81fad6 | 2020-05-27 12:30:27 | [diff] [blame] | 1085 | this._staleRequests = new Set(SDK.NetworkLog.NetworkLog.instance().requests()); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1086 | if (deferUpdate) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1087 | this.scheduleRefresh(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1088 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1089 | this._refresh(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1090 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1091 | } |
| 1092 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1093 | timeCalculator(): NetworkTimeCalculator { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1094 | return this._timeCalculator; |
| 1095 | } |
| 1096 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1097 | calculator(): NetworkTimeCalculator { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1098 | return this._calculator; |
| 1099 | } |
| 1100 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1101 | setCalculator(x: NetworkTimeCalculator): void { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1102 | if (!x || this._calculator === x) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1103 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1104 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1105 | |
| 1106 | if (this._calculator !== x) { |
| 1107 | this._calculator = x; |
| 1108 | this._columns.setCalculator(this._calculator); |
| 1109 | } |
| 1110 | this._calculator.reset(); |
| 1111 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1112 | if (this._calculator.startAtZero) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1113 | this._columns.hideEventDividers(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1114 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1115 | this._columns.showEventDividers(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1116 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1117 | |
| 1118 | this._invalidateAllItems(); |
| 1119 | } |
| 1120 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1121 | _loadEventFired(event: Common.EventTarget.EventTargetEvent): void { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1122 | if (!this._recording) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1123 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1124 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1125 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1126 | const time = (event.data.loadTime as number); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1127 | if (time) { |
| 1128 | this._mainRequestLoadTime = time; |
Alexei Filippov | fdcd8a6 | 2018-12-17 21:32:30 | [diff] [blame] | 1129 | this._columns.addEventDividers([time], 'network-load-divider'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1130 | } |
| 1131 | } |
| 1132 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1133 | _domContentLoadedEventFired(event: Common.EventTarget.EventTargetEvent): void { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1134 | if (!this._recording) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1135 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1136 | } |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1137 | const data = (event.data as number); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1138 | if (data) { |
| 1139 | this._mainRequestDOMContentLoadedTime = data; |
Alexei Filippov | fdcd8a6 | 2018-12-17 21:32:30 | [diff] [blame] | 1140 | this._columns.addEventDividers([data], 'network-dcl-divider'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1141 | } |
| 1142 | } |
| 1143 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1144 | wasShown(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1145 | this._refreshIfNeeded(); |
| 1146 | this._columns.wasShown(); |
| 1147 | } |
| 1148 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1149 | willHide(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1150 | this._columns.willHide(); |
| 1151 | } |
| 1152 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1153 | onResize(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1154 | this._rowHeight = this._computeRowHeight(); |
| 1155 | } |
| 1156 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1157 | flatNodesList(): NetworkNode[] { |
| 1158 | const rootNode = |
| 1159 | (this._dataGrid.rootNode() as |
| 1160 | DataGrid.ViewportDataGrid.ViewportDataGridNode<DataGrid.SortableDataGrid.SortableDataGridNode<NetworkNode>>); |
| 1161 | return rootNode.flatChildren() as NetworkNode[]; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1162 | } |
| 1163 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1164 | _onDataGridFocus(): void { |
Peter Marshall | de3fee7 | 2020-08-24 14:12:49 | [diff] [blame] | 1165 | if (this._dataGrid.element.matches(':focus-visible')) { |
Jack Lynch | 13d4daa | 2020-07-30 03:57:35 | [diff] [blame] | 1166 | this.element.classList.add('grid-focused'); |
Jack Lynch | f376673 | 2020-07-23 01:37:38 | [diff] [blame] | 1167 | } |
Brandon Goddard | 4493490 | 2020-03-25 16:03:18 | [diff] [blame] | 1168 | this.updateNodeBackground(); |
| 1169 | } |
| 1170 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1171 | _onDataGridBlur(): void { |
Brandon Goddard | 4493490 | 2020-03-25 16:03:18 | [diff] [blame] | 1172 | this.element.classList.remove('grid-focused'); |
| 1173 | this.updateNodeBackground(); |
| 1174 | } |
| 1175 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1176 | updateNodeBackground(): void { |
Brandon Goddard | 88d885a | 2019-10-31 16:11:05 | [diff] [blame] | 1177 | if (this._dataGrid.selectedNode) { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1178 | (this._dataGrid.selectedNode as NetworkNode).updateBackgroundColor(); |
Brandon Goddard | 88d885a | 2019-10-31 16:11:05 | [diff] [blame] | 1179 | } |
| 1180 | } |
| 1181 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1182 | updateNodeSelectedClass(isSelected: boolean): void { |
Brandon Goddard | 88d885a | 2019-10-31 16:11:05 | [diff] [blame] | 1183 | if (isSelected) { |
| 1184 | this.element.classList.remove('no-node-selected'); |
| 1185 | } else { |
| 1186 | this.element.classList.add('no-node-selected'); |
| 1187 | } |
| 1188 | } |
| 1189 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1190 | stylesChanged(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1191 | this._columns.scheduleRefresh(); |
| 1192 | } |
| 1193 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1194 | _refresh(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1195 | this._needsRefresh = false; |
| 1196 | |
| 1197 | if (this._refreshRequestId) { |
| 1198 | this.element.window().cancelAnimationFrame(this._refreshRequestId); |
| 1199 | this._refreshRequestId = null; |
| 1200 | } |
| 1201 | |
| 1202 | this.removeAllNodeHighlights(); |
| 1203 | |
| 1204 | this._timeCalculator.updateBoundariesForEventTime(this._mainRequestLoadTime); |
| 1205 | this._durationCalculator.updateBoundariesForEventTime(this._mainRequestLoadTime); |
| 1206 | this._timeCalculator.updateBoundariesForEventTime(this._mainRequestDOMContentLoadedTime); |
| 1207 | this._durationCalculator.updateBoundariesForEventTime(this._mainRequestDOMContentLoadedTime); |
| 1208 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1209 | const nodesToInsert = new Map<NetworkNode, NetworkNode>(); |
| 1210 | const nodesToRefresh: NetworkNode[] = []; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1211 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1212 | const staleNodes = new Set<NetworkRequestNode>(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1213 | |
| 1214 | // While creating nodes it may add more entries into _staleRequests because redirect request nodes update the parent |
| 1215 | // node so we loop until we have no more stale requests. |
| 1216 | while (this._staleRequests.size) { |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1217 | const request = this._staleRequests.values().next().value; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1218 | this._staleRequests.delete(request); |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1219 | let node = networkRequestToNode.get(request); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1220 | if (!node) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1221 | node = this._createNodeForRequest(request); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1222 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1223 | staleNodes.add(node); |
| 1224 | } |
| 1225 | |
| 1226 | for (const node of staleNodes) { |
| 1227 | const isFilteredOut = !this._applyFilter(node); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1228 | if (isFilteredOut && node === this._hoveredNode) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1229 | this._setHoveredNode(null); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1230 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1231 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1232 | if (!isFilteredOut) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1233 | nodesToRefresh.push(node); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1234 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1235 | const request = node.request(); |
| 1236 | this._timeCalculator.updateBoundaries(request); |
| 1237 | this._durationCalculator.updateBoundaries(request); |
| 1238 | const newParent = this._parentNodeForInsert(node); |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1239 | const wasAlreadyFiltered = filteredNetworkRequests.has(node); |
| 1240 | if (wasAlreadyFiltered === isFilteredOut && node.parent === newParent) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1241 | continue; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1242 | } |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1243 | if (isFilteredOut) { |
| 1244 | filteredNetworkRequests.add(node); |
| 1245 | } else { |
| 1246 | filteredNetworkRequests.delete(node); |
| 1247 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1248 | const removeFromParent = node.parent && (isFilteredOut || node.parent !== newParent); |
| 1249 | if (removeFromParent) { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1250 | let parent: NetworkNode| |
| 1251 | (DataGrid.DataGrid.DataGridNode<DataGrid.ViewportDataGrid.ViewportDataGridNode< |
| 1252 | DataGrid.SortableDataGrid.SortableDataGridNode<NetworkNode>>>| |
| 1253 | null) = node.parent; |
Andres Olivares | 03d9c75 | 2020-10-01 15:08:11 | [diff] [blame] | 1254 | if (!parent) { |
| 1255 | continue; |
| 1256 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1257 | parent.removeChild(node); |
| 1258 | while (parent && !parent.hasChildren() && parent.dataGrid && parent.dataGrid.rootNode() !== parent) { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1259 | const grandparent = (parent.parent as NetworkNode); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1260 | grandparent.removeChild(parent); |
| 1261 | parent = grandparent; |
| 1262 | } |
| 1263 | } |
| 1264 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1265 | if (!newParent || isFilteredOut) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1266 | continue; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1267 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1268 | |
| 1269 | if (!newParent.dataGrid && !nodesToInsert.has(newParent)) { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1270 | nodesToInsert.set(newParent, (this._dataGrid.rootNode() as NetworkNode)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1271 | nodesToRefresh.push(newParent); |
| 1272 | } |
| 1273 | nodesToInsert.set(node, newParent); |
| 1274 | } |
| 1275 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1276 | for (const node of nodesToInsert.keys()) { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1277 | (nodesToInsert.get(node) as NetworkNode).appendChild(node); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1278 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1279 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1280 | for (const node of nodesToRefresh) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1281 | node.refresh(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1282 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1283 | |
| 1284 | this._updateSummaryBar(); |
| 1285 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1286 | if (nodesToInsert.size) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1287 | this._columns.sortByCurrentColumn(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1288 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1289 | |
| 1290 | this._dataGrid.updateInstantly(); |
| 1291 | this._didRefreshForTest(); |
| 1292 | } |
| 1293 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1294 | _didRefreshForTest(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1295 | } |
| 1296 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1297 | _parentNodeForInsert(node: NetworkRequestNode): NetworkNode|null { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1298 | if (!this._activeGroupLookup) { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1299 | return this._dataGrid.rootNode() as NetworkNode; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1300 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1301 | |
| 1302 | const groupNode = this._activeGroupLookup.groupNodeForRequest(node.request()); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1303 | if (!groupNode) { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1304 | return this._dataGrid.rootNode() as NetworkNode; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1305 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1306 | return groupNode; |
| 1307 | } |
| 1308 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1309 | _reset(): void { |
Simon Zünd | 9841983 | 2020-03-12 06:18:15 | [diff] [blame] | 1310 | this.dispatchEventToListeners(Events.RequestActivated, {showPanel: false}); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1311 | |
| 1312 | this._setHoveredNode(null); |
| 1313 | this._columns.reset(); |
| 1314 | |
| 1315 | this._timeFilter = null; |
| 1316 | this._calculator.reset(); |
| 1317 | |
| 1318 | this._timeCalculator.setWindow(null); |
Simon Zünd | cdd72c9 | 2020-10-07 11:48:13 | [diff] [blame] | 1319 | this._linkifier.reset(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1320 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1321 | if (this._activeGroupLookup) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1322 | this._activeGroupLookup.reset(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1323 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1324 | this._staleRequests.clear(); |
| 1325 | this._resetSuggestionBuilder(); |
| 1326 | |
| 1327 | this._mainRequestLoadTime = -1; |
| 1328 | this._mainRequestDOMContentLoadedTime = -1; |
| 1329 | |
| 1330 | this._dataGrid.rootNode().removeChildren(); |
| 1331 | this._updateSummaryBar(); |
| 1332 | this._dataGrid.setStickToBottom(true); |
| 1333 | this.scheduleRefresh(); |
| 1334 | } |
| 1335 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1336 | setTextFilterValue(filterString: string): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1337 | this._textFilterUI.setValue(filterString); |
| 1338 | this._dataURLFilterUI.setChecked(false); |
Jan Scheffler | 1ae7c9e | 2019-12-03 15:48:37 | [diff] [blame] | 1339 | this._onlyIssuesFilterUI.setChecked(false); |
Sigurd Schneider | a2afe0b | 2020-03-03 15:27:13 | [diff] [blame] | 1340 | this._onlyBlockedRequestsUI.setChecked(false); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1341 | this._resourceCategoryFilterUI.reset(); |
| 1342 | } |
| 1343 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1344 | _createNodeForRequest(request: SDK.NetworkRequest.NetworkRequest): NetworkRequestNode { |
Tim van der Lippe | 119690c | 2020-01-13 12:31:30 | [diff] [blame] | 1345 | const node = new NetworkRequestNode(this, request); |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1346 | networkRequestToNode.set(request, node); |
| 1347 | filteredNetworkRequests.add(node); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1348 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1349 | for (let redirect = request.redirectSource(); redirect; redirect = redirect.redirectSource()) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1350 | this._refreshRequest(redirect); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1351 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1352 | return node; |
| 1353 | } |
| 1354 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1355 | _onRequestUpdated(event: Common.EventTarget.EventTargetEvent): void { |
| 1356 | const request = (event.data as SDK.NetworkRequest.NetworkRequest); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1357 | this._refreshRequest(request); |
| 1358 | } |
| 1359 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1360 | _refreshRequest(request: SDK.NetworkRequest.NetworkRequest): void { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1361 | NetworkLogView._subdomains(request.domain) |
| 1362 | .forEach(this._suggestionBuilder.addItem.bind(this._suggestionBuilder, FilterType.Domain)); |
| 1363 | this._suggestionBuilder.addItem(FilterType.Method, request.requestMethod); |
| 1364 | this._suggestionBuilder.addItem(FilterType.MimeType, request.mimeType); |
Tim van der Lippe | d7cfd14 | 2021-01-07 12:17:24 | [diff] [blame] | 1365 | this._suggestionBuilder.addItem(FilterType.Scheme, String(request.scheme)); |
| 1366 | this._suggestionBuilder.addItem(FilterType.StatusCode, String(request.statusCode)); |
Sigurd Schneider | 464838b | 2020-08-24 13:53:03 | [diff] [blame] | 1367 | this._suggestionBuilder.addItem(FilterType.ResourceType, request.resourceType().name()); |
Julian Geppert | f8ce40c | 2020-09-01 18:02:03 | [diff] [blame] | 1368 | this._suggestionBuilder.addItem(FilterType.Url, request.securityOrigin()); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1369 | |
| 1370 | const priority = request.priority(); |
| 1371 | if (priority) { |
Tim van der Lippe | ded23fb | 2020-02-13 13:33:50 | [diff] [blame] | 1372 | this._suggestionBuilder.addItem( |
| 1373 | FilterType.Priority, PerfUI.NetworkPriorities.uiLabelForNetworkPriority(priority)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1374 | } |
| 1375 | |
| 1376 | if (request.mixedContentType !== Protocol.Security.MixedContentType.None) { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1377 | this._suggestionBuilder.addItem(FilterType.MixedContent, MixedContentFilterValues.All); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1378 | } |
| 1379 | |
| 1380 | if (request.mixedContentType === Protocol.Security.MixedContentType.OptionallyBlockable) { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1381 | this._suggestionBuilder.addItem(FilterType.MixedContent, MixedContentFilterValues.Displayed); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1382 | } |
| 1383 | |
| 1384 | if (request.mixedContentType === Protocol.Security.MixedContentType.Blockable) { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1385 | const suggestion = |
| 1386 | request.wasBlocked() ? MixedContentFilterValues.Blocked : MixedContentFilterValues.BlockOverridden; |
| 1387 | this._suggestionBuilder.addItem(FilterType.MixedContent, suggestion); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1388 | } |
| 1389 | |
| 1390 | const responseHeaders = request.responseHeaders; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1391 | for (let i = 0, l = responseHeaders.length; i < l; ++i) { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1392 | this._suggestionBuilder.addItem(FilterType.HasResponseHeader, responseHeaders[i].name); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1393 | } |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 1394 | |
| 1395 | for (const cookie of request.responseCookies) { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1396 | this._suggestionBuilder.addItem(FilterType.SetCookieDomain, cookie.domain()); |
| 1397 | this._suggestionBuilder.addItem(FilterType.SetCookieName, cookie.name()); |
| 1398 | this._suggestionBuilder.addItem(FilterType.SetCookieValue, cookie.value()); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1399 | } |
| 1400 | |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 1401 | for (const cookie of request.allCookiesIncludingBlockedOnes()) { |
| 1402 | this._suggestionBuilder.addItem(FilterType.CookieDomain, cookie.domain()); |
| 1403 | this._suggestionBuilder.addItem(FilterType.CookieName, cookie.name()); |
Simon Zünd | c975910 | 2020-03-25 11:24:54 | [diff] [blame] | 1404 | this._suggestionBuilder.addItem(FilterType.CookiePath, cookie.path()); |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 1405 | this._suggestionBuilder.addItem(FilterType.CookieValue, cookie.value()); |
| 1406 | } |
| 1407 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1408 | this._staleRequests.add(request); |
| 1409 | this.scheduleRefresh(); |
| 1410 | } |
| 1411 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1412 | rowHeight(): number { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1413 | return this._rowHeight; |
| 1414 | } |
| 1415 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1416 | switchViewMode(gridMode: boolean): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1417 | this._columns.switchViewMode(gridMode); |
| 1418 | } |
| 1419 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1420 | handleContextMenuForRequest(contextMenu: UI.ContextMenu.ContextMenu, request: SDK.NetworkRequest.NetworkRequest): |
| 1421 | void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1422 | contextMenu.appendApplicableItems(request); |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1423 | let copyMenu = contextMenu.clipboardSection().appendSubMenuItem(i18nString(UIStrings.copy)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1424 | const footerSection = copyMenu.footerSection(); |
| 1425 | if (request) { |
| 1426 | copyMenu.defaultSection().appendItem( |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1427 | UI.UIUtils.copyLinkAddressLabel(), |
| 1428 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText.bind( |
| 1429 | Host.InspectorFrontendHost.InspectorFrontendHostInstance, request.contentURL())); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1430 | if (request.requestHeadersText()) { |
| 1431 | copyMenu.defaultSection().appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1432 | i18nString(UIStrings.copyRequestHeaders), NetworkLogView._copyRequestHeaders.bind(null, request)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1433 | } |
| 1434 | |
| 1435 | if (request.responseHeadersText) { |
| 1436 | copyMenu.defaultSection().appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1437 | i18nString(UIStrings.copyResponseHeaders), NetworkLogView._copyResponseHeaders.bind(null, request)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1438 | } |
| 1439 | |
| 1440 | if (request.finished) { |
| 1441 | copyMenu.defaultSection().appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1442 | i18nString(UIStrings.copyResponse), NetworkLogView._copyResponse.bind(null, request)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1443 | } |
| 1444 | |
Tim van der Lippe | b4faf5a | 2020-11-06 15:02:02 | [diff] [blame] | 1445 | const initiator = request.initiator(); |
| 1446 | |
| 1447 | if (initiator) { |
| 1448 | const stack = initiator.stack; |
| 1449 | if (stack) { |
| 1450 | // We proactively compute the stacktrace text, as we can't determine whether the stacktrace |
| 1451 | // has any context solely based on the top frame. Sometimes, the top frame does not have |
| 1452 | // any callFrames, but its parent frames do. |
| 1453 | const stackTraceText = computeStackTraceText(stack); |
| 1454 | if (stackTraceText !== '') { |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1455 | copyMenu.defaultSection().appendItem(i18nString(UIStrings.copyStacktrace), () => { |
Tim van der Lippe | b4faf5a | 2020-11-06 15:02:02 | [diff] [blame] | 1456 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(stackTraceText); |
| 1457 | }); |
| 1458 | } |
| 1459 | } |
| 1460 | } |
| 1461 | |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 1462 | const disableIfBlob = request.isBlobRequest(); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1463 | if (Host.Platform.isWin()) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1464 | footerSection.appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1465 | i18nString(UIStrings.copyAsPowershell), this._copyPowerShellCommand.bind(this, request), disableIfBlob); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1466 | footerSection.appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1467 | i18nString(UIStrings.copyAsFetch), this._copyFetchCall.bind(this, request, false), disableIfBlob); |
Jan Scheffler | 7c50d1f | 2019-12-17 13:33:29 | [diff] [blame] | 1468 | footerSection.appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1469 | i18nString(UIStrings.copyAsNodejsFetch), this._copyFetchCall.bind(this, request, true), disableIfBlob); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1470 | footerSection.appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1471 | i18nString(UIStrings.copyAsCurlCmd), this._copyCurlCommand.bind(this, request, 'win'), disableIfBlob); |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 1472 | footerSection.appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1473 | i18nString(UIStrings.copyAsCurlBash), this._copyCurlCommand.bind(this, request, 'unix'), disableIfBlob); |
| 1474 | footerSection.appendItem(i18nString(UIStrings.copyAllAsPowershell), this._copyAllPowerShellCommand.bind(this)); |
| 1475 | footerSection.appendItem(i18nString(UIStrings.copyAllAsFetch), this._copyAllFetchCall.bind(this, false)); |
| 1476 | footerSection.appendItem(i18nString(UIStrings.copyAllAsNodejsFetch), this._copyAllFetchCall.bind(this, true)); |
| 1477 | footerSection.appendItem(i18nString(UIStrings.copyAllAsCurlCmd), this._copyAllCurlCommand.bind(this, 'win')); |
| 1478 | footerSection.appendItem(i18nString(UIStrings.copyAllAsCurlBash), this._copyAllCurlCommand.bind(this, 'unix')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1479 | } else { |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 1480 | footerSection.appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1481 | i18nString(UIStrings.copyAsFetch), this._copyFetchCall.bind(this, request, false), disableIfBlob); |
Jan Scheffler | 7c50d1f | 2019-12-17 13:33:29 | [diff] [blame] | 1482 | footerSection.appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1483 | i18nString(UIStrings.copyAsNodejsFetch), this._copyFetchCall.bind(this, request, true), disableIfBlob); |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 1484 | footerSection.appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1485 | i18nString(UIStrings.copyAsCurl), this._copyCurlCommand.bind(this, request, 'unix'), disableIfBlob); |
| 1486 | footerSection.appendItem(i18nString(UIStrings.copyAllAsFetch), this._copyAllFetchCall.bind(this, false)); |
| 1487 | footerSection.appendItem(i18nString(UIStrings.copyAllAsNodejsFetch), this._copyAllFetchCall.bind(this, true)); |
| 1488 | footerSection.appendItem(i18nString(UIStrings.copyAllAsCurl), this._copyAllCurlCommand.bind(this, 'unix')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1489 | } |
| 1490 | } else { |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1491 | copyMenu = contextMenu.clipboardSection().appendSubMenuItem(i18nString(UIStrings.copy)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1492 | } |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1493 | footerSection.appendItem(i18nString(UIStrings.copyAllAsHar), this._copyAll.bind(this)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1494 | |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1495 | contextMenu.saveSection().appendItem(i18nString(UIStrings.saveAllAsHarWithContent), this.exportAll.bind(this)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1496 | |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1497 | contextMenu.editSection().appendItem(i18nString(UIStrings.clearBrowserCache), this._clearBrowserCache.bind(this)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1498 | contextMenu.editSection().appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1499 | i18nString(UIStrings.clearBrowserCookies), this._clearBrowserCookies.bind(this)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1500 | |
| 1501 | if (request) { |
| 1502 | const maxBlockedURLLength = 20; |
Tim van der Lippe | cd0bb37 | 2020-05-01 13:53:21 | [diff] [blame] | 1503 | const manager = SDK.NetworkManager.MultitargetNetworkManager.instance(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1504 | let patterns = manager.blockedPatterns(); |
| 1505 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1506 | function addBlockedURL(url: string): void { |
Tim van der Lippe | ffa7862 | 2019-09-16 12:07:12 | [diff] [blame] | 1507 | patterns.push({enabled: true, url: url}); |
| 1508 | manager.setBlockedPatterns(patterns); |
| 1509 | manager.setBlockingEnabled(true); |
Paul Lewis | 75c7d0d | 2020-03-19 12:17:26 | [diff] [blame] | 1510 | UI.ViewManager.ViewManager.instance().showView('network.blocked-urls'); |
Tim van der Lippe | ffa7862 | 2019-09-16 12:07:12 | [diff] [blame] | 1511 | } |
| 1512 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1513 | function removeBlockedURL(url: string): void { |
Tim van der Lippe | ffa7862 | 2019-09-16 12:07:12 | [diff] [blame] | 1514 | patterns = patterns.filter(pattern => pattern.url !== url); |
| 1515 | manager.setBlockedPatterns(patterns); |
Paul Lewis | 75c7d0d | 2020-03-19 12:17:26 | [diff] [blame] | 1516 | UI.ViewManager.ViewManager.instance().showView('network.blocked-urls'); |
Tim van der Lippe | ffa7862 | 2019-09-16 12:07:12 | [diff] [blame] | 1517 | } |
| 1518 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1519 | const urlWithoutScheme = request.parsedURL.urlWithoutScheme(); |
| 1520 | if (urlWithoutScheme && !patterns.find(pattern => pattern.url === urlWithoutScheme)) { |
| 1521 | contextMenu.debugSection().appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1522 | i18nString(UIStrings.blockRequestUrl), addBlockedURL.bind(null, urlWithoutScheme)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1523 | } else if (urlWithoutScheme) { |
Tim van der Lippe | 213266c | 2021-01-18 15:48:31 | [diff] [blame] | 1524 | const croppedURL = Platform.StringUtilities.trimMiddle(urlWithoutScheme, maxBlockedURLLength); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1525 | contextMenu.debugSection().appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1526 | i18nString(UIStrings.unblockS, {PH1: croppedURL}), removeBlockedURL.bind(null, urlWithoutScheme)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1527 | } |
| 1528 | |
| 1529 | const domain = request.parsedURL.domain(); |
| 1530 | if (domain && !patterns.find(pattern => pattern.url === domain)) { |
| 1531 | contextMenu.debugSection().appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1532 | i18nString(UIStrings.blockRequestDomain), addBlockedURL.bind(null, domain)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1533 | } else if (domain) { |
Tim van der Lippe | 213266c | 2021-01-18 15:48:31 | [diff] [blame] | 1534 | const croppedDomain = Platform.StringUtilities.trimMiddle(domain, maxBlockedURLLength); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1535 | contextMenu.debugSection().appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1536 | i18nString(UIStrings.unblockS, {PH1: croppedDomain}), removeBlockedURL.bind(null, domain)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1537 | } |
| 1538 | |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1539 | if (SDK.NetworkManager.NetworkManager.canReplayRequest(request)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1540 | contextMenu.debugSection().appendItem( |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1541 | i18nString(UIStrings.replayXhr), SDK.NetworkManager.NetworkManager.replayRequest.bind(null, request)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1542 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1543 | } |
| 1544 | } |
| 1545 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1546 | _harRequests(): SDK.NetworkRequest.NetworkRequest[] { |
Wolfgang Beyer | d81fad6 | 2020-05-27 12:30:27 | [diff] [blame] | 1547 | return SDK.NetworkLog.NetworkLog.instance().requests().filter(NetworkLogView.HTTPRequestsFilter).filter(request => { |
Joey Arhar | b3d6de4 | 2019-04-23 21:26:17 | [diff] [blame] | 1548 | return request.finished || |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1549 | (request.resourceType() === Common.ResourceType.resourceTypes.WebSocket && request.responseReceivedTime); |
Joey Arhar | b3d6de4 | 2019-04-23 21:26:17 | [diff] [blame] | 1550 | }); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1551 | } |
| 1552 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1553 | async _copyAll(): Promise<void> { |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1554 | const harArchive = {log: await SDK.HARLog.HARLog.build(this._harRequests())}; |
| 1555 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(JSON.stringify(harArchive, null, 2)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1556 | } |
| 1557 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1558 | async _copyCurlCommand(request: SDK.NetworkRequest.NetworkRequest, platform: string): Promise<void> { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1559 | const command = await this._generateCurlCommand(request, platform); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1560 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(command); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1561 | } |
| 1562 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1563 | async _copyAllCurlCommand(platform: string): Promise<void> { |
Wolfgang Beyer | d81fad6 | 2020-05-27 12:30:27 | [diff] [blame] | 1564 | const commands = await this._generateAllCurlCommand(SDK.NetworkLog.NetworkLog.instance().requests(), platform); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1565 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(commands); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1566 | } |
| 1567 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1568 | async _copyFetchCall(request: SDK.NetworkRequest.NetworkRequest, includeCookies: boolean): Promise<void> { |
Jan Scheffler | 7c50d1f | 2019-12-17 13:33:29 | [diff] [blame] | 1569 | const command = await this._generateFetchCall(request, includeCookies); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1570 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(command); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1571 | } |
| 1572 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1573 | async _copyAllFetchCall(includeCookies: boolean): Promise<void> { |
Wolfgang Beyer | d81fad6 | 2020-05-27 12:30:27 | [diff] [blame] | 1574 | const commands = await this._generateAllFetchCall(SDK.NetworkLog.NetworkLog.instance().requests(), includeCookies); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1575 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(commands); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1576 | } |
| 1577 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1578 | async _copyPowerShellCommand(request: SDK.NetworkRequest.NetworkRequest): Promise<void> { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1579 | const command = await this._generatePowerShellCommand(request); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1580 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(command); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1581 | } |
| 1582 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1583 | async _copyAllPowerShellCommand(): Promise<void> { |
Wolfgang Beyer | d81fad6 | 2020-05-27 12:30:27 | [diff] [blame] | 1584 | const commands = await this._generateAllPowerShellCommand(SDK.NetworkLog.NetworkLog.instance().requests()); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1585 | Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(commands); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1586 | } |
| 1587 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1588 | async exportAll(): Promise<void> { |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1589 | const mainTarget = SDK.SDKModel.TargetManager.instance().mainTarget(); |
| 1590 | if (!mainTarget) { |
| 1591 | return; |
| 1592 | } |
| 1593 | const url = mainTarget.inspectedURL(); |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1594 | const parsedURL = Common.ParsedURL.ParsedURL.fromString(url); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1595 | const filename = parsedURL ? parsedURL.host : 'network-log'; |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1596 | const stream = new Bindings.FileUtils.FileOutputStream(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1597 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1598 | if (!await stream.open(filename + '.har')) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1599 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1600 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1601 | |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1602 | const progressIndicator = new UI.ProgressIndicator.ProgressIndicator(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1603 | this._progressBarContainer.appendChild(progressIndicator.element); |
Tim van der Lippe | 119690c | 2020-01-13 12:31:30 | [diff] [blame] | 1604 | await HARWriter.write(stream, this._harRequests(), progressIndicator); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1605 | progressIndicator.done(); |
| 1606 | stream.close(); |
| 1607 | } |
| 1608 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1609 | _clearBrowserCache(): void { |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1610 | if (confirm(i18nString(UIStrings.areYouSureYouWantToClearBrowser))) { |
Tim van der Lippe | cd0bb37 | 2020-05-01 13:53:21 | [diff] [blame] | 1611 | SDK.NetworkManager.MultitargetNetworkManager.instance().clearBrowserCache(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1612 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1613 | } |
| 1614 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1615 | _clearBrowserCookies(): void { |
Christy Chen | cac3f10 | 2021-02-03 10:07:55 | [diff] [blame] | 1616 | if (confirm(i18nString(UIStrings.areYouSureYouWantToClearBrowserCookies))) { |
Tim van der Lippe | cd0bb37 | 2020-05-01 13:53:21 | [diff] [blame] | 1617 | SDK.NetworkManager.MultitargetNetworkManager.instance().clearBrowserCookies(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1618 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1619 | } |
| 1620 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1621 | _removeAllHighlights(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1622 | this.removeAllNodeHighlights(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1623 | for (let i = 0; i < this._highlightedSubstringChanges.length; ++i) { |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1624 | UI.UIUtils.revertDomChanges(this._highlightedSubstringChanges[i]); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1625 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1626 | this._highlightedSubstringChanges = []; |
| 1627 | } |
| 1628 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1629 | _applyFilter(node: NetworkRequestNode): boolean { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1630 | const request = node.request(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1631 | if (this._timeFilter && !this._timeFilter(request)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1632 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1633 | } |
Christy Chen | 1825c61 | 2021-02-25 10:28:44 | [diff] [blame] | 1634 | const categoryName = request.resourceType().category().title(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1635 | if (!this._resourceCategoryFilterUI.accept(categoryName)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1636 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1637 | } |
| 1638 | if (this._dataURLFilterUI.checked() && (request.parsedURL.isDataURL() || request.parsedURL.isBlobURL())) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1639 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1640 | } |
Sigurd Schneider | c8c1e35 | 2020-05-08 14:33:22 | [diff] [blame] | 1641 | if (this._onlyIssuesFilterUI.checked() && |
Sigurd Schneider | 84b6cf7 | 2021-04-13 06:40:54 | [diff] [blame^] | 1642 | !IssuesManager.RelatedIssue.hasIssueOfCategory(request, IssuesManager.Issue.IssueCategory.SameSiteCookie)) { |
Jan Scheffler | 1ae7c9e | 2019-12-03 15:48:37 | [diff] [blame] | 1643 | return false; |
| 1644 | } |
Sigurd Schneider | 20088de | 2020-10-30 08:08:33 | [diff] [blame] | 1645 | if (this._onlyBlockedRequestsUI.checked() && !request.wasBlocked() && !request.corsErrorStatus()) { |
Sigurd Schneider | a2afe0b | 2020-03-03 15:27:13 | [diff] [blame] | 1646 | return false; |
| 1647 | } |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1648 | if (request.statusText === 'Service Worker Fallback Required') { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1649 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1650 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1651 | for (let i = 0; i < this._filters.length; ++i) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1652 | if (!this._filters[i](request)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1653 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1654 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1655 | } |
| 1656 | return true; |
| 1657 | } |
| 1658 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1659 | _parseFilterQuery(query: string): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1660 | const descriptors = this._filterParser.parse(query); |
| 1661 | this._filters = descriptors.map(descriptor => { |
| 1662 | const key = descriptor.key; |
| 1663 | const text = descriptor.text || ''; |
| 1664 | const regex = descriptor.regex; |
| 1665 | let filter; |
| 1666 | if (key) { |
Tim van der Lippe | bafa3bd | 2021-01-20 12:19:17 | [diff] [blame] | 1667 | const defaultText = Platform.StringUtilities.escapeForRegExp(key + ':' + text); |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1668 | filter = this._createSpecialFilter((key as FilterType), text) || |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1669 | NetworkLogView._requestPathFilter.bind(null, new RegExp(defaultText, 'i')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1670 | } else if (descriptor.regex) { |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1671 | filter = NetworkLogView._requestPathFilter.bind(null, (regex as RegExp)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1672 | } else { |
Tim van der Lippe | bafa3bd | 2021-01-20 12:19:17 | [diff] [blame] | 1673 | filter = NetworkLogView._requestPathFilter.bind( |
| 1674 | null, new RegExp(Platform.StringUtilities.escapeForRegExp(text), 'i')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1675 | } |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1676 | return descriptor.negative ? NetworkLogView._negativeFilter.bind(null, filter) : filter; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1677 | }); |
| 1678 | } |
| 1679 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1680 | _createSpecialFilter(type: FilterType, value: string): Filter|null { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1681 | switch (type) { |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1682 | case FilterType.Domain: |
| 1683 | return NetworkLogView._createRequestDomainFilter(value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1684 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1685 | case FilterType.HasResponseHeader: |
| 1686 | return NetworkLogView._requestResponseHeaderFilter.bind(null, value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1687 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1688 | case FilterType.Is: |
| 1689 | if (value.toLowerCase() === IsFilterType.Running) { |
| 1690 | return NetworkLogView._runningRequestFilter; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1691 | } |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1692 | if (value.toLowerCase() === IsFilterType.FromCache) { |
| 1693 | return NetworkLogView._fromCacheRequestFilter; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1694 | } |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1695 | if (value.toLowerCase() === IsFilterType.ServiceWorkerIntercepted) { |
| 1696 | return NetworkLogView._interceptedByServiceWorkerFilter; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1697 | } |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1698 | if (value.toLowerCase() === IsFilterType.ServiceWorkerInitiated) { |
| 1699 | return NetworkLogView._initiatedByServiceWorkerFilter; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1700 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1701 | break; |
| 1702 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1703 | case FilterType.LargerThan: |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1704 | return this._createSizeFilter(value.toLowerCase()); |
| 1705 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1706 | case FilterType.Method: |
| 1707 | return NetworkLogView._requestMethodFilter.bind(null, value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1708 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1709 | case FilterType.MimeType: |
| 1710 | return NetworkLogView._requestMimeTypeFilter.bind(null, value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1711 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1712 | case FilterType.MixedContent: |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1713 | return NetworkLogView._requestMixedContentFilter.bind(null, (value as MixedContentFilterValues)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1714 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1715 | case FilterType.Scheme: |
| 1716 | return NetworkLogView._requestSchemeFilter.bind(null, value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1717 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1718 | case FilterType.SetCookieDomain: |
| 1719 | return NetworkLogView._requestSetCookieDomainFilter.bind(null, value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1720 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1721 | case FilterType.SetCookieName: |
| 1722 | return NetworkLogView._requestSetCookieNameFilter.bind(null, value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1723 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1724 | case FilterType.SetCookieValue: |
| 1725 | return NetworkLogView._requestSetCookieValueFilter.bind(null, value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1726 | |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 1727 | case FilterType.CookieDomain: |
| 1728 | return NetworkLogView._requestCookieDomainFilter.bind(null, value); |
| 1729 | |
| 1730 | case FilterType.CookieName: |
| 1731 | return NetworkLogView._requestCookieNameFilter.bind(null, value); |
| 1732 | |
Simon Zünd | c975910 | 2020-03-25 11:24:54 | [diff] [blame] | 1733 | case FilterType.CookiePath: |
| 1734 | return NetworkLogView._requestCookiePathFilter.bind(null, value); |
| 1735 | |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 1736 | case FilterType.CookieValue: |
| 1737 | return NetworkLogView._requestCookieValueFilter.bind(null, value); |
| 1738 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1739 | case FilterType.Priority: |
Tim van der Lippe | ded23fb | 2020-02-13 13:33:50 | [diff] [blame] | 1740 | return NetworkLogView._requestPriorityFilter.bind( |
| 1741 | null, PerfUI.NetworkPriorities.uiLabelToNetworkPriority(value)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1742 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1743 | case FilterType.StatusCode: |
| 1744 | return NetworkLogView._statusCodeFilter.bind(null, value); |
Sigurd Schneider | 464838b | 2020-08-24 13:53:03 | [diff] [blame] | 1745 | |
| 1746 | case FilterType.ResourceType: |
| 1747 | return NetworkLogView._resourceTypeFilter.bind(null, value); |
Julian Geppert | f8ce40c | 2020-09-01 18:02:03 | [diff] [blame] | 1748 | |
| 1749 | case FilterType.Url: |
| 1750 | return NetworkLogView._requestUrlFilter.bind(null, value); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1751 | } |
| 1752 | return null; |
| 1753 | } |
| 1754 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1755 | _createSizeFilter(value: string): Filter|null { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1756 | let multiplier = 1; |
| 1757 | if (value.endsWith('k')) { |
Wolfgang Beyer | d451ecd | 2020-10-23 08:35:54 | [diff] [blame] | 1758 | multiplier = 1000; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1759 | value = value.substring(0, value.length - 1); |
| 1760 | } else if (value.endsWith('m')) { |
Wolfgang Beyer | d451ecd | 2020-10-23 08:35:54 | [diff] [blame] | 1761 | multiplier = 1000 * 1000; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1762 | value = value.substring(0, value.length - 1); |
| 1763 | } |
| 1764 | const quantity = Number(value); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1765 | if (isNaN(quantity)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1766 | return null; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1767 | } |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 1768 | return NetworkLogView._requestSizeLargerThanFilter.bind(null, quantity * multiplier); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1769 | } |
| 1770 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1771 | _filterRequests(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1772 | this._removeAllHighlights(); |
| 1773 | this._invalidateAllItems(); |
| 1774 | } |
| 1775 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1776 | _reveal(request: SDK.NetworkRequest.NetworkRequest): NetworkRequestNode|null { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1777 | this.removeAllNodeHighlights(); |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1778 | const node = networkRequestToNode.get(request); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1779 | if (!node || !node.dataGrid) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1780 | return null; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1781 | } |
Brandon Goddard | 5e4244d | 2020-04-08 22:08:47 | [diff] [blame] | 1782 | // Viewport datagrid nodes do not reveal if not in the root node |
| 1783 | // list of flatChildren. For children of grouped frame nodes: |
| 1784 | // reveal and expand parent to ensure child is revealable. |
| 1785 | if (node.parent && node.parent instanceof NetworkGroupNode) { |
| 1786 | node.parent.reveal(); |
| 1787 | node.parent.expand(); |
| 1788 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1789 | node.reveal(); |
| 1790 | return node; |
| 1791 | } |
| 1792 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1793 | revealAndHighlightRequest(request: SDK.NetworkRequest.NetworkRequest): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1794 | const node = this._reveal(request); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1795 | if (node) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1796 | this._highlightNode(node); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1797 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1798 | } |
| 1799 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1800 | selectRequest(request: SDK.NetworkRequest.NetworkRequest, options?: FilterOptions): void { |
chait pinnamaneni | 6bc1c12 | 2020-10-30 17:30:52 | [diff] [blame] | 1801 | const defaultOptions = {clearFilter: true}; |
| 1802 | const {clearFilter} = options || defaultOptions; |
| 1803 | if (clearFilter) { |
| 1804 | this.setTextFilterValue(''); |
| 1805 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1806 | const node = this._reveal(request); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1807 | if (node) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1808 | node.select(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1809 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1810 | } |
| 1811 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1812 | removeAllNodeHighlights(): void { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1813 | if (this._highlightedNode) { |
| 1814 | this._highlightedNode.element().classList.remove('highlighted-row'); |
| 1815 | this._highlightedNode = null; |
| 1816 | } |
| 1817 | } |
| 1818 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1819 | _highlightNode(node: NetworkRequestNode): void { |
Tim van der Lippe | 0ed1d2b | 2020-02-04 13:45:13 | [diff] [blame] | 1820 | UI.UIUtils.runCSSAnimationOnce(node.element(), 'highlighted-row'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1821 | this._highlightedNode = node; |
| 1822 | } |
| 1823 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1824 | _filterOutBlobRequests(requests: SDK.NetworkRequest.NetworkRequest[]): SDK.NetworkRequest.NetworkRequest[] { |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 1825 | return requests.filter(request => !request.isBlobRequest()); |
| 1826 | } |
| 1827 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1828 | async _generateFetchCall(request: SDK.NetworkRequest.NetworkRequest, includeCookies: boolean): Promise<string> { |
| 1829 | const ignoredHeaders = new Set<string>([ |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1830 | // Internal headers |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1831 | 'method', |
| 1832 | 'path', |
| 1833 | 'scheme', |
| 1834 | 'version', |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1835 | |
| 1836 | // Unsafe headers |
| 1837 | // Keep this list synchronized with src/net/http/http_util.cc |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1838 | 'accept-charset', |
| 1839 | 'accept-encoding', |
| 1840 | 'access-control-request-headers', |
| 1841 | 'access-control-request-method', |
| 1842 | 'connection', |
| 1843 | 'content-length', |
| 1844 | 'cookie', |
| 1845 | 'cookie2', |
| 1846 | 'date', |
| 1847 | 'dnt', |
| 1848 | 'expect', |
| 1849 | 'host', |
| 1850 | 'keep-alive', |
| 1851 | 'origin', |
| 1852 | 'referer', |
| 1853 | 'te', |
| 1854 | 'trailer', |
| 1855 | 'transfer-encoding', |
| 1856 | 'upgrade', |
| 1857 | 'via', |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1858 | // TODO(phistuck) - remove this once crbug.com/571722 is fixed. |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1859 | 'user-agent', |
| 1860 | ]); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1861 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1862 | const credentialHeaders = new Set<string>(['cookie', 'authorization']); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1863 | |
| 1864 | const url = JSON.stringify(request.url()); |
| 1865 | |
| 1866 | const requestHeaders = request.requestHeaders(); |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1867 | const headerData: Headers = requestHeaders.reduce((result, header) => { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1868 | const name = header.name; |
| 1869 | |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1870 | if (!ignoredHeaders.has(name.toLowerCase()) && !name.includes(':')) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1871 | result.append(name, header.value); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1872 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1873 | |
| 1874 | return result; |
| 1875 | }, new Headers()); |
| 1876 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1877 | const headers: HeadersInit = {}; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1878 | for (const headerArray of headerData) { |
PhistucK | 6ed0a3e | 2018-08-04 06:28:41 | [diff] [blame] | 1879 | headers[headerArray[0]] = headerArray[1]; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1880 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1881 | |
Sigurd Schneider | 0e88b91 | 2020-05-08 08:28:23 | [diff] [blame] | 1882 | const credentials = request.includedRequestCookies().length || |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1883 | requestHeaders.some(({name}) => credentialHeaders.has(name.toLowerCase())) ? |
Jan Scheffler | 341eea5 | 2019-12-12 09:08:41 | [diff] [blame] | 1884 | 'include' : |
| 1885 | 'omit'; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1886 | |
| 1887 | const referrerHeader = requestHeaders.find(({name}) => name.toLowerCase() === 'referer'); |
| 1888 | |
| 1889 | const referrer = referrerHeader ? referrerHeader.value : void 0; |
| 1890 | |
| 1891 | const referrerPolicy = request.referrerPolicy() || void 0; |
| 1892 | |
| 1893 | const requestBody = await request.requestFormData(); |
| 1894 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1895 | const fetchOptions: RequestInit = { |
PhistucK | 6ed0a3e | 2018-08-04 06:28:41 | [diff] [blame] | 1896 | headers: Object.keys(headers).length ? headers : void 0, |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1897 | referrer, |
| 1898 | referrerPolicy, |
| 1899 | body: requestBody, |
| 1900 | method: request.requestMethod, |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 1901 | mode: 'cors', |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1902 | }; |
| 1903 | |
Jan Scheffler | 7c50d1f | 2019-12-17 13:33:29 | [diff] [blame] | 1904 | if (includeCookies) { |
| 1905 | const cookieHeader = requestHeaders.find(header => header.name.toLowerCase() === 'cookie'); |
| 1906 | if (cookieHeader) { |
| 1907 | fetchOptions.headers = { |
| 1908 | ...headers, |
| 1909 | 'cookie': cookieHeader.value, |
| 1910 | }; |
| 1911 | } |
| 1912 | } else { |
| 1913 | fetchOptions.credentials = credentials; |
| 1914 | } |
| 1915 | |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 1916 | const options = JSON.stringify(fetchOptions, null, 2); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1917 | return `fetch(${url}, ${options});`; |
| 1918 | } |
| 1919 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1920 | async _generateAllFetchCall(requests: SDK.NetworkRequest.NetworkRequest[], includeCookies: boolean): Promise<string> { |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 1921 | const nonBlobRequests = this._filterOutBlobRequests(requests); |
Jan Scheffler | 7c50d1f | 2019-12-17 13:33:29 | [diff] [blame] | 1922 | const commands = |
| 1923 | await Promise.all(nonBlobRequests.map(request => this._generateFetchCall(request, includeCookies))); |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 1924 | return commands.join(' ;\n'); |
| 1925 | } |
| 1926 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1927 | async _generateCurlCommand(request: SDK.NetworkRequest.NetworkRequest, platform: string): Promise<string> { |
| 1928 | let command: string[] = []; |
Eric Lawrence | 7a7b368 | 2019-10-17 23:06:36 | [diff] [blame] | 1929 | // Most of these headers are derived from the URL and are automatically added by cURL. |
| 1930 | // The |Accept-Encoding| header is ignored to prevent decompression errors. crbug.com/1015321 |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1931 | const ignoredHeaders = new Set<string>(['accept-encoding', 'host', 'method', 'path', 'scheme', 'version']); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1932 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1933 | function escapeStringWin(str: string): string { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1934 | /* If there are no new line characters do not escape the " characters |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1935 | since it only uglifies the command. |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1936 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1937 | Because cmd.exe parser and MS Crt arguments parsers use some of the |
| 1938 | same escape characters, they can interact with each other in |
| 1939 | horrible ways, the order of operations is critical. |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1940 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1941 | Replace \ with \\ first because it is an escape character for certain |
| 1942 | conditions in both parsers. |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1943 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1944 | Replace all " with \" to ensure the first parser does not remove it. |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1945 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1946 | Then escape all characters we are not sure about with ^ to ensure it |
| 1947 | gets to MS Crt parser safely. |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1948 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1949 | The % character is special because MS Crt parser will try and look for |
| 1950 | ENV variables and fill them in it's place. We cannot escape them with % |
| 1951 | and cannot escape them with ^ (because it's cmd.exe's escape not MS Crt |
| 1952 | parser); So we can get cmd.exe parser to escape the character after it, |
| 1953 | if it is followed by a valid beginning character of an ENV variable. |
| 1954 | This ensures we do not try and double escape another ^ if it was placed |
| 1955 | by the previous replace. |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1956 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1957 | Lastly we replace new lines with ^ and TWO new lines because the first |
| 1958 | new line is there to enact the escape command the second is the character |
| 1959 | to escape (in this case new line). |
| 1960 | */ |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1961 | const encapsChars = /[\r\n]/.test(str) ? '^"' : '"'; |
| 1962 | return encapsChars + |
| 1963 | str.replace(/\\/g, '\\\\') |
| 1964 | .replace(/"/g, '\\"') |
Jan Scheffler | 747b8a1 | 2020-11-03 17:41:54 | [diff] [blame] | 1965 | .replace(/[^a-zA-Z0-9\s_\-:=+~'\/.',?;()*`&]/g, '^$&') |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1966 | .replace(/%(?=[a-zA-Z0-9_])/g, '%^') |
Jan Scheffler | 747b8a1 | 2020-11-03 17:41:54 | [diff] [blame] | 1967 | .replace(/\r?\n/g, '^\n\n') + |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1968 | encapsChars; |
| 1969 | } |
| 1970 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 1971 | function escapeStringPosix(str: string): string { |
| 1972 | function escapeCharacter(x: string): string { |
Erik Luo | aa67675 | 2018-08-21 05:52:22 | [diff] [blame] | 1973 | const code = x.charCodeAt(0); |
Joey Arhar | 2d21f71 | 2019-05-20 21:07:12 | [diff] [blame] | 1974 | let hexString = code.toString(16); |
| 1975 | // Zero pad to four digits to comply with ANSI-C Quoting: |
| 1976 | // http://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1977 | while (hexString.length < 4) { |
Joey Arhar | 2d21f71 | 2019-05-20 21:07:12 | [diff] [blame] | 1978 | hexString = '0' + hexString; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 1979 | } |
Joey Arhar | 2d21f71 | 2019-05-20 21:07:12 | [diff] [blame] | 1980 | |
| 1981 | return '\\u' + hexString; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1982 | } |
| 1983 | |
Mathias Bynens | f06e8c0 | 2020-02-28 13:58:28 | [diff] [blame] | 1984 | if (/[\0-\x1F\x7F-\x9F!]|\'/.test(str)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1985 | // Use ANSI-C quoting syntax. |
| 1986 | return '$\'' + |
| 1987 | str.replace(/\\/g, '\\\\') |
| 1988 | .replace(/\'/g, '\\\'') |
| 1989 | .replace(/\n/g, '\\n') |
| 1990 | .replace(/\r/g, '\\r') |
Mathias Bynens | f06e8c0 | 2020-02-28 13:58:28 | [diff] [blame] | 1991 | .replace(/[\0-\x1F\x7F-\x9F!]/g, escapeCharacter) + |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1992 | '\''; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1993 | } |
Mathias Bynens | f06e8c0 | 2020-02-28 13:58:28 | [diff] [blame] | 1994 | // Use single quote syntax. |
| 1995 | return '\'' + str + '\''; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1996 | } |
| 1997 | |
| 1998 | // cURL command expected to run on the same platform that DevTools run |
| 1999 | // (it may be different from the inspected page platform). |
| 2000 | const escapeString = platform === 'win' ? escapeStringWin : escapeStringPosix; |
| 2001 | |
| 2002 | command.push(escapeString(request.url()).replace(/[[{}\]]/g, '\\$&')); |
| 2003 | |
| 2004 | let inferredMethod = 'GET'; |
| 2005 | const data = []; |
| 2006 | const requestContentType = request.requestContentType(); |
| 2007 | const formData = await request.requestFormData(); |
| 2008 | if (requestContentType && requestContentType.startsWith('application/x-www-form-urlencoded') && formData) { |
Jan Scheffler | 441bb6a | 2020-02-11 11:46:27 | [diff] [blame] | 2009 | // Note that formData is not necessarily urlencoded because it might for example |
| 2010 | // come from a fetch request made with an explicitly unencoded body. |
| 2011 | data.push('--data-raw ' + escapeString(formData)); |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 2012 | ignoredHeaders.add('content-length'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2013 | inferredMethod = 'POST'; |
| 2014 | } else if (formData) { |
Jan Scheffler | d2663ac | 2020-10-26 09:05:11 | [diff] [blame] | 2015 | data.push('--data-raw ' + escapeString(formData)); |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 2016 | ignoredHeaders.add('content-length'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2017 | inferredMethod = 'POST'; |
| 2018 | } |
| 2019 | |
| 2020 | if (request.requestMethod !== inferredMethod) { |
Jan Scheffler | a4e536a | 2020-01-09 08:51:29 | [diff] [blame] | 2021 | command.push('-X ' + escapeString(request.requestMethod)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2022 | } |
| 2023 | |
| 2024 | const requestHeaders = request.requestHeaders(); |
| 2025 | for (let i = 0; i < requestHeaders.length; i++) { |
| 2026 | const header = requestHeaders[i]; |
| 2027 | const name = header.name.replace(/^:/, ''); // Translate SPDY v3 headers to HTTP headers. |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 2028 | if (ignoredHeaders.has(name.toLowerCase())) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2029 | continue; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2030 | } |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 2031 | command.push('-H ' + escapeString(name + ': ' + header.value)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2032 | } |
| 2033 | command = command.concat(data); |
| 2034 | command.push('--compressed'); |
| 2035 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2036 | if (request.securityState() === Protocol.Security.SecurityState.Insecure) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2037 | command.push('--insecure'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2038 | } |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 2039 | return 'curl ' + command.join(command.length >= 3 ? (platform === 'win' ? ' ^\n ' : ' \\\n ') : ' '); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2040 | } |
| 2041 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2042 | async _generateAllCurlCommand(requests: SDK.NetworkRequest.NetworkRequest[], platform: string): Promise<string> { |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 2043 | const nonBlobRequests = this._filterOutBlobRequests(requests); |
| 2044 | const commands = await Promise.all(nonBlobRequests.map(request => this._generateCurlCommand(request, platform))); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2045 | if (platform === 'win') { |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 2046 | return commands.join(' &\r\n'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2047 | } |
Mathias Bynens | f06e8c0 | 2020-02-28 13:58:28 | [diff] [blame] | 2048 | return commands.join(' ;\n'); |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 2049 | } |
| 2050 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2051 | async _generatePowerShellCommand(request: SDK.NetworkRequest.NetworkRequest): Promise<string> { |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 2052 | const command = []; |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2053 | const ignoredHeaders = new Set<string>( |
| 2054 | ['host', 'connection', 'proxy-connection', 'content-length', 'expect', 'range', 'content-type']); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2055 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2056 | function escapeString(str: string): string { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2057 | return '"' + |
| 2058 | str.replace(/[`\$"]/g, '`$&').replace(/[^\x20-\x7E]/g, char => '$([char]' + char.charCodeAt(0) + ')') + '"'; |
| 2059 | } |
| 2060 | |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 2061 | command.push('-Uri ' + escapeString(request.url())); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2062 | |
| 2063 | if (request.requestMethod !== 'GET') { |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 2064 | command.push('-Method ' + escapeString(request.requestMethod)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2065 | } |
| 2066 | |
| 2067 | const requestHeaders = request.requestHeaders(); |
| 2068 | const headerNameValuePairs = []; |
| 2069 | for (const header of requestHeaders) { |
| 2070 | const name = header.name.replace(/^:/, ''); // Translate h2 headers to HTTP headers. |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2071 | if (ignoredHeaders.has(name.toLowerCase())) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2072 | continue; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2073 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2074 | headerNameValuePairs.push(escapeString(name) + '=' + escapeString(header.value)); |
| 2075 | } |
| 2076 | if (headerNameValuePairs.length) { |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 2077 | command.push('-Headers @{\n' + headerNameValuePairs.join('\n ') + '\n}'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2078 | } |
| 2079 | |
| 2080 | const contentTypeHeader = requestHeaders.find(({name}) => name.toLowerCase() === 'content-type'); |
| 2081 | if (contentTypeHeader) { |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 2082 | command.push('-ContentType ' + escapeString(contentTypeHeader.value)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2083 | } |
| 2084 | |
| 2085 | const formData = await request.requestFormData(); |
| 2086 | if (formData) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2087 | const body = escapeString(formData); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2088 | if (/[^\x20-\x7E]/.test(formData)) { |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 2089 | command.push('-Body ([System.Text.Encoding]::UTF8.GetBytes(' + body + '))'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2090 | } else { |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 2091 | command.push('-Body ' + body); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2092 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2093 | } |
| 2094 | |
Jan Scheffler | 172d521 | 2020-01-02 14:42:56 | [diff] [blame] | 2095 | return 'Invoke-WebRequest ' + command.join(command.length >= 3 ? ' `\n' : ' '); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2096 | } |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 2097 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2098 | async _generateAllPowerShellCommand(requests: SDK.NetworkRequest.NetworkRequest[]): Promise<string> { |
Harley Li | bcf41f9 | 2018-09-10 18:01:13 | [diff] [blame] | 2099 | const nonBlobRequests = this._filterOutBlobRequests(requests); |
| 2100 | const commands = await Promise.all(nonBlobRequests.map(request => this._generatePowerShellCommand(request))); |
| 2101 | return commands.join(';\r\n'); |
| 2102 | } |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 2103 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2104 | static getDCLEventColor(): string { |
Paul Lewis | ca569a5 | 2020-09-09 16:11:51 | [diff] [blame] | 2105 | if (ThemeSupport.ThemeSupport.instance().themeName() === 'dark') { |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 2106 | return '#03A9F4'; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 2107 | } |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 2108 | return '#0867CB'; |
| 2109 | } |
| 2110 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2111 | static getLoadEventColor(): string { |
Paul Lewis | ca569a5 | 2020-09-09 16:11:51 | [diff] [blame] | 2112 | return ThemeSupport.ThemeSupport.instance().patchColorText( |
| 2113 | '#B31412', ThemeSupport.ThemeSupport.ColorUsage.Foreground); |
Joey Arhar | a86c14e | 2019-03-12 03:20:50 | [diff] [blame] | 2114 | } |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 2115 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2116 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2117 | export function computeStackTraceText(stackTrace: Protocol.Runtime.StackTrace): string { |
Tim van der Lippe | b4faf5a | 2020-11-06 15:02:02 | [diff] [blame] | 2118 | let stackTraceText = ''; |
| 2119 | for (const frame of stackTrace.callFrames) { |
| 2120 | const functionName = UI.UIUtils.beautifyFunctionName(frame.functionName); |
| 2121 | stackTraceText += `${functionName} @ ${frame.url}:${frame.lineNumber + 1}\n`; |
| 2122 | } |
| 2123 | if (stackTrace.parent) { |
| 2124 | stackTraceText += computeStackTraceText(stackTrace.parent); |
| 2125 | } |
| 2126 | return stackTraceText; |
| 2127 | } |
| 2128 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2129 | const filteredNetworkRequests = new WeakSet<NetworkRequestNode>(); |
| 2130 | const networkRequestToNode = new WeakMap<SDK.NetworkRequest.NetworkRequest, NetworkRequestNode>(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2131 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2132 | export function isRequestFilteredOut(request: NetworkRequestNode): boolean { |
Tim van der Lippe | 224a862 | 2020-09-23 12:14:37 | [diff] [blame] | 2133 | return filteredNetworkRequests.has(request); |
Tim van der Lippe | 3dc5fd6 | 2020-09-22 13:12:22 | [diff] [blame] | 2134 | } |
| 2135 | |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 2136 | export const HTTPSchemas = { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2137 | 'http': true, |
| 2138 | 'https': true, |
| 2139 | 'ws': true, |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2140 | 'wss': true, |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 2141 | }; |
| 2142 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2143 | // TODO(crbug.com/1167717): Make this a const enum again |
| 2144 | // eslint-disable-next-line rulesdir/const_enum |
| 2145 | export enum FilterType { |
| 2146 | Domain = 'domain', |
| 2147 | HasResponseHeader = 'has-response-header', |
| 2148 | Is = 'is', |
| 2149 | LargerThan = 'larger-than', |
| 2150 | Method = 'method', |
| 2151 | MimeType = 'mime-type', |
| 2152 | MixedContent = 'mixed-content', |
| 2153 | Priority = 'priority', |
| 2154 | Scheme = 'scheme', |
| 2155 | SetCookieDomain = 'set-cookie-domain', |
| 2156 | SetCookieName = 'set-cookie-name', |
| 2157 | SetCookieValue = 'set-cookie-value', |
| 2158 | ResourceType = 'resource-type', |
| 2159 | CookieDomain = 'cookie-domain', |
| 2160 | CookieName = 'cookie-name', |
| 2161 | CookiePath = 'cookie-path', |
| 2162 | CookieValue = 'cookie-value', |
| 2163 | StatusCode = 'status-code', |
| 2164 | Url = 'url', |
Paul Lewis | 5650965 | 2019-12-06 12:51:58 | [diff] [blame] | 2165 | } |
Tim van der Lippe | b1f2b6c | 2020-02-17 13:00:16 | [diff] [blame] | 2166 | |
Jan Scheffler | d6c1d40 | 2021-02-26 16:56:38 | [diff] [blame] | 2167 | // TODO(crbug.com/1167717): Make this a const enum again |
| 2168 | // eslint-disable-next-line rulesdir/const_enum |
| 2169 | export enum MixedContentFilterValues { |
| 2170 | All = 'all', |
| 2171 | Displayed = 'displayed', |
| 2172 | Blocked = 'blocked', |
| 2173 | BlockOverridden = 'block-overridden', |
| 2174 | } |
| 2175 | |
| 2176 | // TODO(crbug.com/1167717): Make this a const enum again |
| 2177 | // eslint-disable-next-line rulesdir/const_enum |
| 2178 | export enum IsFilterType { |
| 2179 | Running = 'running', |
| 2180 | FromCache = 'from-cache', |
| 2181 | ServiceWorkerIntercepted = 'service-worker-intercepted', |
| 2182 | ServiceWorkerInitiated = 'service-worker-initiated', |
| 2183 | } |
| 2184 | |
| 2185 | // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration) |
| 2186 | // eslint-disable-next-line @typescript-eslint/naming-convention |
| 2187 | export const _searchKeys: string[] = Object.values(FilterType); |
| 2188 | |
| 2189 | export interface GroupLookupInterface { |
| 2190 | groupNodeForRequest(request: SDK.NetworkRequest.NetworkRequest): NetworkGroupNode|null; |
| 2191 | reset(): void; |
| 2192 | } |
| 2193 | |
| 2194 | export type Filter = (request: SDK.NetworkRequest.NetworkRequest) => boolean; |