Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <!DOCTYPE html> |
| 2 <head> | 2 <html> |
| 3 <body> | |
| 4 <p id="description"></p> | |
| 5 <div id="test" style="border: 2px solid red;" contenteditable >Test</div> | |
| 6 <div id="console"></div> | |
| 7 <script src="../../fast/js/resources/js-test-pre.js"></script> | |
| 8 <script> | |
| 9 description('Verifies the selection behavior on undoing a word deletion.'); | |
| 10 var startNode = document.getElementById('test').firstChild; | |
| 11 var startOffset = startNode.length; | |
| 12 var selection = window.getSelection(); | |
| 3 | 13 |
| 4 <style> | 14 function undoTest(platform, selectionType, expectedStartOffset, expectedEndOffse t) { |
|
yosin_UTC9
2013/10/25 08:03:05
nit: If we have |debug(platform)|, it helps debugg
| |
| 5 .editing { | 15 internals.settings.setEditingBehavior(platform); |
| 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 | 16 |
| 13 <script> | 17 var range = document.createRange(); |
|
yosin_UTC9
2013/10/25 08:03:05
nit: seletion.collapse(startNode, startOffset) is
| |
| 18 range.setStart(startNode, startOffset); | |
| 19 selection.removeAllRanges(); | |
| 20 selection.addRange(range); | |
| 14 | 21 |
| 15 function editingTest() { | 22 for (var i = 0; i < startOffset; i++) |
| 16 moveSelectionForwardByWordCommand(); | 23 document.execCommand('delete'); |
| 17 moveSelectionForwardByWordCommand(); | 24 document.execCommand('undo'); |
| 18 deleteCommand(); | 25 |
| 19 deleteCommand(); | 26 shouldBeEqualToString('selection.type', selectionType); |
|
yosin_UTC9
2013/10/25 08:03:05
Since, selection.type isn't standard. So, we shoul
| |
| 20 deleteCommand(); | 27 shouldBe('selection.baseNode', 'startNode'); |
|
yosin_UTC9
2013/10/25 08:03:05
Could you use {anchor,focus}{Node,Offste}? They ar
| |
| 21 deleteCommand(); | 28 shouldBe('selection.baseOffset', expectedStartOffset + ''); |
| 22 undoCommand(); | 29 shouldBe('selection.extentNode', 'startNode'); |
| 30 shouldBe('selection.extentOffset', expectedEndOffset + ''); | |
| 23 } | 31 } |
| 24 | 32 |
| 33 if (window.internals) { | |
| 34 undoTest('mac', 'Range', 4, 0); | |
| 35 undoTest('win', 'Range', 4, 0); | |
| 36 undoTest('unix', 'Range', 4, 0); | |
| 37 undoTest('android', 'Range', 4, 0); | |
| 38 } else { | |
| 39 debug("To test manually, place the cursor at the end of the word 'Test' and delete it completely character by character. Do ctrl+z. On Mac, the word 'Test' should be selected. On other platforms the word 'Test' should not be selected an d the cursor should be placed at the end of the word."); | |
|
yosin_UTC9
2013/10/25 08:03:05
nit: Could you put this message in HTML? We can se
| |
| 40 } | |
| 25 </script> | 41 </script> |
| 26 | 42 <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 word should be selected, since the test deleted it a charac ter 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> | 43 </body> |
| 40 </html> | 44 </html> |
| OLD | NEW |