tor-browser

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

focus-tabindex-positive.html (1588B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>HTML Test: focus - positive 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="test" tabindex="1">
     16 </form>
     17 <script>
     18 
     19 var t = async_test("The element with a positive tabindex must be focused by press 'Tab' key");
     20 
     21 setup({timeout: 10000});
     22 
     23 document.forms.fm.addEventListener("focus", function (evt) {
     24  t.step(function () {
     25    var testEle = document.getElementById("test");
     26    assert_equals(testEle.tabIndex, 1, "The tabIndex attribute of the input element should be 1.");
     27    assert_equals(evt.target, testEle, "The input element must be focused.");
     28    assert_equals(document.activeElement, testEle, "The input element must be activated.");
     29  });
     30  t.done();
     31 }, true);
     32 
     33 document.addEventListener("keydown", function (evt) {
     34  t.step(function () {
     35    assert_equals(evt.keyCode, 9, "Please press 'Tab' key.");
     36  });
     37 }, true);
     38 
     39 t.step(function () {
     40  // TAB = '\ue004'
     41  test_driver.send_keys(document.body, "\ue004");
     42 });
     43 
     44 </script>