4 <script src=
"../../resources/ahem.js"></script>
5 <script src=
"../../resources/js-test.js" type=
"text/javascript"></script>
13 <p> Bug
<a href=
"http://webkit.org/b/86390">86390</a>: Expose FrameSelection::absoluteCaretBounds via window.internals
</p>
14 <p>This test demonstrates the usage of window.internals.absoluteCaretBounds()
</p>
15 <div id=
"testDiv" CONTENTEDITABLE
>abcd
</div>
16 <div id=
"console"></div>
20 function verifyCaretRect(left
, top
, width
, height
)
22 if (window
.internals
) {
23 var index
= caretRects
.length
;
24 caretRects
.push(internals
.absoluteCaretBounds());
25 shouldBe("caretRects[" + index
+ "].left", left
.toString());
26 shouldBe("caretRects[" + index
+ "].top", top
.toString());
27 shouldBe("caretRects[" + index
+ "].width", width
.toString());
28 shouldBe("caretRects[" + index
+ "].height", height
.toString());
32 var textNode
= document
.getElementById("testDiv").firstChild
;
33 getSelection().collapse(textNode
, 0); // before a
34 verifyCaretRect(8, 160, 1, 20);
35 getSelection().collapse(textNode
, 1); // after a
36 verifyCaretRect(28, 160, 1, 20);
37 getSelection().collapse(textNode
, 2); // after b
38 verifyCaretRect(48, 160, 1, 20);
39 getSelection().collapse(textNode
, 3); // after c
40 verifyCaretRect(68, 160, 1, 20);
41 getSelection().collapse(textNode
, 4); // after d
42 verifyCaretRect(88, 160, 1, 20);