OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> |
| 6 <body> |
| 7 <div id="d1" contenteditable="true"> hello </div> |
| 8 <div id="console"></div> |
| 9 </body> |
| 10 <script> |
| 11 description('Test getBoundingClientRect of caret for collapsed range.'); |
| 12 |
| 13 /* Set caret position */ |
| 14 var el = document.getElementById('d1'); |
| 15 var sel = window.getSelection(); |
| 16 var range = document.createRange(); |
| 17 range.setStart(el.childNodes[0], 3); |
| 18 range.collapse(true); |
| 19 sel.removeAllRanges(); |
| 20 sel.addRange(range); |
| 21 el.focus(); |
| 22 |
| 23 /* Actual test */ |
| 24 sel = window.getSelection(); |
| 25 range = sel.getRangeAt(0); |
| 26 range.collapse(true); |
| 27 var rect = range.getBoundingClientRect(); |
| 28 |
| 29 shouldBe('rect.left', '22'); |
| 30 shouldBe('rect.top', '8'); |
| 31 shouldBe('rect.width', '0'); |
| 32 shouldBe('rect.height', '19'); |
| 33 </script> |
| 34 </html> |
OLD | NEW |