JS Test Harness: Insert the stylesheet dynamically
[WebKit-https.git] / LayoutTests / fast / dom / Element / getBoundingClientRect-getClientRects-relative-to-viewport.html
1 <script src="../../js/resources/js-test-pre.js"></script>
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>
16     if (window.layoutTestController)
17         layoutTestController.dumpAsText();
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
46     if (window.layoutTestController) {
47         var area = document.getElementById('testArea');
48         area.parentNode.removeChild(area);
49     }
50
51     successfullyParsed = true;
52 </script>
53 <script src="../../js/resources/js-test-post.js"></script>