Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Side by Side Diff: LayoutTests/editing/undo/undo-combined-delete.html

Issue 43523002: Make tests related to undo word deletion platform independent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: All tests modified Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/editing/undo/undo-combined-delete-boundary.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <!DOCTYPE html>
2 <head> 2 <html>
3 <body>
4 <div id="container">
5 <p id="description"></p>
6 <p>To test manually, place the cursor after 'o' in 'word' and delete it complete ly character by character. Do ctrl+z. On Mac, 'word' should be selected. On othe r platforms 'word' should not be selected and the cursor should be placed after 'o' in 'word'.</p>
7 <div id="test" style="border: 2px solid red;" contenteditable>This word should b e selected.</div>
8 </div>
9 <div id="console"></div>
10 <script src="../../fast/js/resources/js-test-pre.js"></script>
11 <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('o') + 1;
15 var startOffset = selectionNode.data.indexOf(' ') + 1;
16 var endOffset = selectionNode.data.indexOf('d') + 1;
17 var selection = window.getSelection();
3 18
4 <style> 19 function undoTest(platform, expectedStartNode, expectedStartOffset, expectedEndN ode, expectedEndOffset, selectedText) {
5 .editing { 20 debug(platform);
6 border: 2px solid red; 21 internals.settings.setEditingBehavior(platform);
7 padding: 12px;
8 font-size: 24px;
9 }
10 </style>
11 <script src="../editing.js" language="JavaScript" type="text/JavaScript" ></scri pt>
12 22
13 <script> 23 selection.collapse(selectionNode, selectionOffset);
24 for (var i = 0; i < 2; i++)
25 document.execCommand('delete');
26 for (var i = 0; i < 2; i++)
27 document.execCommand('forwarddelete');
28 document.execCommand('undo');
14 29
15 function editingTest() { 30 shouldBeEqualToString('selection.anchorNode.data', expectedStartNode.data);
16 moveSelectionForwardByWordCommand(); 31 shouldBe('selection.anchorOffset', expectedStartOffset + '');
17 moveSelectionForwardByCharacterCommand(); 32 shouldBeEqualToString('selection.focusNode.data', expectedEndNode.data);
18 moveSelectionForwardByCharacterCommand(); 33 shouldBe('selection.focusOffset', expectedEndOffset + '');
19 moveSelectionForwardByCharacterCommand(); 34 shouldBeEqualToString('selection.toString()', selectedText);
20 deleteCommand();
21 deleteCommand();
22 forwardDeleteCommand();
23 forwardDeleteCommand();
24 undoCommand();
25 } 35 }
26 36
37 if (window.internals) {
38 undoTest('mac', selectionNode, startOffset, selectionNode, endOffset, 'word' );
39 undoTest('win', selectionNode, startOffset, selectionNode, endOffset, 'word' );
40 undoTest('unix', selectionNode, startOffset, selectionNode, endOffset, 'word ');
41 undoTest('android', selectionNode, startOffset, selectionNode, endOffset, 'w ord');
42 }
43 if (window.testRunner)
44 document.getElementById('container').outerHTML = '';
27 </script> 45 </script>
28 46 <script src="../../fast/js/resources/js-test-post.js"></script>
29 </head>
30 <body>
31 <div contenteditable id="root" class="editing">
32 <span id="test">This word should be selected, since the test deleted it a charac ter at a time and then did an undo.</span>
33 </div>
34
35 <script>
36 if (window.internals)
37 internals.settings.setEditingBehavior("mac");
38 runEditingTest();
39 </script>
40
41 </body> 47 </body>
42 </html> 48 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/editing/undo/undo-combined-delete-boundary.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698