-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Downgrade SiblingUniqueAndFocusable to NeedsReview for Win32 apps
Due to a large number of false positives (and given the fact that Win32 applications don't support UIA natively), this commit downgrades `SiblingUniqueAndFocusable` to `NeedsReview` in Win32 applications. Addresses #1046. Supersedes #1038. Addresses microsoft/accessibility-insights-windows#1838.
- Loading branch information
1 parent
6d27481
commit cd88bf9
Showing
4 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Axe.Windows.Core.Bases; | ||
using Axe.Windows.Core.Enums; | ||
using Axe.Windows.Core.Exceptions; | ||
using Axe.Windows.Core.Misc; | ||
using Axe.Windows.Rules.PropertyConditions; | ||
using Axe.Windows.Rules.Resources; | ||
using System; | ||
using static Axe.Windows.Rules.PropertyConditions.BoolProperties; | ||
using static Axe.Windows.Rules.PropertyConditions.ControlType; | ||
using static Axe.Windows.Rules.PropertyConditions.Framework; | ||
using static Axe.Windows.Rules.PropertyConditions.Relationships; | ||
using static Axe.Windows.Rules.PropertyConditions.StringProperties; | ||
|
||
namespace Axe.Windows.Rules.Library | ||
{ | ||
[RuleInfo(ID = RuleId.SiblingUniqueAndFocusableWin32)] | ||
class SiblingUniqueAndFocusableWin32 : Rule | ||
{ | ||
private static readonly Condition EligibleChild = CreateEligibleChildCondition(); | ||
|
||
private static Condition CreateEligibleChildCondition() | ||
{ | ||
var ExcludedType = Image | Pane | ScrollBar | Thumb | TreeItem | ListItem | Hyperlink; | ||
|
||
return IsKeyboardFocusable | ||
& Win32Framework | ||
& IsContentOrControlElement | ||
& ~ExcludedType | ||
& ~Patterns.GridItem | ||
& ParentExists | ||
& Name.NotNullOrEmpty | ||
& LocalizedControlType.NotNullOrEmpty | ||
& BoundingRectangle.Valid; | ||
} | ||
|
||
public SiblingUniqueAndFocusableWin32() | ||
{ | ||
Info.Description = Descriptions.SiblingUniqueAndFocusable; | ||
Info.HowToFix = HowToFix.SiblingUniqueAndFocusable; | ||
Info.Standard = A11yCriteriaId.NameRoleValue; | ||
Info.ErrorCode = EvaluationCode.NeedsReview; | ||
} | ||
|
||
public override bool PassesTest(IA11yElement e) | ||
{ | ||
if (e == null) throw new ArgumentNullException(nameof(e)); | ||
if (e.Parent == null) throw new ArgumentException(ErrorMessages.ElementParentNull, nameof(e)); | ||
|
||
var siblings = SiblingCount(EligibleChild | ||
& Name.Is(e.Name) | ||
& LocalizedControlType.Is(e.LocalizedControlType)); | ||
var count = siblings.GetValue(e); | ||
if (count < 1) throw new AxeWindowsException(ErrorMessages.NoElementFound.WithParameters(Info.ID)); | ||
|
||
return count == 1; | ||
} | ||
|
||
protected override Condition CreateCondition() | ||
{ | ||
return EligibleChild; | ||
} | ||
} | ||
} |