toolkit/modules/tests/mochitest/test_spatial_navigation.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial