LibWeb: Fix internal logic for recognizing non-abstract ARIA roles

This commit is contained in:
sideshowbarker 2024-12-18 22:18:01 +09:00 committed by Sam Atkins
parent af3d46dc06
commit ce65457746
Notes: github-actions[bot] 2024-12-18 15:25:50 +00:00
7 changed files with 76 additions and 11 deletions

View file

@ -28,7 +28,7 @@ Optional<Role> ARIAMixin::role_from_role_attribute_value() const
auto role = role_from_string(role_name);
if (!role.has_value())
continue;
if (is_non_abstract_role(*role))
if (!is_abstract_role(*role))
return *role;
}

View file

@ -173,15 +173,6 @@ bool is_windows_role(Role role)
Role::dialog);
}
bool is_non_abstract_role(Role role)
{
return is_widget_role(role)
|| is_document_structure_role(role)
|| is_landmark_role(role)
|| is_live_region_role(role)
|| is_windows_role(role);
}
// https://www.w3.org/TR/wai-aria-1.2/#namefromcontent
bool allows_name_from_content(Role role)
{

View file

@ -128,7 +128,6 @@ bool is_landmark_role(Role);
bool is_live_region_role(Role);
bool is_windows_role(Role);
bool is_non_abstract_role(Role);
bool allows_name_from_content(Role);
}

View file

@ -0,0 +1,7 @@
Harness status: OK
Found 2 tests
2 Pass
Pass role is sectionfooter (in main)
Pass role is sectionheader (in main)

View file

@ -0,0 +1,7 @@
Harness status: OK
Found 2 tests
2 Pass
Pass role: sectionheader
Pass role: sectionfooter

View file

@ -0,0 +1,30 @@
<!doctype html>
<html>
<head>
<title>Tentative: Contextual Role Verification Tests</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/testdriver.js"></script>
<script src="../../resources/testdriver-vendor.js"></script>
<script src="../../resources/testdriver-actions.js"></script>
<script src="../../wai-aria/scripts/aria-utils.js"></script>
</head>
<body>
<!--
New sectionheader and sectionfooter roles.
See https://github.com/w3c/aria/pull/1931
-->
<main>
<div role="sectionfooter" data-testname="role is sectionfooter (in main)" data-expectedrole="sectionfooter" class="ex">x</div>
</main>
<main>
<div role="sectionheader" data-testname="role is sectionheader (in main)" data-expectedrole="sectionheader" class="ex">x</div>
</main>
<script>
AriaUtils.verifyRolesBySelector(".ex");
</script>
</body>
</html>

View file

@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<title>New Core ARIA Role Verification Tests</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/testdriver.js"></script>
<script src="../../resources/testdriver-vendor.js"></script>
<script src="../../resources/testdriver-actions.js"></script>
<script src="../../wai-aria/scripts/aria-utils.js"></script>
</head>
<body>
<p>Tests new <a href="https://w3c.github.io/aria/#role_definitions">ARIA role definitions</a>. See comments for more info.</p>
<script>
/*
Tests simple role assignment: <div role="alert">x</div>
*/
AriaUtils.assignAndVerifyRolesByRoleNames([
"sectionheader", // See ARIA pull #1931
"sectionfooter", // See ARIA pull #1931
]);
</script>
</body>
</html>