13 <script src="../../fast/js/resources/js-test-pre.js"></script>
16 <p>This test ensures WebKit takes paddings and borders into account when moving vertically.</p>
18 <li><p contenteditable>left1 <a href="">right1 left2</a> right2</p></li>
19 <li><p contenteditable>left1 <a style="border: solid 5px blue;" href="">right1 left2</a> right2</p></li>
20 <li><p contenteditable>left1 <a style="padding: 5px;" href="">right1 left2</a> right2</p></li>
21 <li><p contenteditable>left1 <a style="padding: 5px;" href="">right1 left2 right2 left3</a> right3</p></li>
23 <div id="console"></div>
26 function moveToMiddleOfWord(node, word) {
27 window.getSelection().setPosition(node, 0);
28 if (!window.find(word))
30 window.getSelection().modify('move', 'backward', 'character');
31 window.getSelection().modify('move', 'forward', 'character');
32 window.getSelection().modify('move', 'forward', 'character');
36 function selectWord() {
37 window.getSelection().modify('move', 'backward', 'word');
38 window.getSelection().modify('extend', 'forward', 'word');
39 return window.getSelection().toString();
42 function moveVerticallyAndVerify(node, direction, from, to) {
43 if (node.innerText.indexOf(from) === -1 || node.innerText.indexOf(to) === -1)
45 if (!moveToMiddleOfWord(node, from))
47 window.getSelection().modify('move', direction, 'line');
48 shouldBe('selectWord()', '"' + to + '"');
51 var tests = document.getElementById('tests').getElementsByTagName('p');
52 for (var i = 0; i < tests.length; i++) {
55 debug('test ' + (i + 1));
58 for (var j = 1; j <= 2; j++) {
59 moveVerticallyAndVerify(node, 'forward', 'left' + j, 'left' + (j + 1));
60 moveVerticallyAndVerify(node, 'forward', 'right' + j, 'right' + (j + 1));
61 moveVerticallyAndVerify(node, 'backward', 'left' + (j + 1), 'left' + j);
62 moveVerticallyAndVerify(node, 'backward', 'right' + (j + 1), 'right' + j);
68 document.getElementById('tests').style.display = 'none';
71 <script src="../../fast/js/resources/js-test-post.js"></script>