summaryrefslogtreecommitdiffstats
path: root/toolkit/modules/tests/mochitest/test_spatial_navigation.html
blob: c1fbb0eec854140cbc497ecaa738b322cc490634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=698437
-->
<head>
  <meta charset="utf-8">
  <title>Test for Bug 698437</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript">

  /** Test for Bug 698437 **/

  SimpleTest.waitForExplicitFinish();

  function Test() {
    if (!SpecialPowers.getBoolPref("snav.enabled")) {
      todo(false, "Enable spatial navigiation on this platform.");
      SimpleTest.finish();
      return;
    }

    var center = document.getElementById("center");
    var right = document.getElementById("right");
    var left = document.getElementById("left");
    var top = document.getElementById("top");
    var bottom = document.getElementById("bottom");

    console.log(top);
    console.log(bottom);
    console.log(center);
    console.log(left);
    console.log(right);

    center.focus();
    is(center.id, document.activeElement.id, "How did we call focus on center and it did" +
                                             " not become the active element?");

    synthesizeKey("VK_UP", { });
    is(document.activeElement.id, top.id,
       "Spatial navigation up key is not handled correctly.");

    center.focus();
    synthesizeKey("VK_DOWN", { });
    is(document.activeElement.id, bottom.id,
       "Spatial navigation down key is not handled correctly.");

    center.focus();
    synthesizeKey("VK_RIGHT", { });
    is(document.activeElement.id, right.id,
       "Spatial navigation right key is not handled correctly.");

    center.focus();
    synthesizeKey("VK_LEFT", { });
    is(document.activeElement.id, left.id,
       "Spatial navigation left key is not handled correctly.");

    SimpleTest.finish();
  }

  </script>
</head>
<body onload="Test();">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=698437">Mozilla Bug 698437</a>
<p id="display"></p>
<div id="content">
  <button id="lefttop">1</button><button id="top">2</button><button id="righttop">3</button><br>
  <button id="left">4</button><button id="center">5</button><button id="right">6</button><br>
  <button id="leftbottom">7</button><button id="bottom">8</button><button id="rightbottom">9</button><br>
</div>
<pre id="test">
</pre>
</body>
</html>