AX: aria-required is not exposed on all expected roles
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jun 2013 16:08:05 +0000 (16:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jun 2013 16:08:05 +0000 (16:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=115123

Patch by James Craig <james@cookiecrook.com> on 2013-06-20
Reviewed by Chris Fleizach.

aria-required is now exposed on more roles. Updated existing test file.

Source/WebCore:

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::supportsRequiredAttribute):
* accessibility/AccessibilityNodeObject.h:
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::supportsRequiredAttribute):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):

LayoutTests:

* platform/mac/accessibility/aria-required-expected.txt:
* platform/mac/accessibility/aria-required.html:
* platform/mac/accessibility/radio-button-group-members-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/aria-required-expected.txt
LayoutTests/platform/mac/accessibility/aria-required.html
LayoutTests/platform/mac/accessibility/radio-button-group-members-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityNodeObject.h
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

index 5a99a4b..7c91b67 100644 (file)
@@ -1,3 +1,16 @@
+2013-06-20  James Craig  <james@cookiecrook.com>
+
+        AX: aria-required is not exposed on all expected roles
+        https://bugs.webkit.org/show_bug.cgi?id=115123
+
+        Reviewed by Chris Fleizach.
+
+        aria-required is now exposed on more roles. Updated existing test file.
+
+        * platform/mac/accessibility/aria-required-expected.txt:
+        * platform/mac/accessibility/aria-required.html:
+        * platform/mac/accessibility/radio-button-group-members-expected.txt:
+
 2013-06-20  Seokju Kwon  <seokju.kwon@gmail.com>
 
         Web Inspector: Use console.timeStamp instead of console.markTimeline
index 103dce3..1492f47 100644 (file)
@@ -7,6 +7,18 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS succeeded is true
 PASS succeeded is true
 PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
+PASS succeeded is true
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 572b37f..5327e37 100644 (file)
@@ -9,6 +9,26 @@
 <input type="text" aria-required="false" id="textfield2">
 <input type="text" id="textfield3">
 
+<div id="toBeHidden">
+
+  <div tabindex="0" aria-required="true" role="listbox" id="lb1">text</div>
+  <div tabindex="0" aria-required="false" role="listbox" id="lb2">text</div>
+  <div tabindex="0" role="listbox" id="lb3">text</div>
+
+  <div tabindex="0" aria-required="true" role="radiogroup" id="rg1">text</div>
+  <div tabindex="0" aria-required="false" role="radiogroup" id="rg2">text</div>
+  <div tabindex="0" role="radiogroup" id="rg3">text</div>
+
+  <div tabindex="0" aria-required="true" role="spinbutton" id="sb1">text</div>
+  <div tabindex="0" aria-required="false" role="spinbutton" id="sb2">text</div>
+  <div tabindex="0" role="spinbutton" id="sb3">text</div>
+
+  <div tabindex="0" aria-required="true" role="tree" id="t1">text</div>
+  <div tabindex="0" aria-required="false" role="tree" id="t2">text</div>
+  <div tabindex="0" role="tree" id="t3">text</div>
+
+</div>
+
 <p id="description"></p>
 <div id="console"></div>
 
 
     description("This tests that aria-required is a usable attribute.");
 
+    function $(id){
+      return document.getElementById(id);
+    }
+
     if (window.accessibilityController) {
 
-          // this text field should be required.
-          document.getElementById("textfield1").focus();
-          var obj = accessibilityController.focusedElement;
+          var succeeded = false;
 
-          var succeeded = obj.isRequired;
+          // textfield 1 is required
+          $("textfield1").focus();
+          succeeded = accessibilityController.focusedElement.isRequired;
+          shouldBe("succeeded", "true");
+          // textfield 2 and 3 are not required
+          $("textfield2").focus();
+          succeeded = !(accessibilityController.focusedElement.isRequired);
+          shouldBe("succeeded", "true");
+          $("textfield3").focus();
+          succeeded = !(accessibilityController.focusedElement.isRequired);
           shouldBe("succeeded", "true");
 
-          // this text field should not be required
-          document.getElementById("textfield2").focus();
-          var obj = accessibilityController.focusedElement;
+          // listbox 1 is required
+          $("lb1").focus();
+          succeeded = accessibilityController.focusedElement.isRequired;
+          shouldBe("succeeded", "true");
+          // listbox 2 and 3 are not required
+          $("lb2").focus();
+          succeeded = !(accessibilityController.focusedElement.isRequired);
+          shouldBe("succeeded", "true");
+          $("lb3").focus();
+          succeeded = !(accessibilityController.focusedElement.isRequired);
+          shouldBe("succeeded", "true");
 
-          var succeeded = !obj.isRequired;
+          // radiogroup 1 is required
+          $("rg1").focus();
+          succeeded = accessibilityController.focusedElement.isRequired;
+          shouldBe("succeeded", "true");
+          // radiogroup 2 and 3 are not required
+          $("rg2").focus();
+          succeeded = !(accessibilityController.focusedElement.isRequired);
+          shouldBe("succeeded", "true");
+          $("rg3").focus();
+          succeeded = !(accessibilityController.focusedElement.isRequired);
           shouldBe("succeeded", "true");
 
-          // this text field should not be required
-          document.getElementById("textfield3").focus();
-          var obj = accessibilityController.focusedElement;
+          // spinbutton 1 is required
+          $("sb1").focus();
+          succeeded = accessibilityController.focusedElement.isRequired;
+          shouldBe("succeeded", "true");
+          // spinbutton 2 and 3 are not required
+          $("sb2").focus();
+          succeeded = !(accessibilityController.focusedElement.isRequired);
+          shouldBe("succeeded", "true");
+          $("sb3").focus();
+          succeeded = !(accessibilityController.focusedElement.isRequired);
+          shouldBe("succeeded", "true");
 
-          var succeeded = !obj.isRequired;
+          // tree 1 is required
+          $("t1").focus();
+          succeeded = accessibilityController.focusedElement.isRequired;
+          shouldBe("succeeded", "true");
+          // tree 2 and 3 are not required
+          $("t2").focus();
+          succeeded = !(accessibilityController.focusedElement.isRequired);
+          shouldBe("succeeded", "true");
+          $("t3").focus();
+          succeeded = !(accessibilityController.focusedElement.isRequired);
           shouldBe("succeeded", "true");
+
     }
 
+    $('toBeHidden').hidden = true; // hide this to avoid text diffs when adding more elements to the test
+
 </script>
 
 <script src="../../../fast/js/resources/js-test-post.js"></script>
index 9208c1d..4189ff4 100644 (file)
@@ -26,6 +26,7 @@ AXAccessKey: (null)
 AXRequired: 0
 AXInvalid: false
 AXARIABusy: 0
+AXRequired: 0
 
 ------------
 AXRole: AXRadioButton
@@ -54,6 +55,7 @@ AXAccessKey: (null)
 AXRequired: 0
 AXInvalid: false
 AXARIABusy: 0
+AXRequired: 0
 
 ------------
 AXRole: AXRadioButton
@@ -82,6 +84,7 @@ AXAccessKey: (null)
 AXRequired: 0
 AXInvalid: false
 AXARIABusy: 0
+AXRequired: 0
 
 ------------
 
@@ -114,6 +117,7 @@ AXAccessKey: (null)
 AXRequired: 0
 AXInvalid: false
 AXARIABusy: 0
+AXRequired: 0
 
 ------------
 AXRole: AXRadioButton
@@ -142,6 +146,7 @@ AXAccessKey: (null)
 AXRequired: 0
 AXInvalid: false
 AXARIABusy: 0
+AXRequired: 0
 
 ------------
 
@@ -174,6 +179,7 @@ AXAccessKey: (null)
 AXRequired: 0
 AXInvalid: false
 AXARIABusy: 0
+AXRequired: 0
 
 ------------
 AXRole: AXRadioButton
@@ -202,6 +208,7 @@ AXAccessKey: (null)
 AXRequired: 0
 AXInvalid: false
 AXARIABusy: 0
+AXRequired: 0
 
 ------------
 
@@ -234,6 +241,7 @@ AXAccessKey: (null)
 AXRequired: 0
 AXInvalid: false
 AXARIABusy: 0
+AXRequired: 0
 
 ------------
 
index b3dbe60..e0bc620 100644 (file)
@@ -1,3 +1,20 @@
+2013-06-20  James Craig  <james@cookiecrook.com>
+
+        AX: aria-required is not exposed on all expected roles
+        https://bugs.webkit.org/show_bug.cgi?id=115123
+
+        Reviewed by Chris Fleizach.
+
+        aria-required is now exposed on more roles. Updated existing test file.
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::supportsRequiredAttribute):
+        * accessibility/AccessibilityNodeObject.h:
+        * accessibility/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::supportsRequiredAttribute):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
+
 2013-06-20  Seokju Kwon  <seokju.kwon@gmail.com>
 
         Web Inspector: Use console.timeStamp instead of console.markTimeline
index 044d2c3..689d692 100644 (file)
@@ -718,6 +718,30 @@ bool AccessibilityNodeObject::isRequired() const
     return false;
 }
 
+bool AccessibilityNodeObject::supportsRequiredAttribute() const
+{
+    switch (roleValue()) {
+    case CheckBoxRole:
+    case ComboBoxRole:
+    case GridRole:
+    case IncrementorRole:
+    case ListBoxRole:
+    case PopUpButtonRole:
+    case RadioButtonRole:
+    case RadioGroupRole:
+    case RowHeaderRole:
+    case SliderRole:
+    case SpinButtonRole:
+    case TableHeaderContainerRole:
+    case TextAreaRole:
+    case TextFieldRole:
+    case ToggleButtonRole:
+        return true;
+    default:
+        return false;
+    }
+}
+
 int AccessibilityNodeObject::headingLevel() const
 {
     // headings can be in block flow and non-block flow
index a7756e6..dd224cd 100644 (file)
@@ -98,6 +98,7 @@ public:
     virtual bool isPressed() const;
     virtual bool isReadOnly() const;
     virtual bool isRequired() const;
+    virtual bool supportsRequiredAttribute() const;
 
     void setNode(Node*);
     virtual Node* node() const { return m_node; }
index 8348a83..44873a0 100644 (file)
@@ -467,6 +467,7 @@ public:
     virtual bool isUnvisited() const { return false; }
     virtual bool isVisited() const { return false; }
     virtual bool isRequired() const { return false; }
+    virtual bool supportsRequiredAttribute() const { return false; }
     virtual bool isLinked() const { return false; }
     virtual bool isExpanded() const;
     virtual bool isVisible() const { return true; }
index e951852..2e5928b 100644 (file)
@@ -1015,9 +1015,12 @@ static id textMarkerRangeFromVisiblePositions(AXObjectCache *cache, VisiblePosit
     // All objects should expose the ARIA busy attribute (ARIA 1.1 with ISSUE-538).
     [additional addObject:NSAccessibilityARIABusyAttribute];
     
-    // Popup buttons on the Mac expose the required and value attributes.
+    // Popup buttons on the Mac expose the value attribute.
     if (m_object->isPopUpButton()) {
         [additional addObject:NSAccessibilityValueAttribute];
+    }
+
+    if (m_object->supportsRequiredAttribute()) {
         [additional addObject:NSAccessibilityRequiredAttribute];
     }