4 <title>client rect precision test</title>
16 Box above should be 5x5px.<br>
20 var testElement = document.getElementById('test');
21 var consoleElement = document.getElementById('console');
25 var rect = testElement.getBoundingClientRect();
26 var width = rect.right - rect.left;
28 if (width == 4.5 && testElement.clientWidth == 4.5 && testElement.offsetWidth == 4.5)
29 log('PASS: getBoundingClientRect, clientWidth, and offsetWidth reports width with subpixel precision (4.5).');
31 log('FAIL: getBoundingClientRect reports width of ' + width +
32 ', expected 4.5. clientWidth reports width of ' + testElement.clientWidth +
33 ', expected 4.5. offsetWidth reports width of ' + testElement.offsetWidth +
36 var height = rect.bottom - rect.top;
37 if (height == 4.5 && testElement.clientHeight == 4.5 && testElement.offsetHeight == 4.5)
38 log('PASS: getBoundingClientRect, clientHeight, and offsetHeight reports height with subpixel precision (4.5).');
40 log('FAIL: getBoundingClientRect reports height of ' + height +
41 ', expected 4.5. clientHeight reports height of ' + testElement.clientHeight +
42 ', expected 4.5. offsetHeight reports height of ' + testElement.offsetHeight +
48 consoleElement.appendChild(document.createTextNode(str));
49 consoleElement.appendChild(document.createElement('br'));