toolkit/modules/tests/mochitest/test_spatial_navigation.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/modules/tests/mochitest/test_spatial_navigation.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=698437
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test for Bug 698437</title>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.14 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.15 +  <script type="application/javascript">
    1.16 +
    1.17 +  /** Test for Bug 698437 **/
    1.18 +
    1.19 +  SimpleTest.waitForExplicitFinish();
    1.20 +
    1.21 +  function Test() {
    1.22 +    if (!SpecialPowers.getBoolPref("snav.enabled")) {
    1.23 +      todo(false, "Enable spatial navigiation on this platform.");
    1.24 +      SimpleTest.finish();
    1.25 +      return;
    1.26 +    }
    1.27 +
    1.28 +    var center = document.getElementById("center");
    1.29 +    var right = document.getElementById("right");
    1.30 +    var left = document.getElementById("left");
    1.31 +    var top = document.getElementById("top");
    1.32 +    var bottom = document.getElementById("bottom");
    1.33 +
    1.34 +    console.log(top);
    1.35 +    console.log(bottom);
    1.36 +    console.log(center);
    1.37 +    console.log(left);
    1.38 +    console.log(right);
    1.39 +
    1.40 +    center.focus();
    1.41 +    is(center.id, document.activeElement.id, "How did we call focus on center and it did" +
    1.42 +                                             " not become the active element?");
    1.43 +
    1.44 +    synthesizeKey("VK_UP", { });
    1.45 +    is(top.id, document.activeElement.id,
    1.46 +       "Spatial navigation up key is not handled correctly.");
    1.47 +
    1.48 +    center.focus();
    1.49 +    synthesizeKey("VK_DOWN", { });
    1.50 +    is(bottom.id, document.activeElement.id,
    1.51 +       "Spatial navigation down key is not handled correctly.");
    1.52 +
    1.53 +    center.focus();
    1.54 +    synthesizeKey("VK_RIGHT", { });
    1.55 +    is(right.id, document.activeElement.id,
    1.56 +       "Spatial navigation right key is not handled correctly.");
    1.57 +
    1.58 +    center.focus();
    1.59 +    synthesizeKey("VK_LEFT", { });
    1.60 +    is(left.id, document.activeElement.id,
    1.61 +       "Spatial navigation left key is not handled correctly.");
    1.62 +
    1.63 +    SimpleTest.finish();
    1.64 +  }
    1.65 +
    1.66 +  </script>
    1.67 +</head>
    1.68 +<body onload="Test();">
    1.69 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=698437">Mozilla Bug 698437</a>
    1.70 +<p id="display"></p>
    1.71 +<div id="content">
    1.72 +  <p> This is a <a id="top" href="#">really</a> long sentence </p>
    1.73 +  <p> <a id="left" href="#">This</a> is a
    1.74 +      <a id="center" href="#">really</a> long
    1.75 +      <a id="right" href="#">sentence</a> </p>
    1.76 +  <p> This is a <a id="bottom" href="#">really</a> long sentence </p>
    1.77 +</div>
    1.78 +<pre id="test">
    1.79 +</pre>
    1.80 +</body>
    1.81 +</html>

mercurial