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

Side by Side Diff: LayoutTests/editing/undo/undo-delete-boundary.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
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 at the end 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 at th e end of 'word'.</p>
7 <div id="test" style="border: 2px solid red;" contenteditable >This wo<b>rd </b> should be 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 sampleHTML = 'This wo<b>rd </b>should be selected.';
14 var selectionNode = document.getElementById('test').childNodes[1].firstChild; // Text node 'rd '
15 var selectionOffset = selectionNode.length - 1;
16 var endNode = document.getElementById('test').firstChild; // Text node 'This wo'
17 var endOffset = endNode.data.indexOf(' ') + 1;
18 var selection = window.getSelection();
3 19
4 <style> 20 function $(id) { return document.getElementById(id); }
5 .editing {
6 border: 2px solid red;
7 padding: 12px;
8 font-size: 24px;
9 }
10 </style>
11 <script src="../editing.js" language="JavaScript" type="text/JavaScript" ></scri pt>
12 21
13 <script> 22 function undoTest(platform, expectedStartNode, expectedStartOffset, expectedEndN ode, expectedEndOffset, selectedText) {
23 debug(platform);
24 internals.settings.setEditingBehavior(platform);
14 25
15 function editingTest() { 26 selection.collapse(selectionNode, selectionOffset);
16 moveSelectionForwardByWordCommand(); 27 for (var i = 0; i < 4; i++)
17 moveSelectionForwardByWordCommand(); 28 document.execCommand('delete');
18 deleteCommand(); 29 document.execCommand('undo');
19 deleteCommand(); 30
20 deleteCommand(); 31 shouldBeEqualToString('selection.anchorNode.data', expectedStartNode.data);
21 deleteCommand(); 32 shouldBe('selection.anchorOffset', expectedStartOffset + '');
22 undoCommand(); 33 shouldBeEqualToString('selection.focusNode.data', expectedEndNode.data);
34 shouldBe('selection.focusOffset', expectedEndOffset + '');
35 shouldBeEqualToString('selection.toString()', selectedText);
36 shouldBeEqualToString('$("test").innerHTML', sampleHTML);
23 } 37 }
24 38
39 if (window.internals) {
40 undoTest('mac', selectionNode, selectionOffset, endNode, endOffset, 'word');
41 undoTest('win', selectionNode, selectionOffset, endNode, endOffset, 'word');
42 undoTest('unix', selectionNode, selectionOffset, endNode, endOffset, 'word') ;
43 undoTest('android', selectionNode, selectionOffset, endNode, endOffset, 'wor d');
44 }
45 if (window.testRunner)
46 document.getElementById('container').outerHTML = '';
25 </script> 47 </script>
26 48 <script src="../../fast/js/resources/js-test-post.js"></script>
27 </head>
28 <body>
29 <div contenteditable id="root" class="editing">
30 <span id="test">This wo<b>rd </b>should be selected, since the test deleted it a character at a time and then did an undo.</span>
31 </div>
32
33 <script>
34 if (window.internals)
35 internals.settings.setEditingBehavior("mac");
36 runEditingTest();
37 </script>
38
39 </body> 49 </body>
40 </html> 50 </html>
OLDNEW
« no previous file with comments | « LayoutTests/editing/undo/undo-delete.html ('k') | LayoutTests/editing/undo/undo-delete-boundary-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698