Bug 830748 - [PATCH 2/2] [AccessFu] tests for improved reading of table semantics. r=eeejay, marcoz
authorYura Zenevich <yura.zenevich@gmail.com>
Thu, 27 Jun 2013 14:15:36 -0700 (2013-06-27)
changeset 136680 2ac97b3842495c25d3eea134c32c44031bcb5dbf
parent 136679 bb3d8befb0e9b09df1772525e65ab272d1f36f1e
child 136681 5f855a230acf3ce8673b1eb5d496554e1954dc46
push id30235
push usereisaacson@mozilla.com
push dateThu, 27 Jun 2013 21:15:42 +0000 (2013-06-27)
treeherdermozilla-inbound@b0761624565c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay, marcoz
bugs830748
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 830748 - [PATCH 2/2] [AccessFu] tests for improved reading of table semantics. r=eeejay, marcoz
accessible/tests/mochitest/jsat/Makefile.in
accessible/tests/mochitest/jsat/output.js
accessible/tests/mochitest/jsat/test_explicit_names.html
accessible/tests/mochitest/jsat/test_tables.html
accessible/tests/mochitest/jsat/test_utterance_order.html
--- a/accessible/tests/mochitest/jsat/Makefile.in
+++ b/accessible/tests/mochitest/jsat/Makefile.in
@@ -10,14 +10,15 @@ VPATH = @srcdir@
 relativesrcdir = @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_A11Y_FILES =\
 jsatcommon.js \
 output.js \
 test_alive.html \
+test_braille.html \
 test_explicit_names.html \
+test_tables.html \
 test_utterance_order.html \
-test_braille.html \
 $(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/accessible/tests/mochitest/jsat/output.js
+++ b/accessible/tests/mochitest/jsat/output.js
@@ -32,17 +32,18 @@ function testContextOutput(expected, aAc
  * Note: test ignores outputs without the name.
  *
  * @param aAccOrElmOrID identifier to get an accessible to test.
  * @param aGenerator    the output generator to use when generating accessible
  *                      output
  */
 function testObjectOutput(aAccOrElmOrID, aGenerator) {
   var accessible = getAccessible(aAccOrElmOrID);
-  var output = aGenerator.genForObject(accessible);
+  var context = new PivotContext(accessible);
+  var output = aGenerator.genForObject(accessible, context);
   var outputOrder;
   try {
     outputOrder = SpecialPowers.getIntPref(PREF_UTTERANCE_ORDER);
   } catch (ex) {
     // PREF_UTTERANCE_ORDER not set.
     outputOrder = 0;
   }
   var expectedNameIndex = outputOrder === 0 ? output.length - 1 : 0;
--- a/accessible/tests/mochitest/jsat/test_explicit_names.html
+++ b/accessible/tests/mochitest/jsat/test_explicit_names.html
@@ -49,40 +49,40 @@
       }, {
         accOrElmOrID: "li_one",
         expected: ["list 2 items", "Test List", "First item", "Top of the list"]
       }, {
         accOrElmOrID: "li_two",
         expected: ["list 2 items", "Test List", "Last item", "2.", "list two"]
       }, {
         accOrElmOrID: "cell",
-        expected: ["table", "Fruits and vegetables", "List of Fruits",
-          "list 4 items","First item", "link", "Apples", "link", "Bananas",
-          "link", "Peaches", "Last item", "link", "Plums"]
+        expected: ["table with 1 column and 1 row", "Fruits and vegetables",
+          "Column 1 Row 1", "List of Fruits", "list 4 items", "First item",
+          "link", "Apples", "link", "Bananas", "link", "Peaches", "Last item",
+          "link", "Plums"]
       }, {
         accOrElmOrID: "app.net",
         expected: ["list 2 items", "First item", "link", "star", "Last item",
           "link", "repost"]
       }, {
         // Test pivot to list from li_one.
         accOrElmOrID: "list",
         oldAccOrElmOrID: "li_one",
         expected: ["list 2 items", "Test List", "First item", "Top of the list",
           "Last item", "2.", "list two"]
       }, {
         // Test pivot to li_one from list.
         accOrElmOrID: "li_one",
         oldAccOrElmOrID: "list",
-        expected: ["list 2 items", "Test List", "First item", "Top of the list"]
+        expected: ["First item", "Top of the list"]
       }, {
         // Test pivot to "apples" link from the table cell.
         accOrElmOrID: "apples",
         oldAccOrElmOrID: "cell",
-        expected: ["List of Fruits", "list 4 items", "First item", "link",
-          "Apples"]
+        expected: ["list 4 items", "First item", "link", "Apples"]
       }, {
         // Test pivot to the table cell from the "apples" link.
         accOrElmOrID: "cell",
         oldAccOrElmOrID: "apples",
         expected: ["List of Fruits", "list 4 items", "First item", "link",
           "Apples", "link", "Bananas", "link", "Peaches", "Last item", "link",
           "Plums"]
       }];
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/jsat/test_tables.html
@@ -0,0 +1,251 @@
+<html>
+<head>
+  <title>[AccessFu] Improve reading of table semantics</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="output.js"></script>
+  <script type="application/javascript">
+
+    function doTest() {
+      // Test the following accOrElmOrID.
+      var tests = [{
+        accOrElmOrID: "table1",
+        expectedUtterance: ["table with 2 columns and 2 rows",
+          "Column 1 Row 1", "col1", "Column 2 Row 1", "col2",
+          "Column 1 Row 2 col1", "cell1", "Column 2 Row 2 col2", "cell2"],
+        expectedBraille: ["tbl 2c 2r", "c1r1", "col1", "c2r1", "col2",
+          "c1r2 col1", "cell1", "c2r2 col2", "cell2"]
+      }, {
+        accOrElmOrID: "table2",
+        expectedUtterance: ["table with 2 columns and 2 rows",
+          "Column 1 Row 1 col1", "cell1", "Column 2 Row 1 col2",
+          "table with 1 column and 2 rows", "Column 1 Row 1", "colheader",
+          "Column 1 Row 2 colheader", "bla", "Column 1 Row 2", "col1",
+          "Column 2 Row 2", "col2"],
+        expectedBraille: ["tbl 2c 2r", "c1r1 col1", "cell1", "c2r1 col2",
+          "tbl 1c 2r", "c1r1", "colheader", "c1r2 colheader", "bla", "c1r2",
+          "col1", "c2r2", "col2"]
+      }, {
+        accOrElmOrID: "table3",
+        expectedUtterance: ["table with 2 columns and 2 rows",
+          "Column 2 Row 1 col2", "table with 1 column and 2 rows",
+          "Column 1 Row 1", "colheader", "Column 1 Row 2 colheader", "bla"],
+        expectedBraille: ["tbl 1c 2r", "c1r1", "colheader", "c1r2 colheader",
+          "bla"]
+      }, {
+        accOrElmOrID: "table4",
+        expectedUtterance: ["table with 4 columns and 3 rows",
+          "Column 1 Row 1", "col1", "Column 2 Row 1", "col2", "Column 3 Row 1",
+          "col3", "Column 1 Row 2 spans 2 columns col1", "row1",
+          "Column 3 Row 2 col3 row1", "cell1",
+          "Column 4 Row 2 spans 2 rows row1", "cell2", "Column 1 Row 3 col1",
+          "row2", "Column 2 Row 3 col2 row2", "cell3",
+          "Column 3 Row 3 col3 row2", "cell4"],
+        expectedBraille: ["tbl 4c 3r", "c1r1", "col1", "c2r1", "col2", "c3r1",
+          "col3", "c1r2 col1", "row1", "c3r2 col3 row1", "cell1", "c4r2 row1",
+          "cell2", "c1r3 col1", "row2", "c2r3 col2 row2", "cell3",
+          "c3r3 col3 row2", "cell4"]
+      }, {
+        accOrElmOrID: "table5",
+        expectedUtterance: ["Row1", "Row2"],
+        expectedBraille: ["Row1", "Row2"]
+      }, {
+        // Test pivot to table1_th1 from table1.
+        accOrElmOrID: "table1_th1",
+        oldAccOrElmOrID: "table1",
+        expectedUtterance: ["Column 1 Row 1", "col1"],
+        expectedBraille: ["c1r1", "col1"]
+      }, {
+        // Test pivot to table1_td2 from table1.
+        accOrElmOrID: "table1_td2",
+        oldAccOrElmOrID: "table1",
+        expectedUtterance: ["Column 2 Row 2 col2", "cell2"],
+        expectedBraille: ["c2r2 col2", "cell2"]
+      }, {
+        // Test pivot to table1_td2 from table1_th1.
+        accOrElmOrID: "table1_td2",
+        oldAccOrElmOrID: "table1_th1",
+        expectedUtterance: ["Column 2 Row 2 col2", "cell2"],
+        expectedBraille: ["c2r2 col2", "cell2"]
+      }, {
+        // Test pivot to table1_td2 from table1_td1.
+        accOrElmOrID: "table1_td2",
+        oldAccOrElmOrID: "table1_td1",
+        expectedUtterance: ["Column 2 col2", "cell2"],
+        expectedBraille: ["c2r2 col2", "cell2"]
+      }, {
+        // Test pivot to table2_cell_1 from table2.
+        accOrElmOrID: "table2_cell_1",
+        oldAccOrElmOrID: "table2",
+        expectedUtterance: ["Column 1 Row 1 col1", "cell1"],
+        expectedBraille: ["c1r1 col1", "cell1"]
+      }, {
+        // Test pivot to table2_cell_2 from table2.
+        accOrElmOrID: "table2_cell_2",
+        oldAccOrElmOrID: "table2",
+        expectedUtterance: ["Column 2 Row 1 col2",
+          "table with 1 column and 2 rows", "Column 1 Row 1", "colheader",
+          "Column 1 Row 2 colheader", "bla"],
+        expectedBraille: ["c2r1 col2", "tbl 1c 2r", "c1r1", "colheader",
+          "c1r2 colheader", "bla"]
+      }, {
+        // Test pivot to table2_cell_1 from table2_cell_2.
+        accOrElmOrID: "table2_cell_1",
+        oldAccOrElmOrID: "table2_cell_2",
+        expectedUtterance: ["Column 1 col1", "cell1"],
+        expectedBraille: ["c1r1 col1", "cell1"]
+      }, {
+        // Test pivot to table3_cell from table2.
+        accOrElmOrID: "table3_cell",
+        oldAccOrElmOrID: "table2",
+        expectedUtterance: ["Column 2 Row 1 col2",
+          "table with 1 column and 2 rows", "Column 1 Row 2 colheader",
+          "bla"],
+        expectedBraille: ["c1r2 colheader", "bla"]
+      }, {
+        // Test pivot to table3_cell from table2_cell_1.
+        accOrElmOrID: "table3_cell",
+        oldAccOrElmOrID: "table2_cell_1",
+        expectedUtterance: ["Column 2 col2", "table with 1 column and 2 rows",
+          "Column 1 Row 2 colheader", "bla"],
+        expectedBraille: ["c1r2 colheader", "bla"]
+      }, {
+        // Test pivot to table3_cell from table3_ch.
+        accOrElmOrID: "table3_cell",
+        oldAccOrElmOrID: "table3_ch",
+        expectedUtterance: ["Row 2", "bla"],
+        expectedBraille: ["c1r2", "bla"]
+      }, {
+        // Test pivot to table3_cell from table1_td1.
+        accOrElmOrID: "table3_cell",
+        oldAccOrElmOrID: "table1_td1",
+        expectedUtterance: ["table with 2 columns and 2 rows",
+          "Column 2 Row 1 col2", "table with 1 column and 2 rows",
+          "Column 1 Row 2 colheader", "bla"],
+        expectedBraille: ["c1r2 colheader", "bla"]
+      }, {
+        // Test pivot to table4_ch_3 from table4.
+        accOrElmOrID: "table4_ch_3",
+        oldAccOrElmOrID: "table4",
+        expectedUtterance: ["Column 3 Row 1", "col3"],
+        expectedBraille: ["c3r1", "col3"]
+      }, {
+        // Test pivot to table4_rh_1 from table4_ch_3.
+        accOrElmOrID: "table4_rh_1",
+        oldAccOrElmOrID: "table4_ch_3",
+        expectedUtterance: ["Column 1 Row 2 spans 2 columns col1", "row1"],
+        expectedBraille: ["c1r2 col1", "row1"]
+      }, {
+        // Test pivot to table4_cell_3 from table4_rh_1.
+        accOrElmOrID: "table4_cell_3",
+        oldAccOrElmOrID: "table4_rh_1",
+        expectedUtterance: ["Column 4 spans 2 rows", "cell2"],
+        expectedBraille: ["c4r2", "cell2"]
+      }, {
+        // Test pivot to table4_cell_5 from table4_cell_3.
+        accOrElmOrID: "table4_cell_5",
+        oldAccOrElmOrID: "table4_cell_3",
+        expectedUtterance: ["Column 2 Row 3 col2 row2", "cell3"],
+        expectedBraille: ["c2r3 col2 row2", "cell3"]
+      }];
+
+      SpecialPowers.setIntPref(PREF_UTTERANCE_ORDER, 0);
+
+      // Test outputs (utterance and braille) for tables including their
+      // headers and cells.
+      tests.forEach(function run(test) {
+        testOutput(test.expectedUtterance, test.accOrElmOrID,
+          test.oldAccOrElmOrID, 1);
+        testOutput(test.expectedBraille, test.accOrElmOrID,
+          test.oldAccOrElmOrID, 0);
+      });
+
+      SpecialPowers.clearUserPref(PREF_UTTERANCE_ORDER);
+      SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addA11yLoadEvent(doTest);
+  </script>
+</head>
+<body>
+  <div id="root">
+    <a target="_blank"
+       href="https://bugzilla.mozilla.org/show_bug.cgi?id=830748"
+       title="[AccessFu] Improve reading of table semantics">
+       Mozilla Bug 830748
+       </a>
+    <p id="display"></p>
+    <div id="content" style="display: none"></div>
+    <pre id="test"></pre>
+    <table id="table1">
+      <thead>
+        <tr>
+          <th id="table1_th1">col1</th>
+          <th>col2</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <td id="table1_td1">cell1</td>
+          <td id="table1_td2">cell2</td>
+        </tr>
+      </tbody>
+    </table>
+    <table id="table2" border="1">
+      <tr>
+        <td id="table2_cell_1" headers="table2_ch_1">cell1</td>
+        <td id="table2_cell_2" headers="table2_ch_2">
+          <table id="table3">
+            <thead>
+              <tr>
+                <th id="table3_ch">colheader</th>
+              </tr>
+            </thead>
+            <tbody>
+              <tr>
+                <td id="table3_cell">bla</td>
+              </tr>
+            </tbody>
+          </table>
+        </td>
+      </tr>
+      <tr>
+        <td id="table2_ch_1" scope="col">col1</td>
+        <td id="table2_ch_2" scope="col">col2</td>
+      </tr>
+    </table>
+    <table id="table4" border="1">
+      <thead>
+        <tr>
+          <th id="table4_ch_1">col1</th>
+          <th id="table4_ch_2">col2</th>
+          <td id="table4_ch_3" scope="col">col3</td>
+        </tr>
+      </thead>
+      <tbody>
+        <tr>
+          <th id="table4_rh_1" colspan="2">row1</th>
+          <td id="table4_cell_2">cell1</td>
+          <td id="table4_cell_3" rowspan="2">cell2</td>
+        </tr>
+        <tr>
+          <td id="table4_rh_2" scope="row">row2</td>
+          <td id="table4_cell_5">cell3</td>
+          <td id="table4_cell_6">cell4</td>
+        </tr>
+      </tbody>
+    </table>
+    <table id="table5">
+      <tr><td>Row1</td></tr>
+      <tr><td>Row2</td></tr>
+    </table>
+  </div>
+</body>
+</html>
\ No newline at end of file
--- a/accessible/tests/mochitest/jsat/test_utterance_order.html
+++ b/accessible/tests/mochitest/jsat/test_utterance_order.html
@@ -52,23 +52,24 @@ https://bugzilla.mozilla.org/show_bug.cg
           accOrElmOrID: "li_one",
           expected: [
             ["list 1 items", "First item", "1.", "list one"],
             ["1.", "list one", "First item", "list 1 items"]
           ]
         }, {
           accOrElmOrID: "cell",
           expected: [[
-            "table", "Fruits and vegetables", "list 4 items", "First item",
-            "link", "Apples", "link", "Bananas", "link", "Peaches",
-            "Last item", "link", "Plums"
+            "table with 1 column and 1 row", "Fruits and vegetables",
+            "Column 1 Row 1", "list 4 items", "First item", "link", "Apples",
+            "link", "Bananas", "link", "Peaches", "Last item", "link", "Plums"
           ], [
             "Apples", "link", "First item", "Bananas", "link", "Peaches",
             "link", "Plums", "link", "Last item", "list 4 items",
-            "Fruits and vegetables", "table"
+            "Column 1 Row 1", "Fruits and vegetables",
+            "table with 1 column and 1 row"
           ]]
         }, {
           // Test pivot to list from li_one.
           accOrElmOrID: "list",
           oldAccOrElmOrID: "li_one",
           expected: [
             ["list 1 items", "First item", "1.", "list one"],
             ["1.", "list one", "First item", "list 1 items"]