@@ -2725,6 +2725,69 @@ it.each([
27252725 }
27262726} ) ;
27272727
2728+ it . each ( [
2729+ [ "com.google.Chrome" , "Google Chrome – Profile" ] ,
2730+ [ "org.chromium.Chromium" , "Chromium" ] ,
2731+ ] ) ( "reads macOS %s page context with an accessibility title suffix" , async ( bundleId , suffix ) => {
2732+ const title = "Issues · pingdotgg/t3code" ;
2733+ const bounds = { x : 0 , y : 33 , width : 1470 , height : 857 } ;
2734+ const window = {
2735+ role : "window" ,
2736+ name : `${ title } - ${ suffix } ` ,
2737+ bounds,
2738+ tree : async ( ) => ( { name : title , children : [ { name : "New issue" , children : [ ] } ] } ) ,
2739+ children : async ( ) => [ { role : "button" , name : "New issue" , bounds, children : async ( ) => [ ] } ] ,
2740+ } ;
2741+ accessibilityByPidMock . mockReset ( ) . mockImplementation ( async ( pid : number ) => ( {
2742+ children : async ( ) => ( pid === 42 ? [ window ] : [ ] ) ,
2743+ } ) ) ;
2744+
2745+ const context = await readAccessibleWindowContext (
2746+ { title, bounds, owner : { processId : 42 , bundleId } } ,
2747+ "darwin" ,
2748+ title ,
2749+ ) ;
2750+
2751+ assert . equal ( context ?. accessibleText , `${ title } \nNew issue` ) ;
2752+ assert . equal ( context ?. accessibility ?. format , "element-tree" ) ;
2753+ assert . equal (
2754+ context ?. accessibility ?. format === "element-tree"
2755+ ? context . accessibility . root . children [ 0 ] ?. name
2756+ : undefined ,
2757+ "New issue" ,
2758+ ) ;
2759+ } ) ;
2760+
2761+ it ( "does not borrow another Chrome process context when the captured PID has no windows" , async ( ) => {
2762+ const title = "Issues · pingdotgg/t3code" ;
2763+ const bounds = { x : 0 , y : 33 , width : 1470 , height : 857 } ;
2764+ const otherWindow = {
2765+ role : "window" ,
2766+ name : `${ title } - Google Chrome – Profile` ,
2767+ bounds,
2768+ tree : async ( ) => ( {
2769+ name : title ,
2770+ children : [ { name : "Other process private text" , children : [ ] } ] ,
2771+ } ) ,
2772+ children : async ( ) => [ ] ,
2773+ } ;
2774+ accessibilityByPidMock . mockReset ( ) . mockResolvedValue ( {
2775+ pid : 42 ,
2776+ children : async ( ) => [ ] ,
2777+ } ) ;
2778+ accessibilityListMock . mockResolvedValue ( [
2779+ { pid : 43 , bundleId : "com.google.Chrome" , children : async ( ) => [ otherWindow ] } ,
2780+ ] ) ;
2781+
2782+ assert . isUndefined (
2783+ await readAccessibleWindowContext (
2784+ { title, bounds, owner : { processId : 42 , bundleId : "com.google.Chrome" } } ,
2785+ "darwin" ,
2786+ title ,
2787+ ) ,
2788+ ) ;
2789+ } ) ;
2790+
27282791it ( "reads Flatpak app text from the AT-SPI proxy when the compositor PID misses" , async ( ) => {
27292792 vi . stubEnv ( "XDG_SESSION_TYPE" , "wayland" ) ;
27302793 const bounds = { x : 0 , y : 0 , width : 1_920 , height : 1_048 } ;
0 commit comments