Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / home-end.html
blob63149edfe827347025a238f6291dab818a35a2bc
1 <head>
2 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
3 <style>
4 div.test {
5 -webkit-user-modify: read-write;
6 padding: 4px;
7 border: 1px dashed lightblue;
8 margin: 4px 4px 4px 24px;
9 outline: none;
10 font-family: Lucida Grande;
11 counter-increment: test-number;
13 div.test:before { content: counter(test-number); position: absolute; left: 8px; font-size: x-small; text-align: right; width: 20px; }
14 div.test span { background-color: #def; }
15 div.test img { width: 1em; height: 1em; background-color: lightgreen; }
16 div.test img + img { background-color: lightblue; }
17 div.test div { border: 1px dashed pink; padding: 3px; height: 2em; }
18 </style>
19 <script>
20 function log(message)
22 document.getElementById("console").appendChild(document.createTextNode(message));
25 function positionsMovingInDirection(sel, direction)
27 var positions = [];
28 positions.push({ node: sel.anchorNode, offset: sel.focusOffset});
29 sel.modify("move", direction, "lineBoundary");
30 positions.push({ node: sel.anchorNode, offset: sel.focusOffset});
31 return positions;
34 function fold(string)
36 var result = "";
37 for (var i = 0; i < string.length; ++i) {
38 var char = string.charCodeAt(i);
39 if (char >= 0x05d0)
40 char -= 0x058f;
41 else if (char == 10) {
42 result += "\\n";
43 continue;
45 result += String.fromCharCode(char);
47 return result;
50 function logPositions(positions)
52 for (var i = 0; i < positions.length; ++i) {
53 if (i) {
54 if (positions[i].node != positions[i - 1].node)
55 log("]");
56 log(", ");
58 if (!i || positions[i].node != positions[i - 1].node)
59 log((positions[i].node instanceof Text ? '"' + fold(positions[i].node.data) + '"' : "<" + positions[i].node.tagName + ">") + "[");
60 log(positions[i].offset);
62 log("]");
65 onload = function()
67 if (!window.testRunner)
68 return;
70 testRunner.dumpAsText();
72 var tests = document.getElementsByClassName("test");
73 var sel = getSelection();
74 log("Test Moving forward/backward\n");
75 for (var i = 0; i < tests.length; ++i) {
76 var positionsMovingForward;
77 var positionsMovingBackward;
79 log("Test " + (i + 1) + ", LTR:\n Moving forward: ");
80 sel.collapse(tests[i], 0);
81 positionsMovingForward = positionsMovingInDirection(sel, "forward");
82 logPositions(positionsMovingForward);
83 log("\n");
85 log(" Moving backward: ");
86 positionsMovingBackward = positionsMovingInDirection(sel, "backward");
87 logPositions(positionsMovingBackward);
88 log("\n");
90 tests[i].style.direction = "rtl";
92 log("Test " + (i + 1) + ", RTL:\n Moving forward: ");
93 sel.collapse(tests[i], 0);
94 positionsMovingForward = positionsMovingInDirection(sel, "forward");
95 logPositions(positionsMovingForward);
96 log("\n");
98 log(" Moving backward: ");
99 positionsMovingBackward = positionsMovingInDirection(sel, "backward");
100 logPositions(positionsMovingBackward);
101 log("\n");
104 log("Test Moving right/left\n");
105 for (var i = 0; i < tests.length; ++i) {
106 var positionsMovingRight;
107 var positionsMovingLeft;
109 tests[i].style.direction = "ltr";
111 log("Test " + (i + 1) + ", LTR:\n Moving right: ");
112 sel.collapse(tests[i], 0);
113 positionsMovingRight = positionsMovingInDirection(sel, "right");
114 logPositions(positionsMovingRight);
115 log("\n");
117 log(" Moving left: ");
118 positionsMovingLeft = positionsMovingInDirection(sel, "left");
119 logPositions(positionsMovingLeft);
120 log("\n");
122 tests[i].style.direction = "rtl";
124 log("Test " + (i + 1) + ", RTL:\n Moving left: ");
125 sel.collapse(tests[i], 0);
126 positionsMovingLeft = positionsMovingInDirection(sel, "left");
127 logPositions(positionsMovingLeft);
128 log("\n");
130 log(" Moving right: ");
131 positionsMovingRight = positionsMovingInDirection(sel, "right");
132 logPositions(positionsMovingRight);
133 log("\n");
135 tests[i].style.display = "none";
139 </script>
140 </head>
141 <body>
143 <div contenteditable class="test">
144 abc &#1488;&#1489;&#1490; xyz &#1491;&#1492;&#1493; def
145 </div>
146 <div contenteditable class="test">
147 &#1488;&#1489;&#1490; xyz &#1491;&#1492;&#1493; def &#1494;&#1495;&#1496;
148 </div>
149 <div contenteditable class="test">
150 &#1488;&#1489;&#1490; &#1491;&#1492;&#1493; &#1488;&#1489;&#1490;
151 </div>
152 <div contenteditable class="test">
153 abc efd dabeb
154 </div>
156 <div contenteditable class="test">Lorem <span style="direction: rtl">ipsum dolor sit</span> amet</div>
157 <div contenteditable class="test">Lorem <span style="direction: rtl">ipsum dolor<div > just a test</div> sit</span> amet</div>
158 <div contenteditable class="test">Lorem <span dir="rtl">ipsum dolor sit</span> amet</div>
159 <div contenteditable class="test">Lorem <div dir="rtl">ipsum dolor sit</div> amet</div>
161 <div contenteditable class="test">Lorem <span style="direction: ltr">ipsum dolor sit</span> amet</div>
162 <div contenteditable class="test">Lorem <span style="direction: ltr">ipsum dolor<div > just a test</div> sit</span> amet</div>
163 <div contenteditable class="test">Lorem <span dir="ltr">ipsum dolor sit</span> amet</div>
164 <div contenteditable class="test">Lorem <div dir="ltr">ipsum dolor sit</div> amet</div>
166 <div class="test" style="direction: ltr;" contenteditable>
167 Just
168 <span>testing רק</span>
169 בודק
170 </div>
172 <div class="test" style="direction: ltr;" contenteditable>
173 Just
174 <span>testing what</span>
175 ever
176 </div>
179 <div class="test" contenteditable>car means &#1488;&#1489;&#1490;.</div>
180 <div class="test" contenteditable>&#x202B;car &#1491;&#1492;&#1493; &#1488;&#1489;&#1490;.&#x202c;</div>
181 <div class="test" contenteditable>he said "&#x202B;car &#1491;&#1492;&#1493; &#1488;&#1489;&#1490;&#x202c;."</div>
182 <div class="test" contenteditable>&#1494;&#1495;&#1496; &#1497;&#1498;&#1499; &#1500;&#1501;&#1502; '&#x202a;he said "&#x202B;car &#1491;&#1492;&#1493; &#1488;&#1489;&#1490;&#x202c;"&#x202c;'?</div>
185 <div class="test" contenteditable>&#1488;&#1489;&#1490; abc &#1491;&#1492;&#1493;<br />edf &#1494;&#1495;&#1496; abrebg</div>
186 <div class="test" contenteditable style="line-break:before-white-space; width:100px">abcdefg abcdefg abcdefg a abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg </div>
187 <div class="test" contenteditable style="line-break:after-white-space; width:100px">abcdefg abcdefg abcdefg a abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg </div>
188 <pre id="console"></pre>
189 </body>