blob: c5ccf4dc314d4878c879910f48e32fd4c172a7e3 [file] [log] [blame]
<!DOCTYPE html>
<div id="container">
<p id="description"></p>
<p>To test manually, place the cursor at the end of 'word' and delete it completely character by character. Do ctrl+z. On Mac, 'word' should be selected. On other platforms 'word' should not be selected and the cursor should be placed at the end of 'word'.</p>
<div id="test" style="border: 2px solid red;" contenteditable>This word should be selected only on mac.</div>
<div id="console"></div>
<script src="../../resources/js-test.js"></script>
description('Verifies the selection behavior on undoing a text deletion.');
var selectionNode = document.getElementById('test').firstChild;
var selectionOffset ='d') + 1;
var endOffsetMac =' ') + 1;
var selection = window.getSelection();
function undoTest(platform, expectedStartNode, expectedStartOffset, expectedEndNode, expectedEndOffset, selectedText) {
selection.collapse(selectionNode, selectionOffset);
for (var i = 0; i < 4; i++)
shouldBe('selection.anchorOffset', expectedStartOffset + '');
shouldBe('selection.focusOffset', expectedEndOffset + '');
shouldBeEqualToString('selection.toString()', selectedText);
if (window.internals) {
undoTest('mac', selectionNode, selectionOffset, selectionNode, endOffsetMac, 'word');
undoTest('win', selectionNode, selectionOffset, selectionNode, selectionOffset, '');
undoTest('unix', selectionNode, selectionOffset, selectionNode, selectionOffset, '');
undoTest('android', selectionNode, selectionOffset, selectionNode, selectionOffset, '');
if (window.testRunner)
document.getElementById('container').outerHTML = '';