From 9ba2144ef1890b42fb83345e3e81b2da88db837d Mon Sep 17 00:00:00 2001 From: Shunguo Yan Date: Mon, 24 Apr 2023 15:11:49 -0500 Subject: [PATCH 1/5] test cases #1301 --- .../src/v2/aria/ARIADefinitions.ts | 2 +- ...aria_hidden_fail_with_summary_element.html | 2 +- .../summary_element.html | 103 ++++++++++++++++++ 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html diff --git a/accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts b/accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts index c8b040852..b35f3278b 100644 --- a/accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts +++ b/accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts @@ -2087,7 +2087,7 @@ export class ARIADefinitions { globalAriaAttributesValid: true }, "summary": { - implicitRole: ["button"], + implicitRole: null, validRoles: null, globalAriaAttributesValid: true }, diff --git a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_hidden_focus_misuse_ruleunit/act_6cfa84_aria_hidden_fail_with_summary_element.html b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_hidden_focus_misuse_ruleunit/act_6cfa84_aria_hidden_fail_with_summary_element.html index f6ff65ae6..c433b0afe 100644 --- a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_hidden_focus_misuse_ruleunit/act_6cfa84_aria_hidden_fail_with_summary_element.html +++ b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_hidden_focus_misuse_ruleunit/act_6cfa84_aria_hidden_fail_with_summary_element.html @@ -57,7 +57,7 @@ ], "path": { "dom": "/html[1]/body[1]/details[1]/summary[1]", - "aria": "/document[1]/generic[1]/group[1]/button[1]" + "aria": "/document[1]/generic[1]/group[1]" }, "reasonId": "Fail_1", "message": "Element \"summary\" should not be focusable within the subtree of an element with an 'aria-hidden' attribute with value 'true'", diff --git a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html new file mode 100644 index 000000000..f6812537a --- /dev/null +++ b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html @@ -0,0 +1,103 @@ + + + + + + + Element with aria-hidden has no focusable content + + + + + +
+ Overview +
    +
  1. Cash on hand: $500.00
  2. +
  3. Current invoice: $75.30
  4. +
  5. Due date: 5/6/19
  6. +
+
+ + + + + \ No newline at end of file From 845c562d089e5554766635be6c023d5a47440c38 Mon Sep 17 00:00:00 2001 From: Shunguo Yan Date: Wed, 26 Apr 2023 15:35:32 -0500 Subject: [PATCH 2/5] create test cases #1301 --- .../src/v2/aria/ARIADefinitions.ts | 18 +- .../v2/checker/accessibility/util/legacy.ts | 20 +- .../summary_element.html | 541 ++++++++++++++++-- 3 files changed, 511 insertions(+), 68 deletions(-) diff --git a/accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts b/accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts index b35f3278b..dec8e12ea 100644 --- a/accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts +++ b/accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts @@ -2086,11 +2086,6 @@ export class ARIADefinitions { validRoles: ["any"], globalAriaAttributesValid: true }, - "summary": { - implicitRole: null, - validRoles: null, - globalAriaAttributesValid: true - }, "sup": { implicitRole: ["superscript"], validRoles: ["any"], @@ -2504,6 +2499,19 @@ export class ARIADefinitions { otherDisallowedAriaAttributes: ["aria-multiselectable"] } }, + "summary": { + "first-summary-of-detail": { + implicitRole: null, + validRoles: null, + globalAriaAttributesValid: true, + otherAllowedAriaAttributes: ["aria-disabled", "aria-haspopup"] + }, + "not-first-summary-of-detail": { + implicitRole: null, + validRoles: ["any"], + globalAriaAttributesValid: true + } + }, "tbody": { "des-table": { implicitRole: ["rowgroup"], diff --git a/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts b/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts index 52cb64af6..97f080380 100644 --- a/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts +++ b/accessibility-checker-engine/src/v2/checker/accessibility/util/legacy.ts @@ -21,6 +21,7 @@ import { DOMWalker } from "../../../dom/DOMWalker"; import { VisUtil } from "../../../dom/VisUtil"; import { FragmentUtil } from "./fragment"; import { getDefinedStyles } from "../../../../v4/util/CSSUtil"; +import { DOMUtil } from "../../../dom/DOMUtil"; export class RPTUtil { @@ -376,7 +377,15 @@ export class RPTUtil { "video": function (element) { return element.hasAttribute("controls"); }, - "summary": true + "summary": function (element) { + // first summary child of a details element is automatically focusable + return element.parentElement && element.parentElement.nodeName.toLowerCase() === 'details' + && DOMUtil.sameNode([...element.parentElement.children].filter(elem=>elem.nodeName.toLowerCase() === 'summary')[0], element); + }, + "details": function (element) { + //details element without a direct summary child is automatically focusable + return element.children && [...element.children].filter(elem=>elem.nodeName.toLowerCase() === 'summary').length === 0; + } } public static wordCount(str) : number { @@ -2559,6 +2568,15 @@ export class RPTUtil { else tagProperty = specialTagProperties["no-multiple-attr-size-gt1"]; break; + case "summary": + specialTagProperties = ARIADefinitions.documentConformanceRequirementSpecialTags["summary"]; + + if (ruleContext.parentElement && ruleContext.parentElement.nodeName.toLowerCase() === 'details' + && DOMUtil.sameNode([...ruleContext.parentElement.children].filter(elem=>elem.nodeName.toLowerCase() === 'summary')[0], ruleContext)) + tagProperty = specialTagProperties["first-summary-of-detail"]; + else + tagProperty = specialTagProperties["no-first-summary-of-detail"]; + break; case "tbody": case "td": case "tr": diff --git a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html index f6812537a..b536d21aa 100644 --- a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html +++ b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html @@ -26,75 +26,492 @@ -
- Overview + + -
    -
  • li element
  • -
+ Third summary +
+ + + + + + + From 476bf68faf93df9c35cf34a5a9241539947cb100 Mon Sep 17 00:00:00 2001 From: Shunguo Yan Date: Fri, 28 Apr 2023 13:28:54 -0500 Subject: [PATCH 3/5] update role support #1301 --- .gitignore | 1 + .../summary_element_hidden.html | 520 ++++++++++++++++++ .../summary_element.html | 24 +- 3 files changed, 531 insertions(+), 14 deletions(-) create mode 100644 accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_hidden_focus_misuse_ruleunit/summary_element_hidden.html diff --git a/.gitignore b/.gitignore index deec545a3..c2abf9ca0 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ jspm_packages .gz .tar accessibility-checker-engine/karma.conf.js +karma-accessibility-checker/package.json diff --git a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_hidden_focus_misuse_ruleunit/summary_element_hidden.html b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_hidden_focus_misuse_ruleunit/summary_element_hidden.html new file mode 100644 index 000000000..b536d21aa --- /dev/null +++ b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_hidden_focus_misuse_ruleunit/summary_element_hidden.html @@ -0,0 +1,520 @@ + + + + + + + Element with aria-hidden has no focusable content + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html index b536d21aa..e472d0c31 100644 --- a/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html +++ b/accessibility-checker-engine/test/v2/checker/accessibility/rules/aria_semantics_role_ruleunit/summary_element.html @@ -20,35 +20,35 @@ - Element with aria-hidden has no focusable content + Summary Element -