blob: 6cd7f299e731ee2969a1a1fe67aec7ec68a11b14 [file] [log] [blame]
<!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 the
document when the document node is non-editable and the document's body element
*is* editable. The expected behavior is to create a selection at [body, 0].
There should be a caret at the start of this paragraph.</p>
<div id="log"></div>
</body>
<script>
test(function() {
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>