Skip to content

feat(wcag): add accessible-authentication rule for wcag 2.2#5046

Open
devansh0703 wants to merge 2 commits intodequelabs:developfrom
devansh0703:feat/accessible-authentication-wcag22
Open

feat(wcag): add accessible-authentication rule for wcag 2.2#5046
devansh0703 wants to merge 2 commits intodequelabs:developfrom
devansh0703:feat/accessible-authentication-wcag22

Conversation

@devansh0703
Copy link
Copy Markdown

Summary

Add a new WCAG 2.2 rule, accessible-authentication, for password inputs with valid autocomplete tokens.

Changes

  • Add new rule/check: accessible-authentication
  • Add evaluate logic for current-password / new-password
  • Add unit tests (including Shadow DOM and multi-token cases)
  • Add integration test HTML/JSON fixtures
  • Update locales/_template.json, doc/rule-descriptions.md, and CHANGELOG.md

Testing

  • npm run fmt
  • npm run eslint
  • npm run build
  • npm run test:unit -- testFiles=lib/checks/forms/accessible-authentication-evaluate.js,test/integration/rules/accessible-authentication/accessible-authentication.json

Notes

  • Rule is part of WCAG 2.2 set and is disabled by default.
  • Existing unrelated baseline failure remains in full npm test (color-contrast).

Add a new accessible-authentication rule and check, with unit and integration tests, locale template messages, and rule docs updates.\n\nInclude shadow DOM coverage in check tests and update changelog for submission readiness.
@devansh0703 devansh0703 requested a review from a team as a code owner March 29, 2026 13:01
Copilot AI review requested due to automatic review settings March 29, 2026 13:01
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 29, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new WCAG 2.2 rule/check (accessible-authentication) intended to validate autocomplete tokens on password inputs, with supporting unit + integration fixtures and documentation/localization updates.

Changes:

  • Introduces accessible-authentication rule definition + check evaluate logic for current-password / new-password.
  • Adds unit tests and integration HTML/JSON fixtures (including multi-token and Shadow DOM scenarios).
  • Updates locale template strings, rule descriptions documentation, changelog, and lockfile.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/rules/accessible-authentication.json New WCAG 2.2 rule definition for password inputs
lib/checks/forms/accessible-authentication.json New check metadata/messages for the rule
lib/checks/forms/accessible-authentication-evaluate.js Evaluate logic for parsing autocomplete tokens
test/checks/forms/accessible-authentication.js Unit tests for the new check
test/integration/rules/accessible-authentication/accessible-authentication.html Integration fixture HTML (includes Shadow DOM input)
test/integration/rules/accessible-authentication/accessible-authentication.json Expected integration results for the fixture
locales/_template.json Adds rule description/help + check pass/fail/incomplete strings
doc/rule-descriptions.md Adds rule to the WCAG 2.2 rules table
CHANGELOG.md Adds Unreleased feature entry for the new rule
package-lock.json Updates lockfile entries (incl. chromedriver spec sync)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +6
{
"id": "accessible-authentication",
"impact": "serious",
"selector": "input[type=\"password\"]",
"tags": ["cat.forms", "wcag22aa", "wcag337"],
"metadata": {
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessible-authentication is intended to be disabled by default per the WCAG 2.2 section and this PR’s description, but this rule JSON does not set "enabled": false. As a result, the rule will run by default, unlike target-size (see lib/rules/target-size.json). Add "enabled": false to keep WCAG 2.2 rules opt-in.

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +27
const autocomplete = virtualNode.attr('autocomplete');
if (!autocomplete) {
return undefined;
}

const tokens = String(autocomplete).toLowerCase().split(/\s+/);
const isValid =
tokens.includes('current-password') || tokens.includes('new-password');

if (isValid) {
return true;
}
return undefined;
}
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check never returns false (it only returns true or undefined), which makes the fail message unreachable and prevents the rule from ever producing a violation—even when autocomplete is present but not one of the supported password tokens. If failures are intended, return false for invalid/missing tokens; if not, remove the fail message (and consider updating the rule description/Issue Type accordingly) to avoid dead/unused metadata.

Copilot uses AI. Check for mistakes.
"description": "accessible-authentication tests",
"rule": "accessible-authentication",
"violations": [],
"passes": [["#pass1"], ["#pass2"], ["#pass3"]],
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HTML fixture includes a shadow-DOM password input with id="pass-shadow", but the expected results don’t include it. Since axe’s flattened-tree querying supports shadow DOM, this test will likely miss an expected pass (typically represented as a selector stack like ["#shadow-host", "#pass-shadow"]). Add the shadow input to passes (or remove it from the fixture if it’s not meant to be asserted).

Suggested change
"passes": [["#pass1"], ["#pass2"], ["#pass3"]],
"passes": [["#pass1"], ["#pass2"], ["#pass3"], ["#shadow-host", "#pass-shadow"]],

Copilot uses AI. Check for mistakes.
Set accessible-authentication as opt-in by default to match WCAG 2.2 rule handling.\n\nReturn false for invalid autocomplete tokens so fail messaging and violations are reachable, while keeping missing autocomplete as incomplete.\n\nUpdate unit and integration tests to reflect the revised pass/violation/incomplete outcomes.
Copy link
Copy Markdown
Contributor

@WilcoFiers WilcoFiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing whether password fields have autocomplete has very little to do with 3.3.8 Accessible Authentication. Instead of opening a pull request can you open an issue to propose what you had in mind so that it can be discussed first?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants