Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / skip-non-editable-1.html
blob9a3a40b0ff435f2a5b55f916537ea5f5ac74fb21
1 <head>
2 <script>
3 if (window.testRunner)
4 testRunner.dumpEditingCallbacks();
5 </script>
7 <style>
8 table, td {
9 border: 1px solid #aaa;
11 </style>
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);
21 function assert(bool) {
22 if (!bool)
23 log("Failure");
24 else
25 log("Success");
27 </script>
28 </head>
30 <body contentEditable="true">
31 <p>This tests moving the caret in content of mixed editability. 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>
41 <ul id="console"></ul>
42 </body>
44 <script>
45 if (window.testRunner)
46 window.testRunner.dumpAsText();
48 var s = window.getSelection();
49 var e1 = document.getElementById("e1");
50 var e2 = document.getElementById("e2");
51 var e3 = document.getElementById("e3");
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);
58 s.modify("move", "backward", "character");
59 s.modify("move", "backward", "character");
60 assert(s.anchorNode == e1.firstChild && s.anchorOffset == e1.firstChild.length);
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);
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>