blob: f62671e76b780f3302a6edeb8b5b5455cc4b4c2b [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
<p>
Test handling of sizes exceeding the maximum supported value.
</p>
<script>
function testSize(width, expectedWidth, opt_tolerance)
{
el.style.width = width + 'px';
var style = window.getComputedStyle(el, null);
var rect = el.getBoundingClientRect();
var tolerance = opt_tolerance || 0;
if (Math.abs(el.offsetWidth - expectedWidth) <= tolerance && Math.abs(rect.width - expectedWidth) <= tolerance && Math.abs(parseInt(style.width, 10) - expectedWidth) <= tolerance)
testPassed('element.width = ' + width + 'px, returns offsetWidth, rect.width and computed width as expected.');
else
testFailed('element.width = ' + width + 'px, returns offsetWidth ' + el.offsetWidth + ', rect.width ' + rect.width + ' and computed width ' + style.width + ', expected ' + expectedWidth + '.');
}
var el = document.createElement('div');
document.body.appendChild(el);
testSize(5000, 5000);
testSize(50000, 50000);
testSize(500000, 500000);
testSize(5000000, 5000000);
testSize(50000000, 0);
testSize(33554424, 33554424);
testSize(33554425, 33554425, 2); // float imprecision
testSize(33554426, 33554426, 2);
testSize(33554427, 33554427, 2);
testSize(33554428, 33554428, 2);
testSize(33554429, 33554429, 2);
testSize(33554430, 33554430, 2);
testSize(33554432, 0);
testSize(35791395, 0);
testSize(35791396, 0);
document.body.removeChild(el);
</script>
</body>
</html>