toolkit/spatial-navigation/tests/chrome/test_snav.xul
author Doug Turner <dougt@meer.net>
Wed, 09 Jul 2008 09:14:05 -0700
changeset 15761 35456868ae00f1ece8aca599367489535476fa2d
parent 15749 ae0d3aeb2621d851c6a710dbec826c308104a459
child 15770 660805dff89be426e22162ac8fae7ea89369633a
permissions -rw-r--r--
Move SimpleTest.finish() after the tests complete. rs=me

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css type="text/css"?>

<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=436084
-->

<window title="Mozilla Bug 288254"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  onload="onLoad();">

  <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>      

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

<a id="start" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436084">Mozilla Bug 436084</a>
<table
 style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="vertical-align: top; text-align: center;"><a id="1" href="a">test</a></td>
      <td style="vertical-align: top; text-align: center;"><a id="2" href="a">test</a></td>
      <td style="vertical-align: top; text-align: center;"><a id="3" href="a">test</a></td>
    </tr>
    <tr>
      <td style="vertical-align: top; text-align: center;"><a id="4" href="a">test</a></td>
      <td style="vertical-align: top; text-align: center;"><a id="5" href="a">test</a></td>
      <td style="vertical-align: top; text-align: center;"><a id="6" href="a">test</a></td>
    </tr>
    <tr>
      <td style="vertical-align: top; text-align: center;"><a id="7" href="a">test</a></td>
      <td style="vertical-align: top; text-align: center;"><a id="8" href="a">test</a></td>
      <td style="vertical-align: top; text-align: center;"><a id="9" href="a">test</a></td>
    </tr>
  </tbody>
</table>
</body>


<script class="testbody" type="application/javascript">
<![CDATA[
Components.utils.import("resource://gre/modules/spatial-navigation.js");

function onLoad()
{
    var x = document.getElementById("some-content");
    var snav = new SpatialNavigation(x);

    function moveAndVerify(direction, value)
    {
        sendKey(direction, document.activeElement);
        ok(document.activeElement.getAttribute("id") == value, "Move");
    }
    
    // get to a known place.
    document.getElementById("start").focus();
    
    // from start.
    moveAndVerify("DOWN", "1");
    
    for (var i = 1 ; i < 10 ; i ++) {
        moveAndVerify("DOWN", "4");
        moveAndVerify("DOWN", "7");
        moveAndVerify("RIGHT", "8");
        moveAndVerify("RIGHT", "9");
        moveAndVerify("UP", "6");
        moveAndVerify("UP", "3");
        moveAndVerify("LEFT", "2");
        moveAndVerify("LEFT", "1");
    }
    SimpleTest.finish();
}

]]></script>
</window>