5 <p id=
"description"></p>
6 <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>
7 <div id=
"test" style=
"border: 2px solid red;" contenteditable
>This word should be selected only on mac.
</div>
9 <div id=
"console"></div>
10 <script src=
"../../resources/js-test.js"></script>
12 description('Verifies the selection behavior on undoing a text deletion.');
13 var selectionNode
= document
.getElementById('test').firstChild
;
14 var selectionOffset
= selectionNode
.data
.indexOf('d') + 1;
15 var endOffsetMac
= selectionNode
.data
.indexOf(' ') + 1;
16 var selection
= window
.getSelection();
18 function undoTest(platform
, expectedStartNode
, expectedStartOffset
, expectedEndNode
, expectedEndOffset
, selectedText
) {
20 internals
.settings
.setEditingBehavior(platform
);
22 selection
.collapse(selectionNode
, selectionOffset
);
23 for (var i
= 0; i
< 4; i
++)
24 document
.execCommand('delete');
25 document
.execCommand('undo');
27 shouldBeEqualToString('selection.anchorNode.data', expectedStartNode
.data
);
28 shouldBe('selection.anchorOffset', expectedStartOffset
+ '');
29 shouldBeEqualToString('selection.focusNode.data', expectedEndNode
.data
);
30 shouldBe('selection.focusOffset', expectedEndOffset
+ '');
31 shouldBeEqualToString('selection.toString()', selectedText
);
34 if (window
.internals
) {
35 undoTest('mac', selectionNode
, selectionOffset
, selectionNode
, endOffsetMac
, 'word');
36 undoTest('win', selectionNode
, selectionOffset
, selectionNode
, selectionOffset
, '');
37 undoTest('unix', selectionNode
, selectionOffset
, selectionNode
, selectionOffset
, '');
38 undoTest('android', selectionNode
, selectionOffset
, selectionNode
, selectionOffset
, '');
40 if (window
.testRunner
)
41 document
.getElementById('container').outerHTML
= '';