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

Side by Side Diff: LayoutTests/editing/caret/caret-direction-auto.html

Issue 541823003: Move caret to correct position when dir=auto (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Compile fix for Windows Created 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/editing/caret/caret-direction-auto-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
3 <script src="../../resources/js-test.js"></script>
4 <textarea id="textarea" dir="auto" style="font-size: 20px; width: 20ex; border: solid thin black; padding: 10px;">&#x05d0;!</textarea>
5 <script>
6 description('Tests various scenarios for caret position when direction is auto') ;
7
8 var text = document.getElementById('textarea');
9 var beforeCaretPos, afterCaretPos;
10 text.focus();
11 shouldBeEqualToString('textarea.value', 'א!');
12
13 debug('1. Caret is at right if text is in LTR direction');
14 beforeCaretPos = textInputController.firstRectForCharacterRange(0, 3);
15 testRunner.execCommand('MoveToEndOfLine');
16 document.execCommand('InsertLineBreak');
17 document.execCommand('InsertText', false, 'hello');
18 afterCaretPos = textInputController.firstRectForCharacterRange(4, 5);
19 shouldBeEqualToString('textarea.value', 'א!\nhello');
20 debug('Compares lines if they are different');
21 shouldNotBe('beforeCaretPos[1]', 'afterCaretPos[1]');
22 debug('New text is in LTR direction, start of caret will differ');
23 shouldBeGreaterThan('beforeCaretPos[0]', 'afterCaretPos[0]');
24
25 debug('2. Addition of RTL text in middle of LTR text, caret moves to the left of the line.');
26 beforeCaretPos = afterCaretPos;
27 document.execCommand('InsertText', false, '\u05d0\u05d0');
28 afterCaretPos = textInputController.firstRectForCharacterRange(4, 7);
29 shouldBeEqualToString('textarea.value', 'א!\nhelloאא');
30 debug('RTL text added will be move caret to start of position where hello begins ');
31 shouldBe('beforeCaretPos[0]', 'afterCaretPos[0]+afterCaretPos[2]');
32
33 debug('3. Adding LTR text after RTL should move caret towards right.');
34 beforeCaretPos = afterCaretPos;
35 document.execCommand('InsertText', false, 'bye');
36 afterCaretPos = textInputController.firstRectForCharacterRange(4, 10);
37 shouldBeEqualToString('textarea.value', 'א!\nhelloאאbye');
38 debug('Start position of caret is same');
39 shouldBe('beforeCaretPos[0]+beforeCaretPos[2]', 'afterCaretPos[0]');
40 debug('But end position differs');
41 shouldNotBe('beforeCaretPos[0]+beforeCaretPos[2]', 'afterCaretPos[0]+afterCaretP os[2]');
42
43 debug('4. Adding space, caret should move caret');
44 beforeCaretPos = afterCaretPos;
45 document.execCommand('InsertText', false, ' ');
46 afterCaretPos = textInputController.firstRectForCharacterRange(4, 11);
47 shouldBeEqualToString('textarea.value', 'א!\nhelloאאbye ');
48 shouldBeGreaterThan('afterCaretPos[0]+afterCaretPos[2]', 'beforeCaretPos[0]+befo reCaretPos[2]');
49
50 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/editing/caret/caret-direction-auto-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698