<html>
  <!--
    This test ensures the content overflow traversal correctness of Spatial Navigation
    algorithm: focusable elements in an scrollable containers (e.g. <div>) should be
    accessible, including offscreen content.

    * Pre-conditions:
    1) DRT support for SNav enable/disable.

    * Navigation steps:
    1) Loads this page, focus goes to "start" automatically.
    2) Move focus down to the visible focusable element in
       scrollable div.
    3) Traverse the page through other focusable elements down the page.
       and then back up.

    * Expected results: All focusable element in scrollable content, including
    offscreen ones, should be accessible via SNav. -->
  <head>
    <style type="text/css">
      .offscreen {
        position: absolute;
        left: -1000em;
      }
    </style>

    <script src="../js/resources/js-test-pre.js"></script>
    <script src="resources/spatial-navigation-utils.js"></script>
    <script type="application/javascript">

    var resultMap = [
      ["Left", "1"],
      ["DONE", "DONE"]
    ];

    if (window.testRunner) {
      testRunner.dumpAsText();
      testRunner.setSpatialNavigationEnabled(true);
      testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
      testRunner.waitUntilDone();
    }

    function runTest()
    {
      // starting the test itself: get to a known place.
      document.getElementById("start").focus();

      initTest(resultMap, testCompleted);
    }

    function testCompleted()
    {
      if (window.testRunner)
        testRunner.notifyDone();
    }

    window.onload = runTest;

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


  <body id="some-content" xmlns="http://www.w3.org/1999/xhtml">

    <div style="margin-left:120px">
      <a id="off" class="offscreen" href="a">offscreen content</a>
      <a id="start" href="a">Right link</a>
    </div><br>
    <a id="1" href="a">Down link</a><br>
    <div id="console"></div>
  </body>
</html>

