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

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

Issue 43143003: Undo of delete/forward-delete of text should not select the deleted text on non-mac platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Function name modified and Tests/Expectations updated 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <div id="container"> 4 <div id="container">
5 <p id="description"></p> 5 <p id="description"></p>
6 <p>To test manually, place the cursor before 'w' of 'word' and delete it complet ely character by character. Do ctrl+z. On Mac, 'word' should be selected. On oth er platforms 'word' should not be selected and the cursor should be placed befor e 'w' of 'word'.</p> 6 <p>To test manually, place the cursor before 'w' of 'word' and delete it complet ely character by character. Do ctrl+z. On Mac, 'word' should be selected. On oth er platforms 'word' should not be selected and the cursor should be placed befor e 'w' of 'word'.</p>
7 <div id="test" style="border: 2px solid red;" contenteditable>This wo<b>rd </b>s hould be selected.</div> 7 <div id="test" style="border: 2px solid red;" contenteditable>This wo<b>rd </b>s hould be selected only on mac.</div>
8 </div> 8 </div>
9 <div id="console"></div> 9 <div id="console"></div>
10 <script src="../../fast/js/resources/js-test-pre.js"></script> 10 <script src="../../fast/js/resources/js-test-pre.js"></script>
11 <script> 11 <script>
12 description('Verifies the selection behavior on undoing a text deletion.'); 12 description('Verifies the selection behavior on undoing a text deletion.');
13 var sampleHTML = 'This wo<b>rd </b>should be selected.'; 13 var sampleHTML = 'This wo<b>rd </b>should be selected only on mac.';
14 var selectionNode = document.getElementById('test').firstChild; // Text node 'Th is wo' 14 var selectionNode = document.getElementById('test').firstChild; // Text node 'Th is wo'
15 var selectionOffset = selectionNode.data.indexOf(' ') + 1; 15 var selectionOffset = selectionNode.data.indexOf(' ') + 1;
16 var endNode = document.getElementById('test').childNodes[1].firstChild; // Text node 'rd ' 16 var endNodeMac = document.getElementById('test').childNodes[1].firstChild; // Te xt node 'rd '
17 var endOffset = endNode.length - 1; 17 var endOffsetMac = endNodeMac.length - 1;
18 var selection = window.getSelection(); 18 var selection = window.getSelection();
19 19
20 function $(id) { return document.getElementById(id); } 20 function $(id) { return document.getElementById(id); }
21 21
22 function undoTest(platform, expectedStartNode, expectedStartOffset, expectedEndN ode, expectedEndOffset, selectedText) { 22 function undoTest(platform, expectedStartNode, expectedStartOffset, expectedEndN ode, expectedEndOffset, selectedText) {
23 debug(platform); 23 debug(platform);
24 internals.settings.setEditingBehavior(platform); 24 internals.settings.setEditingBehavior(platform);
25 25
26 selection.collapse(selectionNode, selectionOffset); 26 selection.collapse(selectionNode, selectionOffset);
27 for (var i = 0; i < 4; i++) 27 for (var i = 0; i < 4; i++)
28 document.execCommand('forwarddelete'); 28 document.execCommand('forwarddelete');
29 document.execCommand('undo'); 29 document.execCommand('undo');
30 30
31 shouldBeEqualToString('selection.anchorNode.data', expectedStartNode.data); 31 shouldBeEqualToString('selection.anchorNode.data', expectedStartNode.data);
32 shouldBe('selection.anchorOffset', expectedStartOffset + ''); 32 shouldBe('selection.anchorOffset', expectedStartOffset + '');
33 shouldBeEqualToString('selection.focusNode.data', expectedEndNode.data); 33 shouldBeEqualToString('selection.focusNode.data', expectedEndNode.data);
34 shouldBe('selection.focusOffset', expectedEndOffset + ''); 34 shouldBe('selection.focusOffset', expectedEndOffset + '');
35 shouldBeEqualToString('selection.toString()', selectedText); 35 shouldBeEqualToString('selection.toString()', selectedText);
36 shouldBeEqualToString('$("test").innerHTML', sampleHTML); 36 shouldBeEqualToString('$("test").innerHTML', sampleHTML);
37 } 37 }
38 38
39 if (window.internals) { 39 if (window.internals) {
40 undoTest('mac', selectionNode, selectionOffset, endNode, endOffset, 'word'); 40 undoTest('mac', selectionNode, selectionOffset, endNodeMac, endOffsetMac, 'w ord');
41 undoTest('win', selectionNode, selectionOffset, endNode, endOffset, 'word'); 41 undoTest('win', selectionNode, selectionOffset, selectionNode, selectionOffs et, '');
42 undoTest('unix', selectionNode, selectionOffset, endNode, endOffset, 'word') ; 42 undoTest('unix', selectionNode, selectionOffset, selectionNode, selectionOff set, '');
43 undoTest('android', selectionNode, selectionOffset, endNode, endOffset, 'wor d'); 43 undoTest('android', selectionNode, selectionOffset, selectionNode, selection Offset, '');
44 } 44 }
45 if (window.testRunner) 45 if (window.testRunner)
46 document.getElementById('container').outerHTML = ''; 46 document.getElementById('container').outerHTML = '';
47 </script> 47 </script>
48 <script src="../../fast/js/resources/js-test-post.js"></script> 48 <script src="../../fast/js/resources/js-test-post.js"></script>
49 </body> 49 </body>
50 </html> 50 </html>
OLDNEW
« no previous file with comments | « LayoutTests/editing/undo/undo-forward-delete.html ('k') | LayoutTests/editing/undo/undo-forward-delete-boundary-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698