<https://webkit.org/b/118754> AX: aria-required.html needs to test @required vs ...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Aug 2013 00:53:03 +0000 (00:53 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Aug 2013 00:53:03 +0000 (00:53 +0000)
Patch by James Craig <james@cookiecrook.com> on 2013-08-19
Reviewed by Chris Fleizach.

More thorough testing of @required and @aria-required, especially regarding conflict resolution.
Found https://webkit.org/b/119988 as a result of the updated test.

* accessibility/aria-required-expected.txt:
* accessibility/aria-required.html:

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

LayoutTests/ChangeLog
LayoutTests/accessibility/aria-required-expected.txt
LayoutTests/accessibility/aria-required.html

index b694948..6084731 100644 (file)
@@ -1,3 +1,15 @@
+2013-08-19  James Craig  <james@cookiecrook.com>
+
+        <https://webkit.org/b/118754> AX: aria-required.html needs to test @required vs @aria-required mismatch reconciliation
+
+        Reviewed by Chris Fleizach.
+
+        More thorough testing of @required and @aria-required, especially regarding conflict resolution.
+        Found https://webkit.org/b/119988 as a result of the updated test.
+
+        * accessibility/aria-required-expected.txt:
+        * accessibility/aria-required.html:
+
 2013-08-19  Ryosuke Niwa  <rniwa@webkit.org>
 
         <https://webkit.org/b/119930> input[type=range]: Fix a crash by changing input type in 'input' event handler
index 1492f47..63e28bf 100644 (file)
@@ -1,24 +1,42 @@
-  
 This tests that aria-required is a usable attribute.
 
 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
+Elements to test: 32
+
+PASS textfield isRequired is false
+PASS textfield_required isRequired is true
+PASS textfield_required_ariarequired isRequired is true
+PASS textfield_ariarequiredfalse isRequired is false
+PASS textfield5 isRequired is true
+PASS checkbox isRequired is false
+PASS checkbox_required isRequired is true
+PASS checkbox_required_ariarequired isRequired is true
+PASS checkbox_ariarequiredfalse isRequired is false
+PASS checkbox_required_ariarequiredfalse isRequired is true
+PASS select isRequired is false
+PASS select_required isRequired is true
+PASS select_required_ariarequired isRequired is true
+PASS select_ariarequiredfalse isRequired is false
+PASS select_required_ariarequiredfalse isRequired is true
+PASS textarea isRequired is false
+PASS textarea_required isRequired is true
+PASS textarea_required_ariarequired isRequired is true
+PASS textarea_ariarequiredfalse isRequired is false
+PASS textarea_required_ariarequiredfalse isRequired is true
+PASS listbox_ariarequiredtrue isRequired is true
+PASS listbox_ariarequiredfalse isRequired is false
+PASS listbox isRequired is false
+PASS radiogroup_ariarequiredtrue isRequired is true
+PASS radiogroup_ariarequiredfalse isRequired is false
+PASS radiogroup isRequired is false
+PASS spinbutton_ariarequiredtrue isRequired is true
+PASS spinbutton_ariarequiredfalse isRequired is false
+PASS spinbutton isRequired is false
+PASS tree_ariarequiredtrue isRequired is true
+PASS tree_ariarequiredfalse isRequired is false
+PASS tree isRequired is false
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 282c86d..535e27d 100644 (file)
@@ -5,27 +5,73 @@
 </head>
 <body id="body">
 
-<input type="text" aria-required="true" id="textfield1">
-<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>
+  <!-- textfields -->
+  <input type="text" id="textfield" data-expectedrequired="false">
+  <input type="text" id="textfield_required" required data-expectedrequired="true">
+  <input type="text" required aria-required="true" id="textfield_required_ariarequired" data-expectedrequired="true">
+  <input type="text" aria-required="false" id="textfield_ariarequiredfalse" data-expectedrequired="false">
+  <!-- these last ones conflict with implicit value of @required, so host language attr should win -->
+  <input type="text" aria-required="textfield_required_ariarequiredfalse" required id="textfield5" data-expectedrequired="true">
+  <!-- BLOCKED by http://webkit.org/b/119988
+  <input type="text" aria-required="true" id="textfield_requiredfalse_ariarequiredtrue" data-expectedrequired="false">
+  -->
+
+
+  <!-- checkboxes -->
+  <input type="checkbox" id="checkbox" data-expectedrequired="false">
+  <input type="checkbox" id="checkbox_required" required data-expectedrequired="true">
+  <input type="checkbox" required aria-required="true" id="checkbox_required_ariarequired" data-expectedrequired="true">
+  <input type="checkbox" aria-required="false" id="checkbox_ariarequiredfalse" data-expectedrequired="false">
+  <!-- these last ones conflict with implicit value of @required, so host language attr should win -->
+  <input type="checkbox" aria-required="false" required id="checkbox_required_ariarequiredfalse" data-expectedrequired="true">
+  <!-- BLOCKED by http://webkit.org/b/119988
+  <input type="checkbox" aria-required="true" id="checkbox_requiredfalse_ariarequiredtrue" data-expectedrequired="false">
+  -->
+
+
+  <!-- select -->
+  <select id="select" data-expectedrequired="false"><option>test</option></select>
+  <select id="select_required" required data-expectedrequired="true"><option>test</option></select>
+  <select required aria-required="true" id="select_required_ariarequired" data-expectedrequired="true"><option>test</option></select>
+  <select aria-required="false" id="select_ariarequiredfalse" data-expectedrequired="false"><option>test</option></select>
+  <!-- these last ones conflict with implicit value of @required, so host language attr should win -->
+  <select aria-required="false" required id="select_required_ariarequiredfalse" data-expectedrequired="true"><option>test</option></select>
+  <!-- BLOCKED by http://webkit.org/b/119988
+  <select aria-required="true" id="select_requiredfalse_ariarequiredtrue" data-expectedrequired="false"><option>test</option></select>
+  -->
+
+  
+  <!-- textarea -->
+  <textarea id="textarea" data-expectedrequired="false"></textarea>
+  <textarea id="textarea_required" required data-expectedrequired="true"></textarea>
+  <textarea required aria-required="true" id="textarea_required_ariarequired" data-expectedrequired="true"></textarea>
+  <textarea aria-required="false" id="textarea_ariarequiredfalse" data-expectedrequired="false"></textarea>
+  <!-- these last ones conflict with implicit value of @required, so host language attr should win -->
+  <textarea aria-required="false" required id="textarea_required_ariarequiredfalse" data-expectedrequired="true"></textarea>
+  <!-- BLOCKED by http://webkit.org/b/119988
+  <textarea aria-required="true" id="textarea_requiredfalse_ariarequiredtrue" data-expectedrequired="false"></textarea>
+  -->
+  
+
+  <!-- Custom ARIA controls (@required is not allowed on these elements, so no conflict resolution needed.) -->
+  <div tabindex="0" aria-required="true" role="listbox" id="listbox_ariarequiredtrue" data-expectedrequired="true">text</div>
+  <div tabindex="0" aria-required="false" role="listbox" id="listbox_ariarequiredfalse" data-expectedrequired="false">text</div>
+  <div tabindex="0" role="listbox" id="listbox" data-expectedrequired="false">text</div>
+
+  <div tabindex="0" aria-required="true" role="radiogroup" id="radiogroup_ariarequiredtrue" data-expectedrequired="true">text</div>
+  <div tabindex="0" aria-required="false" role="radiogroup" id="radiogroup_ariarequiredfalse" data-expectedrequired="false">text</div>
+  <div tabindex="0" role="radiogroup" id="radiogroup" data-expectedrequired="false">text</div>
+
+  <div tabindex="0" aria-required="true" role="spinbutton" id="spinbutton_ariarequiredtrue" data-expectedrequired="true">text</div>
+  <div tabindex="0" aria-required="false" role="spinbutton" id="spinbutton_ariarequiredfalse" data-expectedrequired="false">text</div>
+  <div tabindex="0" role="spinbutton" id="spinbutton" data-expectedrequired="false">text</div>
+
+  <div tabindex="0" aria-required="true" role="tree" id="tree_ariarequiredtrue" data-expectedrequired="true">text</div>
+  <div tabindex="0" aria-required="false" role="tree" id="tree_ariarequiredfalse" data-expectedrequired="false">text</div>
+  <div tabindex="0" role="tree" id="tree" data-expectedrequired="false">text</div>
 
 </div>
 
 
     description("This tests that aria-required is a usable attribute.");
 
-    function $(id){
-      return document.getElementById(id);
-    }
-
     if (window.accessibilityController) {
 
-          var succeeded = false;
-
-          // 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");
-
-          // 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");
-
-          // 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");
-
-          // 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");
-
-          // 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");
+        var result = document.getElementById('console');
+        var elements = document.querySelectorAll('[data-expectedrequired]');
+        result.innerText += "Elements to test: " + elements.length + "\n\n";
+
+        for (var i = 0, c = elements.length; i < c; i++) {
+            var el = elements[i];
+            var id = el.id;
+            var axElement = accessibilityController.accessibleElementById(id);
+            var isRequired = axElement.isRequired;
+
+            // Test whether elementis required.
+            var passed = el.dataset.expectedrequired === isRequired.toString();
+            var output = (passed ? "PASS" : "FAIL") + " " + id + " isRequired is " + isRequired;
+            if (!passed)
+                output += ", expected " + el.dataset.expectedrequired;
+            result.innerText += output + "\n";
+        }
 
     }
 
-    $('toBeHidden').hidden = true; // hide this to avoid text diffs when adding more elements to the test
+    document.getElementById('toBeHidden').hidden = true; // hide this to avoid text diffs when adding more elements to the test
 
 </script>