Skip to content

Commit

Permalink
Merge pull request #49 from browserstack/autocomplete-reverting
Browse files Browse the repository at this point in the history
Reverted autocomplete valid
  • Loading branch information
ansh21 authored May 20, 2024
2 parents df37c1d + 8b2da07 commit db03143
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 293 deletions.
3 changes: 1 addition & 2 deletions lib/checks/forms/autocomplete-a11y-evaluate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isValidAutocomplete } from '../../commons/text';
import { ErrorHandler } from '../../../../a11y-engine-core/lib/core/errors/error-handler';

function checkIsElementValidAutocomplete(node, options, virtualNode) {
const autocomplete = virtualNode
Expand Down Expand Up @@ -69,7 +68,7 @@ function autocompleteA11yEvaluate(node, options, virtualNode) {
return checkIsElementValidAutocomplete(node, options, virtualNode);
}
} catch (err) {
ErrorHandler.addCheckError('autocomplete-attribute-valid-check', err);
// ErrorHandler.addCheckError('autocomplete-attribute-valid-check', err);
return undefined;
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/checks/forms/autocomplete-valid.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id": "autocomplete-valid",
"evaluate": "autocomplete-a11y-evaluate",
"evaluate": "autocomplete-valid-evaluate",
"metadata": {
"impact": "moderate",
"impact": "serious",
"messages": {
"pass": "the autocomplete attribute is correctly formatted",
"fail": "Add autocomplete attribute to form fields with a valid value as per HTML specification. In 'name' attribute of field, prefer to use standard autocomplete value since browsers use 'name' to suggest autofill. For field with no standard autocomplete value (eg: College ID), prefer to use autocomplete='on'."
"fail": "the autocomplete attribute is incorrectly formatted"
}
},
"options": {
Expand Down
15 changes: 4 additions & 11 deletions lib/rules/autocomplete-valid.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
{
"id": "autocomplete-valid",
"matches": "autocomplete-a11y-matches",
"tags": [
"cat.forms",
"wcag21aa",
"wcag22aa",
"wcag135",
"a11y-engine",
"a11y-engine-experimental"
],
"matches": "autocomplete-matches",
"tags": ["cat.forms", "wcag21aa", "wcag135"],
"actIds": ["73f2c2"],
"metadata": {
"description": "Ensure that the necessary form fields use the autocomplete attribute with a valid input.",
"help": "Autocomplete attribute must have a valid value"
"description": "Ensure the autocomplete attribute is correct and suitable for the form field",
"help": "autocomplete attribute must be used correctly"
},
"all": ["autocomplete-valid"],
"any": [],
Expand Down
326 changes: 163 additions & 163 deletions test/checks/forms/autocomplete-valid.js

Large diffs are not rendered by default.

200 changes: 101 additions & 99 deletions test/integration/rules/autocomplete-valid/autocomplete-valid.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

<textarea autocomplete="Street-Address" id="pass3"></textarea>

<input autocomplete="section-partner email" id="pass4" />
<input autocomplete="Work EMail" id="pass4" />

<input autocomplete="section-primary shipping work email" id="pass5" />
<input autocomplete="section-partner email" id="pass5" />

<input autocomplete="section-primary shipping work email" id="pass6" />

<!-- Unknown autocomplete term -->
<input autocomplete="badterm" id="fail1" />
Expand All @@ -27,135 +29,135 @@
<button autocomplete="username" id="inapplicable1"></button>

<!-- Empty attribute -->
<input autocomplete="" id="fail5" />
<input autocomplete="" id="inapplicable2" />

<!-- Hidden through display:none -->
<input autocomplete="username" style="display:none" id="inapplicable2" />
<input autocomplete="username" style="display:none" id="inapplicable3" />

<!-- Off screen and not focusable -->
<input
autocomplete="username"
tabindex="-1"
aria-hidden="true"
style="position:absolute; top:-9999em"
id="inapplicable3"
id="inapplicable4"
/>

<!-- input button -->
<input type="button" autocomplete="username" id="inapplicable4" />
<input type="button" autocomplete="username" id="inapplicable5" />

<!-- hidden -->
<input type="hidden" autocomplete="username" id="inapplicable5" />
<input type="hidden" autocomplete="username" id="inapplicable6" />

<!-- native disabled -->
<input autocomplete="username" disabled id="inapplicable6" />
<input autocomplete="username" disabled id="inapplicable7" />

<!-- ARIA disabled -->
<input autocomplete="username" aria-disabled="true" id="inapplicable7" />
<input autocomplete="username" aria-disabled="true" id="inapplicable8" />

<!-- non-widget element -->
<input
type="button"
role="none"
tabindex="-1"
autocomplete="username"
id="inapplicable8"
id="inapplicable9"
/>
<input autocomplete=" " id="fail6" />

<input autocomplete="on" id="fail7" />
<input autocomplete=" on " id="fail8" />
<input autocomplete=" OFF " id="pass6" />
<input autocomplete=" name " id="pass7" />
<input autocomplete="honorific-prefix" id="pass8" />
<input autocomplete="GIVEN-NAME" id="pass9" />
<input autocomplete="additional-name" id="pass10" />
<input autocomplete="section-foo billing family-name" id="pass11" />
<input autocomplete="honorific-suffix" id="pass12" />
<input autocomplete="nickname" id="pass13" />
<input autocomplete="USERNAME" id="pass14" />
<input autocomplete="section-foo new-password" id="pass15" />
<input autocomplete="shipping current-password" id="pass16" />
<input autocomplete="organization-title" id="pass17" />
<input autocomplete="organization" id="pass18" />
<textarea autocomplete="section-foo street-address" id="pass19"></textarea>
<input autocomplete="address-line1" id="pass20" />
<input autocomplete="billing address-line2" id="pass21" />
<input autocomplete="address-line3" id="pass22" />
<input autocomplete="section-foo address-level4" id="pass23" />
<input autocomplete="address-level3" id="pass24" />
<input autocomplete="address-level2" id="pass25" />
<input autocomplete="SHIPPING address-level1" id="pass26" />
<input autocomplete="section-foo country" id="pass27" />
<input autocomplete="country-name" id="pass28" />
<input autocomplete="postal-code" id="pass29" />
<input autocomplete="CC-name" id="pass30" />
<input autocomplete="section-foo billing cc-given-name" id="pass31" />
<input autocomplete="cc-additional-name" id="pass32" />
<input autocomplete="cc-family-name" id="pass33" />
<input autocomplete="cc-number" id="pass34" />
<input autocomplete="section-foo cc-exp" id="pass35" />
<input autocomplete="shipping CC-Exp-Month" id="pass36" />
<input autocomplete="cc-exp-year" id="pass37" />
<input autocomplete="cc-csc" id="pass38" />
<input autocomplete="section-foo cc-type" id="pass39" />
<input autocomplete="transaction-currency" id="pass40" />
<input autocomplete="billing transaction-amount" id="pass41" />
<input autocomplete="language" id="pass42" />
<input autocomplete="section-foo bday" id="pass43" />
<input autocomplete="bday-day" id="pass44" />
<input autocomplete="bday-month" id="pass45" />
<input autocomplete="section-foo shipping bday-year" id="pass46" />
<input autocomplete="sex" id="pass47" />
<input autocomplete="url" id="pass48" />
<input autocomplete="photo" id="pass49" />
<input autocomplete="section-foo photo" id="pass50" />
<input autocomplete="HOME TEL" id="pass51" />
<input autocomplete="section-foo shipping work tel-country-code" id="pass52" />
<input autocomplete="mobile tel-national" id="pass53" />
<input autocomplete="fax tel-area-code" id="pass54" />
<input autocomplete="pager tel-local" id="pass55" />
<input autocomplete="home tel-local-prefix" id="pass56" />
<input autocomplete="work tel-local-suffix" id="pass57" />
<input autocomplete="SECTION-foo mobile tel-extension" id="pass58" />
<input autocomplete="fax email" id="pass59" />
<input type="username" autocomplete="email" id="pass60" />
<input autocomplete="pager impp" id="pass61" />
<input autocomplete=" " id="inapplicable10" />

<input autocomplete="on" id="pass7" />
<input autocomplete=" on " id="pass8" />
<input autocomplete=" OFF " id="pass9" />
<input autocomplete=" name " id="pass10" />
<input autocomplete="honorific-prefix" id="pass11" />
<input autocomplete="GIVEN-NAME" id="pass12" />
<input autocomplete="additional-name" id="pass13" />
<input autocomplete="section-foo billing family-name" id="pass14" />
<input autocomplete="honorific-suffix" id="pass15" />
<input autocomplete="nickname" id="pass16" />
<input autocomplete="USERNAME" id="pass17" />
<input autocomplete="section-foo new-password" id="pass18" />
<input autocomplete="shipping current-password" id="pass19" />
<input autocomplete="organization-title" id="pass20" />
<input autocomplete="organization" id="pass21" />
<textarea autocomplete="section-foo street-address" id="pass22"></textarea>
<input autocomplete="address-line1" id="pass23" />
<input autocomplete="billing address-line2" id="pass24" />
<input autocomplete="address-line3" id="pass25" />
<input autocomplete="section-foo address-level4" id="pass26" />
<input autocomplete="address-level3" id="pass27" />
<input autocomplete="address-level2" id="pass28" />
<input autocomplete="SHIPPING address-level1" id="pass29" />
<input autocomplete="section-foo country" id="pass30" />
<input autocomplete="country-name" id="pass31" />
<input autocomplete="postal-code" id="pass32" />
<input autocomplete="CC-name" id="pass33" />
<input autocomplete="section-foo billing cc-given-name" id="pass34" />
<input autocomplete="cc-additional-name" id="pass35" />
<input autocomplete="cc-family-name" id="pass36" />
<input autocomplete="cc-number" id="pass37" />
<input autocomplete="section-foo cc-exp" id="pass38" />
<input autocomplete="shipping CC-Exp-Month" id="pass39" />
<input autocomplete="cc-exp-year" id="pass40" />
<input autocomplete="cc-csc" id="pass41" />
<input autocomplete="section-foo cc-type" id="pass42" />
<input autocomplete="transaction-currency" id="pass43" />
<input autocomplete="billing transaction-amount" id="pass44" />
<input autocomplete="language" id="pass45" />
<input autocomplete="section-foo bday" id="pass46" />
<input autocomplete="bday-day" id="pass47" />
<input autocomplete="bday-month" id="pass48" />
<input autocomplete="section-foo shipping bday-year" id="pass49" />
<input autocomplete="sex" id="pass50" />
<input autocomplete="url" id="pass51" />
<input autocomplete="photo" id="pass52" />
<input autocomplete="section-foo photo" id="pass53" />
<input autocomplete="HOME TEL" id="pass54" />
<input autocomplete="section-foo shipping work tel-country-code" id="pass55" />
<input autocomplete="mobile tel-national" id="pass56" />
<input autocomplete="fax tel-area-code" id="pass57" />
<input autocomplete="pager tel-local" id="pass58" />
<input autocomplete="home tel-local-prefix" id="pass59" />
<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"
id="pass62"
id="pass64"
name="input_1"
placeholder="Numeric Input Field"
value="42"
type="tel"
/>
<input autocomplete="on" id="fail9" value="" type="url" />
<input autocomplete="off" id="pass63" value="42" type="datetime-local" />
<input autocomplete="street-address" id="pass64" type="text" />
<input autocomplete="on" id="fail10" value="" type="url " />
<input autocomplete="off" id="pass78" value="42" type=" DateTime-Local" />

<input autocomplete="tel-country-code" id="pass65" type="tel" />
<input autocomplete="tel-national" id="pass66" type="tel" />
<input autocomplete="tel-area-code" id="pass67" type="tel" />
<input autocomplete="tel-local" id="pass68" type="tel" />
<input autocomplete="tel-local-prefix" id="pass69" type="tel" />
<input autocomplete="tel-local-suffix" id="pass70" type="tel" />
<input autocomplete="tel-extension" id="pass71" type="tel" />

<input autocomplete="one-time-code" id="pass72" />

<input autocomplete="cc-number" type="tel" id="pass73" />
<input autocomplete="cc-exp" type="tel" id="pass74" />
<input autocomplete="cc-exp-month" type="tel" id="pass75" />
<input autocomplete="cc-exp-year" type="tel" id="pass76" />
<input autocomplete="cc-csc" type="tel" id="pass77" />
<input autocomplete="on" id="pass65" value="" type="url" />
<input autocomplete="off" id="pass66" value="42" type="datetime-local" />
<input autocomplete="street-address" id="pass67" type="text" />
<input autocomplete="on" id="pass68" value="" type="url " />
<input autocomplete="off" id="pass69" value="42" type=" DateTime-Local" />

<input autocomplete="tel-country-code" id="pass70" type="tel" />
<input autocomplete="tel-national" id="pass71" type="tel" />
<input autocomplete="tel-area-code" id="pass72" type="tel" />
<input autocomplete="tel-local" id="pass73" type="tel" />
<input autocomplete="tel-local-prefix" id="pass74" type="tel" />
<input autocomplete="tel-local-suffix" id="pass75" type="tel" />
<input autocomplete="tel-extension" id="pass76" type="tel" />

<input autocomplete="one-time-code" id="pass77" />

<input autocomplete="cc-number" type="tel" id="pass78" />
<input autocomplete="cc-exp" type="tel" id="pass79" />
<input autocomplete="cc-exp-month" type="tel" id="pass80" />
<input autocomplete="cc-exp-year" type="tel" id="pass81" />
<input autocomplete="cc-csc" type="tel" id="pass82" />

<!-- Attribute values that contains synonyms of on/off -->
<input autocomplete="none" id="pass78" />
<input autocomplete="false" id="pass79" />
<input autocomplete="true" id="pass80" />
<input autocomplete="disabled" id="pass81" />
<input autocomplete="enabled" id="pass82" />
<input autocomplete="undefined" id="pass83" />
<input autocomplete="null" id="pass84" />
<input autocomplete="none" id="pass84" />
<input autocomplete="false" id="pass85" />
<input autocomplete="true" id="pass86" />
<input autocomplete="disabled" id="pass87" />
<input autocomplete="enabled" id="pass88" />
<input autocomplete="undefined" id="pass89" />
<input autocomplete="null" id="pass90" />
21 changes: 8 additions & 13 deletions test/integration/rules/autocomplete-valid/autocomplete-valid.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
{
"description": "autocomplete-valid tests",
"rule": "autocomplete-valid",
"violations": [
["#fail1"],
["#fail2"],
["#fail3"],
["#fail4"],
["#fail5"],
["#fail6"],
["#fail7"],
["#fail8"],
["#fail9"],
["#fail10"]
],
"violations": [["#fail1"], ["#fail2"], ["#fail3"], ["#fail4"]],
"passes": [
["#pass1"],
["#pass2"],
Expand Down Expand Up @@ -97,6 +86,12 @@
["#pass81"],
["#pass82"],
["#pass83"],
["#pass84"]
["#pass84"],
["#pass85"],
["#pass86"],
["#pass87"],
["#pass88"],
["#pass89"],
["#pass90"]
]
}
4 changes: 2 additions & 2 deletions test/rule-matches/autocomplete-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ describe('autocomplete-matches', function() {
});
});

it('returns true for elements with an empty autocomplete', function() {
it('returns false for elements with an empty autocomplete', function() {
var vNode = queryFixture('<input id="target" autocomplete=" ">');
assert.isTrue(rule.matches(null, vNode));
assert.isFalse(rule.matches(null, vNode));
});

it('returns false for intput[type=hidden]', function() {
Expand Down

0 comments on commit db03143

Please sign in to comment.