OLD | NEW |
1 <script src="../../fast/js/resources/js-test-pre.js"></script> | 1 <p> |
2 <script src="./resources/js-test-selection-shared.js"></script> | 2 Test that moving the caret with line granularity within the highest |
3 | 3 editable root works across non-editable content. |
4 <div id="test" contenteditable="true"> | 4 </p> |
| 5 <pre id="console"></pre> |
| 6 <div contenteditable="true"> |
5 <div contenteditable="false"> | 7 <div contenteditable="false"> |
6 <span id="pie" contenteditable="true">apple pie</span> | 8 <span id="pie" contenteditable="true">apple pie</span> |
7 </div> | 9 </div> |
8 <div contenteditable="false"> | 10 <div contenteditable="false"> |
9 pineapple | 11 pineapple |
10 </div> | 12 </div> |
11 <div contenteditable="false"> | 13 <div contenteditable="false"> |
12 <span id="juice" contenteditable="true">apple juice</span> | 14 <span id="juice" contenteditable="true">apple juice</span> |
13 </div> | 15 </div> |
14 </div> | 16 </div> |
| 17 <script> |
| 18 function log(message) |
| 19 { |
| 20 document.getElementById("console").appendChild(document.createTextNode(m
essage + "\n")); |
| 21 } |
15 | 22 |
16 <script> | 23 if (window.testRunner) |
17 description('Test that moving the caret with line granularity within the highest
editable root doesn\'t work across non-editable content.'); | 24 testRunner.dumpAsText(); |
18 | 25 |
19 testCaretMotion({ | 26 var fail = false; |
20 'direction': 'forward', | 27 var pie = document.getElementById("pie"); |
21 'granularity': 'line', | 28 var juice = document.getElementById("juice"); |
22 'origin': 'pie', | |
23 'originOffset': 3, | |
24 'target': 'pie', | |
25 'targetOffset': -1, | |
26 }); | |
27 | 29 |
28 testCaretMotion({ | 30 var sel = getSelection(); |
29 'direction': 'backward', | 31 sel.setPosition(pie.firstChild, 3); |
30 'granularity': 'line', | 32 sel.modify("move", "forward", "line"); |
31 'origin': 'juice', | |
32 'originOffset': 3, | |
33 'target': 'juice', | |
34 'targetOffset': 0, | |
35 }); | |
36 | 33 |
37 if (window.testRunner) | 34 if (sel.anchorNode !== juice.firstChild || sel.anchorOffset != 3) { |
38 $('test').outerHTML = ''; | 35 log("FAIL: Did not move to the next line"); |
| 36 fail = true; |
| 37 } |
| 38 |
| 39 sel.setPosition(juice.firstChild, 3); |
| 40 sel.modify("move", "backward", "line"); |
| 41 |
| 42 if (sel.anchorNode !== pie.firstChild || sel.anchorOffset != 3) { |
| 43 log("FAIL: Did not move to the previous line"); |
| 44 fail = true; |
| 45 } |
| 46 |
| 47 if (!fail) |
| 48 log("PASS"); |
39 </script> | 49 </script> |
40 <script src="../../fast/js/resources/js-test-post.js"></script> | |
OLD | NEW |