4 <div id=
"ltrTextContainer" contenteditable
>foo bar
<span contenteditable=false
>baz
</span> qux quux
</div>
5 <div id=
"rtlTextContainer" contenteditable
dir=
"rtl">שוּרה שוּרה
6 <span contenteditable=false
>שוּרה</span>
7 שוּרה שוּרה</div>
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);
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
);
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();