@@ -440,42 +440,51 @@ it.live("preview_open reports its navigation timeout instead of the request budg
440440 ) . pipe ( Effect . provide ( layer ) ) ,
441441) ;
442442
443- it . live ( "navigate returns the committed page while its load event is still pending" , ( ) =>
444- Effect . scoped (
445- Effect . gen ( function * ( ) {
446- const { broker, tabId } = yield * ready ;
447- const page = contexts [ 0 ] ! . page ;
448- const heavy = "http://localhost:5173/heavy" ;
449- const timedOut = ( method : string , timeout : number | undefined ) =>
450- Object . assign ( new Error ( `${ method } : Timeout ${ timeout } ms exceeded.` ) , {
451- name : "TimeoutError" ,
443+ it . live . each ( [
444+ { renderer : "idle" , title : "Heavy page" } ,
445+ { renderer : "busy" , title : null } ,
446+ ] ) (
447+ "navigate returns the committed page while its load event is still pending ($renderer renderer)" ,
448+ ( { renderer, title } ) =>
449+ Effect . scoped (
450+ Effect . gen ( function * ( ) {
451+ const { broker, tabId } = yield * ready ;
452+ const page = contexts [ 0 ] ! . page ;
453+ // A busy main thread never answers title(); the status must not wait past the broker's grace.
454+ page . title . mockImplementation ( ( ) =>
455+ renderer === "busy" ? new Promise < string > ( ( ) => { } ) : Promise . resolve ( "Heavy page" ) ,
456+ ) ;
457+ const heavy = "http://localhost:5173/heavy" ;
458+ const timedOut = ( method : string , timeout : number | undefined ) =>
459+ Object . assign ( new Error ( `${ method } : Timeout ${ timeout } ms exceeded.` ) , {
460+ name : "TimeoutError" ,
461+ } ) ;
462+ // The document commits and parses, but a stalled subresource holds back `load`.
463+ page . goto . mockImplementation ( async ( next , options ) => {
464+ page . commit ( next ) ;
465+ page . emit ( "request" , {
466+ url : ( ) => next ,
467+ isNavigationRequest : ( ) => true ,
468+ frame : ( ) => page ,
469+ } ) ;
470+ if ( options ?. waitUntil === "load" ) throw timedOut ( "page.goto" , options . timeout ) ;
452471 } ) ;
453- // The document commits and parses, but a stalled subresource holds back `load`.
454- page . goto . mockImplementation ( async ( next , options ) => {
455- page . commit ( next ) ;
456- page . emit ( "request" , {
457- url : ( ) => next ,
458- isNavigationRequest : ( ) => true ,
459- frame : ( ) => page ,
472+ page . waitForLoadState . mockImplementation ( async ( state , options ) => {
473+ if ( state === undefined || state === "load" ) {
474+ throw timedOut ( "page.waitForLoadState" , options ?. timeout ) ;
475+ }
460476 } ) ;
461- if ( options ?. waitUntil === "load" ) throw timedOut ( "page.goto" , options . timeout ) ;
462- } ) ;
463- page . waitForLoadState . mockImplementation ( async ( state , options ) => {
464- if ( state === undefined || state === "load" ) {
465- throw timedOut ( "page.waitForLoadState" , options ?. timeout ) ;
466- }
467- } ) ;
468477
469- const status = yield * broker . invoke < PreviewAutomationStatus > ( {
470- scope,
471- tabId,
472- operation : "navigate" ,
473- input : { url : heavy , timeoutMs : 4_000 } ,
474- } ) ;
478+ const status = yield * broker . invoke < PreviewAutomationStatus > ( {
479+ scope,
480+ tabId,
481+ operation : "navigate" ,
482+ input : { url : heavy , timeoutMs : 4_000 } ,
483+ } ) ;
475484
476- expect ( status ) . toMatchObject ( { url : heavy , loading : true } ) ;
477- } ) ,
478- ) . pipe ( Effect . provide ( layer ) ) ,
485+ expect ( status ) . toMatchObject ( { url : heavy , title , loading : true } ) ;
486+ } ) ,
487+ ) . pipe ( Effect . provide ( layer ) ) ,
479488) ;
480489
481490it . live ( "navigate fails when the page never commits within its timeout" , ( ) =>
0 commit comments