AX: [ATK] Do not return ATK_ROLE_UNKNOWN for null or otherwise invalid accessible...
authorjdiggs@igalia.com <jdiggs@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Nov 2014 22:11:41 +0000 (22:11 +0000)
committerjdiggs@igalia.com <jdiggs@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Nov 2014 22:11:41 +0000 (22:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137867

Reviewed by Chris Fleizach.

Source/WebCore:

Return ATK_ROLE_INVALID for null or otherwise invalid accessible objects.

Test: platform/gtk/accessibility/detached-object-role.html

* accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
(webkitAccessibleGetRole):

Tools:

Add ATK_ROLE_INVALID to roleToString. Remove the null AtkRole check in
AccessibilityUIElement::role: ATK_ROLE_INVALID = 0, and we need to be
able to test for the presence of ATK_ROLE_INVALID.

* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::role):

LayoutTests:

* platform/gtk/accessibility/detached-object-role-expected.txt: Added.
* platform/gtk/accessibility/detached-object-role.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176091 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/gtk/accessibility/detached-object-role-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/detached-object-role.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp

index 427685c3e26e3023d3d5675dba9bef63e9178752..a7da83cdbb3e668f0bba5926db66f4eec78b3380 100644 (file)
@@ -1,3 +1,13 @@
+2014-11-13  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: [ATK] Do not return ATK_ROLE_UNKNOWN for null or otherwise invalid accessible objects
+        https://bugs.webkit.org/show_bug.cgi?id=137867
+
+        Reviewed by Chris Fleizach.
+
+        * platform/gtk/accessibility/detached-object-role-expected.txt: Added.
+        * platform/gtk/accessibility/detached-object-role.html: Added.
+
 2014-11-13  Pratik Solanki  <psolanki@apple.com>
 
         Rename ios-sim to ios-sim-deprecated.
 2014-11-13  Pratik Solanki  <psolanki@apple.com>
 
         Rename ios-sim to ios-sim-deprecated.
diff --git a/LayoutTests/platform/gtk/accessibility/detached-object-role-expected.txt b/LayoutTests/platform/gtk/accessibility/detached-object-role-expected.txt
new file mode 100644 (file)
index 0000000..21f7ebd
--- /dev/null
@@ -0,0 +1,11 @@
+This tests that detached accessible objects report the correct role.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS role != detachedRole is true
+AXRole: AXButton AXRole: AXInvalid
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ Button 2
diff --git a/LayoutTests/platform/gtk/accessibility/detached-object-role.html b/LayoutTests/platform/gtk/accessibility/detached-object-role.html
new file mode 100644 (file)
index 0000000..b3160bd
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<button id="button1">Button 1</button>
+<button id="button2">Button 2</button>
+<script>
+description("This tests that detached accessible objects report the correct role.");
+
+if (window.testRunner && window.accessibilityController) {
+    testRunner.dumpAsText();
+
+    var button = document.getElementById('button1');
+    button.focus();
+
+    var axButton = accessibilityController.focusedElement;
+    var role = axButton.role;
+
+    document.body.removeChild(button);
+    var detachedRole = axButton.role;
+    shouldBeTrue("role != detachedRole");
+    debug(role + " " + detachedRole);
+}
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index 8105fa9e5f71f86e201e2e707eacb9016f1f2651..8afddc0a751cfc4b9d1d107f6a164f7259e0f3c5 100644 (file)
@@ -1,3 +1,17 @@
+2014-11-13  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: [ATK] Do not return ATK_ROLE_UNKNOWN for null or otherwise invalid accessible objects
+        https://bugs.webkit.org/show_bug.cgi?id=137867
+
+        Reviewed by Chris Fleizach.
+
+        Return ATK_ROLE_INVALID for null or otherwise invalid accessible objects.
+
+        Test: platform/gtk/accessibility/detached-object-role.html
+
+        * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
+        (webkitAccessibleGetRole):
+
 2014-11-13  Eric Carlson  <eric.carlson@apple.com>
 
         [iOS] update optimized fullscreen media controls artwork
 2014-11-13  Eric Carlson  <eric.carlson@apple.com>
 
         [iOS] update optimized fullscreen media controls artwork
index 0433ce21d04bde7c48dab97357a725dc174724c6..d09392df687c7119a3b58b2cc022fc2e674d6e49 100644 (file)
@@ -751,13 +751,15 @@ static AtkRole atkRole(AccessibilityObject* coreObject)
 
 static AtkRole webkitAccessibleGetRole(AtkObject* object)
 {
 
 static AtkRole webkitAccessibleGetRole(AtkObject* object)
 {
-    g_return_val_if_fail(WEBKIT_IS_ACCESSIBLE(object), ATK_ROLE_UNKNOWN);
-    returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(object), ATK_ROLE_UNKNOWN);
+    // ATK_ROLE_UNKNOWN should only be applied in cases where there is a valid
+    // WebCore accessible object for which the platform role mapping is unknown.
+    g_return_val_if_fail(WEBKIT_IS_ACCESSIBLE(object), ATK_ROLE_INVALID);
+    returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(object), ATK_ROLE_INVALID);
 
     AccessibilityObject* coreObject = core(object);
 
     if (!coreObject)
 
     AccessibilityObject* coreObject = core(object);
 
     if (!coreObject)
-        return ATK_ROLE_UNKNOWN;
+        return ATK_ROLE_INVALID;
 
     // Note: Why doesn't WebCore have a password field for this
     if (coreObject->isPasswordField())
 
     // Note: Why doesn't WebCore have a password field for this
     if (coreObject->isPasswordField())
index 3bfea61792ae349949bf1bb75ef7c744294273c1..48750bb06aac3a13492f8380d67ef3586e425bdb 100644 (file)
@@ -1,3 +1,17 @@
+2014-11-13  Joanmarie Diggs  <jdiggs@igalia.com>
+
+        AX: [ATK] Do not return ATK_ROLE_UNKNOWN for null or otherwise invalid accessible objects
+        https://bugs.webkit.org/show_bug.cgi?id=137867
+
+        Reviewed by Chris Fleizach.
+
+        Add ATK_ROLE_INVALID to roleToString. Remove the null AtkRole check in
+        AccessibilityUIElement::role: ATK_ROLE_INVALID = 0, and we need to be
+        able to test for the presence of ATK_ROLE_INVALID.
+
+        * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
+        (WTR::AccessibilityUIElement::role):
+
 2014-11-13  Juergen Ributzka  <juergen@apple.com>
 
         Update the "combineModules" script to handel more LLVM metadata.
 2014-11-13  Juergen Ributzka  <juergen@apple.com>
 
         Update the "combineModules" script to handel more LLVM metadata.
index 8610a9fd912ea4ad096d643641e0a2ca920956d5..4dc07067bfa38fbc54444c205a8ff83d7284a0ba 100644 (file)
@@ -369,6 +369,8 @@ const gchar* roleToString(AtkObject* object)
         return "AXImage";
     case ATK_ROLE_IMAGE_MAP:
         return "AXImageMap";
         return "AXImage";
     case ATK_ROLE_IMAGE_MAP:
         return "AXImageMap";
+    case ATK_ROLE_INVALID:
+        return "AXInvalid";
     case ATK_ROLE_LABEL:
         return "AXLabel";
     case ATK_ROLE_LINK:
     case ATK_ROLE_LABEL:
         return "AXLabel";
     case ATK_ROLE_LINK:
@@ -1013,9 +1015,6 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::role()
     if (!ATK_IS_OBJECT(m_element.get()))
         return JSStringCreateWithCharacters(0, 0);
 
     if (!ATK_IS_OBJECT(m_element.get()))
         return JSStringCreateWithCharacters(0, 0);
 
-    if (!atk_object_get_role(ATK_OBJECT(m_element.get())))
-        return JSStringCreateWithCharacters(0, 0);
-
     GUniquePtr<char> roleStringWithPrefix(g_strdup_printf("AXRole: %s", roleToString(ATK_OBJECT(m_element.get()))));
     return JSStringCreateWithUTF8CString(roleStringWithPrefix.get());
 }
     GUniquePtr<char> roleStringWithPrefix(g_strdup_printf("AXRole: %s", roleToString(ATK_OBJECT(m_element.get()))));
     return JSStringCreateWithUTF8CString(roleStringWithPrefix.get());
 }