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

<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
// Selection should be updated after set innerHTML
test(() => assert_selection(
        '<div id="sample"><span contenteditable>^foobar|</span></div>',
        selection => {
            const sample = selection.document.getElementById('sample');
            selection.document.addEventListener('blur', function () {
                selection.selectAllChildren(sample.firstChild);
            }, true);
            sample.firstChild.focus();
            sample.innerHTML = '';
        },
        '<div id="sample">|</div>'),
        'Select by blur');

test(() => assert_selection(
    '<div id="sample">^foobar|</div>',
    selection => {
        const sample = selection.document.getElementById('sample');
        selection.document.addEventListener('DOMNodeRemovedFromDocument',
            () => selection.selectAllChildren(sample), true);
        sample.innerHTML = '';
    },
    '<div id="sample">|</div>'),
    'Select by mutation event');
</script>