Skip to content

Commit

Permalink
fix(autocomplete-appropriate): pass for autocomplete=username and typ…
Browse files Browse the repository at this point in the history
…e=email (#2896)

* allow type=email autocomplete=username

* also add text and search

* add integration test
  • Loading branch information
clottman committed Apr 28, 2021
1 parent 4227011 commit 43394bc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/checks/forms/autocomplete-appropriate-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function autocompleteAppropriateEvaluate(node, options, virtualNode) {
const allowedTypesMap = {
bday: ['text', 'search', 'date'],
email: ['text', 'search', 'email'],
username: ['text', 'search', 'email'],
'street-address': ['text'], // Issue: https://github.com/dequelabs/axe-core/issues/1161
tel: ['text', 'search', 'tel'],
'tel-country-code': ['text', 'search', 'tel'],
Expand Down
6 changes: 6 additions & 0 deletions test/checks/forms/autocomplete-appropriate.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ describe('autocomplete-appropriate', function() {
assert.isTrue(evaluate.apply(checkContext, params));
});

it('returns true if the input type is email and the term is username', function() {
var options = {};
var params = autocompleteCheckParams('username', 'email', 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);
Expand Down
2 changes: 1 addition & 1 deletion test/commons/text/is-valid-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('text.isValidAutocomplete', function() {
);
});

it('returns true if "home", "work", "mobile", "fax" or "pager" is used before aqualifier', function() {
it('returns true if "home", "work", "mobile", "fax" or "pager" is used before a qualifier', function() {
['home', 'work', 'mobile', 'fax', 'pager'].forEach(function(qualifier) {
assert.isTrue(
isValidAutocomplete(qualifier + ' qualified-term', options),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
<input autocomplete="work tel-local-suffix" id="pass60" />
<input autocomplete="SECTION-foo mobile tel-extension" id="pass61" />
<input autocomplete="fax email" id="pass62" />
<input type="username" autocomplete="email" id="pass83" />
<input autocomplete="pager impp" id="pass63" />
<input
autocomplete="off"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
["#pass79"],
["#pass80"],
["#pass81"],
["#pass82"]
["#pass82"],
["#pass83"]
]
}

0 comments on commit 43394bc

Please sign in to comment.