@@ -7,6 +7,7 @@ import '../../../ui/components/icon_button/icon_button.js';
77
88import * as i18n from '../../../core/i18n/i18n.js' ;
99import * as Platform from '../../../core/platform/platform.js' ;
10+ import * as SDK from '../../../core/sdk/sdk.js' ;
1011import * as Trace from '../../../models/trace/trace.js' ;
1112import * as PerfUI from '../../../ui/legacy/components/perf_ui/perf_ui.js' ;
1213import * as Lit from '../../../ui/lit/lit.js' ;
@@ -15,7 +16,7 @@ import * as TimelineUtils from '../utils/utils.js';
1516import networkRequestTooltipStyles from './networkRequestTooltip.css.js' ;
1617import { colorForNetworkRequest , networkResourceCategory } from './Utils.js' ;
1718
18- const { html} = Lit ;
19+ const { html, nothing , Directives : { classMap , ifDefined } } = Lit ;
1920
2021const MAX_URL_LENGTH = 60 ;
2122
@@ -52,6 +53,11 @@ const UIStrings = {
5253 * @description Text to refer to the list of redirects.
5354 */
5455 redirects : 'Redirects' ,
56+ /**
57+ * @description Cell title in Network Data Grid Node of the Network panel
58+ * @example {Fast 4G} PH1
59+ */
60+ wasThrottled : 'Request was throttled ({PH1})' ,
5561} as const ;
5662const str_ = i18n . i18n . registerUIStrings ( 'panels/timeline/components/NetworkRequestTooltip.ts' , UIStrings ) ;
5763const i18nString = i18n . i18n . getLocalizedString . bind ( undefined , str_ ) ;
@@ -106,6 +112,16 @@ export class NetworkRequestTooltip extends HTMLElement {
106112 backgroundColor : color ,
107113 } ;
108114
115+ const sdkNetworkRequest = SDK . TraceObject . RevealableNetworkRequest . create ( networkRequest ) ;
116+ const wasThrottled = sdkNetworkRequest &&
117+ SDK . NetworkManager . MultitargetNetworkManager . instance ( ) . appliedRequestConditions (
118+ sdkNetworkRequest . networkRequest ) ;
119+ const throttledTitle = wasThrottled ? i18nString ( UIStrings . wasThrottled , {
120+ PH1 : typeof wasThrottled . conditions . title === 'string' ? wasThrottled . conditions . title :
121+ wasThrottled . conditions . title ( )
122+ } ) :
123+ undefined ;
124+
109125 // The outside spans are transparent with a border on the outside edge.
110126 // The inside spans are 1px tall rectangles, vertically centered, with background color.
111127 // |
@@ -114,9 +130,20 @@ export class NetworkRequestTooltip extends HTMLElement {
114130 const leftWhisker = html `< span class ="whisker-left "> < span class ="horizontal "> </ span > </ span > ` ;
115131 const rightWhisker = html `< span class ="whisker-right "> < span class ="horizontal "> </ span > </ span > ` ;
116132
133+ const classes = classMap ( {
134+ [ 'timings-row timings-row--duration' ] : true ,
135+ throttled : Boolean ( wasThrottled ?. urlPattern ) ,
136+ } ) ;
117137 return html `
118- < div class ="timings-row timings-row--duration ">
119- < span class ="indicator "> </ span >
138+ < div
139+ class =${ classes }
140+ title =${ ifDefined ( throttledTitle ) } >
141+ ${
142+ wasThrottled ?. urlPattern ? html `< devtools-icon
143+ class =indicator
144+ name =watch
145+ > </ devtools-icon > ` :
146+ html `< span class ="indicator "> </ span > ` }
120147 ${ i18nString ( UIStrings . duration ) }
121148 < span class ="time "> ${ i18n . TimeUtilities . formatMicroSecondsTime ( networkRequest . dur ) } </ span >
122149 </ div >
@@ -173,6 +200,11 @@ export class NetworkRequestTooltip extends HTMLElement {
173200
174201 const redirectsHtml = NetworkRequestTooltip . renderRedirects ( this . #data. networkRequest ) ;
175202
203+ const sdkNetworkRequest = SDK . TraceObject . RevealableNetworkRequest . create ( this . #data. networkRequest ) ;
204+ const wasThrottled = sdkNetworkRequest &&
205+ SDK . NetworkManager . MultitargetNetworkManager . instance ( ) . appliedRequestConditions (
206+ sdkNetworkRequest . networkRequest ) ;
207+
176208 // clang-format off
177209 const output = html `
178210 < style > ${ networkRequestTooltipStyles } </ style >
@@ -186,6 +218,13 @@ export class NetworkRequestTooltip extends HTMLElement {
186218 </ span > ${ networkResourceCategory ( this . #data. networkRequest ) }
187219 </ div >
188220 < div class ="priority-row "> ${ i18nString ( UIStrings . priority ) } : ${ NetworkRequestTooltip . renderPriorityValue ( this . #data. networkRequest ) } </ div >
221+ ${ wasThrottled ? html `
222+ < div class ="throttled-row ">
223+ ${ i18nString ( UIStrings . wasThrottled , {
224+ PH1 : typeof wasThrottled . conditions . title === 'string' ? wasThrottled . conditions . title :
225+ wasThrottled . conditions . title ( )
226+ } ) }
227+ </ div > ` : nothing }
189228 ${ Trace . Helpers . Network . isSyntheticNetworkRequestEventRenderBlocking ( this . #data. networkRequest ) ?
190229 html `< div class ="render-blocking "> ${ i18nString ( UIStrings . renderBlocking ) } </ div > ` : Lit . nothing
191230 }
0 commit comments