@@ -642,7 +642,7 @@ test('records verified current and retained native roots and stable descendants'
642642 }
643643} ) ;
644644
645- test ( 'retained Chrome home and marker roots require a Chrome executable and this state directory ' , async ( ) => {
645+ test ( 'browser home roots require executable containment and marker roots require Chrome ' , async ( ) => {
646646 const stateDir = mkdtempForTestSync ( 'agent-device-web-life-' ) ;
647647 const otherStateDir = mkdtempForTestSync ( 'agent-device-web-other-' ) ;
648648 try {
@@ -662,6 +662,19 @@ test('retained Chrome home and marker roots require a Chrome executable and this
662662 'chrome-150' ,
663663 'chrome' ,
664664 ) ;
665+ const browserRoot = path . dirname ( path . dirname ( home ) ) ;
666+ const helper = path . join ( path . dirname ( home ) , 'Google Chrome Helper' ) ;
667+ const crashpad = path . join ( path . dirname ( home ) , 'chrome_crashpad_handler' ) ;
668+ const outside = path . join ( stateDir , 'system-browser' , 'Google Chrome' ) ;
669+ const sibling = path . join ( `${ browserRoot } -other` , 'chrome' ) ;
670+ for ( const executable of [ home , helper , crashpad , outside , sibling ] ) {
671+ fs . mkdirSync ( path . dirname ( executable ) , { recursive : true } ) ;
672+ fs . writeFileSync ( executable , 'fixture' ) ;
673+ }
674+ const escaped = path . join ( browserRoot , 'escaped-chrome' ) ;
675+ const alias = path . join ( stateDir , 'browser-alias' ) ;
676+ fs . symlinkSync ( outside , escaped ) ;
677+ fs . symlinkSync ( home , alias ) ;
665678 const marker = agentBrowserChromeLaunchMarker ( previous ) ;
666679 const rows : ProcessFixture [ ] = [
667680 { pid : 201 , command : `/opt/Chromium ${ marker } ` , executable : '/opt/Chromium' } ,
@@ -674,14 +687,28 @@ test('retained Chrome home and marker roots require a Chrome executable and this
674687 command : `/opt/Chromium ${ agentBrowserChromeLaunchMarker ( other ) } ` ,
675688 executable : '/opt/Chromium' ,
676689 } ,
690+ { pid : 207 , command : `${ outside } ${ home } ` , executable : outside } ,
691+ { pid : 208 , ppid : 207 , command : 'system browser helper' } ,
692+ { pid : 209 , command : `${ helper } --type=renderer` , executable : helper } ,
693+ { pid : 210 , command : crashpad , executable : crashpad } ,
694+ { pid : 211 , command : `${ escaped } ${ home } ` , executable : escaped } ,
695+ { pid : 212 , command : `${ sibling } ${ home } ` , executable : sibling } ,
696+ { pid : 213 , command : alias , executable : alias } ,
697+ { pid : 214 , command : home , executable : path . join ( browserRoot , 'missing-chrome' ) } ,
677698 ] ;
678699 observeProcesses ( rows ) ;
679700 const store = { replace : vi . fn ( ) , clear : vi . fn ( ) , read : vi . fn ( ( ) => [ ] ) } ;
680701 const summary = await recordManagedAgentBrowserProcesses ( status , store , testHost ) ;
681- expect ( summary . pids ) . toEqual ( [ 201 , 202 ] ) ;
702+ expect ( summary . pids ) . toEqual ( [ 201 , 202 , 209 , 210 , 213 ] ) ;
682703 expect ( summary . processes . map ( ( { reason } ) => reason ) ) . toEqual ( [
683704 'launch-marker' ,
684705 'managed-browser-home' ,
706+ 'managed-browser-home' ,
707+ 'managed-browser-home' ,
708+ 'managed-browser-home' ,
709+ ] ) ;
710+ expect ( store . replace . mock . calls [ 0 ] ?. [ 1 ] . map ( ( { pid } : { pid : number } ) => pid ) ) . toEqual ( [
711+ 201 , 202 , 209 , 210 , 213 ,
685712 ] ) ;
686713 } finally {
687714 fs . rmSync ( stateDir , { recursive : true , force : true } ) ;
0 commit comments