Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / selection / move-by-line-004.html
1 <p>
2     Test that moving the caret with line granularity within the highest
3     editable root works across non-editable content.
4 </p>
5 <pre id="console"></pre>
6 <div contenteditable="true">
7     <div contenteditable="false">
8         <span id="pie" contenteditable="true">apple pie</span>
9     </div>
10     <div contenteditable="false">
11         pineapple
12     </div>
13     <div contenteditable="false">
14         <span id="juice" contenteditable="true">apple juice</span>
15     </div>
16 </div>
17 <script>
18     function log(message)
19     {
20         document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
21     }
22
23     if (window.testRunner)
24         testRunner.dumpAsText();
25
26     var fail = false;
27     var pie = document.getElementById("pie");
28     var juice = document.getElementById("juice");
29
30     var sel = getSelection();
31     sel.collapse(pie.firstChild, 3);
32     sel.modify("move", "forward", "line");
33
34     if (sel.anchorNode !== juice.firstChild || sel.anchorOffset != 3) {
35         log("FAIL: Did not move to the next line");
36         fail = true;
37     }
38
39     sel.collapse(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");
49 </script>