blob: 409af161d7d0907f1253eea7c127e676d5c0ca31 [file] [log] [blame]
<!doctype html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<style>
#container {
overflow: auto;
border: 1px solid black;
width: 200px;
height: 100px;
}
#target {
width: 300px;
height: 200px;
position: relative;
top: -50px;
left: -40px;
background-color: rgba(0, 255, 0, 0.3);
}
</style>
<p>Overflow, with position:relative. position:relative affects overflow.</p>
<div id="container">
<div id="target"></div>
</div>
<script>
var container = document.querySelector('#container');
var target = document.querySelector('#target');
test(function() {
var targetStyle = window.getComputedStyle(target);
assert_equals(container.scrollWidth,
target.offsetWidth + parseInt(targetStyle.left),
"width");
assert_equals(container.scrollHeight,
target.offsetHeight + parseInt(targetStyle.top),
"height");
}, "relative overflow");
test(function() {
target.style.top = "-66px";
var targetStyle = window.getComputedStyle(target);
assert_equals(container.scrollWidth,
target.offsetWidth + parseInt(targetStyle.left),
"width");
assert_equals(container.scrollHeight,
target.offsetHeight + parseInt(targetStyle.top),
"height");
}, "relative overflow, after target move");
</script>