5 <p id=
"description"></p>
6 <p>To test manually:
<br>1. Place the cursor at the end of 'abc'. Delete 'c'. Type in 'x'. Delete 'x'. Do ctrl+z. You should now see 'abx'.
<br>2. Make sure you have the cursor at the end of 'abx'. Type in 'y'. Delete 'y'. Do ctrl+z. You should now see 'abxy'.
</p>
7 <div id=
"test" style=
"border: 2px solid red;" contenteditable
>abc
</div>
9 <div id=
"console"></div>
10 <script src=
"../../resources/js-test.js"></script>
12 description('Verifies undo functionality that follows text insertion.');
14 var selection
= window
.getSelection();
15 selection
.collapse(document
.getElementById('test').firstChild
, 3);
17 // Use case 1: Place the cursor at the end of 'abc'. Delete 'c'. Type in 'x'. Delete 'x'. Do ctrl+z. You should now see 'abx'.
18 document
.execCommand('delete');
19 document
.execCommand('insertText', false, 'x');
20 document
.execCommand('delete');
21 document
.execCommand('undo');
22 shouldBeEqualToString('selection.focusNode.data', 'abx');
24 // Use case 2: Type in 'y'. Delete 'y'. Do ctrl+z. You should now see 'abxy'.
25 selection
.collapseToEnd(); // This is needed for this test to work on mac platform
26 document
.execCommand('insertText', false, 'y');
27 document
.execCommand('delete');
28 document
.execCommand('undo');
29 shouldBeEqualToString('selection.focusNode.data', 'abxy');
31 if (window
.testRunner
)
32 document
.getElementById('container').outerHTML
= '';