tor-browser

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

test_bug417760.html (1874B)


      1 <!DOCTYPE html>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=417760
      5 -->
      6 <head>
      7  <title>cannot focus() img with tabindex="-1"</title>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9  <style type="text/css">
     10    img {
     11      border: 5px solid white;
     12    }
     13    img:focus {
     14      border: 5px solid black;
     15    }
     16  </style>
     17 
     18 
     19  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     20 
     21  <script type="text/javascript">
     22    function checkFocus(aExpected, aTabIndex)
     23    {
     24      elemCurr = document.activeElement.getAttribute("id");
     25      is(elemCurr, aExpected, "Element with tabIndex " + aTabIndex 
     26         + " did not receive focus!");
     27    }
     28 
     29    function doTest()
     30    {
     31      // First, test img with tabindex = 0
     32      document.getElementById("img-tabindex-0").focus();
     33      checkFocus("img-tabindex-0", 0);
     34 
     35      // now test the img with tabindex = -1
     36      document.getElementById("img-tabindex-minus-1").focus();
     37      checkFocus("img-tabindex-minus-1", -1);
     38 
     39      // now test the img without tabindex, should NOT receive focus!
     40      document.getElementById("img-no-tabindex").focus();
     41      checkFocus("img-tabindex-minus-1", null);
     42 
     43      SimpleTest.finish();
     44    }
     45 
     46    SimpleTest.waitForExplicitFinish();
     47    addLoadEvent(doTest);
     48  </script>
     49 </head>
     50 
     51 <body>
     52 
     53  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=417760">Mozilla Bug 417760</a>
     54  <p id="display"></p>
     55  <div id="content" style="display: none"></div>
     56  <pre id="test">
     57  </pre>
     58  <br>img tabindex="0":
     59  <img id="img-tabindex-0"
     60    src="file_bug417760.png"
     61    alt="MoCo logo" tabindex="0"/>
     62  <br>img tabindex="-1":
     63  <img id="img-tabindex-minus-1"
     64    src="file_bug417760.png"
     65    alt="MoCo logo" tabindex="-1"/>
     66  <br>img without tabindex:
     67  <img id="img-no-tabindex"
     68    src="file_bug417760.png"
     69    alt="MoCo logo"/>
     70 </body>
     71 </html>