3 <script src=
"../resources/js-test.js"></script>
7 <p id=
"description"></p>
9 <div style=
"border: 1px solid #000; height: 5000px;">5000-pixel box
</div>
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>
19 <div id=
"console"></div>
22 description("Tests that scrolling to make an element visible successfully scrolls multiple nested scrolling views'.");
25 window
.outerContainer
= document
.getElementById("outer_container");
26 window
.innerContainer
= document
.getElementById("inner_container");
27 window
.target
= document
.getElementById("target");
29 if (window
.accessibilityController
) {
31 var targetAccessibleObject
= accessibilityController
.focusedElement
;
34 // Reset the initial scroll positions (since calling focus() can scroll the page too).
35 window
.scrollTo(0, 0);
36 outerContainer
.scrollTop
= 0;
37 innerContainer
.scrollTop
= 0;
38 shouldBe("window.pageYOffset", "0");
39 shouldBe("outerContainer.scrollTop", "0");
40 shouldBe("innerContainer.scrollTop", "0");
41 shouldBeGreaterThanOrEqual("target.getBoundingClientRect().top", "15000");
43 // Scroll to make target visible.
44 if (window
.accessibilityController
)
45 targetAccessibleObject
.scrollToMakeVisible();
47 // Instead of testing the exact scroll offsets of the two containers, just test that
48 // the new absolute position of the target is on-screen.
49 shouldBeGreaterThanOrEqual("window.innerHeight", "target.getBoundingClientRect().bottom");