chromium/third_party/blink/web_tests/accessibility/scroll-to-make-visible-nested.html

<html>
<head>
<script src="../resources/js-test.js"></script>
</head>
<body>

<p id="description"></p>

<div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>

<div id="outer_container" style="height: 100px; overflow: scroll">
  <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
  <div id="inner_container" style="height: 100px; overflow: scroll">
    <div style="border: 1px solid #000; height: 5000px;">5000-pixel box</div>
    <button id="target">Target</button>
  </div>
</div>

<div id="console"></div>

<script>
description("Tests that scrolling to make an element visible successfully scrolls multiple nested scrolling views'.");

function runTest() {
    window.outerContainer = document.getElementById("outer_container");
    window.innerContainer = document.getElementById("inner_container");
    window.target = document.getElementById("target");

    if (window.accessibilityController) {
        target.focus();
        var targetAccessibleObject = accessibilityController.focusedElement;
    }

    // Reset the initial scroll positions (since calling focus() can scroll the page too).
    window.scrollTo(0, 0);
    outerContainer.scrollTop = 0;
    innerContainer.scrollTop = 0;
    shouldBe("window.pageYOffset", "0");
    shouldBe("outerContainer.scrollTop", "0");
    shouldBe("innerContainer.scrollTop", "0");
    shouldBeGreaterThanOrEqual("target.getBoundingClientRect().top", "15000");

    // Scroll to make target visible.
    if (window.accessibilityController)
        targetAccessibleObject.scrollToMakeVisible();

    // Instead of testing the exact scroll offsets of the two containers, just test that
    // the new absolute position of the target is on-screen.
    shouldBeGreaterThanOrEqual("window.innerHeight", "target.getBoundingClientRect().bottom");

    finishJSTest();
}

runTest();

</script>

</body>
</html>