tor-browser

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

focus-visible-014.html (1524B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8" />
      3 <title>CSS Selectors Test: :focus-visible matches after script focus move</title>
      4 <link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
      5 <link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />
      6 <meta name="assert" content="This test checks that if the active element matches ':focus-visible' and a script causes focus to move elsewhere, the newly focused element should match ':focus-visible'.">
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <style>
     10  @supports not selector(:focus-visible) {
     11    :focus {
     12      outline: red solid 5px;
     13      background-color: red;
     14    }
     15  }
     16 
     17  :focus-visible {
     18    background: lime;
     19  }
     20 
     21  :focus:not(:focus-visible) {
     22    background-color: red;
     23  }
     24 </style>
     25 
     26 <input id="input"></input>
     27 <div id="target" tabindex="0">Target</div>
     28 
     29 <script>
     30  async_test(function(t) {
     31    input.addEventListener("focus", t.step_func(function() {
     32      assert_equals(getComputedStyle(input).backgroundColor, "rgb(0, 255, 0)", `backgroundColor for ${input.tagName}#${input.id} should be lime`);
     33      target.focus();
     34    }));
     35 
     36    target.addEventListener("focus", t.step_func(function() {
     37      assert_equals(getComputedStyle(target).backgroundColor, "rgb(0, 255, 0)", `backgroundColor for ${target.tagName}#${target.id} should be lime`);
     38      t.done();
     39    }));
     40 
     41    input.focus();
     42  }, ":focus-visible matches after script focus move");
     43 </script>