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 chromium noise #951

Merged
merged 10 commits into from Jul 26, 2023
Merged

Conversation

DaveTryon
Copy link
Contributor

@DaveTryon DaveTryon commented Jul 20, 2023

Details

As called out in #836, the ChromiumContentShouldUseWebScanner has caused a lot of confusion. This PR aims to reduce that confusion. It does the following:

  • The ChromiumContentShouldUseWebScanner rule will now trigger only on Chromium-generated Document elements
  • Other rules are disabled on elements that are Chromium-generated Document elements or any of their descendants
  • Future rules default to being disabled on elements that are Chromium-generated Documents or any of their descendants. The default behavior can easily be overridden
  • Where needed for unit tests with strict mocks, provide test constructors that allow unit tests to isolate the class under test from the Chromium suppression
Motivation

Address #836, make the ChromiumContentShouldUseWebScanner rule less intrusive

Attachments

BeforeAndAfter.zip contains 2 a11ytest files

  • Before.a11ytest contains scan results from Edge before this change
  • After.a11ytest contains scan results from Edge after this change

Here are how the numbers line up

Message Count before Count after Count of Chromium elements
An element must not have the same Name and LocalizedControlType as its parent 7 0 7
An element of the given ControlType must not support the Invoke pattern 1 1 0
An element of the given ControlType must support the Text pattern 1 0 1
An on-screen element must not have a null BoundingRectangle property 5 5 0
Chromium components should be scanned with a web-based scanner 63 2 63
The Name must not include the same text as the LocalizedControlType 2 2 0
The Name property must not include the element's control type 2 2 0

Things to note on this table:

  • There are 2 Chromium documents on the page--one for the HTML content and one for the search button. This is an implementation detail of the search button
  • Only the 2 Chromium documents are counted in "Count after". The 61 omitted elements are children of one of the two Chromium documents
  • For all other columns. "Count before" - "Count after" = "Count of Chromium elements". This is as expected

If you open After.a11ytest and inspect the children of the Chromium documents, the UIA properties are reported but no tests were run. That's exactly what this change was intended to do.

Screenshots

Here are visual representations of the test results with all test results displaying. Notice the difference in the HTML document space:

File Snapshot (click to enlarge) Test Results (click to enlarge)
Before image image
After image image
Context

Pull request checklist

@DaveTryon DaveTryon requested a review from a team as a code owner July 20, 2023 01:41
@@ -27,7 +26,7 @@ public override bool PassesTest(IA11yElement e)

protected override Condition CreateCondition()
{
return Chrome & (Document | AnyAncestor(Document));
return Chrome & Document;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the change that reduces the scope of ChromiumComponentsShouldUseWebScanner from all Chromium elements to just Chromium Documents

@@ -19,17 +20,28 @@ abstract class Rule : IRule
{
public RuleInfo Info { get; private set; }
public Condition Condition { get; }
protected static Condition DefaultExcludedCondition => IsChromiumContent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exposing this to derived classes gives us a single place to modify the default, then the production constructors of the derived classes just pick up the new value without requiring any additional code change


InitRuleInfo();
}

protected Rule() : this (excludedCondition: DefaultExcludedCondition)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By default, exclude DefaultExcludedCondition

_elementMock.VerifyAll();
}

public void Matches_FrameworkIsChrome_IsNotDocument_ParentIsChromeDocument_ReturnsTrue()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test overlaps with the one after it, so could potentially be removed


namespace Axe.Windows.Rules.Library
{
[RuleInfo(ID = RuleId.ChromiumComponentsShouldUseWebScanner)]
class ChromiumComponentsShouldUseWebScanner : Rule
{
public ChromiumComponentsShouldUseWebScanner()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could build an argument for renaming this to ChromiumDocumentsShouldUseWebScanner, but that would make the PR harder to review. Happy to put this into a subsequent PR if needed.

@@ -27,7 +25,7 @@ public override bool PassesTest(IA11yElement e)

protected override Condition CreateCondition()
{
return Chrome & (Document | AnyAncestor(Document));
return IsChromiumDocument;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the change that limits ChromiumComponentsShouldUseWebScanner to just scan Chromium Documents

Copy link
Contributor

@codeofdusk codeofdusk left a comment

Choose a reason for hiding this comment

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

Verified that:

  • In a WebView2 application, the "chromium content should use web scanner" rule was reported to fail. No spurious Chromium-related errors were reported.
  • In an Electron application, the "chromium content should use web scanner" rule was reported to fail. No spurious Chromium-related errors were reported.
  • In a non-web scenario, no change is observed.

src/Rules/Conditions/IsChromiumContentCondition.cs Outdated Show resolved Hide resolved
src/Rules/Rule.cs Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Merging #951 (737df70) into main (4fc19c3) will increase coverage by 1.12%.
Report is 331 commits behind head on main.
The diff coverage is 79.02%.

❗ Current head 737df70 differs from pull request most recent head e366517. Consider uploading reports for the commit e366517 to get more accurate results

@@            Coverage Diff             @@
##             main     #951      +/-   ##
==========================================
+ Coverage   73.70%   74.82%   +1.12%     
==========================================
  Files         398      423      +25     
  Lines       12046    13093    +1047     
==========================================
+ Hits         8878     9797     +919     
- Misses       3168     3296     +128     
Files Changed 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%) ⬇️
src/Actions/Resources/ErrorMessages.Designer.cs 0.00% <ø> (-55.56%) ⬇️
src/Automation/AxeWindowsAutomationException.cs 33.33% <ø> (-33.34%) ⬇️
src/Automation/Data/OutputFile.cs 88.88% <ø> (ø)
... and 144 more

... and 241 files with indirect coverage changes

@DaveTryon DaveTryon merged commit b078401 into microsoft:main Jul 26, 2023
4 checks passed
@DaveTryon DaveTryon deleted the reduce-chromium-noise branch August 7, 2023 16:08
DaveTryon added a commit that referenced this pull request Sep 1, 2023
#### Details

In #951, we intentionally excluded all elements inside a Chromium
document from scan results. This makes sense for most developers, since
the conversion from HTML to UIA is convoluted and outside the control of
the HTML developer. However, the Edge team relies on this functionality
to help improve their HTML-to-UIA conversion code. This PR defaults to
excluding the elements inside a Chromium document, but adds a way to
request that scan results include elements within a Chromium document.
This option is exposed in 3 places:
1. In the `Automation` layer
2. In the CLI
3. In the `SelectAction` class (for future use from Accessibility
Insights for Windows)

##### Motivation

Requested by the Edge team

##### Results

[Comparison.zip](https://github.com/microsoft/axe-windows/files/12480720/Comparison.zip)
contains `Default.a11ytest` and `WithChromiumContent.a11ytest`, which
were captured by running the CLI on the same instance of Edge. The rule
comparison is as follows:

Message | Default Count | WithChromiumContent count
--- | --- | ---
An on-screen element must not have a null BoundingRectangle property | 5
| 5
Chromium components should be scanned with an web-based scanner | 2 | 2
The Name must not include the same text as the LocalizedControlType | 2
| 2
The Name property must not include the element's control type | 2 | 2
An element must not have the same Name and LocalizedControlType as its
parent | 0 | 4
An element of the given ControlType must support the Text pattern | 0 |
1

The elements that are unique to the WithChromiumContent file are all
within the Chromium document

##### Screenshots 

Case | Snapshot (click to enlarge) | Results (click to enlarge)
--- | --- | ---
Default |
![image](https://github.com/microsoft/axe-windows/assets/45672944/1665bb43-a93b-44b8-aaf8-94d4af9680ee)
|![image](https://github.com/microsoft/axe-windows/assets/45672944/e2f6cd73-8628-46e7-b7db-3f89f0d12438)
WithChromiumContent |
![image](https://github.com/microsoft/axe-windows/assets/45672944/8702cb77-fda3-40eb-9fc2-a4f360f790d3)
|
![image](https://github.com/microsoft/axe-windows/assets/45672944/79b6bae7-afc5-4e6b-8b9f-37d1356bac9f)
Delta |
![image](https://github.com/microsoft/axe-windows/assets/45672944/aa68946e-ca5c-464e-826c-1914500517a3)
|
![image](https://github.com/microsoft/axe-windows/assets/45672944/6e7da53a-4f5d-4dd6-bc43-e23e957b5a90)

##### Context

<!-- Are there any parts that you've intentionally left out-of-scope for
a later PR to handle? -->
- The `Actions` project didn't previously reference the `Rules` project
directly, so the plumbing may be non-ideal. If we were to use the
existing dependencies, `Actions` would call into `Desktop`, which would
call into `RuleSelection`, which would call into `Rules`. We can add the
2 missing layers if we think there's value there.
- The flag to enable Chromium content is basically global. This will
work as expected in the CLI, in AI-Win, and in AccChecker. It will fail
if someone creates a scenario where concurrent scans want to have
different Chromium behavior. I've taken a YAGNI approach for now, and we
can always make it more complex at a future time, should that prove
necessary.

<!-- Were there any alternative approaches you considered? What
tradeoffs did you consider? -->

#### Pull request checklist
<!-- If a checklist item is not applicable to this change, write "n/a"
in the checkbox -->
- [n/a] Addresses an existing issue:
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.

None yet

4 participants