2 <script src=
"../../resources/js-test.js"></script>
3 <body contenteditable=
"true">
4 <p id=
"p"><span id=
"span" contenteditable=
"false" style=
"display: inline-block; height: 10mm; width:10mm; background-color:yellow;"></span></p>
5 <div id=
"console"></div><!-- to keep the test target at the top of the document -->
7 description('This confirms that settin the caret before an empty non-editable inline-block element with height.');
9 var sel
= getSelection();
10 var range
= document
.createRange();
11 var p
= document
.getElementById('p');
13 range
.setEnd(p
, 0); // not needed, but to ensure the same code path as bug 428986
14 sel
.removeAllRanges();
16 shouldBe('getSelection().rangeCount', '1');
17 shouldBe('getSelection().anchorNode', 'p');
18 shouldBe('getSelection().anchorOffset', '0');
19 shouldBe('getSelection().anchorNode', 'getSelection().focusNode');
20 shouldBe('getSelection().anchorOffset', 'getSelection().focusOffset');
21 caretShouldBe('span.getBoundingClientRect().left');
23 sel
.modify('move', 'forward', 'character');
24 shouldBe('getSelection().rangeCount', '1');
25 shouldBe('getSelection().anchorNode', 'p');
26 shouldBe('getSelection().anchorOffset', '1');
27 shouldBe('getSelection().anchorNode', 'getSelection().focusNode');
28 shouldBe('getSelection().anchorOffset', 'getSelection().focusOffset');
29 caretShouldBe('span.getBoundingClientRect().right', 2);
31 function caretShouldBe(expected
, tolerance
) {
32 if (!window
.internals
) {
33 debug("TEST SKIPPED, cannot test the caret position without window.internals");
36 shouldBe('internals.absoluteCaretBounds().left', expected
, false, tolerance
);