servo/tests/content/test_getBoundingClientRect.html

34 lines
695 B
HTML

<html>
<head>
<script src="harness.js"></script>
<style>
div {
position: relative;
top: 100px;
left: 100px;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<div>my div</div>
<script>
is_function(DOMRect, "DOMRect");
var elems = document.getElementsByTagName('div');
var rect = elems[0].getBoundingClientRect();
is_a(rect, DOMRect);
geq(rect.top, 100);
geq(rect.bottom, 200);
geq(rect.left, 100);
geq(rect.right, 200);
is(rect.width, 100);
is(rect.height, 100);
is(rect.width, rect.right - rect.left);
is(rect.height, rect.bottom - rect.top);
</script>
</body>
</html>