Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / text-iterator / first-letter-word-boundary.html
blob9386c9024d7688e3a1df235d01dbbed0ad024184
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <style type="text/css">
6 #test:first-letter {
7 color: red;
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>
19 if (window.testRunner)
20 testRunner.dumpAsText();
21 if (window.internals)
22 internals.settings.setEditingBehavior("mac");
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';
35 var test = document.getElementById('test');
36 var console = document.getElementById('console');
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);
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);
47 </script>
48 </body>
49 </html>