@@ -607,20 +607,21 @@ describe("DesktopBrowserHost", () => {
607607 params : { sessionId : "t3-preview-page-1" } ,
608608 } ) ;
609609 expect ( yield * Queue . take ( replies ) ) . toBe ( 3 ) ;
610- expect ( painting ) . toEqual ( [ true , false ] ) ;
610+ expect ( painting ) . toEqual ( [ true ] ) ;
611611
612612 // The agent's screenshot waits its turn; painting lets the abandoned one finish first.
613613 yield * command ( host , 4 , "Page.captureScreenshot" ) ;
614614 yield * settle ;
615- expect ( painting ) . toEqual ( [ true , false , true ] ) ;
615+ expect ( painting ) . toEqual ( [ true ] ) ;
616616 debuggee . release ( ) ;
617617 expect ( yield * Queue . take ( replies ) ) . toBe ( 2 ) ;
618618 yield * settle ;
619619 expect ( debuggee . sent ) . toEqual ( [ undefined , 4 ] ) ;
620+ expect ( painting ) . toEqual ( [ true ] ) ;
620621 debuggee . release ( ) ;
621622 expect ( yield * Queue . take ( replies ) ) . toBe ( 4 ) ;
622623 yield * settle ;
623- expect ( painting ) . toEqual ( [ true , false , true , false ] ) ;
624+ expect ( painting ) . toEqual ( [ true , false ] ) ;
624625 } ) . pipe ( Effect . scoped ) ,
625626 ) ;
626627
@@ -645,14 +646,19 @@ describe("DesktopBrowserHost", () => {
645646 expect ( yield * Queue . take ( replies ) ) . toBe ( 2 ) ;
646647 yield * raw ( { id : 3 , method : "Page.captureScreenshot" , sessionId : "t3-preview-page-1" } ) ;
647648 yield * settle ;
648- expect ( painting ) . toEqual ( [ true , false , true ] ) ;
649+ expect ( painting ) . toEqual ( [ true ] ) ;
649650 yield * raw ( {
650651 id : 4 ,
651652 method : "Target.detachFromTarget" ,
652653 params : { sessionId : "t3-preview-page-1" } ,
653654 } ) ;
654655 expect ( yield * Queue . take ( replies ) ) . toBe ( 4 ) ;
655- expect ( painting ) . toEqual ( [ true , false , true , false ] ) ;
656+
657+ // The agent's answers late; the viewer's is dropped unsent, so nothing is left to paint.
658+ debuggee . release ( ) ;
659+ yield * settle ;
660+ expect ( debuggee . sent ) . toEqual ( [ 1 ] ) ;
661+ expect ( painting ) . toEqual ( [ true , false ] ) ;
656662 yield * TestClock . adjust ( "1 minute" ) ;
657663 expect ( debuggee . focusEmulation ) . toEqual ( [ true , false ] ) ;
658664 } ) . pipe ( Effect . scoped ) ,
@@ -682,7 +688,7 @@ describe("DesktopBrowserHost", () => {
682688 } ) . pipe ( Effect . scoped ) ,
683689 ) ;
684690
685- it . effect ( "stops painting for a screenshot still queued when the agent's turn ends" , ( ) =>
691+ it . effect ( "holds no focus for a screenshot still queued when the agent's turn ends" , ( ) =>
686692 Effect . gen ( function * ( ) {
687693 const host = yield * DesktopBrowserHost . make ;
688694 const debuggee = makeDebuggee ( ) ;
@@ -697,15 +703,18 @@ describe("DesktopBrowserHost", () => {
697703 yield * settle ;
698704 yield * turn ( false ) ;
699705 yield * settle ;
700- expect ( painting ) . toEqual ( [ true , false ] ) ;
706+ expect ( painting ) . toEqual ( [ true ] ) ;
701707
702- // The first answers late; the second still goes in turn, but holds nothing .
708+ // The first answers late; the second still goes in turn, painting but holding no focus .
703709 debuggee . releaseFirst ( ) ;
704710 yield * settle ;
705711 expect ( debuggee . sent ) . toEqual ( [ 1 , 2 ] ) ;
706- expect ( painting ) . toEqual ( [ true , false ] ) ;
707712 yield * TestClock . adjust ( "1 minute" ) ;
708713 expect ( debuggee . focusEmulation ) . toEqual ( [ true , false ] ) ;
714+ expect ( painting ) . toEqual ( [ true ] ) ;
715+ debuggee . release ( ) ;
716+ yield * settle ;
717+ expect ( painting ) . toEqual ( [ true , false ] ) ;
709718 } ) . pipe ( Effect . scoped ) ,
710719 ) ;
711720
@@ -952,7 +961,7 @@ describe("DesktopBrowserHost", () => {
952961 } ) . pipe ( Effect . scoped ) ,
953962 ) ;
954963
955- it . effect ( "stops painting for a screenshot Chromium never answers" , ( ) =>
964+ it . effect ( "stops painting for a screenshot Chromium never answers once its document goes " , ( ) =>
956965 Effect . gen ( function * ( ) {
957966 const host = yield * DesktopBrowserHost . make ;
958967 const debuggee = makeDebuggee ( ) ;
@@ -961,32 +970,34 @@ describe("DesktopBrowserHost", () => {
961970 const turn = ( active : boolean ) =>
962971 host . handleCommandLine ( encodeJson ( { type : "turn" , threadId : key . threadId , active } ) ) ;
963972
964- // The server gave up on it, and the agent's turn ends.
973+ // The server gave up on it, and the agent's turn ends; Chromium still holds the capture .
965974 yield * turn ( true ) ;
966975 yield * command ( host , 1 , "Page.captureScreenshot" ) ;
967976 yield * settle ;
968977 yield * turn ( false ) ;
969978 yield * settle ;
970- expect ( painting ) . toEqual ( [ true , false ] ) ;
979+ expect ( painting ) . toEqual ( [ true ] ) ;
971980
972981 // The page loads a new document, which also frees the screenshot turn.
973982 debuggee . navigate ( ) ;
983+ expect ( painting ) . toEqual ( [ true , false ] ) ;
974984 yield * command ( host , 2 , "Page.captureScreenshot" ) ;
975985 yield * settle ;
976986 debuggee . navigate ( ) ;
977987 yield * settle ;
978988 expect ( painting ) . toEqual ( [ true , false , true , false ] ) ;
979989
980- // The server releases the relay.
990+ // The server releases the relay; Chromium still holds the capture .
981991 yield * command ( host , 3 , "Page.captureScreenshot" ) ;
982992 yield * settle ;
983993 yield * host . handleCommandLine ( encodeJson ( { type : "release" , ...key } ) ) ;
984994 yield * settle ;
985- expect ( painting ) . toEqual ( [ true , false , true , false , true , false ] ) ;
995+ expect ( painting ) . toEqual ( [ true , false , true , false , true ] ) ;
986996
987997 // The guest detaches; a replacement starts with no screenshot pending.
988998 const replacement = makeDebuggee ( ) ;
989999 host . attach ( key , replacement . tab ) ;
1000+ expect ( painting ) . toEqual ( [ true , false , true , false , true , false ] ) ;
9901001 yield * command ( host , 4 , "Page.captureScreenshot" ) ;
9911002 yield * settle ;
9921003 host . detach ( key ) ;
0 commit comments