3 <body><div id=
"tests"><div style=
"width: 1ex; font-size: 1em; white-space: pre-wrap;"
4 ></div><div style=
"width: 1ex; font-size: 1em; white-space: pre-wrap; word-wrap: break-word;"
5 ></div><textarea style=
"width: 1ex; font-size: 1em;"
6 ></textarea></div><pre id=
"log"></pre><script>
8 function assertEqual(name
, length
, endOffset
)
10 log
.textContent
+= '\n' + name
+ ': ';
11 if (length
!= endOffset
)
12 log
.textContent
+= 'FAIL - length was ' + length
+ ' but selection end was ' + endOffset
+ ' after selecting all text';
14 log
.textContent
+= 'PASS';
17 var tests
= document
.getElementById('tests').childNodes
;
18 var log
= document
.getElementById('log');
19 log
.textContent
= 'This test ensures WebKit renders the trailing whitespace properly. You should see PASS thrice below.\n';
22 for (var i
= 0; i
< tests
.length
; i
++, letter
= String
.fromCharCode(letter
.charCodeAt(0) + 1)) {
23 if (tests
[i
].select
) {
24 tests
[i
].value
= letter
+ '\t';
27 var endOffset
= tests
[i
].selectionEnd
;
29 tests
[i
].textContent
= letter
+ '\t';
30 window
.getSelection().selectAllChildren(tests
[i
]);
31 var endOffset
= window
.getSelection().getRangeAt(0).endOffset
;
33 assertEqual('test ' + i
, 2, endOffset
);
36 if (window
.testRunner
) {
37 testRunner
.dumpAsText();
38 document
.getElementById('tests').style
.display
= 'none';
41 </script></pre></body>