microsoft / axe-windows

Automated accessibility testing engine for Windows applications
MIT License
136 stars 62 forks source link

fix: Add MSAA role name to LegacyIAccessiblePattern.Role #824

Closed DaveTryon closed 1 year ago

DaveTryon commented 1 year ago

Details

AIWin #1454 requests that we add the enum name for MSAA role types. This change provides the mapping, and it will light up in AIWin after this change gets published and picked up.

We add the LegacyIAccessibleRoleType class to map from numeric values to MSAA role types. We then add this to A11yProperty to capture this on the element. Finally, we need to expose this via the A11yPatternProperty, which leverages the LegacyIAccessibleRoleType class to get the name. In order to avoid confusing quotation marks around the mapped role, we add A11yPatternProperty.OmitQuotesFromString, which gets set only for LegacyIAccessiblePattern.Role. When writing out the JSON file, we set the flag to omit null values, so A11yPatterProperty.OmitQuotesFromString only gets written to disk when it's specified.

Validated by building locally and testing against the pentest site provided in the AIWin issue.

Two notes:

  1. If an .a11ytest file is created with the new build, then opened in a previous version of AIWin, the properties will contain the LegacyIAccessiblePattern.Role value in quotes. This is because older versions don't know about the A11yPatternProperty.OmitQuotesFromString property and include the quotes
  2. Since AIWin displays the data stored in the .a11ytest file, existing .a11ytest files will continue to display just the number without the enum name
Motivation

Set things up to address AIWin #1454

Screenshots
Scenario Before PR After PR
Live mode (pen test) image image
Open old saved file image image
Open new saved file image image
Context

Pull request checklist

codecov-commenter commented 1 year ago

Codecov Report

Merging #824 (a9ff53b) into main (4fc19c3) will increase coverage by 1.02%. The diff coverage is 80.39%.

@@            Coverage Diff             @@
##             main     #824      +/-   ##
==========================================
+ Coverage   73.70%   74.72%   +1.02%     
==========================================
  Files         398      421      +23     
  Lines       12046    12995     +949     
==========================================
+ Hits         8878     9711     +833     
- Misses       3168     3284     +116     
Impacted Files Coverage Δ
src/Actions/Actions/ControlPatternAction.cs 0.00% <0.00%> (ø)
src/Actions/Actions/CustomUIAAction.cs 0.00% <0.00%> (ø)
src/Actions/Actions/ListenAction.cs 0.00% <0.00%> (ø)
src/Actions/Actions/PrivacyExtensions.cs 100.00% <ø> (ø)
src/Actions/Actions/SetDataAction.cs 0.00% <0.00%> (ø)
...rc/Actions/Attributes/InteractionLevelAttribute.cs 0.00% <0.00%> (ø)
src/Actions/Misc/ExtensionMethods.cs 7.46% <0.00%> (-31.60%) :arrow_down:
src/Actions/Resources/ErrorMessages.Designer.cs 0.00% <ø> (-55.56%) :arrow_down:
src/Automation/AxeWindowsAutomationException.cs 33.33% <ø> (-33.34%) :arrow_down:
src/Automation/Data/OutputFile.cs 88.88% <ø> (ø)
... and 432 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.