@@ -106,6 +106,14 @@ const UIStrings = {
106106 *@description Text in Signed Exchange Info View of the Network panel
107107 */
108108 label : 'Label' ,
109+ /**
110+ *@description Text in Request Timing View of the Network panel
111+ */
112+ routerEvaluation : 'Router Evaluation' ,
113+ /**
114+ *@description Text in Request Timing View of the Network panel
115+ */
116+ routerCacheLookup : 'Cache Lookup' ,
109117 /**
110118 *@description Inner element text content in Network Log View Columns of the Network panel
111119 */
@@ -217,6 +225,16 @@ const UIStrings = {
217225 *@description Text used to show that data was retrieved using ServiceWorker fallback code
218226 */
219227 fallbackCode : 'Fallback code' ,
228+ /**
229+ *@description Name of the specified source for SW static routing API.
230+ *@example {network} PH1
231+ */
232+ routerMatchedSource : 'Matched source: {PH1}' ,
233+ /**
234+ *@description Name of the actually used source for SW static routing API.
235+ *@example {network} PH1
236+ */
237+ routerActualSource : 'Actual source: {PH1}' ,
220238} ;
221239const str_ = i18n . i18n . registerUIStrings ( 'panels/network/RequestTimingView.ts' , UIStrings ) ;
222240const i18nString = i18n . i18n . getLocalizedString . bind ( undefined , str_ ) ;
@@ -258,6 +276,10 @@ export class RequestTimingView extends UI.Widget.VBox {
258276 return i18nString ( UIStrings . requestToServiceworker ) ;
259277 case RequestTimeRangeNames . SERVICE_WORKER_PREPARATION :
260278 return i18nString ( UIStrings . startup ) ;
279+ case RequestTimeRangeNames . SERVICE_WORKER_ROUTER_EVALUATION :
280+ return i18nString ( UIStrings . routerEvaluation ) ;
281+ case RequestTimeRangeNames . SERVICE_WORKER_CACHE_LOOKUP :
282+ return i18nString ( UIStrings . routerCacheLookup ) ;
261283 case RequestTimeRangeNames . SERVICE_WORKER_RESPOND_WITH :
262284 return i18nString ( UIStrings . respondwith ) ;
263285 case RequestTimeRangeNames . SSL :
@@ -490,6 +512,15 @@ export class RequestTimingView extends UI.Widget.VBox {
490512 timingBarTitleElement . setAttribute ( 'role' , 'switch' ) ;
491513 UI . ARIAUtils . setChecked ( timingBarTitleElement , false ) ;
492514 }
515+
516+ if ( range . name === 'serviceworker-routerevaluation' ) {
517+ timingBarTitleElement . classList . add ( 'network-fetch-timing-bar-clickable' ) ;
518+ tableElement . createChild ( 'tr' , 'router-evaluation-timing-bar-details' ) ;
519+
520+ timingBarTitleElement . setAttribute ( 'tabindex' , '0' ) ;
521+ timingBarTitleElement . setAttribute ( 'role' , 'switch' ) ;
522+ UI . ARIAUtils . setChecked ( timingBarTitleElement , false ) ;
523+ }
493524 }
494525
495526 if ( ! request . finished && ! request . preserved ) {
@@ -683,6 +714,67 @@ export class RequestTimingView extends UI.Widget.VBox {
683714 }
684715 }
685716
717+ private constructRouterEvaluationView ( ) : void {
718+ if ( ! this . tableElement ) {
719+ return ;
720+ }
721+
722+ const routerEvaluationDetailsElement = this . tableElement . querySelector ( '.router-evaluation-timing-bar-details' ) ;
723+ if ( ! routerEvaluationDetailsElement ) {
724+ return ;
725+ }
726+
727+ routerEvaluationDetailsElement . classList . add ( 'network-fetch-timing-bar-details-collapsed' ) ;
728+
729+ self . onInvokeElement (
730+ this . tableElement , this . onToggleRouterEvaluationDetails . bind ( this , routerEvaluationDetailsElement ) ) ;
731+
732+ const detailsView = new UI . TreeOutline . TreeOutlineInShadow ( ) ;
733+ routerEvaluationDetailsElement . appendChild ( detailsView . element ) ;
734+
735+ const { serviceWorkerRouterInfo} = this . request ;
736+ if ( ! serviceWorkerRouterInfo ) {
737+ return ;
738+ }
739+
740+ const document = this . tableElement . ownerDocument ;
741+
742+ // Add matched source type element
743+ const matchedSourceTypeElement = document . createElement ( 'div' ) ;
744+ matchedSourceTypeElement . classList . add ( 'network-fetch-details-treeitem' ) ;
745+ const matchedSourceType = serviceWorkerRouterInfo . matchedSourceType ;
746+ const matchedSourceTypeString = String ( matchedSourceType ) || i18nString ( UIStrings . unknown ) ;
747+ matchedSourceTypeElement . textContent = i18nString ( UIStrings . routerMatchedSource , { PH1 : matchedSourceTypeString } ) ;
748+
749+ const matchedSourceTypeTreeElement = new UI . TreeOutline . TreeElement ( matchedSourceTypeElement ) ;
750+ detailsView . appendChild ( matchedSourceTypeTreeElement ) ;
751+
752+ // Add actual source type element
753+ const actualSourceTypeElement = document . createElement ( 'div' ) ;
754+ actualSourceTypeElement . classList . add ( 'network-fetch-details-treeitem' ) ;
755+ const actualSourceType = serviceWorkerRouterInfo . actualSourceType ;
756+ const actualSourceTypeString = String ( actualSourceType ) || i18nString ( UIStrings . unknown ) ;
757+ actualSourceTypeElement . textContent = i18nString ( UIStrings . routerActualSource , { PH1 : actualSourceTypeString } ) ;
758+
759+ const actualSourceTypeTreeElement = new UI . TreeOutline . TreeElement ( actualSourceTypeElement ) ;
760+ detailsView . appendChild ( actualSourceTypeTreeElement ) ;
761+ }
762+
763+ private onToggleRouterEvaluationDetails ( routerEvaluationDetailsElement : Element , event : Event ) : void {
764+ if ( ! event . target ) {
765+ return ;
766+ }
767+
768+ const target = ( event . target as Element ) ;
769+ if ( target . classList . contains ( 'network-fetch-timing-bar-clickable' ) ) {
770+ const expanded = target . getAttribute ( 'aria-checked' ) === 'true' ;
771+ target . setAttribute ( 'aria-checked' , String ( ! expanded ) ) ;
772+
773+ routerEvaluationDetailsElement . classList . toggle ( 'network-fetch-timing-bar-details-collapsed' ) ;
774+ routerEvaluationDetailsElement . classList . toggle ( 'network-fetch-timing-bar-details-expanded' ) ;
775+ }
776+ }
777+
686778 override wasShown ( ) : void {
687779 this . request . addEventListener ( SDK . NetworkRequest . Events . TIMING_CHANGED , this . refresh , this ) ;
688780 this . request . addEventListener ( SDK . NetworkRequest . Events . FINISHED_LOADING , this . refresh , this ) ;
@@ -709,6 +801,10 @@ export class RequestTimingView extends UI.Widget.VBox {
709801 if ( this . request . fetchedViaServiceWorker ) {
710802 this . constructFetchDetailsView ( ) ;
711803 }
804+
805+ if ( this . request . serviceWorkerRouterInfo ) {
806+ this . constructRouterEvaluationView ( ) ;
807+ }
712808 }
713809
714810 private boundaryChanged ( ) : void {
0 commit comments