tor-browser

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

focus-tabindex-negative.html (1680B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>HTML Test: focus - negative tabindex</title>
      4 <meta name="timeout" content="long">
      5 <link rel="author" title="Intel" href="http://www.intel.com/">
      6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#sequential-focus-navigation-and-the-tabindex-attribute">
      7 <meta assert="flag" content="interact">
      8 <meta assert="assert" content="Check if the tabindex attribute controls whether an element is supposed to be focusable">
      9 <script src="/resources/testharness.js"></script>
     10 <script src="/resources/testharnessreport.js"></script>
     11 <script src="/resources/testdriver.js"></script>
     12 <script src="/resources/testdriver-vendor.js"></script>
     13 <div id="log"></div>
     14 <form id="fm">
     15  <input id="test1" tabindex="-1">
     16  <input id="test2" tabindex="0">
     17 </form>
     18 <script>
     19 
     20 var t = async_test("The element with a negative tabindex must not be focused by press 'Tab' key");
     21 
     22 setup({timeout: 10000});
     23 
     24 document.forms.fm.addEventListener("focus", function (evt) {
     25  t.step(function () {
     26    var testEle = document.getElementById("test1");
     27    assert_equals(testEle.tabIndex, -1, "The tabIndex attribute of the first input element should be -1.");
     28    assert_not_equals(evt.target, testEle, "The second input element must be focused.");
     29    assert_equals(document.activeElement, document.getElementById("test2"), "The second input element must be activated.");
     30  });
     31  t.done();
     32 }, true);
     33 
     34 document.addEventListener("keydown", function (evt) {
     35  t.step(function () {
     36    assert_equals(evt.keyCode, 9, "Please press 'Tab' key.");
     37  });
     38 }, true);
     39 
     40 t.step(function () {
     41  // TAB = '\ue004'
     42  test_driver.send_keys(document.body, "\ue004");
     43 });
     44 
     45 </script>