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