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