From 2b98639c1367f85365fef88c2ba41ae5f19dfd66 Mon Sep 17 00:00:00 2001 From: Ilia Kebets <104737176+ilia-kebets-sonarsource@users.noreply.github.com> Date: Mon, 25 Mar 2024 15:45:00 +0100 Subject: [PATCH] Fix S6793: `aria-haspopup` must accept values beyond boolean (#294) --- .../org/sonar/plugins/html/api/accessibility/Aria.java | 2 +- .../html/checks/accessibility/AriaProptypesCheckTest.java | 8 ++++---- .../src/test/resources/checks/AriaProptypesCheck.html | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sonar-html-plugin/src/main/java/org/sonar/plugins/html/api/accessibility/Aria.java b/sonar-html-plugin/src/main/java/org/sonar/plugins/html/api/accessibility/Aria.java index 2f9d7b16e..749311704 100644 --- a/sonar-html-plugin/src/main/java/org/sonar/plugins/html/api/accessibility/Aria.java +++ b/sonar-html-plugin/src/main/java/org/sonar/plugins/html/api/accessibility/Aria.java @@ -48,7 +48,7 @@ public class Aria { ARIA_PROPERTIES.put("aria-expanded", new AriaProperty("aria-expanded", AriaPropertyType.BOOLEAN, true, "true", "false")); ARIA_PROPERTIES.put("aria-flowto", new AriaProperty("aria-flowto", AriaPropertyType.IDLIST)); ARIA_PROPERTIES.put("aria-grabbed", new AriaProperty("aria-grabbed", AriaPropertyType.BOOLEAN, true, "true", "false", "undefined")); - ARIA_PROPERTIES.put("aria-haspopup", new AriaProperty("aria-haspopup", AriaPropertyType.BOOLEAN, true, "true", "false", "menu", "listbox", "tree", "grid", "dialog")); + ARIA_PROPERTIES.put("aria-haspopup", new AriaProperty("aria-haspopup", AriaPropertyType.TOKEN, true, "true", "false", "menu", "listbox", "tree", "grid", "dialog")); ARIA_PROPERTIES.put("aria-hidden", new AriaProperty("aria-hidden", AriaPropertyType.BOOLEAN, true, "true", "false")); ARIA_PROPERTIES.put("aria-invalid", new AriaProperty("aria-invalid", AriaPropertyType.TOKEN, "true", "false", "grammar", "spelling")); ARIA_PROPERTIES.put("aria-keyshortcuts", new AriaProperty("aria-keyshortcuts", AriaPropertyType.STRING)); diff --git a/sonar-html-plugin/src/test/java/org/sonar/plugins/html/checks/accessibility/AriaProptypesCheckTest.java b/sonar-html-plugin/src/test/java/org/sonar/plugins/html/checks/accessibility/AriaProptypesCheckTest.java index 2f578aa88..84c4dd634 100644 --- a/sonar-html-plugin/src/test/java/org/sonar/plugins/html/checks/accessibility/AriaProptypesCheckTest.java +++ b/sonar-html-plugin/src/test/java/org/sonar/plugins/html/checks/accessibility/AriaProptypesCheckTest.java @@ -42,11 +42,11 @@ void html() throws Exception { .next().atLine(20).withMessage("The value of the attribute \"aria-checked\" must be a boolean or the string \"mixed\".") .next().atLine(26).withMessage("The value of the attribute \"aria-valuemax\" must be a number.") .next().atLine(32).withMessage("The value of the attribute \"aria-posinset\" must be a integer.") - .next().atLine(37) - .next().atLine(42) + .next().atLine(38) .next().atLine(43) - .next().atLine(48).withMessage("The value of the attribute \"aria-controls\" must be a list of strings that represent DOM element IDs (idlist).") - .next().atLine(52).withMessage("The value of the attribute \"aria-details\" must be a string that represents a DOM element ID.") + .next().atLine(44) + .next().atLine(49).withMessage("The value of the attribute \"aria-controls\" must be a list of strings that represent DOM element IDs (idlist).") + .next().atLine(53).withMessage("The value of the attribute \"aria-details\" must be a string that represents a DOM element ID.") .noMore(); } } diff --git a/sonar-html-plugin/src/test/resources/checks/AriaProptypesCheck.html b/sonar-html-plugin/src/test/resources/checks/AriaProptypesCheck.html index aceccd232..4f42798e1 100644 --- a/sonar-html-plugin/src/test/resources/checks/AriaProptypesCheck.html +++ b/sonar-html-plugin/src/test/resources/checks/AriaProptypesCheck.html @@ -32,6 +32,7 @@
+