Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / extend-backward-by-word-over-non-editable.html
blob888fe4d30793b94bcd65bd73f1c6f0511c9a0c38
1 <!DOCTYPE html>
2 <pre id="log"></pre>
4 <div id="ltrTextContainer" contenteditable>foo bar <span contenteditable=false>baz</span> qux quux</div>
5 <div id="rtlTextContainer" contenteditable dir="rtl">&#x05E9;&#x05D5;&#x05BC;&#x05E8;&#x05D4; &#x05E9;&#x05D5;&#x05BC;&#x05E8;&#x05D4;
6 <span contenteditable=false>&#x05E9;&#x05D5;&#x05BC;&#x05E8;&#x05D4;</span>
7 &#x05E9;&#x05D5;&#x05BC;&#x05E8;&#x05D4; &#x05E9;&#x05D5;&#x05BC;&#x05E8;&#x05D4;</div>
9 <script>
10 function log(s) {
11 document.getElementById("log").appendChild(document.createTextNode(s + "\n"));
14 function placeCursorAfterFirstNoneditableChild(container) {
15 for (var i = 0; i < container.childNodes.length; i++) {
16 var node = container.childNodes[i];
17 if (node.isContentEditable !== undefined && !node.isContentEditable) {
18 getSelection().collapse(node.nextSibling, 0);
19 return node;
22 throw "Couldn't find noneditable child of " + container.textContent;
25 function extendBackwardByWord(container, bidiName) {
26 noneditableChild = placeCursorAfterFirstNoneditableChild(container);
27 getSelection().modify("extend", "backward", "word");
28 if (getSelection().toString() === noneditableChild.textContent)
29 log("PASS for " + bidiName);
30 else
31 log("FAIL for " + bidiName + ", selection is \"" + getSelection() + "\" but should be \"" + noneditableChild.textContent + "\"");
34 extendBackwardByWord(document.getElementById("ltrTextContainer"), "LTR");
35 extendBackwardByWord(document.getElementById("rtlTextContainer"), "RTL");
37 if (window.testRunner)
38 testRunner.dumpAsText();
39 </script>