Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / accessibility / scroll-to-global-point-main-window.html
1 <!DOCTYPE html>
2 <head>
3 <script src="../resources/js-test.js"></script>
4 <style>
5 button {
6   border: 0;
7 }
8 </style>
9 </head>
10 <body>
11
12 <p id="description"></p>
13
14 <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
15 <button id="target">Target</button>
16 <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
17
18 <div id="console"></div>
19
20 <script>
21 description("Tests that scrolling an element to a specific point successfully scrolls the main window.");
22
23 function runTest() {
24     var target = document.getElementById("target");
25
26     if (window.accessibilityController) {
27         target.focus();
28         internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
29         var targetAccessibleObject = accessibilityController.focusedElement;
30     }
31
32     // Reset the initial scroll position (since calling focus() can scroll the page too).
33     window.scrollTo(0, 0);
34     shouldBe("window.pageYOffset", "0");
35
36     // Scroll to various locations and check.
37     if (window.accessibilityController)
38         targetAccessibleObject.scrollToGlobalPoint(0, 0);
39     shouldBe("target.getBoundingClientRect().top", "0");
40     if (window.accessibilityController)
41         targetAccessibleObject.scrollToGlobalPoint(0, 300);
42     shouldBe("target.getBoundingClientRect().top", "300");
43     if (window.accessibilityController)
44         targetAccessibleObject.scrollToGlobalPoint(0, 3000);
45     shouldBe("target.getBoundingClientRect().top", "3000");
46
47     finishJSTest();
48 }
49
50 runTest();
51
52 </script>
53
54 </body>
55 </html>