File tree Expand file tree Collapse file tree
apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -360,6 +360,8 @@ + (NSArray *)snapshotAttributes
360360{
361361 // The mapper expands keypaths with extra attributes that are disproportionately expensive for
362362 // the AX server to compute on large trees. Keep only what is consumed here.
363+ // `hasKeyboardFocus` is not requested: the mapper adds no attribute for it, and the snapshot
364+ // answers it anyway (#4112).
363365 return [self attributesForKeyPaths: @[
364366 @" elementType" ,
365367 @" identifier" ,
@@ -752,8 +754,9 @@ + (nullable NSMutableDictionary *)dictionaryForSnapshot:(id)snapshot
752754 result[@" frame" ] = [self frameValueForSnapshot: snapshot];
753755 result[@" enabled" ] = [self boolNumberForKey: @" enabled" snapshot: snapshot defaultValue: YES ];
754756 result[@" selected" ] = [self boolNumberForKey: @" selected" snapshot: snapshot defaultValue: NO ];
755- result[@" focused" ] = @([[self boolNumberForKey: @" hasKeyboardFocus" snapshot: snapshot defaultValue: NO ] boolValue ]
756- || [[self boolNumberForKey: @" hasFocus" snapshot: snapshot defaultValue: NO ] boolValue ]);
757+ BOOL keyboardFocused = [[self boolNumberForKey: @" hasKeyboardFocus" snapshot: snapshot defaultValue: NO ] boolValue ];
758+ BOOL engineFocused = [[self boolNumberForKey: @" hasFocus" snapshot: snapshot defaultValue: NO ] boolValue ];
759+ result[@" focused" ] = @(keyboardFocused || engineFocused);
757760
758761 NSMutableArray *children = [NSMutableArray array ];
759762 if (depth < maxDepth) {
You can’t perform that action at this time.
0 commit comments