diff --git a/lib/commons/color/get-background-color.js b/lib/commons/color/get-background-color.js index 69eb1352a6..d97dd92a13 100644 --- a/lib/commons/color/get-background-color.js +++ b/lib/commons/color/get-background-color.js @@ -147,13 +147,17 @@ function fullyEncompasses(node, rects) { let { right, bottom } = nodeRect; const style = window.getComputedStyle(node); const overflow = style.getPropertyValue('overflow'); + const paddingLeft = parseInt(style.getPropertyValue('padding-left'), 10); + const paddingRight = parseInt(style.getPropertyValue('padding-right'), 10); + const paddingTop = parseInt(style.getPropertyValue('padding-top'), 10); + const paddingBottom = parseInt(style.getPropertyValue('padding-bottom'), 10); if ( ['scroll', 'auto'].includes(overflow) || node instanceof window.HTMLHtmlElement ) { - right = nodeRect.left + node.scrollWidth; - bottom = nodeRect.top + node.scrollHeight; + right = nodeRect.left + node.scrollWidth + paddingLeft + paddingRight; + bottom = nodeRect.top + node.scrollHeight + paddingTop + paddingBottom; } return rects.every(rect => { diff --git a/test/commons/color/get-background-color.js b/test/commons/color/get-background-color.js index 12852c69df..1837b86395 100644 --- a/test/commons/color/get-background-color.js +++ b/test/commons/color/get-background-color.js @@ -1017,6 +1017,18 @@ describe('color.getBackgroundColor', function () { assertColorsClose(actual, expected); }); + it('calculates background of a textarea', () => { + fixture.innerHTML = + ''; + var target = fixture.querySelector('#target'); + axe.testUtils.flatTreeSetup(fixture); + var bgNodes = []; + var actual = axe.commons.color.getBackgroundColor(target, bgNodes, 1); + + var expected = new axe.commons.color.Color(255, 0, 0, 1); + assertColorsClose(actual, expected); + }); + describe('body and document', function () { it('returns the body background', function () { fixture.innerHTML = '
elm
'; diff --git a/test/integration/rules/color-contrast/color-contrast.html b/test/integration/rules/color-contrast/color-contrast.html index bf47ee73ce..2e697dcbb9 100644 --- a/test/integration/rules/color-contrast/color-contrast.html +++ b/test/integration/rules/color-contrast/color-contrast.html @@ -472,3 +472,7 @@ > Ignore. + + diff --git a/test/integration/rules/color-contrast/color-contrast.json b/test/integration/rules/color-contrast/color-contrast.json index a5a8aa0355..5d3140ef1c 100644 --- a/test/integration/rules/color-contrast/color-contrast.json +++ b/test/integration/rules/color-contrast/color-contrast.json @@ -37,7 +37,8 @@ ["#pass20"], ["#pass21"], ["#pass22"], - ["#pass23"] + ["#pass23"], + ["#pass24"] ], "incomplete": [ ["#canttell1"],