@@ -428,3 +428,113 @@ test.for(CHROME_KIND_PUBLICATIONS)(
428428 ) ;
429429 } ,
430430) ;
431+
432+ type CapturedNode = [
433+ index : number ,
434+ parentIndex : number | undefined ,
435+ type : string ,
436+ role : string ,
437+ label : string | undefined ,
438+ rect : [ x : number , y : number , width : number , height : number ] ,
439+ ] ;
440+
441+ /** Builds a tree from rows captured with `snapshot -i --json`, every node hittable as published. */
442+ function capturedTree ( rows : CapturedNode [ ] ) : RawSnapshotNode [ ] {
443+ const depthByIndex = new Map < number , number > ( ) ;
444+ return rows . map ( ( [ index , parentIndex , type , role , label , [ x , y , width , height ] ] ) => {
445+ const depth = parentIndex === undefined ? 0 : ( depthByIndex . get ( parentIndex ) ?? 0 ) + 1 ;
446+ depthByIndex . set ( index , depth ) ;
447+ return node ( {
448+ index,
449+ parentIndex,
450+ depth,
451+ type,
452+ role,
453+ label,
454+ rect : { x, y, width, height } ,
455+ hittable : true ,
456+ } ) ;
457+ } ) ;
458+ }
459+
460+ /** Labels (or types, for unlabelled nodes) the occlusion pass marks covered, in tree order. */
461+ function coveredLabels ( nodes : RawSnapshotNode [ ] ) : string [ ] {
462+ return annotateCoveredSnapshotNodes ( nodes )
463+ . filter ( ( candidate ) => candidate . interactionBlocked === 'covered' )
464+ . map ( ( candidate ) => candidate . label ?? candidate . type ?? '' ) ;
465+ }
466+
467+ test ( 'the captured iOS 27 SwiftUI sheet toolbar host stops condemning the sheet in the interactive projection' , ( ) => {
468+ // `snapshot -i` of a `.medium` SwiftUI sheet on an iOS 27 simulator. Pruning dropped the wrappers
469+ // sharing the host's frame and the list's frame was rewritten to its scroll-indicator band, so no
470+ // sibling matches the host's 386x451 frame; it encloses the navigation bar and the list beside it.
471+ const nodes = capturedTree ( [
472+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
473+ [ 2 , 0 , 'Button' , '_UIGrabber' , 'Sheet Grabber' , [ 152.99 , 411.19 , 96.02 , 23.04 ] ] ,
474+ [ 3 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , undefined , [ 8 , 430.39 , 386 , 101.78 ] ] ,
475+ [ 4 , 3 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Close' , [ 27.2 , 434.23 , 64.33 , 34.57 ] ] ,
476+ [ 7 , 3 , 'SearchField' , 'UISearchBarTextField' , 'Search' , [ 23.36 , 482.24 , 355.27 , 40.33 ] ] ,
477+ [ 8 , 0 , 'CollectionView' , 'SwiftUI.CollectionView' , undefined , [ 8 , 482.24 , 386 , 331.91 ] ] ,
478+ [ 9 , 8 , 'Cell' , 'SwiftUI.ListCollectionViewCell' , undefined , [ 23.36 , 532.17 , 355.27 , 49.93 ] ] ,
479+ [
480+ 10 ,
481+ 9 ,
482+ 'Button' ,
483+ 'SwiftUI.AccessibilityNode' ,
484+ 'Primary action' ,
485+ [ 23.36 , 532.17 , 355.27 , 49.93 ] ,
486+ ] ,
487+ [ 13 , 8 , 'Cell' , 'SwiftUI.ListCollectionViewCell' , undefined , [ 23.36 , 632.03 , 355.27 , 49.93 ] ] ,
488+ [ 14 , 13 , 'TextField' , 'SwiftUI.UIKitTextField' , 'Name' , [ 38.73 , 646.43 , 324.55 , 21.12 ] ] ,
489+ [ 15 , 8 , 'Cell' , 'SwiftUI.ListCollectionViewCell' , undefined , [ 23.36 , 681.96 , 355.27 , 132.19 ] ] ,
490+ [ 16 , 15 , 'TextView' , 'SwiftUI.TextEditorTextView' , 'Notes' , [ 38.73 , 696.36 , 324.55 , 115.22 ] ] ,
491+ [ 17 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 8 , 415.03 , 386 , 450.97 ] ] ,
492+ [ 18 , 17 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Bottom' , [ 163.55 , 798.79 , 74.9 , 34.57 ] ] ,
493+ ] ) ;
494+
495+ assert . deepEqual ( coveredLabels ( nodes ) , [ ] ) ;
496+ } ) ;
497+
498+ test ( 'the captured iOS 27 sheet toolbar host with a hidden navigation bar stops condemning the list' , ( ) => {
499+ // The same host beside nothing but the list: with `.toolbar(.hidden, for: .navigationBar)` the
500+ // enclosed scroll region is the only sibling evidence the interactive projection keeps.
501+ const nodes = capturedTree ( [
502+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
503+ [ 1 , 0 , 'CollectionView' , 'SwiftUI.CollectionView' , undefined , [ 0 , 100 , 402 , 712 ] ] ,
504+ [ 2 , 1 , 'Cell' , 'SwiftUI.ListCollectionViewCell' , undefined , [ 16 , 100 , 370 , 49 ] ] ,
505+ [ 3 , 2 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Barless primary' , [ 16 , 100 , 370 , 49 ] ] ,
506+ [ 16 , 1 , 'Cell' , 'SwiftUI.ListCollectionViewCell' , 'Barless row 12' , [ 16 , 773 , 370 , 39 ] ] ,
507+ [ 17 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 62 , 402 , 812 ] ] ,
508+ [ 18 , 17 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Barless bottom' , [ 132.67 , 804 , 137 , 36 ] ] ,
509+ ] ) ;
510+
511+ assert . deepEqual ( coveredLabels ( nodes ) , [ ] ) ;
512+ } ) ;
513+
514+ test ( 'a navigation bar enclosing the navigation bar it was presented over still covers it' , ( ) => {
515+ // `snapshot -i` of a full-screen cover on an iOS 27 simulator: the cover's navigation bar encloses
516+ // the presenting screen's bar. A stacked bar is drawn over the one beneath, so only the toolbar
517+ // kind is read as a host.
518+ const nodes = capturedTree ( [
519+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
520+ [ 1 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , 'Home' , [ 0 , 62 , 402 , 106 ] ] ,
521+ [ 2 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Edit' , [ 328.67 , 66 , 53.33 , 36 ] ] ,
522+ [ 19 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , 'Sheet cover' , [ 0 , 62 , 402 , 108 ] ] ,
523+ [ 20 , 19 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Close' , [ 20 , 66 , 67 , 36 ] ] ,
524+ ] ) ;
525+
526+ assert . deepEqual ( coveredLabels ( nodes ) , [ 'Home' , 'Edit' ] ) ;
527+ } ) ;
528+
529+ test ( 'a toolbar host enclosing a plain content sibling still covers it, so the enclosed kind is gated' , ( ) => {
530+ // Non-vacuity for the host rule: the same host frame beside a plain `Other` branch instead of the
531+ // list keeps covering, as the containment case above requires.
532+ const nodes = capturedTree ( [
533+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
534+ [ 1 , 0 , 'Other' , 'UIView' , undefined , [ 0 , 100 , 402 , 712 ] ] ,
535+ [ 3 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Barless primary' , [ 16 , 100 , 370 , 49 ] ] ,
536+ [ 17 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 62 , 402 , 812 ] ] ,
537+ ] ) ;
538+
539+ assert . deepEqual ( coveredLabels ( nodes ) , [ 'Other' , 'Barless primary' ] ) ;
540+ } ) ;
0 commit comments