4 <style type="text/css">
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>
19 if (window.testRunner)
20 testRunner.dumpAsText();
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';
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);