Bug 1453606 - Add tests for Accessible name and Description Computation spec test cases, r?surkov draft
authorMarco Zehe <mzehe@mozilla.com>
Thu, 12 Apr 2018 13:28:26 +0200
changeset 781567 65a3dd178ce3186077c13ee3935499d1bd00f038
parent 781042 ee1d1bf1dc8a83eec16967ddb61dd5024c8d6058
push id106344
push userbmo:mzehe@mozilla.com
push dateFri, 13 Apr 2018 06:10:15 +0000
reviewerssurkov
bugs1453606
milestone61.0a1
Bug 1453606 - Add tests for Accessible name and Description Computation spec test cases, r?surkov MozReview-Commit-ID: 8vmdEF3Rm7V
accessible/tests/mochitest/name/a11y.ini
accessible/tests/mochitest/name/test_ARIACore_examples.html
--- a/accessible/tests/mochitest/name/a11y.ini
+++ b/accessible/tests/mochitest/name/a11y.ini
@@ -2,16 +2,17 @@
 support-files =
   general.css
   general.xbl
   markup.js
   markuprules.xml
   !/accessible/tests/mochitest/*.js
   !/accessible/tests/mochitest/moz.png
 
+[test_ARIACore_examples.html]
 [test_browserui.xul]
 [test_counterstyle.html]
 [test_general.html]
 [test_general.xul]
 [test_link.html]
 [test_list.html]
 [test_markup.html]
 skip-if = (debug && os == 'win') # Bug 1296784
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/name/test_ARIACore_examples.html
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+  <title>Testing a11y name ccomputation testcases</title>
+
+  <link rel="stylesheet"
+        type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+  <script type="application/javascript"
+          src="../common.js"></script>
+  <script type="application/javascript"
+          src="../name.js"></script>
+
+  <script type="application/javascript">
+    function doTest() {
+      // All test cases taken from https://www.w3.org/TR/accname-1.1/
+      // These were especially called out to demonstrate edge cases.
+
+      // Example 1 from section 4.3.1 under 2.B.
+      // Element1 should get its name from the text in element3.
+      // Element2 should not gets name from element1 because that already
+      // gets its name from another element.
+      testName("el1", "hello");
+      testName("el2", null);
+
+      // Example 2 from section 4.3.1 under 2.C.
+      // The buttons should get their name from their labels and the links.
+      testName("del_row1", "Delete Documentation.pdf");
+      testName("del_row2", "Delete HolidayLetter.pdf");
+
+      // Example 3 from section 4.3.1 under 2.F.
+      // Name should be own content text plus the value of the input plus
+      // more own inner text, separated by 1 space.
+      testName("chkbx", "Flash the screen 5 times");
+
+      SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addA11yLoadEvent(doTest);
+  </script>
+
+</head>
+<body>
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+
+  <!-- el1 should be labeled, el2 should not. -->
+  <div id="el1" aria-labelledby="el3"></div>
+  <div id="el2" aria-labelledby="el1"></div>
+  <div id="el3"> hello </div>
+
+  <!-- The buttons should be labeled by themselves and the referenced link -->
+  <ul>
+    <li>
+      <a id="file_row1" href="./files/Documentation.pdf">Documentation.pdf</a>
+      <span role="button" tabindex="0" id="del_row1" aria-label="Delete"
+            aria-labelledby="del_row1 file_row1"></span>
+    </li>
+    <li>
+      <a id="file_row2" href="./files/HolidayLetter.pdf">HolidayLetter.pdf</a>
+      <span role="button" tabindex="0" id="del_row2" aria-label="Delete"
+            aria-labelledby="del_row2 file_row2"></span>
+    </li>
+  </ul>
+
+  <!-- Label from combined text and subtree -->
+  <div id="chkbx" role="checkbox" aria-checked="false">Flash the screen
+       <span role="textbox" aria-multiline="false"> 5 </span> times</div>
+</body>
+</html>