dequelabs / axe-android

WCAG Accessibility compliance library for Android Applications.
Mozilla Public License 2.0
65 stars 19 forks source link

ColorContrast - Image underlays should be filtered out #59

Open DaveTryon opened 4 years ago

DaveTryon commented 4 years ago

The ColorContrast algorithm gets confused if the background of text involves an image underlay, even if all of the underlay is darkened to the point that the background colors are all dark enough to satisfy contrast requirements. The noise from the underlay effectively "camouflages" the text color from the algorithm, leading to false positives based on the darkened underlay color.

I've created a fork that demonstrates the behavior. To demo, clone https://github.com/DaveTryon/axe-android/tree/TextOverlayBugDemo and run the color contrast tests. The new imageTest_textOverlaysImage test should ideally succeed (reporting no confidence in the ColorContrast result), but it fails because the underlay is tricking the algorithm into believing that meaningful data exists.

Screenshot

Here's a screenshot of the test image--the ColorContrast is reporting very dark foreground (ff0c1112) and background (ff000203) colors, and is completely missing the white text, even though it's very clear visually:

image

Why the Control is Accessible

If you use run a color contrast test using the pixels around the white text, most of the pixels are contrasts of about 15:1. Even the brightest spots (the yellows) are reporting a contrast of at least 5:1. I happened to test this with Accessibility Insights, but other tools should produce similar results.