@@ -39,13 +39,15 @@ type RunnerProcess = { pid: number; processStartTime: string };
3939 * foreground process, and `describe` reads it unless the host planned another process, or answers
4040 * the refusal `refuseDescribe` names. A describe given `holdNextDescribe` reads until that promise
4141 * settles, and, like the runner, it keeps reading after the daemon stops waiting: a describe that
42- * arrives meanwhile is refused as `bridge-read-in-flight`. A describe that names surface hosts is
43- * refused as `system-surface-host-unverified`, as a sandbox that refuses the process table does.
42+ * arrives meanwhile is refused as `bridge-read-in-flight`. With `refuseSurfaceHostCheck`, a describe that
43+ * names surface hosts is refused as `system-surface-host-unverified`, as a sandbox that refuses the
44+ * process table does.
4445 */
4546function bridgeRunner ( state : {
4647 process : RunnerProcess ;
4748 refuseDescribe ?: string ;
4849 refuseTarget ?: string ;
50+ refuseSurfaceHostCheck ?: boolean ;
4951 holdNextDescribe ?: Promise < void > ;
5052} ) {
5153 const sent : RunnerCommand [ ] = [ ] ;
@@ -86,7 +88,7 @@ function bridgeRunner(state: {
8688 ) {
8789 return refusal ( 'stale_target' , 'target-process-changed' ) ;
8890 }
89- if ( request . surfaceHostExecutables )
91+ if ( request . surfaceHostExecutables && state . refuseSurfaceHostCheck )
9092 return refusal ( 'unsupported' , 'system-surface-host-unverified' ) ;
9193 if ( state . refuseDescribe ) return refusal ( 'application_not_responding' , state . refuseDescribe ) ;
9294 if ( reading ) return refusal ( 'application_not_responding' , 'bridge-read-in-flight' ) ;
@@ -142,7 +144,7 @@ function verbs(sent: readonly RunnerCommand[]): string[] {
142144 return sent . map ( ( command ) => command . snapshotBridge ?. verb ?? command . command ) ;
143145}
144146
145- /** The bridge route of a runner whose foreground read proves no system surface covers the app . */
147+ /** The bridge route of a runner with an optional foreground session . */
146148function bridgeRoute ( provider : AppleRunnerProvider , runnerSessionId ?: string ) {
147149 const bridge = createRunnerSnapshotBridge ( { device : IOS_SIMULATOR , provider } ) ;
148150 const presented : SnapshotRuntimeAcquiredResult [ ] = [ ] ;
@@ -165,7 +167,9 @@ function bridgeRoute(provider: AppleRunnerProvider, runnerSessionId?: string) {
165167 ...( runnerSessionId ? { sessionChanged : bridge . resetTargets } : { } ) ,
166168 } ,
167169 async ( ) =>
168- runnerSessionId ? { foreground : 'background' , sessionId : runnerSessionId } : 'background' ,
170+ runnerSessionId
171+ ? { foreground : 'background' , sessionId : runnerSessionId }
172+ : { foreground : 'unknown' } ,
169173 ) ;
170174 const snapshot = ( signal = new AbortController ( ) . signal ) =>
171175 route . capture (
@@ -427,6 +431,7 @@ test('the runner runtime reads a remote Simulator through the bridge once its fo
427431
428432test ( 'a runner whose foreground read cannot answer asks the bridge read to check the surface hosts' , async ( ) => {
429433 const { provider, sent } = bridgeRunner ( {
434+ refuseSurfaceHostCheck : true ,
430435 process : { pid : 41 , processStartTime : '1700000000.000001' } ,
431436 } ) ;
432437 const { snapshot, fallbacks } = runtimeSnapshots ( withHostStates ( provider , undefined ) ) ;
@@ -478,6 +483,7 @@ test('the foreground proof starts the runner when none is live, then reads only
478483test ( 'a runner whose session id cannot be read answers the foreground proof as unknown' , async ( ) => {
479484 registry . session = undefined ;
480485 const { provider, sent } = bridgeRunner ( {
486+ refuseSurfaceHostCheck : true ,
481487 process : { pid : 41 , processStartTime : '1700000000.000001' } ,
482488 } ) ;
483489 const { snapshot, fallbacks } = runtimeSnapshots ( withHostStates ( provider , 'notRunning' ) ) ;
@@ -650,7 +656,7 @@ test('a wedge before the runner id is known does not disable a newly identified
650656 targetFreshness : 'cached' ,
651657 sessionChanged : bridge . resetTargets ,
652658 } ,
653- async ( ) => ( sessionId ? { foreground : 'background' , sessionId } : 'background' ) ,
659+ async ( ) => ( sessionId ? { foreground : 'background' , sessionId } : { foreground : 'unknown' } ) ,
654660 ) ;
655661 const snapshot = ( ) =>
656662 route . capture (
0 commit comments