Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: LayoutTests/editing/selection/caret-with-first-letter.html

Issue 20681004: Make first-letter style to work with editing Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-09-20T18:27:32 Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698