Don't report IAccessible alert events if there's no content. #9266
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Fixes #5657.
Summary of the issue:
In Firefox and Chrome, NVDA reports "alert" when an empty element with role="alert" is shown.
Description of how this pull request fixes the issue:
In IAccessible's event_alert, return early if there's no content.
As well as the childCount, we also check name and description, as these might be set using ARIA even on an alert with no children.
Testing performed:
In both Firefox and Chrome, tested with the following test cases.
Empty alert. When button is pressed, nothing is reported:
data:text/html,<div id="al" role="alert" hidden></div><button onClick="al.hidden = false;">Alert</button>
Alert with text content. When button is pressed, "alert text" is reported:
data:text/html,<div id="al" role="alert" hidden>text</div><button onClick="al.hidden = false;">Alert</button>
Alert with aria-label. When button is pressed, "label alert" is reported:
data:text/html,<div id="al" role="alert" aria-label="label" hidden></div><button onClick="al.hidden = false;">Alert</button>
Alert with aria-describedby. When button is pressed, "alert desc" is reported:
data:text/html,<div id="desc">desc</div><div id="al" role="alert" aria-describedby="desc" hidden></div><button onClick="al.hidden = false;">Alert</button>
Alert with button. When button outside the alert is pressed, "alert, inner button" is reported:
data:text/html,<div id="al" role="alert" hidden><button>inner</button></div><button onClick="al.hidden = false;">Alert</button>
Known issues with pull request:
There are obscure cases this won't catch like an alert containing an empty paragraph, but fixing that is somewhat trickier and I doubt it happens in the real world. If it does, we can extend this later.
Change log entry:
Bug Fixes:
- In Mozilla Firefox and Google Chrome, empty alerts are no longer reported.