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