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

Side by Side Diff: LayoutTests/editing/undo/undo-combined-delete.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 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> 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> 7 <div id="test" style="border: 2px solid red;" contenteditable>This word should b e 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 selectionNode = document.getElementById('test').firstChild; 13 var selectionNode = document.getElementById('test').firstChild;
14 var selectionOffset = selectionNode.data.indexOf('o') + 1; 14 var selectionOffset = selectionNode.data.indexOf('o') + 1;
15 var startOffset = selectionNode.data.indexOf(' ') + 1; 15 var startOffsetMac = selectionNode.data.indexOf(' ') + 1;
16 var endOffset = selectionNode.data.indexOf('d') + 1; 16 var endOffsetMac = selectionNode.data.indexOf('d') + 1;
17 var selection = window.getSelection(); 17 var selection = window.getSelection();
18 18
19 function undoTest(platform, expectedStartNode, expectedStartOffset, expectedEndN ode, expectedEndOffset, selectedText) { 19 function undoTest(platform, expectedStartNode, expectedStartOffset, expectedEndN ode, expectedEndOffset, selectedText) {
20 debug(platform); 20 debug(platform);
21 internals.settings.setEditingBehavior(platform); 21 internals.settings.setEditingBehavior(platform);
22 22
23 selection.collapse(selectionNode, selectionOffset); 23 selection.collapse(selectionNode, selectionOffset);
24 for (var i = 0; i < 2; i++) 24 for (var i = 0; i < 2; i++)
25 document.execCommand('delete'); 25 document.execCommand('delete');
26 for (var i = 0; i < 2; i++) 26 for (var i = 0; i < 2; i++)
27 document.execCommand('forwarddelete'); 27 document.execCommand('forwarddelete');
28 document.execCommand('undo'); 28 document.execCommand('undo');
29 29
30 shouldBeEqualToString('selection.anchorNode.data', expectedStartNode.data); 30 shouldBeEqualToString('selection.anchorNode.data', expectedStartNode.data);
31 shouldBe('selection.anchorOffset', expectedStartOffset + ''); 31 shouldBe('selection.anchorOffset', expectedStartOffset + '');
32 shouldBeEqualToString('selection.focusNode.data', expectedEndNode.data); 32 shouldBeEqualToString('selection.focusNode.data', expectedEndNode.data);
33 shouldBe('selection.focusOffset', expectedEndOffset + ''); 33 shouldBe('selection.focusOffset', expectedEndOffset + '');
34 shouldBeEqualToString('selection.toString()', selectedText); 34 shouldBeEqualToString('selection.toString()', selectedText);
35 } 35 }
36 36
37 if (window.internals) { 37 if (window.internals) {
38 undoTest('mac', selectionNode, startOffset, selectionNode, endOffset, 'word' ); 38 undoTest('mac', selectionNode, startOffsetMac, selectionNode, endOffsetMac, 'word');
39 undoTest('win', selectionNode, startOffset, selectionNode, endOffset, 'word' ); 39 undoTest('win', selectionNode, selectionOffset, selectionNode, selectionOffs et, '');
40 undoTest('unix', selectionNode, startOffset, selectionNode, endOffset, 'word '); 40 undoTest('unix', selectionNode, selectionOffset, selectionNode, selectionOff set, '');
41 undoTest('android', selectionNode, startOffset, selectionNode, endOffset, 'w ord'); 41 undoTest('android', selectionNode, selectionOffset, selectionNode, selection Offset, '');
42 } 42 }
43 if (window.testRunner) 43 if (window.testRunner)
44 document.getElementById('container').outerHTML = ''; 44 document.getElementById('container').outerHTML = '';
45 </script> 45 </script>
46 <script src="../../fast/js/resources/js-test-post.js"></script> 46 <script src="../../fast/js/resources/js-test-post.js"></script>
47 </body> 47 </body>
48 </html> 48 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698