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
Conversation
@@ -27,7 +26,7 @@ public override bool PassesTest(IA11yElement e) | |||
|
|||
protected override Condition CreateCondition() | |||
{ | |||
return Chrome & (Document | AnyAncestor(Document)); | |||
return Chrome & Document; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this 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.
Codecov Report
@@ 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
|
#### 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:
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:ChromiumContentShouldUseWebScanner
rule will now trigger only on Chromium-generatedDocument
elementsDocument
elements or any of their descendantsDocuments
or any of their descendants. The default behavior can easily be overriddenmock
s, provide test constructors that allow unit tests to isolate the class under test from the Chromium suppressionMotivation
Address #836, make the
ChromiumContentShouldUseWebScanner
rule less intrusiveAttachments
BeforeAndAfter.zip contains 2
a11ytest
filesBefore.a11ytest
contains scan results from Edge before this changeAfter.a11ytest
contains scan results from Edge after this changeHere are how the numbers line up
Things to note on this table:
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:
Context
Pull request checklist