Index: LayoutTests/editing/selection/block-cursor-overtype-mode.html |
diff --git a/LayoutTests/editing/selection/block-cursor-overtype-mode.html b/LayoutTests/editing/selection/block-cursor-overtype-mode.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f457178584cc34a2fafc9697c28f3454f650af50 |
--- /dev/null |
+++ b/LayoutTests/editing/selection/block-cursor-overtype-mode.html |
@@ -0,0 +1,69 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<script type="text/javascript" src="../editing.js"></script> |
+<script src="../../fast/js/resources/js-test-pre.js" type="text/javascript"></script> |
+</head> |
+<body style="font: 20px Ahem"> |
+<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> |
+<div id="ltrtext" style="direction: ltr;" contenteditable="true">ABC</div> |
+<div id="ltrtext-rtl" style="direction: rtl;" contenteditable="true">ABC</div> |
+<div id="rtltext" style="direction: ltr;" contenteditable="true">שדן</div> |
+<div id="rtltext-rtl" style="direction: rtl;" contenteditable="true">שדן</div> |
+<div id="mixed" style="direction: ltr;" contenteditable="true">שדןABC</div> |
+<div id="mixed-rtl" style="direction: rtl;" contenteditable="true">שדןABC</div> |
+<div id="console"></div> |
+</body> |
+<script> |
+ |
+var blockCursorStartPosition; |
+var blockCursor; |
+var textNode; |
+ |
+function verifyBlockCursorLeftPositionAndWidth(elementId, expected) |
+{ |
+ blockCursorStartPosition = new Array(); |
+ |
+ var element = document.getElementById(elementId); |
+ textNode = element.firstChild; |
+ debug("Verifying block cursor position and width for each position in '" + textNode.nodeValue + "' in a " + element.style.direction + " block"); |
+ |
+ for (var i = 0; i < textNode.length; i++) { |
+ evalAndLog("getSelection().collapse(textNode, "+i+")"); |
+ |
+ blockCursor = internals.selectionBounds(); |
+ blockCursorStartPosition.push(blockCursor.left); |
+ |
+ if (i > 0 && i < textNode.length) { |
+ if (expected[i-1] == ">") |
+ shouldBeTrue("blockCursorStartPosition["+(i-1)+"] > blockCursorStartPosition["+i+"]"); |
+ else |
+ shouldBeTrue("blockCursorStartPosition["+(i-1)+"] < blockCursorStartPosition["+i+"]"); |
+ } |
+ |
+ shouldBeTrue("getSelection().isCollapsed"); |
+ shouldBeTrue("blockCursor.width > 1"); |
+ shouldBe("internals.absoluteCaretBounds().width", "1"); |
+ } |
+ |
+ evalAndLog("getSelection().collapse(textNode, "+i+")"); |
+ blockCursor = internals.selectionBounds(); |
+ shouldBeZero("blockCursor.width"); |
+ shouldBe("internals.absoluteCaretBounds().width", "1"); |
+ debug(""); |
+} |
+ |
+if (window.testRunner) { |
+ |
+ internals.toggleOverwriteModeEnabled(document); |
+ |
+ verifyBlockCursorLeftPositionAndWidth("ltrtext", ["<", "<", "<"]); |
+ verifyBlockCursorLeftPositionAndWidth("ltrtext-rtl", ["<", "<", "<"]); |
+ verifyBlockCursorLeftPositionAndWidth("rtltext", [">", ">", ">"]); |
+ verifyBlockCursorLeftPositionAndWidth("rtltext-rtl", [">", ">", ">"]); |
+ verifyBlockCursorLeftPositionAndWidth("mixed", [">", ">", "<", "<", "<"]); |
+ verifyBlockCursorLeftPositionAndWidth("mixed-rtl", [">", ">", ">", "<", "<"]); |
+} |
+</script> |
+<script src="../../fast/js/resources/js-test-post.js" type="text/javascript"></script> |
+</html> |