chromium/third_party/blink/web_tests/fast/spatial-navigation/snav-unit-overflow-and-scroll-in-direction.html

<!DOCTYPE html>
<a id="start" href="a">Start</a>
<div style='margin-top:100000px'>
  <a id="end" href="a">End</a>
</div>
<p>
  This test ensures the correctness the following Spatial Navigation (SNav) algorithm features.<br>
  <br>
  1) There is no unit overflow in the Spatial Navigation algorithm while calculating the best node candidate<br>
     to move focus to. To test that this page positions some elements 10000000 pixels far from each other<br>
     (distance that can considered large enough for most of the Web Pages on the Internet).<br>
  <br>
  2) Make sure that a best focusable candidate only gets focused if it is visible in the current Viewport.<br>
     Scroll-in-direction is performed otherwise.<br>
  <br>
  * Navigation steps:<br>
  1) Loads this page, focus goes to "start" automatically.<br>
  2) Attempt to move focus down to "end". As it is too far and out of viewport, focus change will not happen<br>
     and page will be scrolled a step down.<br>
  3) By sending an "End" keypress, page gets scrolled down to a place where the "end" node gets visible in the viewport.<br>
  4) Step _1_ is ran again, and "end" gets focused.<br>
</p>

<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/snav-testharness.js"></script>
<script>
  snav.assertSnavEnabledAndTestable();

  // Start at a known place.
  document.getElementById("start").focus();

  snav.triggerMove("Down");
  test(function() {
    assert_equals(document.activeElement, document.getElementById("start"));
    assert_true(document.scrollingElement.scrollTop != 0);
  }, "Focus change will not happen and page will be scrolled a step down.")

  internals.settings.setScrollAnimatorEnabled(false);
  eventSender.keyDown("End");

  snav.triggerMove("Down");
  test(function() {
    assert_equals(document.activeElement, document.getElementById("end"));
  }, "'end' element should get focused.")

</script>