Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / accessibility / scroll-to-make-visible-nested.html
1 <!DOCTYPE html>
2 <head>
3 <script src="../resources/js-test.js"></script>
4 </head>
5 <body>
6
7 <p id="description"></p>
8
9 <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
10
11 <div id="outer_container" style="height: 100px; overflow: scroll">
12   <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
13   <div id="inner_container" style="height: 100px; overflow: scroll">
14     <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
15     <button id="target">Target</button>
16   </div>
17 </div>
18
19 <div id="console"></div>
20
21 <script>
22 description("Tests that scrolling to make an element visible successfully scrolls multiple nested scrolling views'.");
23
24 function runTest() {
25     window.outerContainer = document.getElementById("outer_container");
26     window.innerContainer = document.getElementById("inner_container");
27     window.target = document.getElementById("target");
28
29     var targetAccessibleObject;
30     if (window.accessibilityController) {
31         target.focus();
32         targetAccessibleObject = accessibilityController.focusedElement;
33     }
34
35     // Reset the initial scroll positions (since calling focus() can scroll the page too).
36     window.scrollTo(0, 0);
37     outerContainer.scrollTop = 0;
38     innerContainer.scrollTop = 0;
39     shouldBeZero("window.pageYOffset");
40     shouldBeZero("outerContainer.scrollTop");
41     shouldBeZero("innerContainer.scrollTop");
42     shouldBeGreaterThanOrEqual("target.getBoundingClientRect().top", "15000");
43
44     // Scroll to make target visible.
45     if (window.accessibilityController)
46         targetAccessibleObject.scrollToMakeVisible();
47
48     // Instead of testing the exact scroll offsets of the two containers, just test that
49     // the new absolute position of the target is on-screen.
50     shouldBeGreaterThanOrEqual("window.innerHeight", "target.getBoundingClientRect().bottom");
51
52     finishJSTest();
53 }
54
55 runTest();
56
57 </script>
58
59 </body>
60 </html>