Jelajahi Sumber

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

sideshowbarker 6 bulan lalu
induk
melakukan
ce65457746

+ 1 - 1
Libraries/LibWeb/ARIA/ARIAMixin.cpp

@@ -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;
     }
 

+ 0 - 9
Libraries/LibWeb/ARIA/Roles.cpp

@@ -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)
 {

+ 0 - 1
Libraries/LibWeb/ARIA/Roles.h

@@ -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);
 
 }

+ 7 - 0
Tests/LibWeb/Text/expected/wpt-import/wai-aria/role/contextual-roles.tentative.txt

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

+ 7 - 0
Tests/LibWeb/Text/expected/wpt-import/wai-aria/role/roles.tentative.txt

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

+ 30 - 0
Tests/LibWeb/Text/input/wpt-import/wai-aria/role/contextual-roles.tentative.html

@@ -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>

+ 31 - 0
Tests/LibWeb/Text/input/wpt-import/wai-aria/role/roles.tentative.html

@@ -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>