@@ -428,3 +428,298 @@ 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 parentByIndex = new Map ( rows . map ( ( [ index , parentIndex ] ) => [ index , parentIndex ] ) ) ;
444+ const depthOf = ( index : number | undefined ) : number => {
445+ const parentIndex = index === undefined ? undefined : parentByIndex . get ( index ) ;
446+ return parentIndex === undefined ? 0 : depthOf ( parentIndex ) + 1 ;
447+ } ;
448+ return rows . map ( ( [ index , parentIndex , type , role , label , [ x , y , width , height ] ] ) => {
449+ const depth = depthOf ( index ) ;
450+ return node ( {
451+ index,
452+ parentIndex,
453+ depth,
454+ type,
455+ role,
456+ label,
457+ rect : { x, y, width, height } ,
458+ hittable : true ,
459+ } ) ;
460+ } ) ;
461+ }
462+
463+ /** Labels (or types, for unlabelled nodes) the occlusion pass marks covered, in tree order. */
464+ function coveredLabels ( nodes : RawSnapshotNode [ ] ) : string [ ] {
465+ return annotateCoveredSnapshotNodes ( nodes )
466+ . filter ( ( candidate ) => candidate . interactionBlocked === 'covered' )
467+ . map ( ( candidate ) => candidate . label ?? candidate . type ?? '' ) ;
468+ }
469+
470+ test ( 'the captured iOS 27 SwiftUI sheet toolbar host stops condemning the sheet in the interactive projection' , ( ) => {
471+ // `snapshot -i` of a `.medium` SwiftUI sheet on an iOS 27 simulator. Pruning dropped the wrappers
472+ // sharing the host's frame and the list's frame was rewritten to its scroll-indicator band, so no
473+ // sibling matches the host's 386x451 frame; it encloses the navigation bar and the list beside it.
474+ const nodes = capturedTree ( [
475+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
476+ [ 2 , 0 , 'Button' , '_UIGrabber' , 'Sheet Grabber' , [ 152.99 , 411.19 , 96.02 , 23.04 ] ] ,
477+ [ 3 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , undefined , [ 8 , 430.39 , 386 , 101.78 ] ] ,
478+ [ 4 , 3 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Close' , [ 27.2 , 434.23 , 64.33 , 34.57 ] ] ,
479+ [ 7 , 3 , 'SearchField' , 'UISearchBarTextField' , 'Search' , [ 23.36 , 482.24 , 355.27 , 40.33 ] ] ,
480+ [ 8 , 0 , 'CollectionView' , 'SwiftUI.CollectionView' , undefined , [ 8 , 482.24 , 386 , 331.91 ] ] ,
481+ [ 9 , 8 , 'Cell' , 'SwiftUI.ListCollectionViewCell' , undefined , [ 23.36 , 532.17 , 355.27 , 49.93 ] ] ,
482+ [
483+ 10 ,
484+ 9 ,
485+ 'Button' ,
486+ 'SwiftUI.AccessibilityNode' ,
487+ 'Primary action' ,
488+ [ 23.36 , 532.17 , 355.27 , 49.93 ] ,
489+ ] ,
490+ [ 13 , 8 , 'Cell' , 'SwiftUI.ListCollectionViewCell' , undefined , [ 23.36 , 632.03 , 355.27 , 49.93 ] ] ,
491+ [ 14 , 13 , 'TextField' , 'SwiftUI.UIKitTextField' , 'Name' , [ 38.73 , 646.43 , 324.55 , 21.12 ] ] ,
492+ [ 15 , 8 , 'Cell' , 'SwiftUI.ListCollectionViewCell' , undefined , [ 23.36 , 681.96 , 355.27 , 132.19 ] ] ,
493+ [ 16 , 15 , 'TextView' , 'SwiftUI.TextEditorTextView' , 'Notes' , [ 38.73 , 696.36 , 324.55 , 115.22 ] ] ,
494+ [ 17 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 8 , 415.03 , 386 , 450.97 ] ] ,
495+ [ 18 , 17 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Bottom' , [ 163.55 , 798.79 , 74.9 , 34.57 ] ] ,
496+ ] ) ;
497+
498+ assert . deepEqual ( coveredLabels ( nodes ) , [ ] ) ;
499+ } ) ;
500+
501+ test ( 'the captured iOS 27 sheet toolbar host with a hidden navigation bar stops condemning the list' , ( ) => {
502+ // The same host beside nothing but the list: with `.toolbar(.hidden, for: .navigationBar)` the
503+ // enclosed scroll region is the only sibling evidence the interactive projection keeps.
504+ const nodes = capturedTree ( [
505+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
506+ [ 1 , 0 , 'CollectionView' , 'SwiftUI.CollectionView' , undefined , [ 0 , 100 , 402 , 712 ] ] ,
507+ [ 2 , 1 , 'Cell' , 'SwiftUI.ListCollectionViewCell' , undefined , [ 16 , 100 , 370 , 49 ] ] ,
508+ [ 3 , 2 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Barless primary' , [ 16 , 100 , 370 , 49 ] ] ,
509+ [ 16 , 1 , 'Cell' , 'SwiftUI.ListCollectionViewCell' , 'Barless row 12' , [ 16 , 773 , 370 , 39 ] ] ,
510+ [ 17 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 62 , 402 , 812 ] ] ,
511+ [ 18 , 17 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Barless bottom' , [ 132.67 , 804 , 137 , 36 ] ] ,
512+ ] ) ;
513+
514+ assert . deepEqual ( coveredLabels ( nodes ) , [ ] ) ;
515+ } ) ;
516+
517+ test ( 'a navigation bar enclosing the navigation bar it was presented over still covers it' , ( ) => {
518+ // `snapshot -i` of a full-screen cover on an iOS 27 simulator: the cover's navigation bar encloses
519+ // the presenting screen's bar. A stacked bar is drawn over the one beneath, so only the toolbar
520+ // kind is read as a host.
521+ const nodes = capturedTree ( [
522+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
523+ [ 1 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , 'Home' , [ 0 , 62 , 402 , 106 ] ] ,
524+ [ 2 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Edit' , [ 328.67 , 66 , 53.33 , 36 ] ] ,
525+ [ 19 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , 'Sheet cover' , [ 0 , 62 , 402 , 108 ] ] ,
526+ [ 20 , 19 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Close' , [ 20 , 66 , 67 , 36 ] ] ,
527+ ] ) ;
528+
529+ assert . deepEqual ( coveredLabels ( nodes ) , [ 'Home' , 'Edit' ] ) ;
530+ } ) ;
531+
532+ test ( 'a toolbar host enclosing a plain content sibling still covers it, so the enclosed kind is gated' , ( ) => {
533+ // Non-vacuity for the host rule: the same host frame beside a plain `Other` branch instead of the
534+ // list keeps covering, as the containment case above requires.
535+ const nodes = capturedTree ( [
536+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
537+ [ 1 , 0 , 'Other' , 'UIView' , undefined , [ 0 , 100 , 402 , 712 ] ] ,
538+ [ 3 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Barless primary' , [ 16 , 100 , 370 , 49 ] ] ,
539+ [ 17 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 62 , 402 , 812 ] ] ,
540+ ] ) ;
541+
542+ assert . deepEqual ( coveredLabels ( nodes ) , [ 'Other' , 'Barless primary' ] ) ;
543+ } ) ;
544+
545+ // `snapshot -i` of a SwiftUI `fullScreenCover` presented from a `.large` sheet over the Home tab on an
546+ // iOS 27 simulator, cells trimmed. All three presentations are listed as siblings of the root, each
547+ // ending with its toolbar host. The sheet's host encloses Home's bar and list and the cover's.
548+ const COVER_OVER_SHEET_ROWS : CapturedNode [ ] = [
549+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
550+ [ 1 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , undefined , [ 0 , 62 , 402 , 106 ] ] ,
551+ [ 2 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Edit' , [ 328.67 , 66 , 53.33 , 36 ] ] ,
552+ [ 4 , 0 , 'CollectionView' , 'SwiftUI.UpdateCoalescingCollectionView' , undefined , [ 0 , 116 , 402 , 675 ] ] ,
553+ [ 6 , 4 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Open medium sheet' , [ 16 , 168 , 370 , 52 ] ] ,
554+ [ 16 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 0 , 402 , 874 ] ] ,
555+ [ 17 , 0 , 'TabBar' , 'UITabBar' , 'Tab Bar' , [ 0 , 791 , 402 , 83 ] ] ,
556+ [ 18 , 17 , 'Button' , '_UITabButton' , 'Home' , [ 68 , 795 , 94 , 54 ] ] ,
557+ [ 21 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , undefined , [ 0 , 78 , 402 , 106 ] ] ,
558+ [ 22 , 21 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Close' , [ 20 , 82 , 67 , 36 ] ] ,
559+ [
560+ 26 ,
561+ 0 ,
562+ 'CollectionView' ,
563+ 'SwiftUI.UpdateCoalescingCollectionView' ,
564+ undefined ,
565+ [ 0 , 132 , 402 , 680 ] ,
566+ ] ,
567+ [ 28 , 26 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Primary action' , [ 16 , 184 , 370 , 52 ] ] ,
568+ [ 43 , 26 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Row 1' , [ 16 , 733 , 370 , 52 ] ] ,
569+ [ 46 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 62 , 402 , 812 ] ] ,
570+ [ 47 , 46 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Bottom' , [ 162 , 804 , 78 , 36 ] ] ,
571+ [ 48 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , undefined , [ 0 , 62 , 402 , 54 ] ] ,
572+ [ 49 , 48 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper close' , [ 20 , 66 , 116 , 36 ] ] ,
573+ [ 51 , 48 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper save' , [ 268 , 66 , 114 , 36 ] ] ,
574+ [
575+ 52 ,
576+ 0 ,
577+ 'CollectionView' ,
578+ 'SwiftUI.UpdateCoalescingCollectionView' ,
579+ undefined ,
580+ [ 0 , 116 , 402 , 696 ] ,
581+ ] ,
582+ [ 54 , 52 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper primary' , [ 16 , 151 , 370 , 52 ] ] ,
583+ [ 57 , 52 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper row 0' , [ 16 , 255 , 370 , 52 ] ] ,
584+ [ 68 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 0 , 402 , 874 ] ] ,
585+ [ 69 , 68 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper bottom' , [ 136.67 , 804 , 128.67 , 36 ] ] ,
586+ ] ;
587+
588+ const HOME_ROW_INDEXES = new Set ( [ 1 , 2 , 4 , 6 , 16 , 17 , 18 ] ) ;
589+ const COVER_ROW_INDEXES = new Set ( [ 48 , 49 , 51 , 52 , 54 , 57 , 68 , 69 ] ) ;
590+ const COVER_CONTROLS = [
591+ 'Upper close' ,
592+ 'Upper save' ,
593+ 'Upper primary' ,
594+ 'Upper row 0' ,
595+ 'Upper bottom' ,
596+ ] ;
597+
598+ test ( 'a full-screen cover over a sheet leaves the sheet beneath covered and the cover pressable' , ( ) => {
599+ const covered = coveredLabels ( capturedTree ( COVER_OVER_SHEET_ROWS ) ) ;
600+
601+ for ( const label of [ 'Edit' , 'Open medium sheet' , 'Close' , 'Primary action' , 'Row 1' ] ) {
602+ assert . ok ( covered . includes ( label ) , `${ label } sits beneath the cover` ) ;
603+ }
604+ for ( const label of COVER_CONTROLS ) {
605+ assert . ok ( ! covered . includes ( label ) , `${ label } is on the cover` ) ;
606+ }
607+ } ) ;
608+
609+ test ( 'a toolbar host enclosing the bars of a presentation stacked over it keeps covering' , ( ) => {
610+ // The capture without Home: only the cover's bar and list, listed after the sheet's host, tell it
611+ // apart from a lone sheet.
612+ const rows = COVER_OVER_SHEET_ROWS . filter ( ( [ index ] ) => ! HOME_ROW_INDEXES . has ( index ) ) ;
613+ const covered = coveredLabels ( capturedTree ( rows ) ) ;
614+
615+ assert . ok ( covered . includes ( 'Primary action' ) ) ;
616+ assert . ok ( covered . includes ( 'Row 1' ) ) ;
617+ for ( const label of COVER_CONTROLS ) assert . ok ( ! covered . includes ( label ) ) ;
618+ } ) ;
619+
620+ test ( 'a toolbar host enclosing the bars of a presentation beneath it keeps covering' , ( ) => {
621+ // The capture without the cover: a sheet host enclosing Home's bar and list, which sit before Home's
622+ // own host, covers Home. It covers the sheet too, failing closed; iOS publishes no presentation
623+ // beneath a sheet, so this shape is not captured live.
624+ const rows = COVER_OVER_SHEET_ROWS . filter ( ( [ index ] ) => ! COVER_ROW_INDEXES . has ( index ) ) ;
625+ const covered = coveredLabels ( capturedTree ( rows ) ) ;
626+
627+ assert . ok ( covered . includes ( 'Edit' ) ) ;
628+ assert . ok ( covered . includes ( 'Open medium sheet' ) ) ;
629+ } ) ;
630+
631+ test . for ( [
632+ {
633+ name : 'a sheet over a sheet' ,
634+ rows : [
635+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
636+ [ 1 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , undefined , [ 0 , 88 , 402 , 54 ] ] ,
637+ [ 2 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper close' , [ 20 , 92 , 116 , 36 ] ] ,
638+ [ 4 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper save' , [ 268 , 92 , 114 , 36 ] ] ,
639+ [
640+ 5 ,
641+ 0 ,
642+ 'CollectionView' ,
643+ 'SwiftUI.UpdateCoalescingCollectionView' ,
644+ undefined ,
645+ [ 0 , 142 , 402 , 670 ] ,
646+ ] ,
647+ [ 7 , 5 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper primary' , [ 16 , 177 , 370 , 52 ] ] ,
648+ [ 20 , 5 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper row 5' , [ 16 , 541 , 370 , 52 ] ] ,
649+ [ 21 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 72 , 402 , 802 ] ] ,
650+ [ 22 , 21 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper bottom' , [ 136.67 , 804 , 128.67 , 36 ] ] ,
651+ ] ,
652+ } ,
653+ {
654+ name : 'a sheet over a plain screen' ,
655+ rows : [
656+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
657+ [ 1 , 0 , 'NavigationBar' , 'SwiftUI.UIKitNavigationBar' , undefined , [ 0 , 78 , 402 , 54 ] ] ,
658+ [ 2 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper close' , [ 20 , 82 , 116 , 36 ] ] ,
659+ [ 4 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper save' , [ 268 , 82 , 114 , 36 ] ] ,
660+ [
661+ 5 ,
662+ 0 ,
663+ 'CollectionView' ,
664+ 'SwiftUI.UpdateCoalescingCollectionView' ,
665+ undefined ,
666+ [ 0 , 132 , 402 , 680 ] ,
667+ ] ,
668+ [ 7 , 5 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper primary' , [ 16 , 167 , 370 , 52 ] ] ,
669+ [ 20 , 5 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper row 5' , [ 16 , 531 , 370 , 52 ] ] ,
670+ [ 21 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 62 , 402 , 812 ] ] ,
671+ [ 22 , 21 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Upper bottom' , [ 136.67 , 804 , 128.67 , 36 ] ] ,
672+ ] ,
673+ } ,
674+ ] satisfies { name : string ; rows : CapturedNode [ ] } [ ] ) (
675+ 'the captured iOS 27 $name publishes only the top sheet, and none of it is covered' ,
676+ ( { rows } ) => {
677+ // iOS drops the presentation beneath a sheet from the capture, so no lower control gets a ref.
678+ assert . deepEqual ( coveredLabels ( capturedTree ( rows ) ) , [ ] ) ;
679+ } ,
680+ ) ;
681+
682+ test ( 'a toolbar host enclosing only a scroll indicator still covers, so the scroll evidence is a container' , ( ) => {
683+ const nodes = capturedTree ( [
684+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
685+ [ 1 , 0 , 'Other' , 'UIView' , undefined , [ 0 , 100 , 402 , 712 ] ] ,
686+ [ 3 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Barless primary' , [ 16 , 100 , 370 , 49 ] ] ,
687+ [ 4 , 0 , 'ScrollBar' , '_UIScrollViewScrollIndicator' , undefined , [ 396 , 100 , 3 , 712 ] ] ,
688+ [ 17 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 62 , 402 , 812 ] ] ,
689+ ] ) ;
690+
691+ assert . ok ( coveredLabels ( nodes ) . includes ( 'Barless primary' ) ) ;
692+ } ) ;
693+
694+ test . for ( [
695+ {
696+ name : 'an Android RecyclerView type' ,
697+ type : 'androidx.recyclerview.widget.RecyclerView' ,
698+ role : '' ,
699+ } ,
700+ { name : 'a scroll kind published only in role' , type : 'Other' , role : 'UIScrollView' } ,
701+ ] ) ( 'a toolbar host enclosing $name reads it as a scroll container' , ( { type, role } ) => {
702+ const nodes = capturedTree ( [
703+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
704+ [ 1 , 0 , type , role , undefined , [ 0 , 100 , 402 , 712 ] ] ,
705+ [ 3 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Barless primary' , [ 16 , 100 , 370 , 49 ] ] ,
706+ [ 17 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 62 , 402 , 812 ] ] ,
707+ ] ) ;
708+
709+ assert . deepEqual ( coveredLabels ( nodes ) , [ ] ) ;
710+ } ) ;
711+
712+ test ( 'a control the exempt toolbar host really hosts still covers the row it overlaps' , ( ) => {
713+ // The host is exempt for the list it encloses, but a bar-kind strip it hosts is judged by its own
714+ // rect: it covers the row beneath it and leaves the row above it alone.
715+ const nodes = capturedTree ( [
716+ [ 0 , undefined , 'Other' , 'SwiftUIApplication' , 'SheetRepro' , [ 0 , 0 , 402 , 874 ] ] ,
717+ [ 1 , 0 , 'CollectionView' , 'SwiftUI.CollectionView' , undefined , [ 0 , 100 , 402 , 712 ] ] ,
718+ [ 3 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Barless primary' , [ 16 , 100 , 370 , 49 ] ] ,
719+ [ 16 , 1 , 'Button' , 'SwiftUI.AccessibilityNode' , 'Barless row 12' , [ 16 , 773 , 370 , 39 ] ] ,
720+ [ 17 , 0 , 'Toolbar' , '_UIFloatingBarContainerView' , 'Toolbar' , [ 0 , 62 , 402 , 812 ] ] ,
721+ [ 18 , 17 , 'Toolbar' , '_UIBarPlatterView' , 'Bottom bar' , [ 16 , 760 , 370 , 60 ] ] ,
722+ ] ) ;
723+
724+ assert . deepEqual ( coveredLabels ( nodes ) , [ 'Barless row 12' ] ) ;
725+ } ) ;
0 commit comments