tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug265203.html (3049B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=265203
      5 -->
      6 <head>
      7  <title>Test for Bug 265203</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=265203">Mozilla Bug 265203</a>
     14 <p id="display">
     15 <a id="a1" href="http://www.mozilla.org">Mozilla</a><a id="a2" 
     16 href="http://www.mozilla.org/products/firefox">Firefox</a><br>
     17 <br>
     18 <table cellpadding="2" cellspacing="2" border="1"
     19 style="text-align: left; width: 100%;">
     20  <tbody>
     21 
     22    <tr>
     23      <td style="vertical-align: top;"><a id="a3" href="http://www.mozilla.org">Mozilla</a></td>
     24      <td style="vertical-align: top;"><a
     25 href="http://www.mozilla.org/products/firefox">Firefox</a></td>
     26    </tr>
     27    <tr>
     28      <td style="vertical-align: top;"><a href="http://www.mozilla.org">Mozilla</a></td>
     29      <td style="vertical-align: top;"><a
     30 href="http://www.mozilla.org/products/firefox">Firefox</a></td>
     31 
     32    </tr>
     33  </tbody>
     34 </table>
     35 </p>
     36 <div id="content" style="display: none">
     37  
     38 </div>
     39 <pre id="test">
     40 <script type="application/javascript">
     41 
     42 /** Test for Bug 265203 */
     43 var gTestStarted = false;
     44 var expectedResult = [ null, 0, null ];
     45 var nextTest;
     46 var test = 0;
     47 
     48 function testFocus() {
     49    var selection = window.getSelection()
     50    is(selection.focusNode, expectedResult[0],"test" + test + ": " + "caret node");
     51    is(selection.focusOffset, expectedResult[1],"test" + test + ": " + "caret offset");
     52    is(document.activeElement, expectedResult[2],"test" + test + ": " + "focused node");
     53    ++test;
     54    if (nextTest)
     55      nextTest();
     56 }
     57 
     58 function test0() {
     59    $("a1").focus();
     60    expectedResult = [ $("a1"), 0, $("a1") ]
     61    nextTest = test1;
     62    testFocus();
     63 }
     64 function test1() {
     65    synthesizeKey("KEY_ArrowRight");
     66    synthesizeKey("KEY_ArrowRight");
     67    synthesizeKey("KEY_ArrowRight");
     68    synthesizeKey("KEY_ArrowRight");
     69    synthesizeKey("KEY_ArrowRight");
     70    synthesizeKey("KEY_ArrowRight");
     71    synthesizeKey("KEY_ArrowRight");
     72    expectedResult = [ $("a1").firstChild, 7, $("a2") ]
     73    nextTest = test2;
     74    testFocus();
     75 }
     76 function test2() {
     77    $("a3").focus();
     78    expectedResult = [ $("a3"), 0, $("a3") ]
     79    nextTest = test3;
     80    testFocus();
     81 }
     82 function test3() {
     83    synthesizeKey("KEY_ArrowRight");
     84    synthesizeKey("KEY_ArrowRight");
     85    synthesizeKey("KEY_ArrowRight");
     86    synthesizeKey("KEY_ArrowRight");
     87    synthesizeKey("KEY_ArrowRight");
     88    synthesizeKey("KEY_ArrowRight");
     89    synthesizeKey("KEY_ArrowRight");
     90    expectedResult = [ $("a3").firstChild, 7, $("a3") ]
     91    nextTest = SimpleTest.finish;
     92    testFocus();
     93 }
     94 
     95 function startTest() {
     96  if (gTestStarted)
     97    return;
     98  gTestStarted = true;
     99  SpecialPowers.pushPrefEnv({"set": [["accessibility.browsewithcaret", true]]}, test0);
    100 }
    101 
    102 SimpleTest.waitForExplicitFinish();
    103 SimpleTest.waitForFocus(startTest);
    104 
    105 </script>
    106 </pre>
    107 </body>
    108 </html>