@@ -52,7 +52,76 @@ describeWithEnvironment('PreloadingDetailsReportView', () => {
5252 it ( 'renders prerendering details' , async ( ) => {
5353 const url = 'https://example.com/prerendered.html' as Platform . DevToolsPath . UrlString ;
5454 const data : PreloadingComponents . PreloadingDetailsReportView . PreloadingDetailsReportViewData = {
55- preloadingAttempt : {
55+ pipeline : SDK . PreloadingModel . PreloadPipeline . newFromAttemptsForTesting ( [
56+ {
57+ action : Protocol . Preload . SpeculationAction . Prefetch ,
58+ key : {
59+ loaderId : 'loaderId' as Protocol . Network . LoaderId ,
60+ action : Protocol . Preload . SpeculationAction . Prefetch ,
61+ url,
62+ targetHint : undefined ,
63+ } ,
64+ pipelineId : 'pipelineId:1' as Protocol . Preload . PreloadPipelineId ,
65+ status : SDK . PreloadingModel . PreloadingStatus . SUCCESS ,
66+ prefetchStatus : Protocol . Preload . PrefetchStatus . PrefetchResponseUsed ,
67+ requestId : 'requestId:1' as Protocol . Network . RequestId ,
68+ ruleSetIds : [ 'ruleSetId' ] as Protocol . Preload . RuleSetId [ ] ,
69+ nodeIds : [ 1 ] as Protocol . DOM . BackendNodeId [ ] ,
70+ } ,
71+ {
72+ action : Protocol . Preload . SpeculationAction . Prerender ,
73+ key : {
74+ loaderId : 'loaderId' as Protocol . Network . LoaderId ,
75+ action : Protocol . Preload . SpeculationAction . Prerender ,
76+ url,
77+ targetHint : undefined ,
78+ } ,
79+ pipelineId : 'pipelineId:1' as Protocol . Preload . PreloadPipelineId ,
80+ status : SDK . PreloadingModel . PreloadingStatus . RUNNING ,
81+ prerenderStatus : null ,
82+ disallowedMojoInterface : null ,
83+ mismatchedHeaders : null ,
84+ ruleSetIds : [ 'ruleSetId' ] as Protocol . Preload . RuleSetId [ ] ,
85+ nodeIds : [ 1 ] as Protocol . DOM . BackendNodeId [ ] ,
86+ } ,
87+ ] ) ,
88+ ruleSets : [
89+ {
90+ id : 'ruleSetId' as Protocol . Preload . RuleSetId ,
91+ loaderId : 'loaderId' as Protocol . Network . LoaderId ,
92+ sourceText : `
93+ {
94+ "prefetch": [
95+ {
96+ "source": "list",
97+ "urls": ["/subresource.js"]
98+ }
99+ ]
100+ }
101+ ` ,
102+ } ,
103+ ] ,
104+ pageURL : 'https://example.com/' as Platform . DevToolsPath . UrlString ,
105+ } ;
106+
107+ const component = await renderPreloadingDetailsReportView ( data ) ;
108+ const report = getElementWithinComponent ( component , 'devtools-report' , ReportView . ReportView . Report ) ;
109+
110+ const keys = getCleanTextContentFromElements ( report , 'devtools-report-key' ) ;
111+ const values = getCleanTextContentFromElements ( report , 'devtools-report-value' ) ;
112+ assert . deepEqual ( zip2 ( keys , values ) , [
113+ [ 'URL' , url ] ,
114+ [ 'Action' , 'Prerender' ] ,
115+ [ 'Status' , 'Speculative load is running.' ] ,
116+ [ 'Rule set' , 'example.com/' ] ,
117+ ] ) ;
118+ } ) ;
119+
120+ // Prerender2FallbackPrefetchSpecRules disabled case.
121+ it ( 'doesn\'t render (automatically fell back to prefetch) if prerender alone' , async ( ) => {
122+ const url = 'https://example.com/prerendered.html' as Platform . DevToolsPath . UrlString ;
123+ const data : PreloadingComponents . PreloadingDetailsReportView . PreloadingDetailsReportViewData = {
124+ pipeline : SDK . PreloadingModel . PreloadPipeline . newFromAttemptsForTesting ( [ {
56125 action : Protocol . Preload . SpeculationAction . Prerender ,
57126 key : {
58127 loaderId : 'loaderId' as Protocol . Network . LoaderId ,
@@ -67,7 +136,7 @@ describeWithEnvironment('PreloadingDetailsReportView', () => {
67136 mismatchedHeaders : null ,
68137 ruleSetIds : [ 'ruleSetId' ] as Protocol . Preload . RuleSetId [ ] ,
69138 nodeIds : [ 1 ] as Protocol . DOM . BackendNodeId [ ] ,
70- } ,
139+ } ] ) ,
71140 ruleSets : [
72141 {
73142 id : 'ruleSetId' as Protocol . Preload . RuleSetId ,
@@ -105,22 +174,39 @@ describeWithEnvironment('PreloadingDetailsReportView', () => {
105174 it ( 'renders prerendering details with cancelled reason' , async ( ) => {
106175 const url = 'https://example.com/prerendered.html' as Platform . DevToolsPath . UrlString ;
107176 const data : PreloadingComponents . PreloadingDetailsReportView . PreloadingDetailsReportViewData = {
108- preloadingAttempt : {
109- action : Protocol . Preload . SpeculationAction . Prerender ,
110- key : {
111- loaderId : 'loaderId' as Protocol . Network . LoaderId ,
177+ pipeline : SDK . PreloadingModel . PreloadPipeline . newFromAttemptsForTesting ( [
178+ {
179+ action : Protocol . Preload . SpeculationAction . Prefetch ,
180+ key : {
181+ loaderId : 'loaderId' as Protocol . Network . LoaderId ,
182+ action : Protocol . Preload . SpeculationAction . Prefetch ,
183+ url,
184+ targetHint : undefined ,
185+ } ,
186+ pipelineId : 'pipelineId:1' as Protocol . Preload . PreloadPipelineId ,
187+ status : SDK . PreloadingModel . PreloadingStatus . SUCCESS ,
188+ prefetchStatus : Protocol . Preload . PrefetchStatus . PrefetchResponseUsed ,
189+ requestId : 'requestId:1' as Protocol . Network . RequestId ,
190+ ruleSetIds : [ 'ruleSetId' ] as Protocol . Preload . RuleSetId [ ] ,
191+ nodeIds : [ 1 ] as Protocol . DOM . BackendNodeId [ ] ,
192+ } ,
193+ {
112194 action : Protocol . Preload . SpeculationAction . Prerender ,
113- url,
114- targetHint : undefined ,
195+ key : {
196+ loaderId : 'loaderId' as Protocol . Network . LoaderId ,
197+ action : Protocol . Preload . SpeculationAction . Prerender ,
198+ url,
199+ targetHint : undefined ,
200+ } ,
201+ pipelineId : 'pipelineId:1' as Protocol . Preload . PreloadPipelineId ,
202+ status : SDK . PreloadingModel . PreloadingStatus . FAILURE ,
203+ prerenderStatus : Protocol . Preload . PrerenderFinalStatus . MojoBinderPolicy ,
204+ disallowedMojoInterface : 'device.mojom.GamepadMonitor' ,
205+ mismatchedHeaders : null ,
206+ ruleSetIds : [ 'ruleSetId' ] as Protocol . Preload . RuleSetId [ ] ,
207+ nodeIds : [ 1 ] as Protocol . DOM . BackendNodeId [ ] ,
115208 } ,
116- pipelineId : 'pipelineId:1' as Protocol . Preload . PreloadPipelineId ,
117- status : SDK . PreloadingModel . PreloadingStatus . FAILURE ,
118- prerenderStatus : Protocol . Preload . PrerenderFinalStatus . MojoBinderPolicy ,
119- disallowedMojoInterface : 'device.mojom.GamepadMonitor' ,
120- mismatchedHeaders : null ,
121- ruleSetIds : [ 'ruleSetId' ] as Protocol . Preload . RuleSetId [ ] ,
122- nodeIds : [ 1 ] as Protocol . DOM . BackendNodeId [ ] ,
123- } ,
209+ ] ) ,
124210 ruleSets : [
125211 {
126212 id : 'ruleSetId' as Protocol . Preload . RuleSetId ,
@@ -147,8 +233,8 @@ describeWithEnvironment('PreloadingDetailsReportView', () => {
147233 const values = getCleanTextContentFromElements ( report , 'devtools-report-value' ) ;
148234 assert . deepEqual ( zip2 ( keys , values ) , [
149235 [ 'URL' , url ] ,
150- [ 'Action' , 'Prerender' ] ,
151- [ 'Status' , 'Speculative load failed.' ] ,
236+ [ 'Action' , 'Prerender (automatically fell back to prefetch) ' ] ,
237+ [ 'Status' , 'Speculative load failed, but fallback to prefetch succeeded .' ] ,
152238 [
153239 'Failure reason' ,
154240 'The prerendered page used a forbidden JavaScript API that is currently not supported. (Internal Mojo interface: device.mojom.GamepadMonitor)' ,
@@ -166,7 +252,7 @@ describeWithEnvironment('PreloadingDetailsReportView', () => {
166252
167253 const url = 'https://example.com/prefetch.html' as Platform . DevToolsPath . UrlString ;
168254 const data : PreloadingComponents . PreloadingDetailsReportView . PreloadingDetailsReportViewData = {
169- preloadingAttempt : {
255+ pipeline : SDK . PreloadingModel . PreloadPipeline . newFromAttemptsForTesting ( [ {
170256 action : Protocol . Preload . SpeculationAction . Prefetch ,
171257 key : {
172258 loaderId : 'loaderId' as Protocol . Network . LoaderId ,
@@ -180,7 +266,7 @@ describeWithEnvironment('PreloadingDetailsReportView', () => {
180266 requestId : 'requestId:1' as Protocol . Network . RequestId ,
181267 ruleSetIds : [ 'ruleSetId' ] as Protocol . Preload . RuleSetId [ ] ,
182268 nodeIds : [ 1 ] as Protocol . DOM . BackendNodeId [ ] ,
183- } ,
269+ } ] ) ,
184270 ruleSets : [
185271 {
186272 id : 'ruleSetId' as Protocol . Preload . RuleSetId ,
@@ -227,7 +313,7 @@ describeWithEnvironment('PreloadingDetailsReportView', () => {
227313
228314 const url = 'https://example.com/prefetch.html' as Platform . DevToolsPath . UrlString ;
229315 const data : PreloadingComponents . PreloadingDetailsReportView . PreloadingDetailsReportViewData = {
230- preloadingAttempt : {
316+ pipeline : SDK . PreloadingModel . PreloadPipeline . newFromAttemptsForTesting ( [ {
231317 action : Protocol . Preload . SpeculationAction . Prefetch ,
232318 key : {
233319 loaderId : 'loaderId' as Protocol . Network . LoaderId ,
@@ -241,7 +327,7 @@ describeWithEnvironment('PreloadingDetailsReportView', () => {
241327 requestId : 'requestId:1' as Protocol . Network . RequestId ,
242328 ruleSetIds : [ 'ruleSetId' ] as Protocol . Preload . RuleSetId [ ] ,
243329 nodeIds : [ 1 ] as Protocol . DOM . BackendNodeId [ ] ,
244- } ,
330+ } ] ) ,
245331 ruleSets : [
246332 {
247333 id : 'ruleSetId' as Protocol . Preload . RuleSetId ,
@@ -278,4 +364,6 @@ describeWithEnvironment('PreloadingDetailsReportView', () => {
278364 [ 'Rule set' , 'example.com/speculation-rules.json' ] ,
279365 ] ) ;
280366 } ) ;
367+
368+ // TODO: Add test for pipeline
281369} ) ;
0 commit comments