chromium/third_party/blink/web_tests/accessibility/list-with-selection.html

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

<ul id="ul">
  <li>Item1</li>
  <li>Item2</li>
</ul>

<ul id="ul_editable" contenteditable>
  <li>Item1</li>
  <li>Item2</li>
</ul>

<ol id="ol">
  <li>Item1</li>
  <li>Item2</li>
</ol>

<ol id="ol_editable" contenteditable>
  <li>Item1</li>
  <li>Item2</li>
</ol>

<script>
  test(function() {
    if (!window.accessibilityController)
      return;

    let ids = ['ul', 'ul_editable', 'ol', 'ol_editable'];
    for (let id of ids) {
      let axList = accessibilityController.accessibleElementById(id);
      assert_not_equals(axList, undefined, id);

      // Select both items in the list.
      axList.setSelectedTextRange(0, 2);
      assert_equals(axList.selectionAnchorOffset, 0, id);
      assert_equals(axList.selectionFocusOffset, 2, id);

      let selection = window.getSelection();
      let selectionText = 'Item1\nItem2';
      assert_equals(selection.toString(), selectionText, id);

      if (window.testRunner)
        document.getElementById(id).style.display = "none";;
    }
      }, 'Setting the selection on various lists through the accessibility APIs should work.');
</script>