diff --git a/lib/checks/forms/autocomplete-appropriate.js b/lib/checks/forms/autocomplete-appropriate.js index 259dea94dd..43358f0b42 100644 --- a/lib/checks/forms/autocomplete-appropriate.js +++ b/lib/checks/forms/autocomplete-appropriate.js @@ -38,9 +38,13 @@ const autocomplete = node.getAttribute('autocomplete'); const autocompleteTerms = autocomplete .split(/\s+/g) .map(term => term.toLowerCase()); + const purposeTerm = autocompleteTerms[autocompleteTerms.length - 1]; -const allowedTypes = allowedTypesMap[purposeTerm]; +if (axe.commons.text.autocomplete.stateTerms.includes(purposeTerm)) { + return true; +} +const allowedTypes = allowedTypesMap[purposeTerm]; if (typeof allowedTypes === 'undefined') { return node.type === 'text'; } diff --git a/test/checks/forms/autocomplete-appropriate.js b/test/checks/forms/autocomplete-appropriate.js index aae35f69be..30be5c6bc1 100644 --- a/test/checks/forms/autocomplete-appropriate.js +++ b/test/checks/forms/autocomplete-appropriate.js @@ -54,6 +54,18 @@ describe('autocomplete-appropriate', function() { assert.isTrue(evaluate.apply(checkContext, params)); }); + it('returns true if the input type is tel and the term is off', function() { + var options = {}; + var params = autocompleteCheckParams('off', 'tel', options); + assert.isTrue(evaluate.apply(checkContext, params)); + }); + + it('returns true if the input type is url and the term is on', function() { + var options = {}; + var params = autocompleteCheckParams('on', 'url', options); + assert.isTrue(evaluate.apply(checkContext, params)); + }); + it('returns false if the input type is text and the term maps to an empty array', function() { var options = { foo: [] }; var params = autocompleteCheckParams('foo', 'text', options); diff --git a/test/integration/rules/autocomplete-valid/autocomplete-valid.html b/test/integration/rules/autocomplete-valid/autocomplete-valid.html index ef58c8a23b..3168a36246 100644 --- a/test/integration/rules/autocomplete-valid/autocomplete-valid.html +++ b/test/integration/rules/autocomplete-valid/autocomplete-valid.html @@ -115,3 +115,7 @@ + + + + diff --git a/test/integration/rules/autocomplete-valid/autocomplete-valid.json b/test/integration/rules/autocomplete-valid/autocomplete-valid.json index 99ef0ae81a..7f3867a27b 100644 --- a/test/integration/rules/autocomplete-valid/autocomplete-valid.json +++ b/test/integration/rules/autocomplete-valid/autocomplete-valid.json @@ -71,6 +71,9 @@ ["#pass60"], ["#pass61"], ["#pass62"], - ["#pass63"] + ["#pass63"], + ["#pass64"], + ["#pass65"], + ["#pass66"] ] }