chromium/third_party/blink/web_tests/editing/selection/collapse/collapse_document_in_design_mode.html

<!doctype HTML>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<body contenteditable>
<p id="anchor">This tests for setting the selection at a position inside a
document in designMode. You should see a caret at the start of the body.</p>
<div id="log"></div>
</body>
<script>
test(function() {
    document.designMode = 'on';
    var selection = window.getSelection();
    selection.collapse(document, 0);

    var anchor = document.getElementById('anchor').firstChild;
    assert_equals(selection.anchorNode, document, 'DOM anchorNode');
    assert_equals(selection.anchorOffset, 0, 'DOM anchorOffset');
    assert_equals(selection.focusNode, document, 'DOM focusNode');
    assert_equals(selection.focusOffset, 0, 'DOM focusOffset');

    assert_own_property(window, 'internals');
    assert_equals(internals.visibleSelectionAnchorNode, anchor, 'Canonicalized anchorNode');
    assert_equals(internals.visibleSelectionAnchorOffset, 0, 'Canonicalized anchorOffset');
    assert_equals(internals.visibleSelectionFocusNode, anchor, 'Canonicalized focusNode');
    assert_equals(internals.visibleSelectionFocusOffset, 0, 'Canonicalized focusOffset');
});
</script>
</html>