OLD | NEW |
(Empty) | |
| 1 <head> |
| 2 <style> |
| 3 .test:first-letter { |
| 4 color: red; |
| 5 } |
| 6 </style> |
| 7 </head> |
| 8 <body> |
| 9 <div id="container"> |
| 10 <div id="sample" contenteditable="true"> |
| 11 <p class="test">abcdefgh</p> |
| 12 </div> |
| 13 </div> |
| 14 <script src="../../fast/js/resources/js-test-pre.js"></script> |
| 15 <script> |
| 16 function $(id) { return document.getElementById(id); } |
| 17 $('sample').focus(); |
| 18 |
| 19 var range = document.createRange(); |
| 20 range.setStart($('sample').querySelector('p.test').firstChild, 4); |
| 21 var selection = window.getSelection(); |
| 22 selection.removeAllRanges(); |
| 23 selection.addRange(range); |
| 24 |
| 25 debug('Insert newline'); |
| 26 document.execCommand('InsertText', false, '\n'); |
| 27 shouldBeEqualToString('selection.type', 'Caret'); |
| 28 shouldBe('selection.anchorNode', 'document.querySelectorAll("p.test")[1].firstCh
ild'); |
| 29 shouldBe('selection.anchorOffset', '0'); |
| 30 shouldBeEqualToString('selection.anchorNode.textContent', 'efgh'); |
| 31 |
| 32 debug('Delete newline'); |
| 33 document.execCommand('Delete'); |
| 34 shouldBeEqualToString('selection.type', 'Caret'); |
| 35 shouldBe('selection.anchorNode', 'document.querySelectorAll("p.test")[0].firstCh
ild'); |
| 36 shouldBe('selection.anchorOffset', '4'); |
| 37 shouldBeEqualToString('selection.anchorNode.textContent', 'abcdefgh'); |
| 38 |
| 39 if (window.testRunner) |
| 40 $('container').outerHTML = ''; |
| 41 </script> |
| 42 <script src="../../fast/js/resources/js-test-post.js"></script> |
| 43 </body> |
OLD | NEW |