OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <style> |
| 4 .test { |
| 5 font-family: monospace; |
| 6 } |
| 7 .test:first-letter { |
| 8 color: red; |
| 9 } |
| 10 </style> |
| 11 </head> |
| 12 <body> |
| 13 <div id="container"> |
| 14 <p id="description"></p> |
| 15 <ol> |
| 16 <li>Set caret before "a".</li> |
| 17 <li>Hit right arrow key.</li> |
| 18 <li>Hit right arrow key.</li> |
| 19 <li>Hit right left key.</li> |
| 20 <li>Hit right left key.</li> |
| 21 <li>Caret should be before "a".</li> |
| 22 </ol> |
| 23 <div id="sample" contenteditable="true"> |
| 24 <p class="test">abcdefgh</p> |
| 25 </div> |
| 26 </div> |
| 27 <div id="console"></div> |
| 28 <script src="../../fast/js/resources/js-test-pre.js"></script> |
| 29 <script> |
| 30 description('Check left/right arrow key around first letter'); |
| 31 function $(id) { return document.getElementById(id); } |
| 32 |
| 33 var selection = window.getSelection(); |
| 34 var test = document.querySelector('.test'); |
| 35 $('sample').focus(); |
| 36 |
| 37 debug('Move caret before first letter'); |
| 38 var range = document.createRange(); |
| 39 range.setStart(test.firstChild, 0); |
| 40 selection.removeAllRanges(); |
| 41 selection.addRange(range); |
| 42 |
| 43 shouldBeEqualToString('selection.type', 'Caret'); |
| 44 shouldBe('selection.anchorNode', 'test.firstChild'); |
| 45 shouldBe('selection.anchorOffset', '0'); |
| 46 |
| 47 if (window.eventSender) { |
| 48 |
| 49 debug('Hit right arrow key'); |
| 50 eventSender.keyDown('rightArrow'); |
| 51 shouldBeEqualToString('selection.type', 'Caret'); |
| 52 shouldBe('selection.anchorNode', 'test.firstChild'); |
| 53 shouldBe('selection.anchorOffset', '1'); |
| 54 |
| 55 debug('Hit right arrow key'); |
| 56 eventSender.keyDown('rightArrow'); |
| 57 shouldBeEqualToString('selection.type', 'Caret'); |
| 58 shouldBe('selection.anchorNode', 'test.firstChild'); |
| 59 shouldBe('selection.anchorOffset', '2'); |
| 60 |
| 61 debug('Hit left arrow key'); |
| 62 eventSender.keyDown('rightArrow'); |
| 63 shouldBeEqualToString('selection.type', 'Caret'); |
| 64 shouldBe('selection.anchorNode', 'test.firstChild'); |
| 65 shouldBe('selection.anchorOffset', '1'); |
| 66 |
| 67 debug('Hit left arrow key'); |
| 68 eventSender.keyDown('rightArrow'); |
| 69 shouldBeEqualToString('selection.type', 'Caret'); |
| 70 shouldBe('selection.anchorNode', 'test.firstChild'); |
| 71 shouldBe('selection.anchorOffset', '0'); |
| 72 } |
| 73 |
| 74 if (window.testRunner) |
| 75 $('container').outerHTML = ''; |
| 76 </script> |
| 77 <script src="../../fast/js/resources/js-test-post.js"></script> |
| 78 </body> |
OLD | NEW |