chromium/third_party/blink/web_tests/editing/undo/undo-smart-delete-word.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script><html>
<div class="scenario">
Tests:
<br>
Select a word via double-click. Delete. Then undo the delete. The space that got
smart deleted should now be selected.
</div>
</div>

<div contenteditable id="root">
foo <span id="word">bar</span> baz
</div>
<div id="log"></div>
<script>
test(function() {
    if (!window.eventSender || !window.internals) {
        assert_unreached('This test requires eventSender and internals.');
        return;
    }
    // Make double-click to select trailing whitespace too.
    internals.settings.setEditingBehavior('win');
    internals.settings.setSelectTrailingWhitespaceEnabled(true);

    // Select "bar "
    var word = document.getElementById('word');
    var x = word.offsetLeft + word.offsetWidth / 2;
    var y = word.offsetTop + word.offsetHeight / 2;
    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.mouseDown();
    eventSender.mouseUp();

    document.execCommand('Delete');
    document.execCommand('Undo');

    var selection = window.getSelection();
    assert_equals(selection.anchorNode, word.firstChild, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
    assert_equals(selection.focusNode, word.nextSibling, 'focusNode');
    assert_equals(selection.focusOffset, 1, 'focusOffset');
});
</script>