chromium/third_party/blink/web_tests/editing/pasteboard/smart-paste-008.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>There was a bug in paste's smart replace whitespace handling. In some cases,
it used information gathered at the start of the selection being pasted into to
decide whether or not a space needed to be added to the end of the incoming
content.</p>
<p>A smart paste is performed into a selection starting in one block and ending
in another. Spaces should surround the pasted word.</p>
<div id="sample" contenteditable="true"><div id="foo">foo</div><div id="bar">x bar</div></div>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();
    var sample = document.getElementById('sample');

    if (!window.internals && !window.eventSender)
        return;

    internals.settings.setEditingBehavior('win');

    var foo = document.getElementById('foo');
    selection.selectAllChildren(foo);
    var rects = window.getSelection().getRangeAt(0).getClientRects();
    var x = rects[0].left;
    var y = rects[0].top;
    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.mouseDown();
    eventSender.mouseUp();
    document.execCommand('copy');

    selection.collapse(foo.firstChild, 1);
    selection.extend(document.getElementById('bar').firstChild, 1);
    document.execCommand('paste');

    assert_equals(sample.innerHTML, '<div id="foo">f foo bar</div>', 'innerHTML');
    assert_true(selection.isCollapsed, 'isCollapsed');
    assert_equals(selection.anchorNode, foo.firstChild, 'anchorNode');
    assert_equals(selection.anchorOffset, 5, 'anchorOffset');
});
</script>