chromium/third_party/blink/web_tests/editing/selection/double_click_and_modify.html

<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
// TODO(editing-dev): Once http://crbug.com/736253 fixed, we should use
// |chrome.pointerActionSequence()| instead of |eventSender|.
test(() => {
  function doDoubleClickInMiddle(selection, target) {
    const document = selection.document;
    const clickX = target.offsetLeft + target.offsetWidth / 2;
    const clickY = target.offsetTop + target.offsetHeight / 2;
    eventSender.mouseMoveTo(document.offsetLeft + clickX,
                            document.offsetTop + clickY);
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.mouseDown();
    eventSender.mouseUp();
  }

  assert_own_property(window, 'eventSender', 'This test requires eventSender.');

  assert_selection(
    '<span id="sample">xyz</span>',
    selection => {
      const sample = selection.document.getElementById('sample');
      doDoubleClickInMiddle(selection, sample);
      sample.insertBefore(new Text('abc'), sample.firstChild);
    },
    '<span id="sample">abc^xyz|</span>',
    'DOM modification outside selection should not affect selection');
}, 'Double-click and modify text');
</script>