4 <meta http-equiv=
"content-type" content=
"text/html;charset=utf-8">
5 <style type=
"text/css">
13 .tests div, .tests pre {
14 border: solid
1px black
;
24 <p>This tests selecting LTR/RTL text that spans multiple lines in RTL/LTR block (opposite directionality).
25 To manually test, select text in each of editable regions below by dragging mouse from one edge to another.
26 The entire line should be selected.
</p>
29 <li><div contenteditable
title=
"0 3, 4 6">abc
<br>def
</div></li>
30 <li><div contenteditable
title=
"0 3">ابص
</div></li>
31 <li><div contenteditable
dir=
"rtl" title=
"0 3">abc
</div></li>
32 <li><div contenteditable
title=
"0 3, 4, 5 6">ابص
<span dir=
"ltr"><br><br>a
</span></div></li>
33 <li><div contenteditable
dir=
"rtl" title=
"0 3, 4, 5 6">abc
<span dir=
"rtl"><br><br>ا
</span></div></li>
34 <li><div contenteditable
title=
"0 3, 4, 5 6">ابص
<br><br>a
</div></li>
35 <li><div contenteditable
dir=
"rtl" title=
"0 3, 4, 5 6">ابص
<br><br>a
</div></li>
38 <li><pre contenteditable
title=
"0 3, 4, 5 6"><span dir=
"rtl">ابص
41 <li><pre contenteditable
dir=
"rtl" title=
"0 3, 4, 5 6"><span dir=
"ltr">abc
44 <li><pre contenteditable
dir=
"rtl" title=
"0 3, 4, 5 6">abc
<span dir=
"rtl">
49 <pre id=
"log"><script>
51 function selectLineSafely(test
, lineTop
) {
52 var y
= test
.offsetTop
+ lineTop
+ 5;
53 eventSender
.mouseMoveTo(test
.offsetLeft
+ 5, y
);
54 eventSender
.mouseDown();
56 eventSender
.leapForward(200);
58 eventSender
.mouseMoveTo(test
.offsetLeft
+ test
.offsetWidth
- 5, y
);
59 eventSender
.mouseUp();
62 if (window
.testRunner
) {
63 testRunner
.dumpAsText();
65 if (!window
.eventSender
)
66 document
.writeln('This test requires eventSender');
68 var tests
= document
.getElementsByTagName('li');
71 for (var i
= 0; i
< tests
.length
; i
++) {
72 var test
= tests
[i
].firstChild
;
73 offsets
= test
.title
.split(', ');
75 for (var j
= 0; j
< offsets
.length
; j
++) {
77 return document
.write('TEST ' + (i
+ 1) + ' line ' + (j
+ 1) + ':' + msg
+ '\n');
80 var start
= parseInt(offsets
[j
].split(' ')[0]);
81 var afterEnd
= parseInt(offsets
[j
].split(' ')[1]); // Might be NaN
82 var selection
= window
.getSelection();
84 selectLineSafely(test
, 13 * (j
+ 1));
86 var actual
= selection
.toString();
87 var expected
= test
.innerText
.substr(start
, afterEnd
);
88 if (actual
== expected
)
91 log('FAIL - expected "' + expected
+ '" but got "' + actual
+ '"');
96 document
.getElementById('tests').style
.display
= 'none';
98 document
.addEventListener('selectionchange', function () {
99 var selection
= window
.getSelection();
100 if (selection
.isCollapsed
)
101 document
.getElementById('log').innerHTML
+= selection
.baseOffset
+ '\n';
103 document
.getElementById('log').innerHTML
+= selection
.baseOffset
+ ':' + selection
.extentOffset
+ '\n';