Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / selection / skip-non-editable-rtl.html
1 <head>
2 <script>
3 if (window.testRunner)
4      testRunner.dumpEditingCallbacks();
5 </script>
6
7 <style>
8 table, td {
9     border: 1px solid #aaa;
10 }
11 </style>
12
13 <script>
14 function log(str) {
15     var li = document.createElement("li");
16     li.appendChild(document.createTextNode(str));
17     var console = document.getElementById("console");
18     console.appendChild(li);
19 }
20
21 function assert(bool) {
22     if (!bool)
23         log("Failure");
24     else
25         log("Success");
26 }
27 </script>
28 </head>
29
30 <body contentEditable="true" dir="rtl">
31 <p>This tests moving the caret in content of mixed editability with direction RTL.  The caret should jump to the next editable region that shares a common editable ancestor when it reaches non-editable content.</p>
32 <div id="e1">editable content</div>
33 <table cellpadding="5" contentEditable="false">
34 <tr>
35 <td>non-editable content</td>
36 <td>non-editable content</td>
37 <td id="e2" contentEditable="true">editable content</td>
38 </table>
39 <div id="e3">editable content</div>
40
41 <ul id="console"></ul>
42 </body>
43
44 <script>
45 if (window.testRunner)
46     window.testRunner.dumpAsText();
47     
48 var s = window.getSelection();
49 var e1 = document.getElementById("e1");
50 var e2 = document.getElementById("e2");
51 var e3 = document.getElementById("e3");
52
53 s.collapse(e1.firstChild, e1.firstChild.length);
54 s.modify("move", "forward", "character");
55 s.modify("move", "forward", "character");
56 assert(s.anchorNode == e2.firstChild && s.anchorOffset == 0);
57
58 s.modify("move", "backward", "character");
59 s.modify("move", "backward", "character");
60 assert(s.anchorNode == e1.firstChild && s.anchorOffset == e1.firstChild.length);
61     
62 s.collapse(e2.firstChild, e2.firstChild.length);
63 s.modify("move", "forward", "character");
64 s.modify("move", "forward", "character");
65 assert(s.anchorNode == e3.firstChild && s.anchorOffset == 0);
66
67 s.modify("move", "backward", "character");
68 s.modify("move", "backward", "character");
69 assert(s.anchorNode == e2.firstChild && s.anchorOffset == e2.firstChild.length)
70 </script>