tor-browser

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

focus-visible-022.tentative.html (1381B)


      1 <!doctype html>
      2 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
      3 <link rel="author" title="Mozilla" href="https://mozilla.org">
      4 <link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />
      5 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1711057">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <script src="/resources/testdriver.js"></script>
      9 <script src="/resources/testdriver-vendor.js"></script>
     10 
     11 <div id="one" tabindex="1">One</div>
     12 <div id="two" tabindex="1">Two</div>
     13 
     14 <script>
     15 let one = document.getElementById("one");
     16 let two = document.getElementById("two");
     17 
     18 document.addEventListener("keydown", function(e) {
     19  two.focus();
     20 });
     21 
     22 promise_test(async t => {
     23  await test_driver.click(one);
     24  assert_equals(document.activeElement, one, "#one should be focused by mouse");
     25  assert_true(one.matches(":focus"), "#one should match :focus");
     26  assert_true(!one.matches(":focus-visible"), "#one should not match :focus-visible");
     27 
     28  await test_driver.send_keys(document.body, " ");
     29 
     30  assert_equals(document.activeElement, two, "#two should be focused by our event listener");
     31  assert_true(two.matches(":focus"), "#two should match :focus");
     32  assert_true(two.matches(":focus-visible"), "#two should match :focus-visible");
     33 });
     34 </script>