Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / undo / undo-insert-delete.html
bloba3515ff56572c79646753692ebbba14e91e23454
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <div id="container">
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>
8 </div>
9 <div id="console"></div>
10 <script src="../../resources/js-test.js"></script>
11 <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 = '';
33 </script>
34 </body>
35 </html>