OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script type="text/javascript" src="../editing.js"></script> |
| 5 <script src="../../fast/js/resources/js-test-pre.js" type="text/javascript"></sc
ript> |
| 6 </head> |
| 7 <body style="font: 20px Ahem"> |
| 8 <p>This test checks that the cursor covers the next character to be overwritten
in overtype mode instead of being painted as a caret (1px width bar)</p> |
| 9 <div id="ltrtext" style="direction: ltr;" contenteditable="true">ABC</div> |
| 10 <div id="ltrtext-rtl" style="direction: rtl;" contenteditable="true">ABC</div> |
| 11 <div id="rtltext" style="direction: ltr;" contenteditable="true">שד
;ן</div> |
| 12 <div id="rtltext-rtl" style="direction: rtl;" contenteditable="true">ש&#x
05d3;ן</div> |
| 13 <div id="mixed" style="direction: ltr;" contenteditable="true">שד&
#x05df;ABC</div> |
| 14 <div id="mixed-rtl" style="direction: rtl;" contenteditable="true">ש
d3;ןABC</div> |
| 15 <div id="console"></div> |
| 16 </body> |
| 17 <script> |
| 18 |
| 19 var blockCursorStartPosition; |
| 20 var blockCursor; |
| 21 var textNode; |
| 22 |
| 23 function verifyBlockCursorLeftPositionAndWidth(elementId, expected) |
| 24 { |
| 25 blockCursorStartPosition = new Array(); |
| 26 |
| 27 var element = document.getElementById(elementId); |
| 28 textNode = element.firstChild; |
| 29 debug("Verifying block cursor position and width for each position in '" + t
extNode.nodeValue + "' in a " + element.style.direction + " block"); |
| 30 |
| 31 for (var i = 0; i < textNode.length; i++) { |
| 32 evalAndLog("getSelection().collapse(textNode, "+i+")"); |
| 33 |
| 34 blockCursor = internals.selectionBounds(); |
| 35 blockCursorStartPosition.push(blockCursor.left); |
| 36 |
| 37 if (i > 0 && i < textNode.length) { |
| 38 if (expected[i-1] == ">") |
| 39 shouldBeTrue("blockCursorStartPosition["+(i-1)+"] > blockCursorS
tartPosition["+i+"]"); |
| 40 else |
| 41 shouldBeTrue("blockCursorStartPosition["+(i-1)+"] < blockCursorS
tartPosition["+i+"]"); |
| 42 } |
| 43 |
| 44 shouldBeTrue("getSelection().isCollapsed"); |
| 45 shouldBeTrue("blockCursor.width > 1"); |
| 46 shouldBe("internals.absoluteCaretBounds().width", "1"); |
| 47 } |
| 48 |
| 49 evalAndLog("getSelection().collapse(textNode, "+i+")"); |
| 50 blockCursor = internals.selectionBounds(); |
| 51 shouldBeZero("blockCursor.width"); |
| 52 shouldBe("internals.absoluteCaretBounds().width", "1"); |
| 53 debug(""); |
| 54 } |
| 55 |
| 56 if (window.testRunner) { |
| 57 |
| 58 internals.toggleOverwriteModeEnabled(document); |
| 59 |
| 60 verifyBlockCursorLeftPositionAndWidth("ltrtext", ["<", "<", "<"]); |
| 61 verifyBlockCursorLeftPositionAndWidth("ltrtext-rtl", ["<", "<", "<"]); |
| 62 verifyBlockCursorLeftPositionAndWidth("rtltext", [">", ">", ">"]); |
| 63 verifyBlockCursorLeftPositionAndWidth("rtltext-rtl", [">", ">", ">"]); |
| 64 verifyBlockCursorLeftPositionAndWidth("mixed", [">", ">", "<", "<", "<"]); |
| 65 verifyBlockCursorLeftPositionAndWidth("mixed-rtl", [">", ">", ">", "<", "<"]
); |
| 66 } |
| 67 </script> |
| 68 <script src="../../fast/js/resources/js-test-post.js" type="text/javascript"></s
cript> |
| 69 </html> |
OLD | NEW |