4 <title> Testcase for bug https://bugs.webkit.org/show_bug.cgi?id=
89649 </title>
5 <script src=
"../../resources/ahem.js"></script>
15 <script src=
"../../resources/js-test.js"></script>
18 description('Testcase for bug <a href="http://www.webkit.org/b/89649">http://www.webkit.org/b/89649</a>. \
19 The test case checks if caret is drawn properly (especially scrolls properly) inside a editable container having word-wrap:normal.');
21 editableContainer
= document
.getElementById('test');
22 editableContainer
.focus();
24 startCaretRect
= internals
.absoluteCaretBounds();
26 window
.getSelection().collapse(editableContainer
,0);
27 if (window
.testRunner
)
28 testRunner
.execCommand('MoveToEndOfLine');
30 finalCaretRect
= {right
:-1,left
:-1};
32 finalCaretRect
= internals
.absoluteCaretBounds();
34 caretWidth
= finalCaretRect
.right
- finalCaretRect
.left
;
36 debug('To manually test, move the caret to the end of the line. \nThe content must scroll for the caret to reach the end of the editable text.');
37 shouldBeTrue("editableContainer.scrollLeft > 0");
39 debug('<br>Final caret rect is calculated by following constraints');
40 debug('1) ScrollWidth = text content width + caret width');
41 debug('2) Caret rect is always within container bounding box (thus subtracting the scroll left)');
42 shouldBe("startCaretRect.left + editableContainer.scrollWidth - editableContainer.scrollLeft", "finalCaretRect.right");
44 document
.body
.removeChild(editableContainer
);
45 isSuccessfullyParsed();
49 <body onload=
"runTest();">
50 <div id=
"test" contenteditable=
"true" class=
"editableDiv" >
51 SOMEFILLERTEXTSOMEFILLERTEXTSOMEFILLERFILLERSFILLERSFILLERSFILLERSFILLERS
53 <div id=
"description"></div>
54 <div id=
"console"></div>