mark.lam@apple.com | b130a34 | 2013-09-07 22:48:36 +0000 | [diff] [blame] | 1 | <script src="../../../resources/js-test-pre.js"></script> |
weinig@apple.com | 7113bea | 2009-02-25 02:38:21 +0000 | [diff] [blame] | 2 | <style> |
| 3 | #pusher { |
| 4 | width: 1000px; |
| 5 | height: 1000px; |
| 6 | outline: 1px solid black; |
| 7 | } |
| 8 | </style> |
| 9 | <div id="console"></div> |
| 10 | <div id="testArea"> |
| 11 | <br> |
| 12 | <p id="test">Test content</p> |
| 13 | <div id="pusher">This box is here to create scrollbars.</div> |
| 14 | </div> |
| 15 | <script> |
rniwa@webkit.org | ada3c20 | 2012-06-20 03:28:42 +0000 | [diff] [blame] | 16 | if (window.testRunner) |
| 17 | testRunner.dumpAsText(); |
weinig@apple.com | 7113bea | 2009-02-25 02:38:21 +0000 | [diff] [blame] | 18 | |
| 19 | var element = document.getElementById('test'); |
| 20 | |
| 21 | // Get base numbers |
| 22 | var unScrolledBoundingBox = element.getBoundingClientRect(); |
| 23 | var unScrolledBoundingBoxes = element.getClientRects(); |
| 24 | |
| 25 | // Test scrolling down |
| 26 | window.scrollBy(0, 50); |
| 27 | var scrolledDownBoundingBox = element.getBoundingClientRect(); |
| 28 | var scrolledDownBoundingBoxes = element.getClientRects(); |
| 29 | |
| 30 | // Reset |
| 31 | window.scrollTo(0, 0); |
| 32 | |
| 33 | // Test scrolling right |
| 34 | window.scrollBy(50, 0); |
| 35 | var scrolledRightBoundingBox = element.getBoundingClientRect(); |
| 36 | var scrolledRightBoundingBoxes = element.getClientRects(); |
| 37 | |
| 38 | // Reset |
| 39 | window.scrollTo(0, 0); |
| 40 | |
| 41 | shouldBe("unScrolledBoundingBox.top - scrolledDownBoundingBox.top", "50"); |
| 42 | shouldBe("unScrolledBoundingBoxes[0].top - scrolledDownBoundingBoxes[0].top", "50"); |
| 43 | shouldBe("unScrolledBoundingBox.left - scrolledRightBoundingBox.left", "50"); |
| 44 | shouldBe("unScrolledBoundingBoxes[0].left - scrolledRightBoundingBoxes[0].left", "50"); |
| 45 | |
rniwa@webkit.org | ada3c20 | 2012-06-20 03:28:42 +0000 | [diff] [blame] | 46 | if (window.testRunner) { |
weinig@apple.com | 7113bea | 2009-02-25 02:38:21 +0000 | [diff] [blame] | 47 | var area = document.getElementById('testArea'); |
| 48 | area.parentNode.removeChild(area); |
| 49 | } |
weinig@apple.com | 7113bea | 2009-02-25 02:38:21 +0000 | [diff] [blame] | 50 | </script> |
mark.lam@apple.com | b130a34 | 2013-09-07 22:48:36 +0000 | [diff] [blame] | 51 | <script src="../../../resources/js-test-post.js"></script> |