dom/tests/mochitest/bugs/test_bug265203.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/bugs/test_bug265203.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,114 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=265203
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 265203</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=265203">Mozilla Bug 265203</a>
    1.17 +<p id="display">
    1.18 +<a id="a1" href="http://www.mozilla.org">Mozilla</a><a id="a2" 
    1.19 + href="http://www.mozilla.org/products/firefox">Firefox</a><br>
    1.20 +<br>
    1.21 +<table cellpadding="2" cellspacing="2" border="1"
    1.22 + style="text-align: left; width: 100%;">
    1.23 +  <tbody>
    1.24 +
    1.25 +    <tr>
    1.26 +      <td style="vertical-align: top;"><a id="a3" href="http://www.mozilla.org">Mozilla</a></td>
    1.27 +      <td style="vertical-align: top;"><a
    1.28 + href="http://www.mozilla.org/products/firefox">Firefox</a></td>
    1.29 +    </tr>
    1.30 +    <tr>
    1.31 +      <td style="vertical-align: top;"><a href="http://www.mozilla.org">Mozilla</a></td>
    1.32 +      <td style="vertical-align: top;"><a
    1.33 + href="http://www.mozilla.org/products/firefox">Firefox</a></td>
    1.34 +
    1.35 +    </tr>
    1.36 +  </tbody>
    1.37 +</table>
    1.38 +</p>
    1.39 +<div id="content" style="display: none">
    1.40 +  
    1.41 +</div>
    1.42 +<pre id="test">
    1.43 +<script type="application/javascript">
    1.44 +
    1.45 +/** Test for Bug 265203 **/
    1.46 +
    1.47 +// Turn off spatial navigation because it hijacks VK_RIGHT and VK_LEFT keydown
    1.48 +// events
    1.49 +SpecialPowers.setBoolPref("snav.enabled", false);
    1.50 +
    1.51 +var gTestStarted = false;
    1.52 +var expectedResult = [ null, 0, null ];
    1.53 +var nextTest;
    1.54 +var test = 0;
    1.55 +
    1.56 +function testFocus() {
    1.57 +    var selection = window.getSelection()
    1.58 +    is(selection.focusNode, expectedResult[0],"test" + test + ": " + "caret node");
    1.59 +    is(selection.focusOffset, expectedResult[1],"test" + test + ": " + "caret offset");
    1.60 +    is(document.activeElement, expectedResult[2],"test" + test + ": " + "focused node");
    1.61 +    ++test;
    1.62 +    if (nextTest)
    1.63 +      nextTest();
    1.64 +}
    1.65 +
    1.66 +function test0() {
    1.67 +    $("a1").focus();
    1.68 +    expectedResult = [ $("a1"), 0, $("a1") ]
    1.69 +    nextTest = test1;
    1.70 +    testFocus();
    1.71 +}
    1.72 +function test1() {
    1.73 +    synthesizeKey("VK_RIGHT", { });
    1.74 +    synthesizeKey("VK_RIGHT", { });
    1.75 +    synthesizeKey("VK_RIGHT", { });
    1.76 +    synthesizeKey("VK_RIGHT", { });
    1.77 +    synthesizeKey("VK_RIGHT", { });
    1.78 +    synthesizeKey("VK_RIGHT", { });
    1.79 +    synthesizeKey("VK_RIGHT", { });
    1.80 +    expectedResult = [ $("a1").firstChild, 7, $("a2") ]
    1.81 +    nextTest = test2;
    1.82 +    testFocus();
    1.83 +}
    1.84 +function test2() {
    1.85 +    $("a3").focus();
    1.86 +    expectedResult = [ $("a3"), 0, $("a3") ]
    1.87 +    nextTest = test3;
    1.88 +    testFocus();
    1.89 +}
    1.90 +function test3() {
    1.91 +    synthesizeKey("VK_RIGHT", { });
    1.92 +    synthesizeKey("VK_RIGHT", { });
    1.93 +    synthesizeKey("VK_RIGHT", { });
    1.94 +    synthesizeKey("VK_RIGHT", { });
    1.95 +    synthesizeKey("VK_RIGHT", { });
    1.96 +    synthesizeKey("VK_RIGHT", { });
    1.97 +    synthesizeKey("VK_RIGHT", { });
    1.98 +    expectedResult = [ $("a3").firstChild, 7, $("a3") ]
    1.99 +    nextTest = SimpleTest.finish;
   1.100 +    testFocus();
   1.101 +}
   1.102 +
   1.103 +function startTest() {
   1.104 +  if (gTestStarted)
   1.105 +    return;
   1.106 +  gTestStarted = true;
   1.107 +
   1.108 +  SpecialPowers.pushPrefEnv({"set": [["accessibility.browsewithcaret", true]]}, test0);
   1.109 +}
   1.110 +
   1.111 +SimpleTest.waitForExplicitFinish();
   1.112 +SimpleTest.waitForFocus(startTest);
   1.113 +
   1.114 +</script>
   1.115 +</pre>
   1.116 +</body>
   1.117 +</html>

mercurial