Index: LayoutTests/editing/selection/caret-with-first-letter.html |
diff --git a/LayoutTests/editing/selection/caret-with-first-letter.html b/LayoutTests/editing/selection/caret-with-first-letter.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e93252a4c7a559509f9a23cfb640eafc612c94cf |
--- /dev/null |
+++ b/LayoutTests/editing/selection/caret-with-first-letter.html |
@@ -0,0 +1,78 @@ |
+<html> |
+<head> |
+<style> |
+.test { |
+ font-family: monospace; |
+} |
+.test:first-letter { |
+ color: red; |
+} |
+</style> |
+</head> |
+<body> |
+<div id="container"> |
+<p id="description"></p> |
+<ol> |
+<li>Set caret before "a".</li> |
+<li>Hit right arrow key.</li> |
+<li>Hit right arrow key.</li> |
+<li>Hit right left key.</li> |
+<li>Hit right left key.</li> |
+<li>Caret should be before "a".</li> |
+</ol> |
+<div id="sample" contenteditable="true"> |
+<p class="test">abcdefgh</p> |
+</div> |
+</div> |
+<div id="console"></div> |
+<script src="../../fast/js/resources/js-test-pre.js"></script> |
+<script> |
+description('Check left/right arrow key around first letter'); |
+function $(id) { return document.getElementById(id); } |
+ |
+var selection = window.getSelection(); |
+var test = document.querySelector('.test'); |
+$('sample').focus(); |
+ |
+debug('Move caret before first letter'); |
+var range = document.createRange(); |
+range.setStart(test.firstChild, 0); |
+selection.removeAllRanges(); |
+selection.addRange(range); |
+ |
+shouldBeEqualToString('selection.type', 'Caret'); |
+shouldBe('selection.anchorNode', 'test.firstChild'); |
+shouldBe('selection.anchorOffset', '0'); |
+ |
+if (window.eventSender) { |
+ |
+ debug('Hit right arrow key'); |
+ eventSender.keyDown('rightArrow'); |
+ shouldBeEqualToString('selection.type', 'Caret'); |
+ shouldBe('selection.anchorNode', 'test.firstChild'); |
+ shouldBe('selection.anchorOffset', '1'); |
+ |
+ debug('Hit right arrow key'); |
+ eventSender.keyDown('rightArrow'); |
+ shouldBeEqualToString('selection.type', 'Caret'); |
+ shouldBe('selection.anchorNode', 'test.firstChild'); |
+ shouldBe('selection.anchorOffset', '2'); |
+ |
+ debug('Hit left arrow key'); |
+ eventSender.keyDown('rightArrow'); |
+ shouldBeEqualToString('selection.type', 'Caret'); |
+ shouldBe('selection.anchorNode', 'test.firstChild'); |
+ shouldBe('selection.anchorOffset', '1'); |
+ |
+ debug('Hit left arrow key'); |
+ eventSender.keyDown('rightArrow'); |
+ shouldBeEqualToString('selection.type', 'Caret'); |
+ shouldBe('selection.anchorNode', 'test.firstChild'); |
+ shouldBe('selection.anchorOffset', '0'); |
+} |
+ |
+if (window.testRunner) |
+ $('container').outerHTML = ''; |
+</script> |
+<script src="../../fast/js/resources/js-test-post.js"></script> |
+</body> |