tor-browser

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

focus-visible-013.html (2462B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8" />
      3 <title>CSS Selectors Test: :focus-visible does not match after mouse focus even if previous focused element was matching :focus-visible</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 <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 <style>
     11  @supports not selector(:focus-visible) {
     12    :focus {
     13      outline: red solid 5px;
     14    }
     15  }
     16 
     17  #initial:focus-visible {
     18    outline: green solid 5px;
     19  }
     20 
     21  #initial:focus:not(:focus-visible) {
     22    outline: red solid 5px;
     23  }
     24 
     25  #target:focus-visible {
     26    outline: red solid 5px;
     27  }
     28 
     29  #target:focus:not(:focus-visible) {
     30    outline: green solid 5px;
     31  }
     32 </style>
     33 
     34 <p>This test checks that if the active element matches ':focus-visible' and a mouse click causes focus to move elsewhere, the newly focused element should not match <code>:focus-visible</code>.</p>
     35 <ol id="instructions">
     36  <li>If the user-agent does not claim to support the <code>:focus-visible</code> pseudo-class then SKIP this test.</li>
     37  <li>Press the TAB key.</li>
     38  <li>If the element that says "Initial" has a red outline, then the test rsult is a FAILURE.</li>
     39  <li>Use the mouse to focus the element below that says "Target".</li>
     40  <li>If the element that says "Target" has a green outline, then the test result is a SUCCESS.</li>
     41 </ol>
     42 
     43 <div id="initial" tabindex="0">Initial</div>
     44 <div id="target" tabindex="0">Target</div>
     45 
     46 <script>
     47  setup({ explicit_done: true });
     48 
     49  async_test(function(t) {
     50    initial.addEventListener("focus", t.step_func(function() {
     51      assert_equals(getComputedStyle(initial).outlineColor, "rgb(0, 128, 0)", `outlineColor for ${initial.tagName}#${initial.id} should be green`);
     52      test_driver.click(target).then(() => done());
     53    }));
     54 
     55    target.addEventListener("focus", t.step_func_done(function() {
     56      assert_equals(getComputedStyle(target).outlineColor, "rgb(0, 128, 0)", `outlineColor for ${target.tagName}#${target.id} should be green`);
     57    }));
     58 
     59    const tab_key = '\ue004';
     60    test_driver.send_keys(document.body, tab_key);
     61  }, ":focus-visible does not match after mouse click even if previous focused element was matching :focus-visible");
     62 </script>