toolkit/modules/tests/mochitest/test_spatial_navigation.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=698437
     5 -->
     6 <head>
     7   <meta charset="utf-8">
     8   <title>Test for Bug 698437</title>
     9   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    11   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    12   <script type="application/javascript">
    14   /** Test for Bug 698437 **/
    16   SimpleTest.waitForExplicitFinish();
    18   function Test() {
    19     if (!SpecialPowers.getBoolPref("snav.enabled")) {
    20       todo(false, "Enable spatial navigiation on this platform.");
    21       SimpleTest.finish();
    22       return;
    23     }
    25     var center = document.getElementById("center");
    26     var right = document.getElementById("right");
    27     var left = document.getElementById("left");
    28     var top = document.getElementById("top");
    29     var bottom = document.getElementById("bottom");
    31     console.log(top);
    32     console.log(bottom);
    33     console.log(center);
    34     console.log(left);
    35     console.log(right);
    37     center.focus();
    38     is(center.id, document.activeElement.id, "How did we call focus on center and it did" +
    39                                              " not become the active element?");
    41     synthesizeKey("VK_UP", { });
    42     is(top.id, document.activeElement.id,
    43        "Spatial navigation up key is not handled correctly.");
    45     center.focus();
    46     synthesizeKey("VK_DOWN", { });
    47     is(bottom.id, document.activeElement.id,
    48        "Spatial navigation down key is not handled correctly.");
    50     center.focus();
    51     synthesizeKey("VK_RIGHT", { });
    52     is(right.id, document.activeElement.id,
    53        "Spatial navigation right key is not handled correctly.");
    55     center.focus();
    56     synthesizeKey("VK_LEFT", { });
    57     is(left.id, document.activeElement.id,
    58        "Spatial navigation left key is not handled correctly.");
    60     SimpleTest.finish();
    61   }
    63   </script>
    64 </head>
    65 <body onload="Test();">
    66 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=698437">Mozilla Bug 698437</a>
    67 <p id="display"></p>
    68 <div id="content">
    69   <p> This is a <a id="top" href="#">really</a> long sentence </p>
    70   <p> <a id="left" href="#">This</a> is a
    71       <a id="center" href="#">really</a> long
    72       <a id="right" href="#">sentence</a> </p>
    73   <p> This is a <a id="bottom" href="#">really</a> long sentence </p>
    74 </div>
    75 <pre id="test">
    76 </pre>
    77 </body>
    78 </html>

mercurial