chromium/third_party/blink/web_tests/accessibility/selection-change-notification-aria-textbox.html

<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/run-after-layout-and-paint.js"></script>

<div id="ariaTextbox" role="textbox" tabIndex="0">
  <p>Before</p>
  <p id="p">One paragraph in an ARIA textbox</p>
  <p>After</p>
</div>

<script>
'use strict';

async_test_after_layout_and_paint((t) => {
  const axRootElement = accessibilityController.rootElement;
  axRootElement.setNotificationListener(t.step_func((notification, intents) => {
    // Focus notification will come asynchronously.
    if (notification == 'Focus' || notification == 'LoadStart' ||
        notification == 'LoadComplete' || notification == 'MarkDirty') {
      return;
    }

    if (notification == 'DocumentSelectionChanged') {
      assert_array_equals(intents,
                          ['AXEventIntent(setSelection,none,character,forward)']);
      axRootElement.unsetNotificationListener();
      t.done();
      return;
    }

    assert_unreached('Unexpected notification: ' + notification);
  }));

  const element = document.getElementById('ariaTextbox');
  element.focus();
  const p = document.getElementById('p');
  const range = document.createRange();
  range.setStart(p.firstChild, 0);
  range.setEnd(p.firstChild, 1);
  window.getSelection().removeAllRanges();
  window.getSelection().addRange(range);
});

</script>