chromium/third_party/blink/web_tests/accessibility/description-calc-table-caption.html

<!DOCTYPE HTML>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>

<div class="container">
    <!-- Note: border=1 overrides layout table heuristics -->
    <table id="table1" border=1>
        <caption>Caption</caption>
        <tr><td>Cell 1</td><td>Cell 2</td></tr>
    </table>
</div>

<script>
test(function(t) {
    var axTable1 = accessibilityController.accessibleElementById("table1");
    assert_equals(axTable1.name, "Caption");
    assert_equals(axTable1.nameFrom, "caption");
    assert_equals(axTable1.description, "");
    assert_equals(axTable1.descriptionFrom, "");
}, "Table with caption.");
</script>

<div class="container">
    <!-- Note: border=1 overrides layout table heuristics -->
    <table id="table2" border=1 aria-label="Label">
        <caption>Caption</caption>
        <tr><td>Cell 1</td><td>Cell 2</td></tr>
    </table>
</div>

<script>
test(function(t) {
    var axTable2 = accessibilityController.accessibleElementById("table2");
    assert_equals(axTable2.name, "Label");
    assert_equals(axTable2.nameFrom, "attribute");
    assert_equals(axTable2.description, "Caption");
    assert_equals(axTable2.descriptionFrom, "tableCaption");
    assert_equals(axTable2.descriptionElementCount(), 1);
    assert_equals(axTable2.descriptionElementAtIndex(0).role, "AXRole: AXCaption");
}, "Table with caption and aria-label.");
</script>