chromium/third_party/blink/web_tests/accessibility/aria-row-name.html

<!DOCTYPE HTML>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<body id="body">
<div role="treegrid">
  <div role="row" id="treegrid1-row1" tabindex="-1">
    <div role="rowheader">row head</div>
    <div role="gridcell">data</div>
  </div>
</div>
<div role="treegrid" aria-activedescendant="treegrid2-row1">
  <div role="row" id="treegrid2-row1">
    <div role="rowheader">row head</div>
    <div role="gridcell">data</div>
  </div>
</div>
<div role="grid">
  <div role="row" id="treegrid3-row1">
    <div role="rowheader">row head</div>
    <div role="gridcell">data</div>
  </div>
</div>

<input type="text" role="combobox" aria-activedescendant="treegrid4-row1">
<div role="grid">
    <div id="treegrid4-row1" role="row">
        <div role="gridcell">data</div>
    </div>
</div>

<input type="text" role="combobox" aria-controls="treegrid5" aria-activedescendant="treegrid5-row1">
<div id="treegrid5" role="grid">
    <div id="treegrid5-row1" role="row">
        <div role="gridcell">data</div>
    </div>
</div>

<input id="input6" type="text" role="combobox" aria-controls="treegrid6">
<div id="treegrid6-container" role="none">
    <div id="treegrid6" role="grid">
        <div id="treegrid6-row1" role="row">
            <div role="gridcell">data</div>
        </div>
    </div>
</div>

<div role="treegrid" id="row-container-will-change-role">
    <div id="treegrid7-row1" role="row">
        <div role="gridcell">Hello</div>
    </div>
</div>

</body>

<script>
function axElementById(id) {
    return accessibilityController.accessibleElementById(id);
}

test(function(t) {
    var axRow = axElementById("treegrid1-row1");
    assert_equals(axRow.name, 'row head data');
}, "The row's name must concatenate the children if the row is focusable");

test(function(t) {
    var axRow = axElementById("treegrid2-row1");
    assert_equals(axRow.name, 'row head data');
}, "The row's name must concatenate the children if the parent has aria-activedescendant");

test(function(t) {
    var axRow = axElementById("treegrid3-row1");
    assert_equals(axRow.name, 'row head data');
}, "The row's name must concatenate the children if the row is inside a grid or treegrid");

test(function(t) {
    var axRow = axElementById("treegrid4-row1");
    assert_equals(axRow.name, 'data');
}, "The row's name must concatenate the children if a textfield controlling the grid has aria-activedescendant");

test(function(t) {
    var axRow = axElementById("treegrid5-row1");
    assert_equals(axRow.name, 'data');
}, "The row's name must concatenate the children if the grid has a previous sibling input with aria-activedescendant");

test(function(t) {
    document.getElementById('input6').setAttribute('aria-activedescendant', "treegrid6-row1");
    var axRow = axElementById("treegrid6-row1");
    assert_equals(axRow.name, 'data');
}, "The row's name must concatenate the children if the grid has a previous unignored sibling input with a late-added aria-activedescendant");

test(function(t) {
    var axRow = axElementById('treegrid7-row1');
    assert_equals(axRow.name, 'Hello');
    document.getElementById('row-container-will-change-role').role = 'grid';
    axRow = axElementById('treegrid7-row1');
    assert_equals(axRow.name, 'Hello');
}, "The row's name must concatenate the children if its inside a grid or tree grid, even after changing role");

</script>