From 695ce3763e271502537130f4073afa9b7ba0a034 Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Fri, 20 Dec 2024 15:16:42 +0900 Subject: [PATCH] =?UTF-8?q?LibWeb:=20Replace=20ARIA=20=E2=80=9Csynonym?= =?UTF-8?q?=E2=80=9D=20roles=20with=20their=20preferred=20synonyms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change does replacement of ARIA roles that have newer synonyms. There are a number of newer ARIA roles that are synonyms for older roles. https://wpt.fyi/results/wai-aria/role/synonym-roles.html has a number of subtests which expect that when retrieving the value of an explicitly- specified role attribute, if the value is one of the older role values, implementations must replace that with its newer synonym. --- Libraries/LibWeb/ARIA/ARIAMixin.cpp | 14 ++++++++ .../wai-aria/role/synonym-roles.txt | 12 +++++++ .../wai-aria/role/synonym-roles.html | 34 +++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/wai-aria/role/synonym-roles.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/wai-aria/role/synonym-roles.html diff --git a/Libraries/LibWeb/ARIA/ARIAMixin.cpp b/Libraries/LibWeb/ARIA/ARIAMixin.cpp index 8d03486d394..73c64b2897e 100644 --- a/Libraries/LibWeb/ARIA/ARIAMixin.cpp +++ b/Libraries/LibWeb/ARIA/ARIAMixin.cpp @@ -28,6 +28,20 @@ Optional ARIAMixin::role_from_role_attribute_value() const auto role = role_from_string(role_name); if (!role.has_value()) continue; + // NOTE: Per https://w3c.github.io/aria/#directory, "Authors are advised to treat directory as deprecated and to + // use 'list'." Further, the "directory role == computedrole list" and "div w/directory role == computedrole + // list" tests in https://wpt.fyi/results/wai-aria/role/synonym-roles.html expect "list", not "directory". + if (role == Role::directory) + return Role::list; + // NOTE: The "image" role value is a synonym for the older "img" role value; however, the "synonym img role == + // computedrole image" test in https://wpt.fyi/results/wai-aria/role/synonym-roles.html expects "image", not "img". + if (role == Role::img) + return Role::image; + // NOTE: Per https://w3c.github.io/aria/#presentation, "the working group introduced none as the preferred + // synonym to the presentation role"; further, https://wpt.fyi/results/wai-aria/role/synonym-roles.html has a + // "synonym presentation role == computedrole none" test that expects "none", not "presentation". + if (role == Role::presentation) + return Role::none; if (!is_abstract_role(*role)) return *role; } diff --git a/Tests/LibWeb/Text/expected/wpt-import/wai-aria/role/synonym-roles.txt b/Tests/LibWeb/Text/expected/wpt-import/wai-aria/role/synonym-roles.txt new file mode 100644 index 00000000000..636d204d2a5 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/wai-aria/role/synonym-roles.txt @@ -0,0 +1,12 @@ +Harness status: OK + +Found 7 tests + +7 Pass +Pass image role == computedrole image +Pass synonym img role == computedrole image +Pass list role == computedrole list +Pass directory role == computedrole list +Pass div w/directory role == computedrole list +Pass none role == computedrole none +Pass synonym presentation role == computedrole none \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/wai-aria/role/synonym-roles.html b/Tests/LibWeb/Text/input/wpt-import/wai-aria/role/synonym-roles.html new file mode 100644 index 00000000000..44eaaa9a7c4 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/wai-aria/role/synonym-roles.html @@ -0,0 +1,34 @@ + + + + Region Role Verification Tests + + + + + + + + + +

Tests synonym roles image/img and none/presentation via Core-AAM Computed Role.

+ + + +
x
+ + +
x
+ + + + + +
x
+ + + + \ No newline at end of file