10 if (window
.testRunner
)
11 testRunner
.dumpAsText();
21 var element
= document
.getElementById('test');
22 var parent
= element
.parentNode
;
23 parent
.removeChild(element
);
24 var console
= document
.createElement("pre");
25 console
.textContent
= _log
;
26 parent
.appendChild(console
);
32 function test(x
, y
, __expectedContainer
, __expectedOffset
)
34 var expectedContainer
= eval(__expectedContainer
);
35 var expectedOffset
= eval(__expectedOffset
);
38 var range
= document
.caretRangeFromPoint(x
, y
);
40 if (range
.startContainer
== expectedContainer
) {
41 log("PASS: range.startContainer == " + __expectedContainer
+ ".");
43 log("FAIL: range.startContainer == " + range
.startContainer
+ ".");
47 if (range
.startOffset
== expectedOffset
) {
48 log("PASS: range.startOffset == " + __expectedOffset
+ ".");
50 log("FAIL: range.startOffset == " + range
.startOffset
+ ".");
54 window
.onload = function()
56 element
= document
.getElementById('test');
57 image
= document
.getElementById('image');
59 var rect
= element
.getBoundingClientRect();
60 var imageRect
= image
.getBoundingClientRect();
62 log("Testing left of the image");
63 test(imageRect
.left
- 10, (imageRect
.top
+ imageRect
.height
) - 5, "image.previousSibling", "34");
65 log("Testing right of the image");
66 test((imageRect
.left
+ imageRect
.width
) + 10, (imageRect
.top
+ imageRect
.height
) - 5, "image.nextSibling", "1");
68 log("Testing on the image");
69 test((imageRect
.left
+ (imageRect
.width
/ 2) + 1) , (imageRect
.top
+ imageRect
.height
) - 5, "image.parentNode", "2");
76 <div id=
"test">xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx
<img id=
"image" src=
"../../resources/abe.png">xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx
</div>