Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Reduce noise in ChromiumComponentsShouldUseWebScanner rule #931

Merged
merged 3 commits into from
Jun 2, 2023

Conversation

DaveTryon
Copy link
Contributor

Details

microsoft/accessibility-insights-windows#1625 points out that the ChromiumComponentsShouldUseWebScanner rule is flagging items that are outside the context of a web page, which goes against the rule's primary purpose. This change limits the ChromiumComponentsShouldUseWebScanner rule to elements within a HTML document (including the document itself).

While working on this, we discovered a bug in WebView2, which is tracked at MicrosoftEdge/WebView2Feedback#3530.

Motivation

Address microsoft/accessibility-insights-windows#1625

Before & after
Text results using Edge

As expected, only the ChromiumComponentsShouldUseWebScanner rule is impacted

Rule Count Before Count After
An element of the given ControlType must not support the invoke pattern 1 1
An on-screen element must not have a null BoundingRectangle property 7 7
Chromium components should be scanned with a web-based scanner 211 135
The Name must not include the same text as the LocalizedControlType 5 5
The Name property must not contain only whitespace 3 3
The Name property must not include the element's control type 1 1
The Name property of a focusable element must not be null 10 10
Screenshots using Edge

These screenshots are limited to just the ChromiumComponentsShouldUseWebScanner rule:

State Screenshot
Before change image
After change image
Context

This includes an opportunistic optimization to some of the code in Relationships, because the unit test code looked odd with arbitrary multipliers to compensate for hoe Relationships is coded. This could be a separate PR if that's preferred.

Pull request checklist

@DaveTryon DaveTryon requested a review from a team as a code owner June 1, 2023 23:07
@@ -38,17 +39,19 @@ private static Condition CreateSecondChildCondition()
private static bool MatchOrderInSiblings(IA11yElement e, int index)
{
if (e == null) throw new ArgumentNullException(nameof(e));
if (e.Parent == null || e.Parent.Children == null) return false;
Copy link
Contributor Author

@DaveTryon DaveTryon Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code evaluated e.Parent up to 4 times, and e.Parent.Children up to 3 times. Updated code maxes out at once for each.


var count = (from c in e.Parent.Children
Copy link
Contributor Author

@DaveTryon DaveTryon Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code evaluated e.Parent up to twice. New code maxes out at once.

@@ -66,9 +69,10 @@ private static bool MatchParent(Condition c, IA11yElement e)
{
if (c == null) throw new ArgumentNullException(nameof(c));
if (e == null) throw new ArgumentNullException(nameof(e));
if (e.Parent == null) return false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code evaluated e.Parent up to twice. New code maxes out at once.

@DaveTryon DaveTryon merged commit 2db94f5 into microsoft:main Jun 2, 2023
@DaveTryon DaveTryon deleted the reduce-chromium-noise branch June 2, 2023 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants