File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1214,14 +1214,22 @@ it.effect(
12141214 } ;
12151215 } ;
12161216 deferReads ( ) ;
1217- const { viewer, cdp } = yield * openDesktopViewer ;
1217+ const { viewer, cdp, context } = yield * openDesktopViewer ;
12181218 const answer = ( width : number , height : number ) => ( {
12191219 result : { value : { width, height } } ,
12201220 } ) ;
12211221 const resized = ( ) => cdp . emitAsync ( "Page.frameResized" ) ;
12221222 // An alert open on attach blocks the first read, which gives up with no size to send.
12231223 const blocked = yield * Queue . take ( reads ) ;
12241224 yield * TestClock . adjust ( "1 second" ) ;
1225+ // While it stays open nothing reads again; the host closing it clears it.
1226+ context . page . emit ( "dialog" , {
1227+ type : ( ) => "alert" ,
1228+ message : ( ) => "" ,
1229+ defaultValue : ( ) => "" ,
1230+ } ) ;
1231+ yield * Effect . promise ( resized ) ;
1232+ expect ( yield * Queue . size ( reads ) ) . toBe ( 0 ) ;
12251233 // Closing it resizes nothing, so the close itself remeasures.
12261234 desktopSizeAnswer = null ;
12271235 yield * Effect . promise ( ( ) => cdp . emitAsync ( "Page.javascriptDialogClosed" ) ) ;
Original file line number Diff line number Diff line change @@ -650,7 +650,8 @@ const make = Effect.gen(function* () {
650650 } ) ) ;
651651
652652 const layoutSize = async ( tab : ServerTab ) => {
653- if ( tab . desktop ) return measureDesktopViewport ( tab ) ;
653+ // A dialog blocks page script; its close measures again.
654+ if ( tab . desktop ) return tab . dialog ? tab . desktopViewport : measureDesktopViewport ( tab ) ;
654655 const size = tab . page . viewportSize ( ) ;
655656 if ( ! size ) return size ;
656657 return {
@@ -857,8 +858,11 @@ const make = Effect.gen(function* () {
857858 if ( tab . viewers . size > 0 ) return broadcastViewport ( tab ) . catch ( constVoid ) ;
858859 } ;
859860 cdp . on ( "Page.frameResized" , remeasure ) ;
860- // A dialog blocks size reads, and closing one resizes nothing.
861- cdp . on ( "Page.javascriptDialogClosed" , remeasure ) ;
861+ // Closing a dialog resizes nothing, and the host can close it without us.
862+ cdp . on ( "Page.javascriptDialogClosed" , ( ) => {
863+ tab . dialog = null ;
864+ return remeasure ( ) ;
865+ } ) ;
862866 await cdp . send ( "Page.enable" ) ;
863867 }
864868 const isMainNavigation = ( request : { isNavigationRequest ( ) : boolean ; frame ( ) : unknown } ) =>
You can’t perform that action at this time.
0 commit comments