Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / text-iterator / first-letter-word-boundary.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <style type="text/css">
5
6 #test:first-letter {
7     color: red;
8 }
9
10 </style>
11 </head>
12 <body>
13 <p>This tests moving caret around a word with a first-letter rule. WebKit should not crash.
14 This test also demonstrates a bug that word position is incorrectly reported.</p>
15 <div id="test" contenteditable> hello world'</div>
16 <pre id="console"></pre>
17 <script>
18
19 if (window.testRunner)
20     testRunner.dumpAsText();
21 if (window.internals)
22   internals.settings.setEditingBehavior("mac");
23
24 function runTest(actor, expectedOffset) {
25     window.getSelection().collapse(test.firstChild, 4);
26     var action = actor() + ' from offset ' + 4 + ' put caret at offset ';
27     var startOffset = window.getSelection().getRangeAt(0).startOffset;
28     action += startOffset;
29     if (startOffset == expectedOffset)
30         console.innerHTML += 'PASS: ' + action + '\n';
31     else
32         console.innerHTML += 'FAIL: ' + action + ' but expected ' + expectedOffset + '\n';
33 }
34
35 var test = document.getElementById('test');
36 var console = document.getElementById('console');
37
38 console.innerHTML += 'white-space: normal;\n';
39 runTest(function () {window.getSelection().modify('move', 'forward', 'word'); return 'moving forward by word';}, 6);
40 runTest(function () {window.getSelection().modify('move', 'backward', 'word'); return 'moving backward by word';}, 1);
41
42 console.innerHTML += 'white-space: pre;\n';
43 test.style.whiteSpace = 'pre';
44 runTest(function () {window.getSelection().modify('move', 'forward', 'word'); return 'moving forward by word';}, 6);
45 runTest(function () {window.getSelection().modify('move', 'backward', 'word'); return 'moving backward by word';}, 1);
46
47 </script>
48 </body>
49 </html>